diff --git a/assets/public/js/app.min.js b/assets/public/js/app.min.js
index 591959f5..987b0a67 100644
--- a/assets/public/js/app.min.js
+++ b/assets/public/js/app.min.js
@@ -1 +1 @@
-$(document).ready(function(){$("#logout").click(function(a){return a.preventDefault(),$.ajax({type:"GET",url:"/admin",async:!1,username:"username",password:"password",headers:{Authorization:"Basic xxx"}}).fail(function(){window.location="/"}),!1}),$(document).pjax("a[data-pjax]","#content")}),$(document).on("ready pjax:end",function(){function a(){this.style.height="5px",this.style.height=this.scrollHeight+"px"}return $("#content").off(),document.title=document.getElementById("site-title").innerHTML,$("textarea").each(a),$("textarea").keyup(a),$(window).resize(function(){$("textarea").each(a)}),$("main").hasClass("browse")&&$(document).trigger("page:browse"),$(".editor")[0]&&$(document).trigger("page:editor"),!1}),$(document).on("page:browse",function(){var a="#foreground",b="form#delete",c=null;$("#content").on("click",".delete",function(d){return d.preventDefault(),c=new Object,c.url=$(this).data("file"),c.row=$(this).parent().parent(),c.filename=$(c.row).find(".filename").text(),$(b).find("span").text(c.filename),$(b).fadeIn(200),$(a).fadeIn(200),!1}),$("#content").on("submit",b,function(d){if(d.preventDefault(),null==c)return notification({text:"Something is wrong with your form.",type:"error"}),!1;var e=new XMLHttpRequest;return e.open("DELETE",c.url),e.send(),e.onreadystatechange=function(){if(4==e.readyState){var d=JSON.parse(e.responseText),f="success",g=5e3;$(a).fadeOut(200),$(b).fadeOut(200),$(c.row).fadeOut(200),200!=e.status&&(f="error",g=!1),notification({text:d.message,type:f,timeout:g}),c=null}},!1}),$("#content").on("change",'input[type="file"]',function(a){a.preventDefault(),files=a.target.files,$("#loading").fadeIn();var b=new FormData;return $.each(files,function(a,c){b.append(a,c)}),$.ajax({url:window.location.pathname,type:"POST",data:b,cache:!1,dataType:"json",headers:{"X-Upload":"true"},processData:!1,contentType:!1}).done(function(a){notification({text:"File(s) uploaded successfully.",type:"success",timeout:5e3}),$("#loading").fadeOut(),$.pjax({url:window.location.pathname,container:"#content"})}).fail(function(a){$("#loading").fadeOut(),notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1}),$("#content").on("click","#upload",function(a){return a.preventDefault(),$('.actions input[type="file"]').click(),!1});var d="form#new",e=d+' input[type="text"]';$("#content").on("click",".new",function(b){return b.preventDefault(),$(a).fadeIn(200),$(d).fadeIn(200),!1}),$("#content").on("keypress",e,function(a){return 13==a.keyCode?(a.preventDefault(),$(d).submit(),!1):void 0}),$("#content").on("submit",d,function(a){a.preventDefault();var b=$(e).val(),c=b.split(":"),d="",f="";if(""==b)return notification({text:"You have to write something. If you want to close the box, click the button again.",type:"warning",timeout:5e3}),!1;if(1==c.length)d=b;else{if(2!=c.length)return notification({text:"Hmm... I don't understand you. Try writing something like 'name[:archetype]'.",type:"error"}),!1;d=c[0],f=c[1]}var g={filename:d,archetype:f},h=new XMLHttpRequest;return h.open("POST",window.location.pathname),h.setRequestHeader("Content-Type","application/json;charset=UTF-8"),h.send(JSON.stringify(g)),h.onreadystatechange=function(){if(4==h.readyState){var a=JSON.parse(h.responseText),b="success",c=5e3;200!=h.status&&(b="error",c=!1),notification({text:a.message,type:b,timeout:c}),200==h.status&&$.pjax({url:a.location,container:"#content"})}},!1});var f="form#rename",g=f+' input[type="text"]',h=null;$("#content").on("click",".rename",function(b){return b.preventDefault(),h=$(this).parent().parent().find(".filename").text(),$(a).fadeIn(200),$(f).fadeIn(200),$(f).find("span").text(h),$(f).find('input[type="text"]').val(h),!1}),$("#content").on("keypress",g,function(a){return 13==a.keyCode?(a.preventDefault(),$(f).submit(),!1):void 0}),$("#content").on("submit",f,function(a){a.preventDefault();var b=$(this).find('input[type="text"]').val();if(""===b)return!1;"/"!=b.substring(0,1)&&(b=window.location.pathname.replace("/admin/browse/","")+"/"+b);var c={filename:b},d=new XMLHttpRequest;return d.open("PUT",h),d.setRequestHeader("Content-Type","application/json;charset=UTF-8"),d.send(JSON.stringify(c)),d.onreadystatechange=function(){if(4==d.readyState){var a=JSON.parse(d.responseText),b="success",c=5e3;200!=d.status&&(b="error",c=!1),$.pjax({url:window.location.pathname,container:"#content"}),notification({text:a.message,type:b,timeout:c}),h=null}},!1});var i="button.git",j="form#git",k=j+' input[type="text"]';$("#content").on("click",i,function(b){return b.preventDefault(),$(a).fadeIn(200),$(j).fadeIn(200),!1}),$("#content").on("keypress",k,function(a){return 13==a.keyCode?(a.preventDefault(),$(j).submit(),!1):void 0}),$("#content").on("submit",j,function(b){b.preventDefault();var c=$(this).find('input[type="text"]').val();if(""==c)return notification({text:"You have to write something. If you want to close the box, click outside of it.",type:"warning",timeout:5e3}),!1;var d=new XMLHttpRequest;return d.open("POST","/admin/git"),d.setRequestHeader("Content-Type","application/json;charset=UTF-8"),d.send(JSON.stringify({command:c})),d.onreadystatechange=function(){if(4==d.readyState){var b=JSON.parse(d.responseText);200==d.status?(notification({text:b.message,type:"success",timeout:5e3}),$(j).fadeOut(200),$(a).fadeOut(200),$.pjax({url:window.location.pathname,container:"#content"})):notification({text:b.message,type:"error"})}},!1}),$("#content").on("click",".close",function(b){return b.preventDefault(),$(this).parent().parent().fadeOut(200),$(a).click(),!1}),$("#content").on("click",a,function(c){return c.preventDefault(),$(a).fadeOut(200),$(d).fadeOut(200),$(f).fadeOut(200),$(b).fadeOut(200),$(j).fadeOut(200),!1})}),$(document).on("page:editor",function(){var a=$(".editor"),b=$("#editor-preview"),c=$("#editor-source");if(a.hasClass("complete")&&$("#content").on("keyup","#site-title",function(){$(".frontmatter #title").val($(this).val())}),!a.hasClass("frontmatter-only")){var d=$("#editor-source").data("mode"),e=$('textarea[name="content"]').hide(),f=ace.edit("editor-source");f.getSession().setMode("ace/mode/"+d),f.getSession().setValue(e.val()),f.getSession().on("change",function(){e.val(f.getSession().getValue())}),f.setOptions({wrap:!0,maxLines:1/0,theme:"ace/theme/github",showPrintMargin:!1,fontSize:"1em",minLines:20}),$("#content").on("click","#see-source",function(a){a.preventDefault(),b.hide(),c.fadeIn(),$(this).addClass("active"),$("#see-preview").removeClass("active"),$("#see-preview").data("previewing","false")}),$("#content").on("click","#see-preview",function(a){if(a.preventDefault(),"true"==$(this).data("previewing"))b.hide(),c.fadeIn(),$(this).removeClass("active"),$("#see-source").addClass("active"),$(this).data("previewing","false");else{var d=new showdown.Converter,e=f.getValue(),g=d.makeHtml(e);c.hide(),b.html(g).fadeIn(),$(this).addClass("active"),$("#see-source").removeClass("active"),$(this).data("previewing","true")}return!1})}$("#content").on("keypress","input",function(a){return 13==a.keyCode?(a.preventDefault(),$('input[value="Save"]').focus().click(),!1):void 0});var g=null;$("#content").on("click","form input[type=submit]",function(a){g=this}),$("#content").on("submit","form",function(d){d.preventDefault(),a.hasClass("frontmatter-only")||(b.html("").fadeOut(),$("#see-preview").data("previewing","false"),c.fadeIn());var e=$(g),f={content:$(this).serializeJSON(),contentType:e.data("type"),schedule:e.data("schedule"),regenerate:e.data("regenerate")},h=new XMLHttpRequest;return h.open("POST",window.location),h.setRequestHeader("Content-Type","application/json;charset=UTF-8"),h.send(JSON.stringify(f)),h.onreadystatechange=function(){if(4==h.readyState){var a=JSON.parse(h.responseText),b="success",c=5e3;200==h.status&&(a.message=e.data("message")),200!=h.status&&(b="error",c=!1),notification({text:a.message,type:b,timeout:c})}},!1}),$("#content").on("click",".add",function(a){if(a.preventDefault(),defaultID="lorem-ipsum-sin-dolor-amet",newItem=$("#"+defaultID),newItem.length&&newItem.remove(),block=$(this).parent().parent(),blockType=block.data("type"),blockID=block.attr("id"),"array"==blockType&&(newID=blockID+"[]",input=blockID,input=input.replace(/\[/,"\\["),input=input.replace(/\]/,"\\]"),block.append('
div").length+'" data-type="array-item">
'),console.log("New array item added.")),block.is("div")&&block.hasClass("frontmatter")&&(block=$(".blocks"),blockType="object"),"object"==blockType){if(block.append(''),newItem=$("#"+defaultID),newItem.html(''),field=$("#name-"+defaultID),!document.cookie.replace(/(?:(?:^|.*;\s*)placeholdertip\s*\=\s*([^;]*).*$)|^.*$/,"$1")){var b=new Date;b.setDate(b.getDate()+365),document.cookie="placeholdertip=true; expires="+b.toUTCString+"; path=/",notification({text:'Write the field name and then press enter. If you want to create an array or an object, end the name with ":array" or ":object".',type:"information"})}$(field).keypress(function(a){return 13==a.which?(a.preventDefault(),value=field.val(),""==value?(newItem.remove(),!1):(elements=value.split(":"),elements.length>2?(notification({text:"Invalid syntax. It must be 'name[:type]'.",type:"error"}),!1):2==elements.length&&"array"!=elements[1]&&"object"!=elements[1]?(notification({text:"Only arrays and objects are allowed.",type:"error"}),!1):(field.remove(),"undefined"==typeof blockID?blockID=elements[0]:blockID=blockID+"["+elements[0]+"]",1==elements.length?(newItem.attr("id","block-"+blockID),newItem.append(' '),newItem.prepend(' ')):(type="","array"==elements[1]?type="array":type="object",template='',template=template.replace("${blockID}",blockID),template=template.replace("${elements[0]}",elements[0]),template=template.replace("${type}",type),newItem.after(template),newItem.remove(),console.log('"'+blockID+'" block of type "'+type+'" added.')),!1))):void 0})}return!1}),$("#content").on("click",".delete",function(a){return a.preventDefault(),button=$(this),name=button.parent().parent().attr("for")||button.parent().parent().attr("id")||button.parent().parent().parent().attr("id"),name=name.replace(/\[/,"\\["),name=name.replace(/\]/,"\\]"),console.log(name),$('label[for="'+name+'"]').fadeOut().remove(),$("#"+name).fadeOut().remove(),!1})}),$.noty.themes.admin={name:"admin",helpers:{},modal:{css:{position:"fixed",width:"100%",height:"100%",backgroundColor:"#000",zIndex:1e4,opacity:.6,display:"none",left:0,top:0}}},$.noty.defaults={layout:"topRight",theme:"admin",dismissQueue:!0,animation:{open:"animated bounceInRight",close:"animated fadeOut",easing:"swing",speed:500},timeout:!1,force:!1,modal:!1,maxVisible:5,killer:!1,closeWith:["click"],callback:{onShow:function(){},afterShow:function(){},onClose:function(){},afterClose:function(){},onCloseClick:function(){}},buttons:!1},notification=function(a){var b;switch(a.type){case"success":b='';break;case"error":b='';break;case"warning":b='';break;case"information":b='';break;default:b=''}var c={template:'
'+b+'
'};if(a=$.extend({},c,a),noty(a),!document.cookie.replace(/(?:(?:^|.*;\s*)stickynoties\s*\=\s*([^;]*).*$)|^.*$/,"$1")&&!a.timeout){var d=new Date;d.setDate(d.getDate()+365),document.cookie="stickynoties=true; expires="+d.toUTCString+"; path=/",notification({text:"Some notifications are sticky. If it doesn't go away, click to dismiss it.",type:"information"})}};
\ No newline at end of file
+var basePath="/";$(document).ready(function(){basePath+=window.location.pathname.split("/")[0],$("#logout").click(function(a){return a.preventDefault(),$.ajax({type:"GET",url:basePath+"",async:!1,username:"username",password:"password",headers:{Authorization:"Basic xxx"}}).fail(function(){window.location="/"}),!1}),$(document).pjax("a[data-pjax]","#content")}),$(document).on("ready pjax:end",function(){function a(){this.style.height="5px",this.style.height=this.scrollHeight+"px"}return $("#content").off(),document.title=document.getElementById("site-title").innerHTML,$("textarea").each(a),$("textarea").keyup(a),$(window).resize(function(){$("textarea").each(a)}),$("main").hasClass("browse")&&$(document).trigger("page:browse"),$(".editor")[0]&&$(document).trigger("page:editor"),!1}),$(document).on("page:browse",function(){var a="#foreground",b="form#delete",c=null;$("#content").on("click",".delete",function(d){return d.preventDefault(),c=new Object,c.url=$(this).data("file"),c.row=$(this).parent().parent(),c.filename=$(c.row).find(".filename").text(),$(b).find("span").text(c.filename),$(b).fadeIn(200),$(a).fadeIn(200),!1}),$("#content").on("submit",b,function(d){if(d.preventDefault(),null==c)return notification({text:"Something is wrong with your form.",type:"error"}),!1;var e=new XMLHttpRequest;return e.open("DELETE",c.url),e.send(),e.onreadystatechange=function(){if(4==e.readyState){var d=JSON.parse(e.responseText),f="success",g=5e3;$(a).fadeOut(200),$(b).fadeOut(200),$(c.row).fadeOut(200),200!=e.status&&(f="error",g=!1),notification({text:d.message,type:f,timeout:g}),c=null}},!1}),$("#content").on("change",'input[type="file"]',function(a){a.preventDefault(),files=a.target.files,$("#loading").fadeIn();var b=new FormData;return $.each(files,function(a,c){b.append(a,c)}),$.ajax({url:window.location.pathname,type:"POST",data:b,cache:!1,dataType:"json",headers:{"X-Upload":"true"},processData:!1,contentType:!1}).done(function(a){notification({text:"File(s) uploaded successfully.",type:"success",timeout:5e3}),$("#loading").fadeOut(),$.pjax({url:window.location.pathname,container:"#content"})}).fail(function(a){$("#loading").fadeOut(),notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1}),$("#content").on("click","#upload",function(a){return a.preventDefault(),$('.actions input[type="file"]').click(),!1});var d="form#new",e=d+' input[type="text"]';$("#content").on("click",".new",function(b){return b.preventDefault(),$(a).fadeIn(200),$(d).fadeIn(200),!1}),$("#content").on("keypress",e,function(a){return 13==a.keyCode?(a.preventDefault(),$(d).submit(),!1):void 0}),$("#content").on("submit",d,function(a){a.preventDefault();var b=$(e).val(),c=b.split(":"),d="",f="";if(""==b)return notification({text:"You have to write something. If you want to close the box, click the button again.",type:"warning",timeout:5e3}),!1;if(1==c.length)d=b;else{if(2!=c.length)return notification({text:"Hmm... I don't understand you. Try writing something like 'name[:archetype]'.",type:"error"}),!1;d=c[0],f=c[1]}var g={filename:d,archetype:f},h=new XMLHttpRequest;return h.open("POST",window.location.pathname),h.setRequestHeader("Content-Type","application/json;charset=UTF-8"),h.send(JSON.stringify(g)),h.onreadystatechange=function(){if(4==h.readyState){var a=JSON.parse(h.responseText),b="success",c=5e3;200!=h.status&&(b="error",c=!1),notification({text:a.message,type:b,timeout:c}),200==h.status&&$.pjax({url:a.location,container:"#content"})}},!1});var f="form#rename",g=f+' input[type="text"]',h=null;$("#content").on("click",".rename",function(b){return b.preventDefault(),h=$(this).parent().parent().find(".filename").text(),$(a).fadeIn(200),$(f).fadeIn(200),$(f).find("span").text(h),$(f).find('input[type="text"]').val(h),!1}),$("#content").on("keypress",g,function(a){return 13==a.keyCode?(a.preventDefault(),$(f).submit(),!1):void 0}),$("#content").on("submit",f,function(a){a.preventDefault();var b=$(this).find('input[type="text"]').val();if(""===b)return!1;"/"!=b.substring(0,1)&&(b=window.location.pathname.replace(basePath+"/browse/","")+"/"+b);var c={filename:b},d=new XMLHttpRequest;return d.open("PUT",h),d.setRequestHeader("Content-Type","application/json;charset=UTF-8"),d.send(JSON.stringify(c)),d.onreadystatechange=function(){if(4==d.readyState){var a=JSON.parse(d.responseText),b="success",c=5e3;200!=d.status&&(b="error",c=!1),$.pjax({url:window.location.pathname,container:"#content"}),notification({text:a.message,type:b,timeout:c}),h=null}},!1});var i="button.git",j="form#git",k=j+' input[type="text"]';$("#content").on("click",i,function(b){return b.preventDefault(),$(a).fadeIn(200),$(j).fadeIn(200),!1}),$("#content").on("keypress",k,function(a){return 13==a.keyCode?(a.preventDefault(),$(j).submit(),!1):void 0}),$("#content").on("submit",j,function(b){b.preventDefault();var c=$(this).find('input[type="text"]').val();if(""==c)return notification({text:"You have to write something. If you want to close the box, click outside of it.",type:"warning",timeout:5e3}),!1;var d=new XMLHttpRequest;return d.open("POST",basePath+"/git"),d.setRequestHeader("Content-Type","application/json;charset=UTF-8"),d.send(JSON.stringify({command:c})),d.onreadystatechange=function(){if(4==d.readyState){var b=JSON.parse(d.responseText);200==d.status?(notification({text:b.message,type:"success",timeout:5e3}),$(j).fadeOut(200),$(a).fadeOut(200),$.pjax({url:window.location.pathname,container:"#content"})):notification({text:b.message,type:"error"})}},!1}),$("#content").on("click",".close",function(b){return b.preventDefault(),$(this).parent().parent().fadeOut(200),$(a).click(),!1}),$("#content").on("click",a,function(c){return c.preventDefault(),$(a).fadeOut(200),$(d).fadeOut(200),$(f).fadeOut(200),$(b).fadeOut(200),$(j).fadeOut(200),!1})}),$(document).on("page:editor",function(){var a=$(".editor"),b=$("#editor-preview"),c=$("#editor-source");if(a.hasClass("complete")&&$("#content").on("keyup","#site-title",function(){$(".frontmatter #title").val($(this).val())}),!a.hasClass("frontmatter-only")){var d=$("#editor-source").data("mode"),e=$('textarea[name="content"]').hide(),f=ace.edit("editor-source");f.getSession().setMode("ace/mode/"+d),f.getSession().setValue(e.val()),f.getSession().on("change",function(){e.val(f.getSession().getValue())}),f.setOptions({wrap:!0,maxLines:1/0,theme:"ace/theme/github",showPrintMargin:!1,fontSize:"1em",minLines:20}),$("#content").on("click","#see-source",function(a){a.preventDefault(),b.hide(),c.fadeIn(),$(this).addClass("active"),$("#see-preview").removeClass("active"),$("#see-preview").data("previewing","false")}),$("#content").on("click","#see-preview",function(a){if(a.preventDefault(),"true"==$(this).data("previewing"))b.hide(),c.fadeIn(),$(this).removeClass("active"),$("#see-source").addClass("active"),$(this).data("previewing","false");else{var d=new showdown.Converter,e=f.getValue(),g=d.makeHtml(e);c.hide(),b.html(g).fadeIn(),$(this).addClass("active"),$("#see-source").removeClass("active"),$(this).data("previewing","true")}return!1})}$("#content").on("keypress","input",function(a){return 13==a.keyCode?(a.preventDefault(),$('input[value="Save"]').focus().click(),!1):void 0});var g=null;$("#content").on("click","form input[type=submit]",function(a){g=this}),$("#content").on("submit","form",function(d){d.preventDefault(),a.hasClass("frontmatter-only")||(b.html("").fadeOut(),$("#see-preview").data("previewing","false"),c.fadeIn());var e=$(g),f={content:$(this).serializeJSON(),contentType:e.data("type"),schedule:e.data("schedule"),regenerate:e.data("regenerate")};console.log(JSON.stringify(f));var h=new XMLHttpRequest;return h.open("POST",window.location),h.setRequestHeader("Content-Type","application/json;charset=UTF-8"),h.send(JSON.stringify(f)),h.onreadystatechange=function(){if(4==h.readyState){var a=JSON.parse(h.responseText),b="success",c=5e3;200==h.status&&(a.message=e.data("message")),200!=h.status&&(b="error",c=!1),notification({text:a.message,type:b,timeout:c})}},!1}),$("#content").on("click",".add",function(a){if(a.preventDefault(),defaultID="lorem-ipsum-sin-dolor-amet",newItem=$("#"+defaultID),newItem.length&&newItem.remove(),block=$(this).parent().parent(),blockType=block.data("type"),blockID=block.attr("id"),"array"==blockType&&(newID=blockID+"[]",input=blockID,input=input.replace(/\[/,"\\["),input=input.replace(/\]/,"\\]"),block.append('
div").length+'" data-type="array-item">
')),block.is("div")&&block.hasClass("frontmatter")&&(block=$(".blocks"),blockType="object"),"object"==blockType){if(block.append(''),newItem=$("#"+defaultID),newItem.html(''),field=$("#name-"+defaultID),!document.cookie.replace(/(?:(?:^|.*;\s*)placeholdertip\s*\=\s*([^;]*).*$)|^.*$/,"$1")){var b=new Date;b.setDate(b.getDate()+365),document.cookie="placeholdertip=true; expires="+b.toUTCString+"; path=/",notification({text:'Write the field name and then press enter. If you want to create an array or an object, end the name with ":array" or ":object".',type:"information"})}$(field).keypress(function(a){return 13==a.which?(a.preventDefault(),value=field.val(),""==value?(newItem.remove(),!1):(elements=value.split(":"),elements.length>2?(notification({text:"Invalid syntax. It must be 'name[:type]'.",type:"error"}),!1):2==elements.length&&"array"!=elements[1]&&"object"!=elements[1]?(notification({text:"Only arrays and objects are allowed.",type:"error"}),!1):(field.remove(),"undefined"==typeof blockID?blockID=elements[0]:blockID=blockID+"["+elements[0]+"]",1==elements.length?(newItem.attr("id","block-"+blockID),newItem.append(' '),newItem.prepend(' ')):(type="","array"==elements[1]?type="array":type="object",template='',template=template.replace("${blockID}",blockID),template=template.replace("${elements[0]}",elements[0]),template=template.replace("${type}",type),newItem.after(template),newItem.remove()),!1))):void 0})}return!1}),$("#content").on("click",".delete",function(a){return a.preventDefault(),button=$(this),name=button.parent().parent().attr("for")||button.parent().parent().attr("id")||button.parent().parent().parent().attr("id"),name=name.replace(/\[/,"\\["),name=name.replace(/\]/,"\\]"),$('label[for="'+name+'"]').fadeOut().remove(),$("#"+name).fadeOut().remove(),!1})}),$.noty.themes.admin={name:"admin",helpers:{},modal:{css:{position:"fixed",width:"100%",height:"100%",backgroundColor:"#000",zIndex:1e4,opacity:.6,display:"none",left:0,top:0}}},$.noty.defaults={layout:"topRight",theme:"admin",dismissQueue:!0,animation:{open:"animated bounceInRight",close:"animated fadeOut",easing:"swing",speed:500},timeout:!1,force:!1,modal:!1,maxVisible:5,killer:!1,closeWith:["click"],callback:{onShow:function(){},afterShow:function(){},onClose:function(){},afterClose:function(){},onCloseClick:function(){}},buttons:!1},notification=function(a){var b;switch(a.type){case"success":b='';break;case"error":b='';break;case"warning":b='';break;case"information":b='';break;default:b=''}var c={template:'
'+b+'
'};if(a=$.extend({},c,a),noty(a),!document.cookie.replace(/(?:(?:^|.*;\s*)stickynoties\s*\=\s*([^;]*).*$)|^.*$/,"$1")&&!a.timeout){var d=new Date;d.setDate(d.getDate()+365),document.cookie="stickynoties=true; expires="+d.toUTCString+"; path=/",notification({text:"Some notifications are sticky. If it doesn't go away, click to dismiss it.",type:"information"})}};
\ No newline at end of file
diff --git a/assets/public_src/js/app.js b/assets/public_src/js/app.js
index bdf01667..5c4e806b 100644
--- a/assets/public_src/js/app.js
+++ b/assets/public_src/js/app.js
@@ -1,10 +1,14 @@
+var basePath = "/";
+
$(document).ready(function() {
+ basePath += window.location.pathname.split('/')[0];
+
// Log out the user sending bad credentials to the server
$("#logout").click(function(event) {
event.preventDefault();
$.ajax({
type: "GET",
- url: "/admin",
+ url: basePath + "",
async: false,
username: "username",
password: "password",
diff --git a/assets/public_src/js/browse.js b/assets/public_src/js/browse.js
index 91818fa8..a6c0b3cf 100644
--- a/assets/public_src/js/browse.js
+++ b/assets/public_src/js/browse.js
@@ -247,7 +247,7 @@ $(document).on('page:browse', function() {
}
if (filename.substring(0, 1) != "/") {
- filename = window.location.pathname.replace("/admin/browse/", "") + '/' + filename;
+ filename = window.location.pathname.replace(basePath + "/browse/", "") + '/' + filename;
}
var content = {
@@ -323,7 +323,7 @@ $(document).on('page:browse', function() {
}
var request = new XMLHttpRequest();
- request.open("POST", "/admin/git");
+ request.open("POST", basePath + "/git");
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
request.send(JSON.stringify({
command: value
diff --git a/assets/public_src/js/editor.js b/assets/public_src/js/editor.js
index 23c18f03..86182cb8 100644
--- a/assets/public_src/js/editor.js
+++ b/assets/public_src/js/editor.js
@@ -103,6 +103,8 @@ $(document).on('page:editor', function() {
regenerate: button.data("regenerate")
}
+ console.log(JSON.stringify(data));
+
var request = new XMLHttpRequest();
request.open("POST", window.location);
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
@@ -155,7 +157,6 @@ $(document).on('page:editor', function() {
input = input.replace(/\[/, '\\[');
input = input.replace(/\]/, '\\]');
block.append('
');
- console.log('New array item added.');
}
// Main add button, after all blocks
@@ -241,8 +242,6 @@ $(document).on('page:editor', function() {
template = template.replace("${type}", type);
newItem.after(template);
newItem.remove();
-
- console.log('"' + blockID + '" block of type "' + type + '" added.');
}
return false;
@@ -260,7 +259,6 @@ $(document).on('page:editor', function() {
name = button.parent().parent().attr("for") || button.parent().parent().attr("id") || button.parent().parent().parent().attr("id");
name = name.replace(/\[/, '\\[');
name = name.replace(/\]/, '\\]');
- console.log(name)
$('label[for="' + name + '"]').fadeOut().remove();
$('#' + name).fadeOut().remove();
diff --git a/assets/templates/base_full.tmpl b/assets/templates/base_full.tmpl
index 6912deaf..aec36a68 100644
--- a/assets/templates/base_full.tmpl
+++ b/assets/templates/base_full.tmpl
@@ -9,23 +9,21 @@
{{ if Defined . "Name" }}{{ .Name }}{{ end }}
-
- {{ if and (Defined . "Config")}}{{ if not (eq .Config.Styles "") }}{{ end }}{{ end }}
- {{ if and (Defined . "User") }}{{ if not (eq .User.Styles "") }}{{ end }}{{ end }}
+
+ {{ if not (eq .Config.Styles "") }}{{ end }}
-
-
+
-
+
diff --git a/assets/templates/browse.tmpl b/assets/templates/browse.tmpl
index be967a9c..cf200e13 100644
--- a/assets/templates/browse.tmpl
+++ b/assets/templates/browse.tmpl
@@ -1,4 +1,6 @@
-{{ define "content" }}{{ $path := .Path }}
+{{ define "content" }}
+{{ $path := .Path }}
+{{ $admin := .User.Admin }}
@@ -42,12 +44,12 @@
{{if .IsDir}}
{{.Name}} {{else}} {{ if CanBeEdited .URL }}
- {{.Name}} {{ else }}
+ {{.Name}} {{ else }}
{{.Name}} {{ end }} {{ end }}
{{.HumanSize}}
{{.HumanModTime "01/02/2006 3:04:05 PM"}}
-
+
{{end}}
diff --git a/routes/browse/browse.go b/routes/browse/browse.go
index 45b081d0..76e6f13e 100644
--- a/routes/browse/browse.go
+++ b/routes/browse/browse.go
@@ -21,13 +21,13 @@ type response struct {
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
conf = c
// Removes the page main path from the URL
- r.URL.Path = strings.Replace(r.URL.Path, "/admin/browse", "", 1)
+ r.URL.Path = strings.Replace(r.URL.Path, c.Admin+"/browse", "", 1)
switch r.Method {
case "DELETE":
return DELETE(w, r)
case "POST":
- return POST(w, r)
+ return POST(w, r, c)
case "GET":
return GET(w, r)
case "PUT":
diff --git a/routes/browse/post.go b/routes/browse/post.go
index c8c38f32..84619fa1 100644
--- a/routes/browse/post.go
+++ b/routes/browse/post.go
@@ -10,13 +10,14 @@ import (
"path/filepath"
"strings"
+ "github.com/hacdias/caddy-hugo/config"
"github.com/hacdias/caddy-hugo/tools/commands"
s "github.com/hacdias/caddy-hugo/tools/server"
)
// POST handles the POST method on browse page. It's used to create new files,
// folders and upload content.
-func POST(w http.ResponseWriter, r *http.Request) (int, error) {
+func POST(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
// Remove prefix slash
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/")
@@ -47,7 +48,7 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
filename := info["filename"].(string)
filename = strings.TrimPrefix(filename, "/")
filename = strings.TrimSuffix(filename, "/")
- url := "/admin/edit/" + r.URL.Path + filename
+ url := c.Admin + "/edit/" + r.URL.Path + filename
filename = conf.Path + r.URL.Path + filename
if strings.HasPrefix(filename, conf.Path+"content/") &&
diff --git a/routes/browse/put.go b/routes/browse/put.go
index 67958aaa..087ec6f5 100644
--- a/routes/browse/put.go
+++ b/routes/browse/put.go
@@ -10,7 +10,7 @@ import (
"github.com/hacdias/caddy-hugo/tools/server"
)
-// PUT handles the HTTP PUT request for all /admin/browse related requests.
+// PUT handles the HTTP PUT request for all /{admin}/browse related requests.
// Renames a file and/or a folder.
func PUT(w http.ResponseWriter, r *http.Request) (int, error) {
// Remove both beginning and trailing slashes
diff --git a/routes/editor/editor.go b/routes/editor/editor.go
index 4c8ad09e..5e45f6aa 100644
--- a/routes/editor/editor.go
+++ b/routes/editor/editor.go
@@ -16,7 +16,7 @@ var (
// ServeHTTP serves the editor page
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
conf = c
- filename = strings.Replace(r.URL.Path, "/admin/edit/", "", 1)
+ filename = strings.Replace(r.URL.Path, c.Admin+"/edit/", "", 1)
filename = c.Path + filename
switch r.Method {
diff --git a/routes/editor/post.go b/routes/editor/post.go
index a9ccddd4..ee69e435 100644
--- a/routes/editor/post.go
+++ b/routes/editor/post.go
@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"errors"
+ "fmt"
"io/ioutil"
"net/http"
"path/filepath"
@@ -17,8 +18,6 @@ import (
"github.com/spf13/hugo/parser"
)
-var data info
-
type info struct {
ContentType string
Schedule bool
@@ -32,11 +31,15 @@ type response struct {
// POST handles the POST method on editor page
func POST(w http.ResponseWriter, r *http.Request) (int, error) {
+ var data info
+
// Get the JSON information sent using a buffer
rawBuffer := new(bytes.Buffer)
rawBuffer.ReadFrom(r.Body)
err := json.Unmarshal(rawBuffer.Bytes(), &data)
+ fmt.Println(string(rawBuffer.Bytes()))
+
if err != nil {
return server.RespondJSON(w, &response{"Error decrypting json."}, http.StatusInternalServerError, err)
}
@@ -46,7 +49,7 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
switch data.ContentType {
case "frontmatter-only":
- f, code, err := parseFrontMatterOnlyFile()
+ f, code, err := parseFrontMatterOnlyFile(data)
if err != nil {
return server.RespondJSON(w, &response{err.Error()}, code, err)
}
@@ -59,7 +62,7 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
file = []byte(mainContent)
case "complete":
- f, code, err := parseCompleteFile()
+ f, code, err := parseCompleteFile(data)
if err != nil {
return server.RespondJSON(w, &response{err.Error()}, code, err)
}
@@ -83,7 +86,7 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
return server.RespondJSON(w, nil, http.StatusOK, nil)
}
-func parseFrontMatterOnlyFile() ([]byte, int, error) {
+func parseFrontMatterOnlyFile(data info) ([]byte, int, error) {
frontmatter := strings.TrimPrefix(filepath.Ext(filename), ".")
var mark rune
@@ -121,7 +124,7 @@ func parseFrontMatterOnlyFile() ([]byte, int, error) {
return f, http.StatusOK, nil
}
-func parseCompleteFile() ([]byte, int, error) {
+func parseCompleteFile(data info) ([]byte, int, error) {
// The main content of the file
mainContent := data.Content["content"].(string)
mainContent = "\n\n" + strings.TrimSpace(mainContent) + "\n"