Commits

Anonymous committed e1d3029

fix alias mapping in couch. While I'm here regenerate static files.

  • Participants
  • Parent commits 574a3ba

Comments (0)

Files changed (3)

File couchit/_design/page/alias/map.js

 function(doc) {
     if (doc.itemType == 'aliaspage')
-        emit([doc.site, doc.title.toLowerCase().replace(/ /g, "_"), doc);
+        emit([doc.site, doc.title.toLowerCase().replace(/ /g, "_")], doc);
 }

File static/css/screen.css

 table.difftabular th {text-align:center;}
 table.difftabular th.linenos {text-align:center;}
 .claim, .logout, .login {font-weight:bold;text-decoration:none;}
+.rename {font-size:12px;line-height:18px;vertical-align:middle;}
 .hidden {display:none;}
 body {min-width:700px;color:#000;}
 html,body,#container {height:100%;}
 header h2 {padding-bottom:10px;}
 header h1 a {text-decoration:none;}
 #page article,#pedit #pedit_wrapper {display:block;padding:10px;border-right:4px solid;border-left:4px solid;border-bottom:4px solid;-moz-border-radius-bottomleft:5px;-moz-border-radius-bottomright:5px;-khtml-border-bottom-left-radius:5px;-webkit-border-bottom-left-radius:5px;-khtml-border-bottom-right-radius:5px;-webkit-border-bottom-right-radius:5px;border-bottom-left-radius:5px;border-bottom-right-radius:5px;min-height:350px;}
-span.rename {font-size:12px;line-height:18px;vertical-align:middle;}
+.rename {display:inline;width:200px;margin-left:10px;opacity:0.6;filter:0.6;}
 #phistory, #pdiff,#pdesign,#psettings,#pgeneric {display:block;padding:10px;border:4px solid;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-radius:5px;border-radius:5px;min-height:350px;}
 #pgeneric {text-align:left;margin-top:10px;}
 #pdiff h4 {border-bottom:1px solid;}

File static/js/couchit-page.js

-var PageUI=Class.create({initialize:function(){var A=this;this.Sidebar=$("sidebar");this.Page=$("page");this.tabs=new Control.Tabs("tabs_wiki");this.textarea=new Control.TextArea("content");this.toolbar=new Control.TextArea.ToolBar(this.textarea);this.toolbar.container.id="markdown_toolbar";this.converter=new Showdown.converter;this.converter_callback=function(C){$("preview").innerHTML=A.converter.makeHtml(C)};this.converter_callback(this.textarea.getValue());this.textarea.observe("change",A.converter_callback);this.snippet_window=new Control.Window($("snippet_window"),{resizable:true,draggable:$("snippet_window_title"),closeOnClick:$("snippet_window_close")});this.build_toolbar();this.init();this.tabs.observe("beforeChange",function(D,C){if(!Page.created){A.update_tabs(C)}else{var E=window.confirm("Are you sure you want to navigate away from this page?\n\nYou have unsaved changes. Continue and discard those changes?\n\nClick OK to continue, or click Cancel to stay on this page.");if(!E){throw $break}else{history.go(-1)}}});window.onresize=function(D){var C=document.viewport.getHeight()-250;$("content").setStyle({height:C+"px"})};$("cancelEdit").observe("click",function(C){Event.stop(C);A.tabs.setActiveTab("pview");return false});var B=$("page_delete");if(B){B.observe("click",function(C){Event.stop(C);var D=window.confirm("Are you sure you want to delete this page?\n\nClick OK to continue, or click Cancel to stay on this page.");if(!D){return false}document.location.href=this.href},false)}},init:function(){var B=this.tabs.activeContainer;if(Page.created&&B.id!="pedit"){this.tabs.setActiveTab("pedit")}B=this.tabs.activeContainer;if(B){this.update_tabs(B)}var A=document.viewport.getHeight()-250;$("content").setStyle({height:A+"px"})},update_tabs:function(A){if(A.id=="pedit"){this.Sidebar.hide();this.Page.setStyle({width:"99%"})}else{this.Page.setStyle({width:"76%"});this.Sidebar.show()}},build_toolbar:function(){var A=this;this.toolbar.addButton("Italics",function(){this.wrapSelection("*","*")},{id:"markdown_italics_button"});this.toolbar.addButton("Bold",function(){this.wrapSelection("**","**")},{id:"markdown_bold_button"});this.toolbar.addButton("Link",function(){var C=this.getSelection();var B=prompt("Enter Link URL","");if(B==null){return }this.replaceSelection("["+(C==""?"Link Text":C)+"]("+(B==""?"http://link_url/":B).replace(/^(?!(f|ht)tps?:\/\/)/,"http://")+")")},{id:"markdown_link_button"});this.toolbar.addButton("Image",function(){var C=this.getSelection();var B=prompt("Enter Image URL","");if(B==null){return }this.replaceSelection("!["+(C==""?"Image Alt Text":C)+"]("+(B==""?"http://image_url/":B).replace(/^(?!(f|ht)tps?:\/\/)/,"http://")+")")},{id:"markdown_image_button"});this.toolbar.addButton("Heading",function(){var B=this.getSelection();if(B==""){B="Heading"}this.replaceSelection("\n"+B+"\n"+$R(0,Math.max(5,B.length)).collect(function(){}).join("")+"\n")},{id:"markdown_heading_button"});this.toolbar.addButton("Unordered List",function(B){this.collectFromEachSelectedLine(function(C){return B.shiftKey?(C.match(/^\*{2,}/)?C.replace(/^\*/,""):C.replace(/^\*\s/,"")):(C.match(/\*+\s/)?"*":"* ")+C})},{id:"markdown_unordered_list_button"});this.toolbar.addButton("Ordered List",function(C){var B=0;this.collectFromEachSelectedLine(function(D){if(!D.match(/^\s+$/)){++B;return C.shiftKey?D.replace(/^\d+\.\s/,""):(D.match(/\d+\.\s/)?"":B+". ")+D}})},{id:"markdown_ordered_list_button"});this.toolbar.addButton("Block Quote",function(B){this.collectFromEachSelectedLine(function(C){return B.shiftKey?C.replace(/^\> /,""):"> "+C})},{id:"markdown_quote_button"});this.toolbar.addButton("Code Block",function(B){this.collectFromEachSelectedLine(function(C){return B.shiftKey?C.replace(/    /,""):"    "+C})},{id:"markdown_code_button"});this.toolbar.addButton("Snippet",function(E){var C=this.getSelection();if(C){var B=C.split("\n");if(B[0].match(/\s*:::(\w*)/)){var H=B[0].replace(/\s*:::(\w*)/,"$1");B.splice(0,1);if(H){$("snippet_language").select("option").each(function(I){if(I.value==H){I.selected=true}})}}var D=$A(B).collect(function(I){return I.replace(/    /,"")}).join("\n");$("snippet_content").value=D}A.snippet_window.open();var F=this;var G=function(L){Event.stop(L);var K=$("fsnippet").getInputs("radio","snippet_from");if(K[0].checked){var J=$("snippet_content").getValue();J=$A(J.split("\n")).collect(function(M){M="    "+M;return M}).join("\n");D="\n\n    :::"+$("snippet_language").getValue()+"\n"+J;F.replaceSelection(D);A.snippet_window.close();$("snippet_content").value=""}else{var I="/proxy?url="+encodeURIComponent($("snippet_url").getValue());new Ajax.Request(I,{method:"get",contentType:"application/json",requestHeaders:{Accept:"application/json"},onSuccess:function(M){data=M.responseText.evalJSON(true);J=$A(data.snippet.split("\n")).collect(function(N){return"    "+N}).join("\n");D=" \n\n    :::"+data.language+"\n"+J;F.replaceSelection(D);A.snippet_window.close();$("snippet_content").value=""},onFailure:function(){alert("mmm... error while trying to fetch content from friendpaste:(")}})}return false};$("ssnippet").observe("click",G,false);$("cancelSnippet").observe("click",function(I){Event.stop(I);A.snippet_window.close();return false});$("snippet_url","snippet_language","snippet_content").each(function(I){I.observe("focus",function(J){if(this.id=="snippet_url"){$("sfp").checked=true}else{$("si").checked=true}},false)})},{id:"markdown_snippet_button"});this.toolbar.addButton("Help",function(){window.open("http://daringfireball.net/projects/markdown/dingus")},{id:"markdown_help_button"})}});
+var PageUI=Class.create({initialize:function(){var A=this;this.Sidebar=$("sidebar");this.Page=$("page");this.tabs=new Control.Tabs("tabs_wiki");this.textarea=new Control.TextArea("content");this.toolbar=new Control.TextArea.ToolBar(this.textarea);this.toolbar.container.id="markdown_toolbar";this.converter=new Showdown.converter;this.converter_callback=function(C){$("preview").innerHTML=A.converter.makeHtml(C)};this.converter_callback(this.textarea.getValue());this.textarea.observe("change",A.converter_callback);this.snippet_window=new Control.Window($("snippet_window"),{resizable:true,draggable:$("snippet_window_title"),closeOnClick:$("snippet_window_close")});this.build_toolbar();this.init();this.tabs.observe("beforeChange",function(D,C){if(!Page.created){A.update_tabs(C)}else{var E=window.confirm("Are you sure you want to navigate away from this page?\n\nYou have unsaved changes. Continue and discard those changes?\n\nClick OK to continue, or click Cancel to stay on this page.");if(!E){throw $break}else{history.go(-1)}}});window.onresize=function(D){var C=document.viewport.getHeight()-250;$("content").setStyle({height:C+"px"})};$("cancelEdit").observe("click",function(C){Event.stop(C);A.tabs.setActiveTab("pview");return false});var B=$("page_delete");if(B){B.observe("click",function(C){Event.stop(C);var D=window.confirm("Are you sure you want to delete this page?\n\nClick OK to continue, or click Cancel to stay on this page.");if(!D){return false}document.location.href=this.href},false)}this._renamingPage=false;if(!Page.created&&!Page.home){this.page_title=$("page_title");this.page_title.setStyle({cursor:"pointer"});this.page_title.title="Click to rename";this.createRenameForm();this.page_title.observe("click",function(C){this._renamingPage=true;A.handleRename()},false)}},init:function(){var B=this.tabs.activeContainer;if(Page.created&&B.id!="pedit"){this.tabs.setActiveTab("pedit")}B=this.tabs.activeContainer;if(B){this.update_tabs(B)}var A=document.viewport.getHeight()-250;$("content").setStyle({height:A+"px"})},update_tabs:function(A){if(A.id=="pedit"){this.Sidebar.hide();this.Page.setStyle({width:"99%"});if(this._renamingPage){this.removeRenameForm()}}else{this.Page.setStyle({width:"76%"});this.Sidebar.show()}},build_toolbar:function(){var A=this;this.toolbar.addButton("Italics",function(){this.wrapSelection("*","*")},{id:"markdown_italics_button"});this.toolbar.addButton("Bold",function(){this.wrapSelection("**","**")},{id:"markdown_bold_button"});this.toolbar.addButton("Link",function(){var C=this.getSelection();var B=prompt("Enter Link URL","");if(B==null){return }this.replaceSelection("["+(C==""?"Link Text":C)+"]("+(B==""?"http://link_url/":B).replace(/^(?!(f|ht)tps?:\/\/)/,"http://")+")")},{id:"markdown_link_button"});this.toolbar.addButton("Image",function(){var C=this.getSelection();var B=prompt("Enter Image URL","");if(B==null){return }this.replaceSelection("!["+(C==""?"Image Alt Text":C)+"]("+(B==""?"http://image_url/":B).replace(/^(?!(f|ht)tps?:\/\/)/,"http://")+")")},{id:"markdown_image_button"});this.toolbar.addButton("Heading",function(){var B=this.getSelection();if(B==""){B="Heading"}this.replaceSelection("\n"+B+"\n"+$R(0,Math.max(5,B.length)).collect(function(){}).join("")+"\n")},{id:"markdown_heading_button"});this.toolbar.addButton("Unordered List",function(B){this.collectFromEachSelectedLine(function(C){return B.shiftKey?(C.match(/^\*{2,}/)?C.replace(/^\*/,""):C.replace(/^\*\s/,"")):(C.match(/\*+\s/)?"*":"* ")+C})},{id:"markdown_unordered_list_button"});this.toolbar.addButton("Ordered List",function(C){var B=0;this.collectFromEachSelectedLine(function(D){if(!D.match(/^\s+$/)){++B;return C.shiftKey?D.replace(/^\d+\.\s/,""):(D.match(/\d+\.\s/)?"":B+". ")+D}})},{id:"markdown_ordered_list_button"});this.toolbar.addButton("Block Quote",function(B){this.collectFromEachSelectedLine(function(C){return B.shiftKey?C.replace(/^\> /,""):"> "+C})},{id:"markdown_quote_button"});this.toolbar.addButton("Code Block",function(B){this.collectFromEachSelectedLine(function(C){return B.shiftKey?C.replace(/    /,""):"    "+C})},{id:"markdown_code_button"});this.toolbar.addButton("Snippet",function(E){var C=this.getSelection();if(C){var B=C.split("\n");if(B[0].match(/\s*:::(\w*)/)){var H=B[0].replace(/\s*:::(\w*)/,"$1");B.splice(0,1);if(H){$("snippet_language").select("option").each(function(I){if(I.value==H){I.selected=true}})}}var D=$A(B).collect(function(I){return I.replace(/    /,"")}).join("\n");$("snippet_content").value=D}A.snippet_window.open();var F=this;var G=function(L){Event.stop(L);var K=$("fsnippet").getInputs("radio","snippet_from");if(K[0].checked){var J=$("snippet_content").getValue();J=$A(J.split("\n")).collect(function(M){M="    "+M;return M}).join("\n");D="\n\n    :::"+$("snippet_language").getValue()+"\n"+J;F.replaceSelection(D);A.snippet_window.close();$("snippet_content").value=""}else{var I="/proxy?url="+encodeURIComponent($("snippet_url").getValue());new Ajax.Request(I,{method:"get",contentType:"application/json",requestHeaders:{Accept:"application/json"},onSuccess:function(M){data=M.responseText.evalJSON(true);J=$A(data.snippet.split("\n")).collect(function(N){return"    "+N}).join("\n");D=" \n\n    :::"+data.language+"\n"+J;F.replaceSelection(D);A.snippet_window.close();$("snippet_content").value=""},onFailure:function(){alert("mmm... error while trying to fetch content from friendpaste:(")}})}return false};$("ssnippet").observe("click",G,false);$("cancelSnippet").observe("click",function(I){Event.stop(I);A.snippet_window.close();return false});$("snippet_url","snippet_language","snippet_content").each(function(I){I.observe("focus",function(J){if(this.id=="snippet_url"){$("sfp").checked=true}else{$("si").checked=true}},false)})},{id:"markdown_snippet_button"});this.toolbar.addButton("Help",function(){window.open("http://daringfireball.net/projects/markdown/dingus")},{id:"markdown_help_button"})},createRenameForm:function(){var D=$("fedit").action;this._form=new Element("form",{id:"frename",method:"post",action:D});var A=new Element("input",{type:"text",id:"new_title",name:"new_title",value:$("page_title").innerHTML});var B=new Element("input",{type:"hidden",id:"old_title",name:"old_title",value:$("page_title").innerHTML});var C=new Element("a",{id:"rcancel","class":"cancel",href:"#"}).update("Cancel");this._form.insert(B);this._form.insert(A);this._form.insert(C);this._form.onsubmit=this.renamePage.bind(this)},renamePage:function(C){Event.stop(C);var B=$("new_title").getValue();var A=$("old_title").getValue();if(!B){alert("Page title can't be empty.")}else{if(A==B){this.removeRenameForm()}else{new Ajax.Request(this._form.action,{method:"post",contentType:"application/json",requestHeaders:{Accept:"application/json"},postBody:Object.toJSON(this._form.serialize(true)),onSuccess:function(D){data=D.responseText.evalJSON(true);if(data.ok){this._renamingPage=false;document.location.href=data.redirect_url}else{alert(data.error)}},onFailure:function(){alert("mmm... error while trying rename :(, Please contact administrator")}})}}},createRenameHelp:function(){var A=this;this._help=new Element("div",{"class":"rename hidden",}).update("⇤ Click to rename");this.page_title.insert(this._help);this.page_title.observe("mouseover",function(B){A._help.removeClassName("hidden")},false);this.page_title.observe("mouseout",function(B){A._help.addClassName("hidden")},false)},removeRenameForm:function(){this._form.remove();this.createRenameForm();this.page_title.show();this._renamingPage=false},handleRename:function(){var A=this;this.page_title.hide();this.page_title.parentNode.insertBefore(this._form,$("page_title"));this._form.select(".cancel").each(function(B){B.observe("click",function(C){Event.stop(C);A.removeRenameForm();return false},false)})}});