diff --git a/assets/public/js/app.min.js b/assets/public/js/app.min.js
index 34d931b3..6c9dcbfc 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=new Object;b.selector="form#delete",b.form=$(b.selector),b.row="",b.button="",b.url="",$("#content").on("click",".delete",function(c){return c.preventDefault(),b.button=$(this),b.row=$(this).parent().parent(),$(a).fadeIn(200),b.url=b.row.find(".filename").text(),b.form.find("span").text(b.url),b.form.fadeIn(200),!1}),$("#content").on("submit",b.selector,function(c){c.preventDefault();var d=new XMLHttpRequest;return d.open("DELETE",b.button.data("file")),d.send(),d.onreadystatechange=function(){if(4==d.readyState){var c=JSON.parse(d.responseText),e="success",f=5e3;$(a).fadeOut(200),b.form.fadeOut(200),b.row.fadeOut(200),200!=d.status&&(e="error",f=!1),notification({text:c.message,type:e,timeout:f})}},!1}),$("#content").on("change",'input[type="file"]',function(a){a.preventDefault(),files=a.target.files;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}),$.pjax({url:window.location.pathname,container:"#content"})}).fail(function(a){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 c=new Object;c.selector="form#new",c.form=$(c.selector),c.input=c.selector+' input[type="text"]',c.button="",c.url="",$("#content").on("click",".new",function(b){return b.preventDefault(),c.button=$(this),$(a).fadeIn(200),c.form.fadeIn(200),!1}),$("#content").on("keypress",c.input,function(a){return 13==a.keyCode?(a.preventDefault(),$(c.form).submit(),!1):void 0}),$("#content").on("submit",c.selector,function(a){a.preventDefault();var b=c.form.find('input[type="text"]').val(),d=b.split(":"),e="",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==d.length)e=b;else{if(2!=d.length)return notification({text:"Hmm... I don't understand you. Try writing something like 'name[:archetype]'.",type:"error"}),!1;e=d[0],f=d[1]}var g={filename:e,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:h.Location,container:"#content"})}},!1});var d=new Object;d.selector="form#rename",d.form=$(d.selector),d.input=d.selector+' input[type="text"]',d.button="",d.url="",$("#content").on("click",".rename",function(b){return b.preventDefault(),d.button=$(this),$(a).fadeIn(200),d.url=$(this).parent().parent().find(".filename").text(),d.form.fadeIn(200),d.form.find("span").text(d.url),d.form.find('input[type="text"]').val(d.url),!1}),$("#content").on("keypress",d.input,function(a){return 13==a.keyCode?(a.preventDefault(),$(d.form).submit(),!1):void 0}),$("#content").on("submit",d.selector,function(a){a.preventDefault();var b=d.form.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},e=new XMLHttpRequest;return e.open("PUT",d.url),e.setRequestHeader("Content-Type","application/json;charset=UTF-8"),e.send(JSON.stringify(c)),e.onreadystatechange=function(){if(4==e.readyState){var a=JSON.parse(e.responseText),b="success",c=5e3;200!=e.status&&(b="error",c=!1),$.pjax({url:window.location.pathname,container:"#content"}),notification({text:a.message,type:b,timeout:c})}},!1});var e=new Object;e.selector="form#git",e.form=$(e.selector),e.input=e.selector+' input[type="text"]',$("#content").on("click","button.git",function(b){return b.preventDefault(),$(a).fadeIn(200),e.form.fadeIn(200),!1}),$("#content").on("keypress",e.input,function(a){return 13==a.keyCode?(a.preventDefault(),$(e.form).submit(),!1):void 0}),$("#content").on("submit",e.selector,function(a){a.preventDefault();var b=e.form.find('input[type="text"]').val();if(""==b)return notification({text:"You have to write something. If you want to close the box, click outside of the box.",type:"warning",timeout:5e3}),!1;var c=new XMLHttpRequest;return c.open("POST","/admin/git"),c.setRequestHeader("Content-Type","application/json;charset=UTF-8"),c.send(JSON.stringify({command:b})),c.onreadystatechange=function(){if(4==c.readyState){var a=JSON.parse(c.responseText);200==c.status?notification({text:a.message,type:"success"}):notification({text:a.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(f){return f.preventDefault(),$(a).fadeOut(200),c.form.fadeOut(200),d.form.fadeOut(200),b.form.fadeOut(200),e.form.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}),$("#content").on("submit","form",function(d){d.preventDefault(),a.hasClass("frontmatter-only")||(b.html("").fadeOut(),$("#see-preview").data("previewing","false"),c.fadeIn());var e=$(this).find("input[type=submit]:focus"),f={content:$(this).serializeJSON(),contentType:e.data("type"),schedule:e.data("schedule"),regenerate:e.data("regenerate")},g=new XMLHttpRequest;return g.open("POST",window.location),g.setRequestHeader("Content-Type","application/json;charset=UTF-8"),g.send(JSON.stringify(f)),g.onreadystatechange=function(){if(4==g.readyState){var a=JSON.parse(g.responseText),b="success",c=5e3;200==g.status&&(a.message=e.data("message")),200!=g.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
+$(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=new Object;b.selector="form#delete",b.form=$(b.selector),b.row="",b.button="",b.url="",$("#content").on("click",".delete",function(c){return c.preventDefault(),b.button=$(this),b.row=$(this).parent().parent(),$(a).fadeIn(200),b.url=b.row.find(".filename").text(),b.form.find("span").text(b.url),b.form.fadeIn(200),!1}),$("#content").on("submit",b.selector,function(c){c.preventDefault();var d=new XMLHttpRequest;return d.open("DELETE",b.button.data("file")),d.send(),d.onreadystatechange=function(){if(4==d.readyState){var c=JSON.parse(d.responseText),e="success",f=5e3;$(a).fadeOut(200),b.form.fadeOut(200),b.row.fadeOut(200),200!=d.status&&(e="error",f=!1),notification({text:c.message,type:e,timeout:f})}},!1}),$("#content").on("change",'input[type="file"]',function(a){a.preventDefault(),files=a.target.files;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}),$.pjax({url:window.location.pathname,container:"#content"})}).fail(function(a){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 c=new Object;c.selector="form#new",c.form=$(c.selector),c.input=c.selector+' input[type="text"]',c.button="",c.url="",$("#content").on("click",".new",function(b){return b.preventDefault(),c.button=$(this),$(a).fadeIn(200),c.form.fadeIn(200),!1}),$("#content").on("keypress",c.input,function(a){return 13==a.keyCode?(a.preventDefault(),$(c.form).submit(),!1):void 0}),$("#content").on("submit",c.selector,function(a){a.preventDefault();var b=c.form.find('input[type="text"]').val(),d=b.split(":"),e="",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==d.length)e=b;else{if(2!=d.length)return notification({text:"Hmm... I don't understand you. Try writing something like 'name[:archetype]'.",type:"error"}),!1;e=d[0],f=d[1]}var g={filename:e,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 d=new Object;d.selector="form#rename",d.form=$(d.selector),d.input=d.selector+' input[type="text"]',d.button="",d.url="",$("#content").on("click",".rename",function(b){return b.preventDefault(),d.button=$(this),$(a).fadeIn(200),d.url=$(this).parent().parent().find(".filename").text(),d.form.fadeIn(200),d.form.find("span").text(d.url),d.form.find('input[type="text"]').val(d.url),!1}),$("#content").on("keypress",d.input,function(a){return 13==a.keyCode?(a.preventDefault(),$(d.form).submit(),!1):void 0}),$("#content").on("submit",d.selector,function(a){a.preventDefault();var b=d.form.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},e=new XMLHttpRequest;return e.open("PUT",d.url),e.setRequestHeader("Content-Type","application/json;charset=UTF-8"),e.send(JSON.stringify(c)),e.onreadystatechange=function(){if(4==e.readyState){var a=JSON.parse(e.responseText),b="success",c=5e3;200!=e.status&&(b="error",c=!1),$.pjax({url:window.location.pathname,container:"#content"}),notification({text:a.message,type:b,timeout:c})}},!1});var e=new Object;e.selector="form#git",e.form=$(e.selector),e.input=e.selector+' input[type="text"]',$("#content").on("click","button.git",function(b){return b.preventDefault(),$(a).fadeIn(200),e.form.fadeIn(200),!1}),$("#content").on("keypress",e.input,function(a){return 13==a.keyCode?(a.preventDefault(),$(e.form).submit(),!1):void 0}),$("#content").on("submit",e.selector,function(a){a.preventDefault();var b=e.form.find('input[type="text"]').val();if(""==b)return notification({text:"You have to write something. If you want to close the box, click outside of the box.",type:"warning",timeout:5e3}),!1;var c=new XMLHttpRequest;return c.open("POST","/admin/git"),c.setRequestHeader("Content-Type","application/json;charset=UTF-8"),c.send(JSON.stringify({command:b})),c.onreadystatechange=function(){if(4==c.readyState){var a=JSON.parse(c.responseText);200==c.status?notification({text:a.message,type:"success"}):notification({text:a.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(f){return f.preventDefault(),$(a).fadeOut(200),c.form.fadeOut(200),d.form.fadeOut(200),b.form.fadeOut(200),e.form.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}),$("#content").on("submit","form",function(d){d.preventDefault(),a.hasClass("frontmatter-only")||(b.html("").fadeOut(),$("#see-preview").data("previewing","false"),c.fadeIn());var e=$(this).find("input[type=submit]:focus"),f={content:$(this).serializeJSON(),contentType:e.data("type"),schedule:e.data("schedule"),regenerate:e.data("regenerate")},g=new XMLHttpRequest;return g.open("POST",window.location),g.setRequestHeader("Content-Type","application/json;charset=UTF-8"),g.send(JSON.stringify(f)),g.onreadystatechange=function(){if(4==g.readyState){var a=JSON.parse(g.responseText),b="success",c=5e3;200==g.status&&(a.message=e.data("message")),200!=g.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
diff --git a/assets/public_src/js/browse.js b/assets/public_src/js/browse.js
index 2e8f1c8d..b452d5bc 100644
--- a/assets/public_src/js/browse.js
+++ b/assets/public_src/js/browse.js
@@ -186,7 +186,7 @@ $(document).on('page:browse', function() {
if (request.status == 200) {
$.pjax({
- url: request.Location,
+ url: response.location,
container: '#content'
})
}
diff --git a/assets/templates/error.tmpl b/assets/templates/error.tmpl
new file mode 100644
index 00000000..0c8a6cf2
--- /dev/null
+++ b/assets/templates/error.tmpl
@@ -0,0 +1,8 @@
+{{ define "content" }}
+
+
{{ .Title }}
+ {{ .Message }}
+
+
If this error persists contact us on Gitter chat or open an issue at GitHub.
+
+{{ end }}
diff --git a/hugo.go b/hugo.go
index a76afbf5..2a8b0f2a 100644
--- a/hugo.go
+++ b/hugo.go
@@ -18,6 +18,7 @@ import (
"github.com/hacdias/caddy-hugo/routes/assets"
"github.com/hacdias/caddy-hugo/routes/browse"
"github.com/hacdias/caddy-hugo/routes/editor"
+ "github.com/hacdias/caddy-hugo/routes/errors"
"github.com/hacdias/caddy-hugo/routes/git"
"github.com/hacdias/caddy-hugo/tools/commands"
"github.com/hacdias/caddy-hugo/tools/hugo"
@@ -143,6 +144,10 @@ func (h CaddyHugo) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
code, err = git.ServeHTTP(w, r, h.Config)
}
+ if code != 0 && code != 200 {
+ code, err = errors.ServeHTTP(w, r, code, err)
+ }
+
return code, err
}
diff --git a/routes/browse/browse.go b/routes/browse/browse.go
index 95c50bcc..45b081d0 100644
--- a/routes/browse/browse.go
+++ b/routes/browse/browse.go
@@ -10,6 +10,11 @@ import (
var conf *config.Config
+type response struct {
+ Message string `json:"message"`
+ Location string `json:"location"`
+}
+
// ServeHTTP is used to serve the content of Browse page using Browse middleware
// from Caddy. It handles the requests for DELETE, POST, GET and PUT related to
// /browse interface.
diff --git a/routes/browse/delete.go b/routes/browse/delete.go
index 74a0ba28..da5997b3 100644
--- a/routes/browse/delete.go
+++ b/routes/browse/delete.go
@@ -5,7 +5,7 @@ import (
"os"
"strings"
- "github.com/hacdias/caddy-hugo/tools/server"
+ s "github.com/hacdias/caddy-hugo/tools/server"
)
// DELETE handles the delete requests on browse pages
@@ -31,17 +31,11 @@ func DELETE(w http.ResponseWriter, r *http.Request) (int, error) {
// Check for errors
if err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": "Something went wrong.",
- }, 500, nil)
+ return s.RespondJSON(w, &response{err.Error(), ""}, http.StatusInternalServerError, err)
}
} else {
- return server.RespondJSON(w, map[string]string{
- "message": "File not found.",
- }, 404, nil)
+ return s.RespondJSON(w, &response{"File not found.", ""}, http.StatusNotFound, nil)
}
- return server.RespondJSON(w, map[string]string{
- "message": message,
- }, 200, nil)
+ return s.RespondJSON(w, &response{message, ""}, http.StatusOK, nil)
}
diff --git a/routes/browse/post.go b/routes/browse/post.go
index fe42d195..c8c38f32 100644
--- a/routes/browse/post.go
+++ b/routes/browse/post.go
@@ -11,7 +11,7 @@ import (
"strings"
"github.com/hacdias/caddy-hugo/tools/commands"
- "github.com/hacdias/caddy-hugo/tools/server"
+ s "github.com/hacdias/caddy-hugo/tools/server"
)
// POST handles the POST method on browse page. It's used to create new files,
@@ -36,15 +36,11 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
// Check if filename and archetype are specified in
// the request
if _, ok := info["filename"]; !ok {
- return server.RespondJSON(w, map[string]string{
- "message": "Filename not specified.",
- }, 500, nil)
+ return s.RespondJSON(w, &response{"Filename not specified.", ""}, http.StatusBadRequest, nil)
}
if _, ok := info["archetype"]; !ok {
- return server.RespondJSON(w, map[string]string{
- "message": "Archtype not specified.",
- }, 500, nil)
+ return s.RespondJSON(w, &response{"Archtype not specified.", ""}, http.StatusBadRequest, nil)
}
// Sanitize the file name path
@@ -66,9 +62,7 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
}
if err := commands.Run(conf.Hugo, args, conf.Path); err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": "Something went wrong.",
- }, 500, err)
+ return s.RespondJSON(w, &response{"Something went wrong.", ""}, http.StatusInternalServerError, err)
}
} else {
var err error
@@ -83,26 +77,19 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
}
if err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": "Something went wrong.",
- }, 500, err)
+ return s.RespondJSON(w, &response{"Something went wrong.", ""}, http.StatusInternalServerError, err)
}
}
- return server.RespondJSON(w, map[string]string{
- "location": url,
- "message": "File created.",
- }, 200, nil)
+ return s.RespondJSON(w, &response{"File created!", url}, http.StatusOK, nil)
}
func upload(w http.ResponseWriter, r *http.Request) (int, error) {
// Parse the multipart form in the request
err := r.ParseMultipartForm(100000)
if err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": "Something went wrong.",
- }, 500, err)
+ return s.RespondJSON(w, &response{"Something went wrong.", ""}, http.StatusInternalServerError, err)
}
// For each file header in the multipart form
@@ -112,29 +99,23 @@ func upload(w http.ResponseWriter, r *http.Request) (int, error) {
// Open the first file
var infile multipart.File
if infile, err = hdr.Open(); nil != err {
- return server.RespondJSON(w, map[string]string{
- "message": "Something went wrong.",
- }, 500, err)
+ return s.RespondJSON(w, &response{"Something went wrong.", ""}, http.StatusInternalServerError, err)
}
// Create the file
var outfile *os.File
if outfile, err = os.Create(conf.Path + r.URL.Path + hdr.Filename); nil != err {
- return server.RespondJSON(w, map[string]string{
- "message": "Something went wrong.",
- }, 500, err)
+ return s.RespondJSON(w, &response{"Something went wrong.", ""}, http.StatusInternalServerError, err)
}
// Copy the file content
if _, err = io.Copy(outfile, infile); nil != err {
- return server.RespondJSON(w, map[string]string{
- "message": "Something went wrong.",
- }, 500, err)
+ return s.RespondJSON(w, &response{"Something went wrong.", ""}, http.StatusInternalServerError, err)
}
defer outfile.Close()
}
}
- return server.RespondJSON(w, nil, 200, nil)
+ return s.RespondJSON(w, nil, http.StatusOK, nil)
}
diff --git a/routes/browse/put.go b/routes/browse/put.go
index 33d3b2af..67958aaa 100644
--- a/routes/browse/put.go
+++ b/routes/browse/put.go
@@ -30,9 +30,7 @@ func PUT(w http.ResponseWriter, r *http.Request) (int, error) {
// Check if filename and archetype are specified in
// the request
if _, ok := info["filename"]; !ok {
- return server.RespondJSON(w, map[string]string{
- "message": "Filename not specified.",
- }, 400, nil)
+ return server.RespondJSON(w, &response{"Filename not specified.", ""}, http.StatusBadRequest, nil)
}
// Sanitize the file name path
@@ -43,12 +41,8 @@ func PUT(w http.ResponseWriter, r *http.Request) (int, error) {
// Renames the file/folder
if err := os.Rename(old, new); err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": "Something went wrong.",
- }, 500, err)
+ return server.RespondJSON(w, &response{err.Error(), ""}, http.StatusInternalServerError, err)
}
- return server.RespondJSON(w, map[string]string{
- "message": "File renamed.",
- }, 200, nil)
+ return server.RespondJSON(w, &response{"File renamed.", ""}, http.StatusOK, nil)
}
diff --git a/routes/editor/get.go b/routes/editor/get.go
index 7786409f..f5b56953 100644
--- a/routes/editor/get.go
+++ b/routes/editor/get.go
@@ -37,9 +37,9 @@ func GET(w http.ResponseWriter, r *http.Request) (int, error) {
// Check if the file exists.
if _, err := os.Stat(filename); os.IsNotExist(err) {
- return http.StatusNotFound, nil
+ return http.StatusNotFound, err
} else if os.IsPermission(err) {
- return http.StatusForbidden, nil
+ return http.StatusForbidden, err
} else if err != nil {
return http.StatusInternalServerError, err
}
@@ -47,7 +47,7 @@ func GET(w http.ResponseWriter, r *http.Request) (int, error) {
// Open the file and check if there was some error while opening
file, err := ioutil.ReadFile(filename)
if os.IsPermission(err) {
- return http.StatusForbidden, nil
+ return http.StatusForbidden, err
} else if err != nil {
return http.StatusInternalServerError, err
}
diff --git a/routes/editor/post.go b/routes/editor/post.go
index c8788dce..a9ccddd4 100644
--- a/routes/editor/post.go
+++ b/routes/editor/post.go
@@ -26,6 +26,10 @@ type info struct {
Content map[string]interface{}
}
+type response struct {
+ Message string `json:"message"`
+}
+
// POST handles the POST method on editor page
func POST(w http.ResponseWriter, r *http.Request) (int, error) {
// Get the JSON information sent using a buffer
@@ -34,9 +38,7 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
err := json.Unmarshal(rawBuffer.Bytes(), &data)
if err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": "Error decrypting json.",
- }, http.StatusInternalServerError, err)
+ return server.RespondJSON(w, &response{"Error decrypting json."}, http.StatusInternalServerError, err)
}
// Initializes the file content to write
@@ -46,9 +48,7 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
case "frontmatter-only":
f, code, err := parseFrontMatterOnlyFile()
if err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": err.Error(),
- }, code, err)
+ return server.RespondJSON(w, &response{err.Error()}, code, err)
}
file = f
@@ -61,25 +61,19 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
case "complete":
f, code, err := parseCompleteFile()
if err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": err.Error(),
- }, code, err)
+ return server.RespondJSON(w, &response{err.Error()}, code, err)
}
file = f
default:
- return server.RespondJSON(w, map[string]string{
- "message": "Invalid content type.",
- }, http.StatusBadRequest, nil)
+ return server.RespondJSON(w, &response{"Invalid content type."}, http.StatusBadRequest, nil)
}
// Write the file
err = ioutil.WriteFile(filename, file, 0666)
if err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": err.Error(),
- }, http.StatusInternalServerError, err)
+ return server.RespondJSON(w, &response{err.Error()}, http.StatusInternalServerError, err)
}
if data.Regenerate {
diff --git a/routes/errors/errors.go b/routes/errors/errors.go
new file mode 100644
index 00000000..fdcaf618
--- /dev/null
+++ b/routes/errors/errors.go
@@ -0,0 +1,51 @@
+package errors
+
+import (
+ "net/http"
+ "strconv"
+ "text/template"
+
+ "github.com/hacdias/caddy-hugo/tools/server"
+ "github.com/hacdias/caddy-hugo/tools/templates"
+ "github.com/hacdias/caddy-hugo/tools/variables"
+)
+
+type errorInformation struct {
+ Title string `json:"title"`
+ Message string `json:"message"`
+ err error
+}
+
+// ServeHTTP is used to serve the content of GIT API.
+func ServeHTTP(w http.ResponseWriter, r *http.Request, code int, err error) (int, error) {
+ page := new(errorInformation)
+ page.Title = strconv.Itoa(code) + " " + http.StatusText(code)
+ page.err = err
+
+ if err != nil {
+ page.Message = err.Error()
+ }
+
+ switch r.Method {
+ case "GET":
+ functions := template.FuncMap{
+ "Defined": variables.Defined,
+ }
+
+ tpl, err := templates.Get(r, functions, "error")
+
+ if err != nil {
+ return http.StatusInternalServerError, err
+ }
+
+ err = tpl.Execute(w, page)
+
+ if err != nil {
+ return http.StatusInternalServerError, err
+ }
+
+ return 0, page.err
+ default:
+ return server.RespondJSON(w, page, code, err)
+ }
+}
diff --git a/routes/git/post.go b/routes/git/post.go
index 1037e49d..e72eb84f 100644
--- a/routes/git/post.go
+++ b/routes/git/post.go
@@ -7,16 +7,18 @@ import (
"os/exec"
"strings"
- "github.com/hacdias/caddy-hugo/tools/server"
+ s "github.com/hacdias/caddy-hugo/tools/server"
)
+type postError struct {
+ Message string `json:"message"`
+}
+
// POST handles the POST method on GIT page which is only an API.
func POST(w http.ResponseWriter, r *http.Request) (int, error) {
// Check if git is installed on the computer
if _, err := exec.LookPath("git"); err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": "Git is not installed on your computer.",
- }, 400, nil)
+ return s.RespondJSON(w, &postError{"Git is not installed on your computer."}, 400, nil)
}
// Get the JSON information sent using a buffer
@@ -29,9 +31,7 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
// Check if command was sent
if _, ok := info["command"]; !ok {
- return server.RespondJSON(w, map[string]string{
- "message": "Command not specified.",
- }, 400, nil)
+ return s.RespondJSON(w, &postError{"Command not specified."}, 400, nil)
}
command := info["command"].(string)
@@ -42,9 +42,7 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
}
if len(args) == 0 {
- return server.RespondJSON(w, map[string]string{
- "message": "Command not specified.",
- }, 400, nil)
+ return s.RespondJSON(w, &postError{"Command not specified."}, 400, nil)
}
cmd := exec.Command("git", args...)
@@ -52,12 +50,8 @@ func POST(w http.ResponseWriter, r *http.Request) (int, error) {
output, err := cmd.CombinedOutput()
if err != nil {
- return server.RespondJSON(w, map[string]string{
- "message": err.Error(),
- }, 500, err)
+ return s.RespondJSON(w, &postError{err.Error()}, 500, err)
}
- return server.RespondJSON(w, map[string]string{
- "message": string(output),
- }, 200, nil)
+ return s.RespondJSON(w, &postError{string(output)}, 200, nil)
}
diff --git a/tools/server/response.go b/tools/server/response.go
index 3f118b42..e56699c4 100644
--- a/tools/server/response.go
+++ b/tools/server/response.go
@@ -2,12 +2,11 @@ package server
import (
"encoding/json"
- "errors"
"net/http"
)
// RespondJSON used to send JSON responses to the web server
-func RespondJSON(w http.ResponseWriter, message map[string]string, code int, err error) (int, error) {
+func RespondJSON(w http.ResponseWriter, message interface{}, code int, err error) (int, error) {
if message == nil {
message = map[string]string{}
}
@@ -18,10 +17,6 @@ func RespondJSON(w http.ResponseWriter, message map[string]string, code int, err
return 500, msgErr
}
- if code == 500 && err != nil {
- err = errors.New(message["message"])
- }
-
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
w.Write(msg)