$self->render_static( $ANGULAR_JS );
};
+# CouchDB proxy for _design _view
+
+get '/:database/_design/:design/_view/:view' => sub {
+ my $self = shift;
+ my $url = join('/', $self->param('database'),'_design',$self->param('design'),'_view',$self->param('view') );
+ my $param = $self->req->url->query->clone->remove('callback')->to_string;
+ $url .= '?' . $param if $param;
+ warn "CouchDB proxy $url";
+ _render_jsonp( $self, _couchdb_get($url));
+};
+
app->start;
__DATA__
if ( id != this.registration.$id ) {
if (id) {
var self = this;
- this.registration = this.Registration.get({ id: id }, function(registration) {
+ this.Registration.get({ id: id }, function(registration) {
+console.debug('registration', id, registration);
self.last_saved = angular.copy(registration);
- if ( registration.type == 'symposium' ) {
- //self.symposium = self.Symposium.get({ id: s_id });
- self.load_symposium();
- }
+ self.registration = registration; // needed for load_symposium below
+ self.load_symposium();
});
}
else this.reset();
},
load_symposium: function() {
var self = this;
- var s_id = self.registration.symposium.$id || self.registration.$id;
+ if ( self.registration.type != 'symposium' ) return;
- if ( s_id = self.symposium.$id ) {
+ var s_id = self.registration.$id;
+ if ( self.registration.symposium ) s_id = self.registration.symposium.$id;
+
+ if ( self.symposium && self.symposium.$id == s_id ) {
console.debug('load_symposium ', s_id, ' allready loaded');
return;
}
console.debug( self.$xhr );
self.$xhr("JSON"
- , "http://localhost:5984/conference/_design/symposium/_view/works?callback=JSON_CALLBACK;key=" + s_id
+ , "/conference/_design/symposium/_view/works?callback=JSON_CALLBACK;key=" + s_id
, function(code, response){
console.log('symposium/_view/works', code, response);
angular.foreach( response.rows, function(row) {
this.data = data;
this.xhr("JSON"
- , "http://localhost:5984/conference/_design/symposium/_view/work_nr%2Ctitle?callback=JSON_CALLBACK"
+ , "/conference/_design/symposium/_view/work_nr%2Ctitle?callback=JSON_CALLBACK"
, function(code, response){
console.log(code, response, data);
data.response = response;