Skip to content
Browse files

Updated minified scripts.

  • Loading branch information...
1 parent 5e9f043 commit a426283ad208518f3fbc28d7d670f8b378778718 Michael Aufreiter committed Aug 4, 2011
Showing with 28 additions and 26 deletions.
  1. +6 −3 public/javascripts/substance.js
  2. +22 −22 public/javascripts/substance.min.js
  3. +0 −1 server.js
View
9 public/javascripts/substance.js
@@ -2296,7 +2296,7 @@ var DocumentBrowser = Backbone.View.extend({
var property = $(e.currentTarget).attr('property'),
operator = $(e.currentTarget).attr('operator'),
value = $(e.currentTarget).attr('value');
-
+
this.applyCommand({command: 'add_criterion', options: {
property: property,
operator: operator,
@@ -2344,7 +2344,9 @@ var DocumentBrowser = Backbone.View.extend({
success: function(res) {
that.graph = new Data.Graph(seed);
that.graph.merge(res.graph);
- that.facets = new Facets({el: '#facets', browser: that});
+
+
+ that.facets = new Facets({browser: that});
that.loaded = true;
that.trigger('loaded');
that.render();
@@ -2434,10 +2436,10 @@ var DocumentBrowser = Backbone.View.extend({
});
var Facets = Backbone.View.extend({
-
initialize: function(options) {
this.browser = options.browser;
this.facetChoices = {};
+ this.el = '#facets';
},
select: function(property) {
@@ -2762,6 +2764,7 @@ var Router = Backbone.Router.extend({
this.route("subscribed", "subscribed", app.subscribedDocs);
this.route("recent", "recent", app.recentDocs);
this.route("search/:searchstr", "search", app.searchDocs);
+ this.route("", "startpage", app.toggleStartpage);
},
loadDocument: function(username, docname, node, comment) {
View
44 public/javascripts/substance.min.js
@@ -75,10 +75,10 @@ AddCriterion.prototype.execute=function(){this.graph=app.browser.graph;var a=new
var RemoveCriterion=function(a,b){this.app=a;this.options=b};RemoveCriterion.prototype.execute=function(){};RemoveCriterion.prototype.unexecute=function(){};
var DocumentBrowser=Backbone.View.extend({events:{"click a.add-criterion":"addCriterion","click a.remove-criterion":"removeCriterion"},addCriterion:function(a){var b=$(a.currentTarget).attr("property"),c=$(a.currentTarget).attr("operator");a=$(a.currentTarget).attr("value");this.applyCommand({command:"add_criterion",options:{property:b,operator:c,value:a}});this.render();return false},removeCriterion:function(a){var b=$(a.currentTarget).attr("property"),c=$(a.currentTarget).attr("operator");a=$(a.currentTarget).attr("value");
this.applyCommand({command:"remove_criterion",options:{property:b,operator:c,value:a}});this.render();return false},initialize:function(a){this.app=a.app;this.browserTab=new BrowserTab({el:"#browser_tab",browser:this});this.documents=[];this.commands=[];this.graph=new Data.Graph(seed)},load:function(a){var b=this;this.query=a;$("#browser_tab").show().html("   Loading documents...");$("#browser_wrapper").html("");$.ajax({type:"GET",url:"/documents/search/"+a.type+"/"+encodeURI(a.value),
-dataType:"json",success:function(c){b.graph=new Data.Graph(seed);b.graph.merge(c.graph);b.facets=new Facets({el:"#facets",browser:b});b.loaded=true;b.trigger("loaded");b.render()},error:function(){}})},render:function(){if(this.loaded){this.documents=this.graph.find({"type|=":"/type/document"});this.documents=this.documents.sort(function(a,b){var c=a.value.get("updated_at"),e=b.value.get("updated_at");return c===e?0:c>e?-1:1});$(this.el).html(_.tpl("document_browser",{documents:this.documents,user:this.query.type===
+dataType:"json",success:function(c){b.graph=new Data.Graph(seed);b.graph.merge(c.graph);b.facets=new Facets({browser:b});b.loaded=true;b.trigger("loaded");b.render()},error:function(){}})},render:function(){if(this.loaded){this.documents=this.graph.find({"type|=":"/type/document"});this.documents=this.documents.sort(function(a,b){var c=a.value.get("updated_at"),e=b.value.get("updated_at");return c===e?0:c>e?-1:1});$(this.el).html(_.tpl("document_browser",{documents:this.documents,user:this.query.type===
"user"?this.graph.get("/user/"+this.query.value):null,query:this.query}));this.loaded&&this.facets.render();this.browserTab.render()}},applyCommand:function(a){var b;if(a.command==="add_criterion")b=new AddCriterion(this,a.options);else if(a.command==="remove_criterion")b=new RemoveCriterion(this,a.options);this.currentCommand<this.commands.length-1&&this.commands.splice(this.currentCommand+1);var c=undefined;$.each(this.commands,function(e,d){if(d.matchesInverse(b))c=e});if(c>=0){this.commands[c].unexecute();
this.commands.splice(c,1);for(a=c;a<this.commands.length;a++)this.commands[a].execute()}else{this.commands.push(b);b.execute()}this.currentCommand=this.commands.length-1;return b},undo:function(){if(this.currentCommand>=0){this.commands[this.currentCommand].unexecute();this.currentCommand-=1;this.render()}},redo:function(){if(this.currentCommand<this.commands.length-1){this.currentCommand+=1;this.commands[this.currentCommand].execute();this.render()}}}),Facets=Backbone.View.extend({initialize:function(a){this.browser=
-a.browser;this.facetChoices={}},select:function(a){$(".facet").removeClass("selected");$("#facet_"+a).toggleClass("selected")},addChoice:function(a,b,c){this.facetChoices[a+"::"+b+"::"+c]=true},removeChoice:function(a,b,c){delete this.facetChoices[a+"::"+b+"::"+c]},buildView:function(){var a=this,b={facets:[]},c=new Data.Hash;app.browser.graph.get("/config/substance").get("document_types").each(function(e){c=c.union(app.browser.graph.get(e).properties())});app.browser.graph.get("/type/document").all("properties").each(function(e,
+a.browser;this.facetChoices={};this.el="#facets"},select:function(a){$(".facet").removeClass("selected");$("#facet_"+a).toggleClass("selected")},addChoice:function(a,b,c){this.facetChoices[a+"::"+b+"::"+c]=true},removeChoice:function(a,b,c){delete this.facetChoices[a+"::"+b+"::"+c]},buildView:function(){var a=this,b={facets:[]},c=new Data.Hash;app.browser.graph.get("/config/substance").get("document_types").each(function(e){c=c.union(app.browser.graph.get(e).properties())});app.browser.graph.get("/type/document").all("properties").each(function(e,
d){if(e.meta.facet){var f=[],g=[];e.all("values").each(function(h){a.facetChoices[d+"::CONTAINS::"+h._id]===true?g.push({key:escape(h._id),value:h.toString(),item_count:h.referencedObjects.length}):f.push({key:escape(h._id),value:h.toString(),item_count:h.referencedObjects.length})});f.length+g.length>0&&b.facets.push({property:d,property_name:e.name,facet_choices:f,selected_facet_choices:g})}});return b},render:function(){$(this.el).html(_.renderTemplate("facets",this.buildView()))}}),Collaborators=
Backbone.View.extend({initialize:function(){this.render()},render:function(){$(this.el).html(Helpers.renderTemplate("collaborators",{status:app.editor.status,id:app.editor.model.id,author:app.editor.model.author,name:app.editor.model.name,hostname:window.location.hostname+(window.location.port!==80?":"+window.location.port:"")}))}}),UserSettings=Backbone.View.extend({events:{"submit form":"updateUser"},updateUser:function(){this.$("#user_password").val()===""||this.$("#user_password").val()===this.$("#user_password_confirmation").val()?
$.ajax({type:"POST",url:"/updateuser",data:{username:this.$("#user_username").val(),name:this.$("#user_name").val(),email:this.$("#user_email").val(),password:this.$("#user_password").val(),website:this.$("#user_website").val(),company:this.$("#user_company").val(),location:this.$("#user_location").val()},dataType:"json",success:function(a){if(a.status==="error")notifier.notify({message:"An error occured. Check your input",type:"error"});else{graph.merge(a.seed);app.username=a.username;app.render();
@@ -89,26 +89,26 @@ e.username+'" class="result-item user"><div class="username">'+e.username+'</div
"'s documents";break;case "recent":a="Recent Documents";break;case "subscribed":a="Subscribed Documents";break;default:a="Documents for &quot;"+this.browser.query.value+"&quot;"}else a="Type to search ...";$(this.el).html(_.tpl("browser_tab",{documents:this.browser.documents,query_descr:a,query:this.browser.query}))}}),Header=Backbone.View.extend({events:{"focus #login-user":"focusUser","blur #login-user":"blurUser","focus #login-password":"focusPassword","blur #login-password":"blurPassword"},initialize:function(){},
focusUser:function(a){a=$(a.currentTarget);if(a.hasClass("hint")){a.val("");a.removeClass("hint")}},blurUser:function(a){a=$(a.currentTarget);if(a.val()===""){a.addClass("hint");a.val("Username")}},focusPassword:function(a){a=$(a.currentTarget);if(a.hasClass("hint")){a.val("");a.removeClass("hint")}},blurPassword:function(a){a=$(a.currentTarget);if(a.val()===""){a.addClass("hint");a.val("Password")}},render:function(){var a=this.options.app.username,b=graph.find({"type|=":"/type/notification",recipient:"/user/"+
a});b=b.sort(function(c,e){c=c.value.get("created_at");e=e.value.get("created_at");return c===e?0:c>e?-1:1});$(this.el).html(_.tpl("header",{user:graph.get("/user/"+a),notifications:b,count:b.select(function(c){return!c.get("read")}).length,notifications_active:this.notificationsActive}))}}),Router=Backbone.Router.extend({initialize:function(){this.route(":username","user",app.userDocs);this.route(":username/:docname/:node/:comment","comment",this.loadDocument);this.route(":username/:docname/:node",
-"node",this.loadDocument);this.route(":username/:docname","document",this.loadDocument);this.route("subscribed","subscribed",app.subscribedDocs);this.route("recent","recent",app.recentDocs);this.route("search/:searchstr","search",app.searchDocs)},loadDocument:function(a,b,c,e){app.browser.load({type:"user",value:a});app.document.loadDocument(a,b,c,e);$("#document_wrapper").attr("url",a+"/"+b+(c?"/"+c:"")+(e?"/"+e:""));$("#browser_wrapper").attr("url",a);return false}}),Application=Backbone.View.extend({events:{"click .new-document":"newDocument",
-"click a.load-document":"loadDocument","click a.signup":"toggleSignup","click .tab":"switchTab","click a.show-attributes":"showAttributes","submit #create_document":"createDocument","submit #login-form":"login","click a.delete-document":"deleteDocument","click a.toggle-signup":"toggleSignup","click a.toggle-startpage":"toggleStartpage","click a.toggle-edit-mode":"toggleEditMode","click a.toggle-show-mode":"toggleShowMode","click .toggle.logout":"logout","click .toggle.user-settings":"toggleUserSettings",
-"click .toggle.user-profile":"toggleUserProfile","submit #signup-form":"registerUser","click .toggle.notifications":"toggleNotifications","click .toggle-toc":"toggleTOC","click #event_notifications a .notification":"hideNotifications","click #toc_wrapper":"toggleTOC","click a.open-notification":"openNotification","change #document_name":"updateDocumentName","click a.toggle-recent":"toggleRecent","click a.toggle-subscribed":"toggleSubscribed","click a.toggle-userdocs":"toggleUserDocs"},toggleRecent:function(){this.recentDocs();
-return false},toggleSubscribed:function(){this.subscribedDocs();return false},toggleUserDocs:function(){this.userDocs(app.username);return false},userDocs:function(a){app.browser.load({type:"user",value:a});$("#browser_wrapper").attr("url",a);app.browser.bind("loaded",function(){app.toggleView("browser");app.browser.unbind("loaded")});return false},updateDocumentName:function(a){var b=$(a.currentTarget).val();this.checkDocumentName(b,function(c){if(c){app.document.updateName(b);router.navigate(app.username+
-"/"+b)}else{$("#document_name").val(app.document.model.get("name"));alert("Sorry, this name is already taken.")}});return false},login:function(){this.authenticate();return false},openNotification:function(a){a=$(a.currentTarget).attr("href");var b=a.replace("#","").split("/");app.document.loadDocument(b[0],b[1],b[2],b[3]);$("#document_wrapper").attr("url",a);return false},recentDocs:function(){app.browser.load({type:"recent",value:50});$("#browser_wrapper").attr("url","recent");app.browser.bind("loaded",
-function(){app.toggleView("browser");app.browser.unbind("loaded")});return false},subscribedDocs:function(){app.browser.load({type:"subscribed",value:50});$("#browser_wrapper").attr("url","subscribed");app.browser.bind("loaded",function(){app.toggleView("browser");app.browser.unbind("loaded")});return false},searchDocs:function(a){app.browser.load({type:"keyword",value:encodeURI(a)});$("#browser_wrapper").attr("url","search/"+encodeURI(a));app.browser.bind("loaded",function(){app.toggleView("browser")})},
-toggleStartpage:function(){app.browser.browserTab.render();$("#content_wrapper").html(_.tpl("startpage"));$("#slider").nivoSlider({manualAdvance:true});var a=document.createElement("script"),b=document.getElementsByTagName("script")[0];a.type="text/javascript";a.async=true;a.src="http://api.flattr.com/js/0.6/load.js?mode=auto";b.parentNode.insertBefore(a,b);app.toggleView("content");return false},showNotifications:function(){this.header.notificationsActive=true;this.header.render()},toggleTOC:function(){if($("#toc_wrapper").is(":hidden")){$("#document .board").addClass("active");
-$("#toc_wrapper").slideDown();$("#toc_wrapper").css("top",Math.max(_.scrollTop()-$("#document").offset().top,0))}else{$("#document .board").removeClass("active");$("#toc_wrapper").slideUp()}return false},hideNotifications:function(){graph.find({"type|=":"/type/notification",recipient:"/user/"+app.username}).select(function(a){return!a.get("read")}).each(function(a){a.set({read:true})});this.header.notificationsActive=false;this.header.render()},toggleNotifications:function(){$("#event_notifications").hasClass("active")?
-this.hideNotifications():this.showNotifications();return false},loadNotifications:function(){var a=this;$.ajax({type:"GET",url:"/notifications",dataType:"json",success:function(b){var c={};_.each(b,function(e,d){graph.get(d)||(c[d]=e)});graph.merge(c);a.header.render()}})},toggleUserProfile:function(){var a=this;app.browser.load({type:"user",value:this.username});app.browser.bind("loaded",function(){app.toggleView("browser");$("#browser_wrapper").attr("url",a.username);app.browser.unbind("loaded")})},
-newDocument:function(){if(!head.browser.webkit){alert("You need to use a Webkit based browser (Google Chrome, Safari) in order to write documents. In future, other browers will be supported too.");return false}this.content=new NewDocument({el:"#content_wrapper"});this.content.render();this.toggleView("content");return false},scrollTo:function(a){(a=$("#"+a).offset())&&$("html, body").animate({scrollTop:a.top},"slow");return false},toggleUserSettings:function(){this.content=new UserSettings({el:"#content_wrapper"});
-this.content.render();this.toggleView("content");return false},toggleSignup:function(){app.browser.browserTab.render();$("#content_wrapper").html(_.tpl("signup"));app.toggleView("content");return false},switchTab:function(a){this.toggleView($(a.currentTarget).attr("view"))},toggleView:function(a){$(".tab").removeClass("active");$("#"+a+"_tab").addClass("active");if(!(a==="browser"&&!this.browser.loaded)){$(".view").hide();$("#"+a+"_wrapper").show();setTimeout(function(){router.navigate($("#"+a+"_wrapper").attr("url"))},
-10);return false}},checkDocumentName:function(a,b){if(RegExp(graph.get("/type/document").get("properties","name").validator).test(a)){$.ajax({type:"GET",url:"/documents/"+app.username+"/"+a,dataType:"json",success:function(c){c.status==="error"?b(true):b(false)},error:function(){b(false)}});return false}else b(false)},createDocument:function(){var a=this,b=$("#create_document input[name=new_document_name]").val(),c=_.slug(b);this.checkDocumentName(c,function(e){if(e)a.document.newDocument("/type/article",
-c,b);else{$("#create_document input[name=new_document_name]").addClass("error");$("#new_document_name_message").html("This document name is already taken.")}});return false},toggleEditMode:function(){var a=app.document.model.get("creator")._id.split("/")[2],b=app.document.model.get("name");app.document.loadDocument(a,b,null,null,"edit");return false},toggleShowMode:function(){var a=app.document.model.get("creator")._id.split("/")[2],b=app.document.model.get("name");app.document.loadDocument(a,b,null,
-null,"show");return false},loadDocument:function(a){var b=$(a.currentTarget).attr("user").toLowerCase();name=$(a.currentTarget).attr("name");app.document.loadDocument(b,name,null,null);if(router){router.navigate($(a.currentTarget).attr("href"));$("#document_wrapper").attr("url",$(a.currentTarget).attr("href"))}return false},showAttributes:function(){app.document.drawer.toggle("Attributes");$(".show-attributes").toggleClass("selected");return false},logout:function(){var a=this;$.ajax({type:"POST",
-url:"/logout",dataType:"json",success:function(){a.username=null;a.authenticated=false;a.render();$(".new-document").hide()}});return false},deleteDocument:function(){if(confirm("Are you sure you want to delete this document?")){this.document.deleteDocument(app.document.model._id);this.document.closeDocument()}return false},updateSystemStatus:function(a){this.activeUsers=a.active_users},query:function(){return this.authenticated?{type:"user",value:this.username}:{type:"user",value:"demo"}},initialize:function(){var a=
-this;this.browser=new DocumentBrowser({el:this.$("#browser_wrapper"),app:this});this.document=new Document({el:"#document_wrapper",app:this});this.header=new Header({el:"#header",app:this});this.activeUsers=[];$("body").click(function(){app.document.reset(true);return true});if(session.username){graph.merge(session.seed);this.authenticated=true;this.username=session.username;this.trigger("authenticated");$("#tabs").show();$(".new-document").show()}else this.authenticated=false;this.bind("authenticated",
-function(){a.authenticated=true;$("#tabs").show();$(".new-document").show();a.render();a.browser.load(a.query())});setInterval(function(){a.loadNotifications()},3E4);a.render()},connect:function(){var a=this;DNode({Session:{updateStatus:function(b){a.document.status=b;a.document.trigger("status:changed")},updateSystemStatus:function(b){a.updateSystemStatus(b)},updateNode:function(b,c){app.document.updateNode(b,c)},moveNode:function(){throw"Not implemented";},insertNode:function(b,c,e,d,f){b==="sibling"?
-app.document.addSibling(c,e,d,f):app.document.addChild(c,e,d,f)},removeNode:function(b,c){app.document.removeNode(b,c)},getDocument:function(b){var c=a.getFullDocument(app.document.model._id);b(c)}}}).connect(function(b){remote=b;a.trigger("connected")})},getFullDocument:function(a){function b(e){if(!c[e]){var d=graph.get(e);c[e]=d.toJSON();d.type.all("properties").each(function(f){f.isObjectType()&&d.all(f.key).each(function(g){g.type&&b(g._id)})})}}var c={};b(a);return c},authenticate:function(){var a=
-this;$.ajax({type:"POST",url:"/login",data:{username:$("#login-user").val(),password:$("#login-password").val()},dataType:"json",success:function(b){if(b.status==="error")return notifier.notify(Notifications.AUTHENTICATION_FAILED);else{graph.merge(b.seed);a.username=b.username;a.trigger("authenticated")}},error:function(){notifier.notify(Notifications.AUTHENTICATION_FAILED)}});return false},registerUser:function(){var a=this;$(".page-content .input-message").empty();$("#registration_error_message").empty();
-$(".page-content input").removeClass("error");$.ajax({type:"POST",url:"/register",data:{username:$("#signup_user").val(),name:$("#signup_name").val(),email:$("#signup_email").val(),password:$("#signup_password").val()},dataType:"json",success:function(b){if(b.status==="error")if(b.field==="username"){$("#signup_user").addClass("error");$("#signup_user_message").html(b.message)}else $("#registration_error_message").html(b.message);else{graph.merge(b.seed);notifier.notify(Notifications.AUTHENTICATED);
+"node",this.loadDocument);this.route(":username/:docname","document",this.loadDocument);this.route("subscribed","subscribed",app.subscribedDocs);this.route("recent","recent",app.recentDocs);this.route("search/:searchstr","search",app.searchDocs);this.route("","startpage",app.toggleStartpage)},loadDocument:function(a,b,c,e){app.browser.load({type:"user",value:a});app.document.loadDocument(a,b,c,e);$("#document_wrapper").attr("url",a+"/"+b+(c?"/"+c:"")+(e?"/"+e:""));$("#browser_wrapper").attr("url",
+a);return false}}),Application=Backbone.View.extend({events:{"click .new-document":"newDocument","click a.load-document":"loadDocument","click a.signup":"toggleSignup","click .tab":"switchTab","click a.show-attributes":"showAttributes","submit #create_document":"createDocument","submit #login-form":"login","click a.delete-document":"deleteDocument","click a.toggle-signup":"toggleSignup","click a.toggle-startpage":"toggleStartpage","click a.toggle-edit-mode":"toggleEditMode","click a.toggle-show-mode":"toggleShowMode",
+"click .toggle.logout":"logout","click .toggle.user-settings":"toggleUserSettings","click .toggle.user-profile":"toggleUserProfile","submit #signup-form":"registerUser","click .toggle.notifications":"toggleNotifications","click .toggle-toc":"toggleTOC","click #event_notifications a .notification":"hideNotifications","click #toc_wrapper":"toggleTOC","click a.open-notification":"openNotification","change #document_name":"updateDocumentName","click a.toggle-recent":"toggleRecent","click a.toggle-subscribed":"toggleSubscribed",
+"click a.toggle-userdocs":"toggleUserDocs"},toggleRecent:function(){this.recentDocs();return false},toggleSubscribed:function(){this.subscribedDocs();return false},toggleUserDocs:function(){this.userDocs(app.username);return false},userDocs:function(a){app.browser.load({type:"user",value:a});$("#browser_wrapper").attr("url",a);app.browser.bind("loaded",function(){app.toggleView("browser");app.browser.unbind("loaded")});return false},updateDocumentName:function(a){var b=$(a.currentTarget).val();this.checkDocumentName(b,
+function(c){if(c){app.document.updateName(b);router.navigate(app.username+"/"+b)}else{$("#document_name").val(app.document.model.get("name"));alert("Sorry, this name is already taken.")}});return false},login:function(){this.authenticate();return false},openNotification:function(a){a=$(a.currentTarget).attr("href");var b=a.replace("#","").split("/");app.document.loadDocument(b[0],b[1],b[2],b[3]);$("#document_wrapper").attr("url",a);return false},recentDocs:function(){app.browser.load({type:"recent",
+value:50});$("#browser_wrapper").attr("url","recent");app.browser.bind("loaded",function(){app.toggleView("browser");app.browser.unbind("loaded")});return false},subscribedDocs:function(){app.browser.load({type:"subscribed",value:50});$("#browser_wrapper").attr("url","subscribed");app.browser.bind("loaded",function(){app.toggleView("browser");app.browser.unbind("loaded")});return false},searchDocs:function(a){app.browser.load({type:"keyword",value:encodeURI(a)});$("#browser_wrapper").attr("url","search/"+
+encodeURI(a));app.browser.bind("loaded",function(){app.toggleView("browser")})},toggleStartpage:function(){app.browser.browserTab.render();$("#content_wrapper").html(_.tpl("startpage"));$("#slider").nivoSlider({manualAdvance:true});var a=document.createElement("script"),b=document.getElementsByTagName("script")[0];a.type="text/javascript";a.async=true;a.src="http://api.flattr.com/js/0.6/load.js?mode=auto";b.parentNode.insertBefore(a,b);app.toggleView("content");return false},showNotifications:function(){this.header.notificationsActive=
+true;this.header.render()},toggleTOC:function(){if($("#toc_wrapper").is(":hidden")){$("#document .board").addClass("active");$("#toc_wrapper").slideDown();$("#toc_wrapper").css("top",Math.max(_.scrollTop()-$("#document").offset().top,0))}else{$("#document .board").removeClass("active");$("#toc_wrapper").slideUp()}return false},hideNotifications:function(){graph.find({"type|=":"/type/notification",recipient:"/user/"+app.username}).select(function(a){return!a.get("read")}).each(function(a){a.set({read:true})});
+this.header.notificationsActive=false;this.header.render()},toggleNotifications:function(){$("#event_notifications").hasClass("active")?this.hideNotifications():this.showNotifications();return false},loadNotifications:function(){var a=this;$.ajax({type:"GET",url:"/notifications",dataType:"json",success:function(b){var c={};_.each(b,function(e,d){graph.get(d)||(c[d]=e)});graph.merge(c);a.header.render()}})},toggleUserProfile:function(){var a=this;app.browser.load({type:"user",value:this.username});
+app.browser.bind("loaded",function(){app.toggleView("browser");$("#browser_wrapper").attr("url",a.username);app.browser.unbind("loaded")})},newDocument:function(){if(!head.browser.webkit){alert("You need to use a Webkit based browser (Google Chrome, Safari) in order to write documents. In future, other browers will be supported too.");return false}this.content=new NewDocument({el:"#content_wrapper"});this.content.render();this.toggleView("content");return false},scrollTo:function(a){(a=$("#"+a).offset())&&
+$("html, body").animate({scrollTop:a.top},"slow");return false},toggleUserSettings:function(){this.content=new UserSettings({el:"#content_wrapper"});this.content.render();this.toggleView("content");return false},toggleSignup:function(){app.browser.browserTab.render();$("#content_wrapper").html(_.tpl("signup"));app.toggleView("content");return false},switchTab:function(a){this.toggleView($(a.currentTarget).attr("view"))},toggleView:function(a){$(".tab").removeClass("active");$("#"+a+"_tab").addClass("active");
+if(!(a==="browser"&&!this.browser.loaded)){$(".view").hide();$("#"+a+"_wrapper").show();setTimeout(function(){router.navigate($("#"+a+"_wrapper").attr("url"))},10);return false}},checkDocumentName:function(a,b){if(RegExp(graph.get("/type/document").get("properties","name").validator).test(a)){$.ajax({type:"GET",url:"/documents/"+app.username+"/"+a,dataType:"json",success:function(c){c.status==="error"?b(true):b(false)},error:function(){b(false)}});return false}else b(false)},createDocument:function(){var a=
+this,b=$("#create_document input[name=new_document_name]").val(),c=_.slug(b);this.checkDocumentName(c,function(e){if(e)a.document.newDocument("/type/article",c,b);else{$("#create_document input[name=new_document_name]").addClass("error");$("#new_document_name_message").html("This document name is already taken.")}});return false},toggleEditMode:function(){var a=app.document.model.get("creator")._id.split("/")[2],b=app.document.model.get("name");app.document.loadDocument(a,b,null,null,"edit");return false},
+toggleShowMode:function(){var a=app.document.model.get("creator")._id.split("/")[2],b=app.document.model.get("name");app.document.loadDocument(a,b,null,null,"show");return false},loadDocument:function(a){var b=$(a.currentTarget).attr("user").toLowerCase();name=$(a.currentTarget).attr("name");app.document.loadDocument(b,name,null,null);if(router){router.navigate($(a.currentTarget).attr("href"));$("#document_wrapper").attr("url",$(a.currentTarget).attr("href"))}return false},showAttributes:function(){app.document.drawer.toggle("Attributes");
+$(".show-attributes").toggleClass("selected");return false},logout:function(){var a=this;$.ajax({type:"POST",url:"/logout",dataType:"json",success:function(){a.username=null;a.authenticated=false;a.render();$(".new-document").hide()}});return false},deleteDocument:function(){if(confirm("Are you sure you want to delete this document?")){this.document.deleteDocument(app.document.model._id);this.document.closeDocument()}return false},updateSystemStatus:function(a){this.activeUsers=a.active_users},query:function(){return this.authenticated?
+{type:"user",value:this.username}:{type:"user",value:"demo"}},initialize:function(){var a=this;this.browser=new DocumentBrowser({el:this.$("#browser_wrapper"),app:this});this.document=new Document({el:"#document_wrapper",app:this});this.header=new Header({el:"#header",app:this});this.activeUsers=[];$("body").click(function(){app.document.reset(true);return true});if(session.username){graph.merge(session.seed);this.authenticated=true;this.username=session.username;this.trigger("authenticated");$("#tabs").show();
+$(".new-document").show()}else this.authenticated=false;this.bind("authenticated",function(){a.authenticated=true;$("#tabs").show();$(".new-document").show();a.render();a.browser.load(a.query())});setInterval(function(){a.loadNotifications()},3E4);a.render()},connect:function(){var a=this;DNode({Session:{updateStatus:function(b){a.document.status=b;a.document.trigger("status:changed")},updateSystemStatus:function(b){a.updateSystemStatus(b)},updateNode:function(b,c){app.document.updateNode(b,c)},moveNode:function(){throw"Not implemented";
+},insertNode:function(b,c,e,d,f){b==="sibling"?app.document.addSibling(c,e,d,f):app.document.addChild(c,e,d,f)},removeNode:function(b,c){app.document.removeNode(b,c)},getDocument:function(b){var c=a.getFullDocument(app.document.model._id);b(c)}}}).connect(function(b){remote=b;a.trigger("connected")})},getFullDocument:function(a){function b(e){if(!c[e]){var d=graph.get(e);c[e]=d.toJSON();d.type.all("properties").each(function(f){f.isObjectType()&&d.all(f.key).each(function(g){g.type&&b(g._id)})})}}
+var c={};b(a);return c},authenticate:function(){var a=this;$.ajax({type:"POST",url:"/login",data:{username:$("#login-user").val(),password:$("#login-password").val()},dataType:"json",success:function(b){if(b.status==="error")return notifier.notify(Notifications.AUTHENTICATION_FAILED);else{graph.merge(b.seed);a.username=b.username;a.trigger("authenticated")}},error:function(){notifier.notify(Notifications.AUTHENTICATION_FAILED)}});return false},registerUser:function(){var a=this;$(".page-content .input-message").empty();
+$("#registration_error_message").empty();$(".page-content input").removeClass("error");$.ajax({type:"POST",url:"/register",data:{username:$("#signup_user").val(),name:$("#signup_name").val(),email:$("#signup_email").val(),password:$("#signup_password").val()},dataType:"json",success:function(b){if(b.status==="error")if(b.field==="username"){$("#signup_user").addClass("error");$("#signup_user_message").html(b.message)}else $("#registration_error_message").html(b.message);else{graph.merge(b.seed);notifier.notify(Notifications.AUTHENTICATED);
a.username=b.username;a.trigger("authenticated")}},error:function(){$("#registration_error_message").html("Unknown error.")}});return false},render:function(){this.document.render();this.browser.render();this.header.render();return this}}),remote,app,router,editor,graph=(new Data.Graph(seed)).connect("ajax");
(function(){$(function(){function a(){confirm("There are conflicted or rejected nodes since the last sync. The workspace will be reset for your own safety");window.location.reload(true)}if(function(){if(head.browser.mozilla&&head.browser.version>"1.9.2")return true;if(head.browser.webkit&&head.browser.version>"533.0")return true;if(head.browser.opera&&head.browser.version>"11.0")return true;return false}()){$("#container").show();window.positionBoard=function(){if(document.getElementById("document_wrapper").offsetTop-
_.scrollTop()<0){$("#document .board").addClass("docked");$("#document .board").css("left",$("#document").offset().left+"px");$("#document .board").css("width",$("#document").width()+"px");var c=$("#toc_wrapper").offset();c&&_.scrollTop()<c.top&&$("#toc_wrapper").css("top",_.scrollTop()-$("#document").offset().top+"px")}else{$("#document .board").css("left","");$("#toc_wrapper").css("top",0);$("#document .board").removeClass("docked")}};positionBoard();$(window).bind("scroll",positionBoard);$(window).bind("resize",
View
1 server.js
@@ -178,7 +178,6 @@ function scripts() {
app.get('/sitemap.xml', function(req, res) {
Document.recent(3000, '', function(err, nodes, count) {
res.writeHead(200, {'Content-Type': 'text/plain'});
- var count = 0;
_.each(nodes, function(n) {
if (_.include(n.type, '/type/document')) {
res.write("http://substance.io/"+n.creator.split('/')[2]+"/"+n.name+"\n");

0 comments on commit a426283

Please sign in to comment.
Something went wrong with that request. Please try again.