pull/20/head
Henrique Dias 2015-09-19 22:17:38 +01:00
parent 537fe27f2e
commit 3c0383d500
13 changed files with 249 additions and 294 deletions

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
$(document).ready(function(){$(document).pjax("a","#main")}),$(document).on("ready pjax:success",function(){$(".scroll").perfectScrollbar(),$("#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}),$(".editor")[0]&&(editor=!1,preview=$("#preview-area"),textarea=$("#content-area"),textarea[0]&&(options={mode:textarea.data("mode"),theme:"mdn-like",lineWrapping:!0,lineNumbers:!0,scrollbarStyle:null},"markdown"==textarea.data("mode")&&(options.lineNumbers=!1),editor=CodeMirror.fromTextArea(textarea[0],options),codemirror=$(".CodeMirror"),$("#preview").click(function(a){if(a.preventDefault(),"true"==$(this).data("previewing"))preview.hide(),codemirror.fadeIn(),$(this).data("previewing","false"),notification({text:"Think, relax and do the better you can!",type:"information",timeout:2e3});else{editor.save();var b=new showdown.Converter,c=textarea.val(),d=b.makeHtml(c);codemirror.hide(),preview.html(d).fadeIn(),$(this).data("previewing","true"),notification({text:"This is how your post looks like.",type:"information",timeout:2e3})}return!1})),$("form").submit(function(a){a.preventDefault();var b=JSON.stringify($(this).serializeJSON()),c=$(this).find("input[type=submit]:focus");$.ajax({type:"POST",url:window.location,data:b,headers:{"X-Regenerate":c.data("regenerate"),"X-Content-Type":c.data("type")},dataType:"json",encode:!0}).done(function(a){notification({text:c.data("message"),type:"success",timeout:5e3})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)})}),$(".add").click(function(a){return a.preventDefault(),$("#new").length?!1:(title=$(this).parent().parent(),fieldset=title.parent(),type=fieldset.data("type"),name=fieldset.data("name"),title.is("h1")&&(fieldset=$(".sidebar .content"),fieldset.prepend('<div id="ghost"></div>'),title=$("#ghost"),type="object"),"object"==type&&(title.after('<input id="new" placeholder="Write the field name and press enter..."></input>'),element=$("#new"),$(element).keypress(function(a){return 13==a.which?(a.preventDefault(),value=element.val(),element.remove(),""==value?!1:("undefined"==name?name=value:name=name+"["+value+"]",title.after('<input name="'+name+':auto" id="'+name+'"></input><br>'),title.after('<label for="'+name+'">'+value+' <span class="actions"><button class="delete"><i class="fa fa-minus"></i></button></span></label>'),!1)):void 0})),"array"==type&&(name+="[]",title.after('<input name="'+name+':auto" id="'+name+'"></input><br>')),!1)}),$(".delete").click(function(a){a.preventDefault(),name=$(this).parent().parent().attr("for")||$(this).parent().parent().parent().attr("id"),console.log(name),$("#"+name).fadeOut().remove(),$('label[for="'+name+'"]').fadeOut().remove()}),$("body").on("keypress","input",function(a){return 13==a.keyCode?(a.preventDefault(),$('input[value="Save"]').focus().click(),!1):void 0}))}),$(document).on("pjax:send",function(){$("#loading").fadeIn()}),$(document).on("pjax:complete",function(){$("#loading").fadeOut()}),$.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='<i class="fa fa-check"></i>';break;case"error":b='<i class="fa fa-times"></i>';break;case"warning":b='<i class="fa fa-exclamation"></i>';break;case"information":b='<i class="fa fa-info"></i>';break;default:b='<i class="fa fa-bell"></i>'}var c={template:'<div class="noty_message"><span class="noty_icon">'+b+'</span><span class="noty_text"></span></div>'};a=$.extend({},c,a),noty(a)};
$(document).ready(function(){$(document).pjax("a","#content")}),$(document).on("ready pjax:success",function(){$(".scroll").perfectScrollbar(),$("#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}),$(".editor")[0]&&(editor=!1,preview=$("#preview-area"),textarea=$("#content-area"),textarea[0]&&(options={mode:textarea.data("mode"),theme:"mdn-like",lineWrapping:!0,lineNumbers:!0,scrollbarStyle:null},"markdown"==textarea.data("mode")&&(options.lineNumbers=!1),editor=CodeMirror.fromTextArea(textarea[0],options),codemirror=$(".CodeMirror"),$("#preview").click(function(a){if(a.preventDefault(),"true"==$(this).data("previewing"))preview.hide(),codemirror.fadeIn(),$(this).data("previewing","false"),notification({text:"Think, relax and do the better you can!",type:"information",timeout:2e3});else{editor.save();var b=new showdown.Converter,c=textarea.val(),d=b.makeHtml(c);codemirror.hide(),preview.html(d).fadeIn(),$(this).data("previewing","true"),notification({text:"This is how your post looks like.",type:"information",timeout:2e3})}return!1})),$("form").submit(function(a){a.preventDefault();var b=JSON.stringify($(this).serializeJSON()),c=$(this).find("input[type=submit]:focus");$.ajax({type:"POST",url:window.location,data:b,headers:{"X-Regenerate":c.data("regenerate"),"X-Content-Type":c.data("type")},dataType:"json",encode:!0}).done(function(a){notification({text:c.data("message"),type:"success",timeout:5e3})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)})}),$(".add").click(function(a){return a.preventDefault(),$("#new").length?!1:(title=$(this).parent().parent(),fieldset=title.parent(),type=fieldset.data("type"),name=fieldset.data("name"),title.is("h1")&&(fieldset=$(".sidebar .content"),fieldset.prepend('<div id="ghost"></div>'),title=$("#ghost"),type="object"),"object"==type&&(title.after('<input id="new" placeholder="Write the field name and press enter..."></input>'),element=$("#new"),$(element).keypress(function(a){return 13==a.which?(a.preventDefault(),value=element.val(),element.remove(),""==value?!1:("undefined"==name?name=value:name=name+"["+value+"]",title.after('<input name="'+name+':auto" id="'+name+'"></input><br>'),title.after('<label for="'+name+'">'+value+' <span class="actions"><button class="delete"><i class="fa fa-minus"></i></button></span></label>'),!1)):void 0})),"array"==type&&(name+="[]",title.after('<input name="'+name+':auto" id="'+name+'"></input><br>')),!1)}),$(".delete").click(function(a){a.preventDefault(),name=$(this).parent().parent().attr("for")||$(this).parent().parent().parent().attr("id"),console.log(name),$("#"+name).fadeOut().remove(),$('label[for="'+name+'"]').fadeOut().remove()}),$("body").on("keypress","input",function(a){return 13==a.keyCode?(a.preventDefault(),$('input[value="Save"]').focus().click(),!1):void 0}))}),$(document).on("pjax:send",function(){$("#loading").fadeIn()}),$(document).on("pjax:complete",function(){$("#loading").fadeOut()}),$.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='<i class="fa fa-check"></i>';break;case"error":b='<i class="fa fa-times"></i>';break;case"warning":b='<i class="fa fa-exclamation"></i>';break;case"information":b='<i class="fa fa-info"></i>';break;default:b='<i class="fa fa-bell"></i>'}var c={template:'<div class="noty_message"><span class="noty_icon">'+b+'</span><span class="noty_text"></span></div>'};a=$.extend({},c,a),noty(a)};

View File

@ -1,5 +1,5 @@
$(document).ready(function() {
$(document).pjax('a', '#main');
$(document).pjax('a', '#content');
});
$(document).on('ready pjax:success', function() {

View File

@ -0,0 +1,32 @@
.browse a {
color : inherit;
text-decoration: none;
}
.browse table {
width: 100%;
}
.browse .actions {
background-color: #455a64;
color : #fff;
padding : 1.5em 0;
}
.browse .actions .container {
margin : 0 auto;
display: flex;
}
.browse .actions .fa {
vertical-align: middle;
}
.browse .actions .go-right {
margin-left: auto;
}
.browse tr {
line-height : 2em;
border-bottom: 1px solid rgba(0,0,0,0.03);
}

View File

@ -1,5 +1,5 @@
/* EDITOR GENERAL STYLES */
.editor .sidebar {
.editor .frontmatter {
overflow-y : auto;
overflow-x : hidden;
color : #37474f;
@ -7,27 +7,16 @@
background-color: #ddd;
}
.editor .container {
overflow : hidden;
width : 100%;
box-sizing: border-box;
}
.full .container {
position: fixed;
top : 3em;
right : 0;
width : 75%;
height : calc(100% - 6em);
}
.editor .sidebar h2 {
.editor .frontmatter h2 {
margin-top: 0;
}
.editor #content-area {
display: none;
}
.editor #preview-area,
.editor textarea,
.CodeMirror {
.editor .CodeMirror {
position : relative;
box-sizing: border-box;
height : 100%;
@ -37,40 +26,16 @@
font-size : 1.05em;
}
.CodeMirror {
.editor .CodeMirror {
padding: 0;
}
.cm-s-mdn-like.CodeMirror {
background: none;
}
.editor #preview-area *:first-child {
margin-top: 0;
}
.editor textarea {
resize : none;
font-family: monospace;
}
.editor textarea:focus {
outline: 0;
}
.editor input {
width : 100%;
background-color: rgba(0, 0, 0, 0.25);
color : rgba(255, 255, 255, 0.3);
border : 0;
border-radius : 5px;
padding : .5em 1em;
box-sizing : border-box;
}
.editor input:focus {
color : rgba(255, 255, 255, 0.7);
border: 0;
.editor .cm-s-mdn-like.CodeMirror {
background: none;
}
.editor h3 {
@ -79,7 +44,7 @@
font-weight: bold;
}
.action-bar {
.toolbar {
position : fixed;
bottom : 0;
right : 0;
@ -92,11 +57,11 @@
z-index : 999;
}
.action-bar .left {
.toolbar .left {
margin-right: auto;
}
.action-bar *:last-child {
.toolbar *:last-child {
margin-left: 1em;
}
@ -106,7 +71,7 @@
height: calc(100% - 6em);
}
.frontmatter-only .sidebar {
.frontmatter-only .frontmatter {
width: 100%;
}
@ -123,8 +88,8 @@
color: #555;
}
.frontmatter-only .action-bar input,
.frontmatter-only .action-bar input:focus {
.frontmatter-only .toolbar input,
.frontmatter-only .toolbar input:focus {
color: #fff;
}
@ -150,13 +115,13 @@ input:-ms-input-placeholder {
}
/* EDITOR CONTENT ONLY STYLES */
.content-only #content-area,
.content-only #preview-area {
.editor.content-only #content-area,
.editor.content-only #preview-area {
padding: 0;
}
/* EDITOR FULL STYLES */
.full .sidebar {
.editor.complete .frontmatter {
position : fixed;
left : 0;
top : 3em;
@ -167,12 +132,22 @@ input:-ms-input-placeholder {
height : calc(100% - 3em);
}
.full .action-bar {
.editor.complete .container {
position : fixed;
top : 3em;
right : 0;
width : 75%;
max-width: none;
height : calc(100% - 6em);
margin : 1.5em auto;
}
.editor.complete .toolbar {
width: 75%;
}
.full .cm-s-mdn-like.CodeMirror {
.editor.complete .cm-s-mdn-like.CodeMirror {
width : auto;
margin: 3em 10%;
height: calc(100% - 6em);
margin: 0 10%;
height: calc(100% - 3em);
}

View File

@ -1,18 +1,21 @@
/* FORMS ELEMENTS */
form input {
color : rgba(0, 0, 0, 0.41);
width : 15em;
line-height : 1.25em;
width : 100%;
background-color: rgba(0, 0, 0, 0.25);
color : rgba(255, 255, 255, 0.3);
border : 0;
border-radius : 5px;
padding : .5em 1em;
box-sizing : border-box;
margin : .5em 0;
border : 1px solid #fff;
line-height : 1.25em;
transition : .5s ease-out all;
background-color: transparent;
}
form input:focus {
color : inherit;
outline : 0;
border-bottom: 1px solid #2196f3;
color : rgba(255, 255, 255, 0.7);
border : 0;
outline: 0;
}
form label {
@ -28,10 +31,6 @@ form fieldset {
border-top: 1px solid rgba(255, 255, 255, 0.25);
}
form legend {
font-size: 1.5em;
}
input[type="file"] {
display: none;
}

View File

@ -0,0 +1,49 @@
nav {
position : fixed;
top : 0;
left : 0;
height : 3em;
width : 100%;
background-color: #263238;
padding : 0 1em;
box-sizing : border-box;
z-index : 999;
color : #eee;
}
nav ul {
margin : 0;
padding: 0;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
nav ul li {
list-style-type: none;
display : inline-block;
vertical-align : middle;
}
nav ul li:last-child {
margin-left: auto;
}
nav img {
height: 2em;
}
nav ul li a {
padding : .5em;
line-height : 2em;
display : block;
text-decoration: none;
color : inherit;
transition : .5s ease background-color;
}
nav ul li a:hover {
background-color: rgba(255, 255, 255, 0.57);
}

View File

@ -1,69 +1,20 @@
@import "navigation";
@import "scrollbar";
@import "notifications";
@import "animations";
@import 'editor';
@import 'forms';
@import "browse";
body {
font-family: 'Roboto', sans-serif;
color : #212121;
height : 100%;
width : 100%;
}
h2 {
margin: .83em 0;
}
nav {
position : fixed;
top : 0;
left : 0;
height : 3em;
font-family : 'Roboto', sans-serif;
color : #212121;
background-color: #ddd;
height : 100%;
width : 100%;
background-color: #263238;
padding : 0 1em;
box-sizing : border-box;
z-index : 999;
color : #eee;
}
nav ul {
margin : 0;
padding: 0;
display: -webkit-box;
/* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box;
/* OLD - Firefox 19- (buggy but mostly works) */
display: -ms-flexbox;
/* TWEENER - IE 10 */
display: -webkit-flex;
/* NEW - Chrome */
display: flex;
}
nav ul li {
list-style-type: none;
display : inline-block;
vertical-align : middle;
}
nav ul li:last-child {
margin-left: auto;
}
nav img {
height: 2em;
}
nav ul li a {
padding : .5em;
line-height : 2em;
display : block;
text-decoration: none;
color : inherit;
transition : .5s ease background-color;
}
nav ul li a:hover {
background-color: rgba(255, 255, 255, 0.57);
}
.box {
#content {
position: fixed;
top : 3em;
left : 0;
@ -72,6 +23,16 @@ nav ul li a:hover {
overflow: hidden;
}
.full {
position: fixed;
height : calc(100% - 3em);
width : 100%;
}
h2 {
margin: .83em 0;
}
header {
color : #fff;
background-color: #37474f;
@ -82,27 +43,7 @@ header h1 {
margin: 0;
}
footer {
background-color: #ddd;
padding : 1.5em 0;
text-align : center;
color : rgba(0,0,0,0.5);
}
footer a {
text-decoration: none;
color : inherit;
}
footer p {
margin: 0;
}
main {
width: 100%;
}
.content {
.container {
margin : 1.5em auto;
width : 80%;
max-width: 800px;
@ -111,50 +52,11 @@ main {
.hidden {
display: none;
}
@import 'editor';
@import 'forms';
/* BROWSE */
.left {
text-align: left;
}
.right {
text-align: right;
}
.browse a {
color : inherit;
text-decoration: none;
}
.browse table {
width: 100%;
}
.browse .actions {
background-color: #455a64;
color : #fff;
padding : 1.5em 0;
}
.actions .content {
margin : 0 auto;
display: flex;
}
.actions .fa {
vertical-align: middle;
}
.actions .go-right {
margin-left: auto;
}
.browse tr {
line-height : 2em;
border-bottom: 1px solid rgba(0,0,0,0.03);
}
@import "scrollbar";
@import "notifications";
@import "animations";
}

View File

@ -110,7 +110,7 @@ func post(w http.ResponseWriter, r *http.Request, filename string) (int, error)
mainContent = "\n\n" + strings.TrimSpace(mainContent)
file = []byte(mainContent)
case "full":
case "complete":
// The main content of the file
mainContent := rawFile["content"].(string)
mainContent = "\n\n" + strings.TrimSpace(mainContent)
@ -195,7 +195,7 @@ func get(w http.ResponseWriter, r *http.Request, filename string) (int, error) {
// Parses the page content and the frontmatter
page.Content = strings.TrimSpace(string(file.Content()))
page.FrontMatter, err = frontmatter.Pretty(file.FrontMatter())
page.Class = "full"
page.Class = "complete"
} else {
// The editor will handle only content
page.Class = "content-only"

View File

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@ -23,15 +24,16 @@
<li><a id="logout" href="#logout"><i class="fa fa-sign-out"></i> Logout</a></li>
</ul>
</nav>
<div id="main">
{{ template "content" . }}
<div id="content">
{{ template "content" . }}
</div>
<div id="loading">
<div class="double-bounce">
<div class="child double-bounce1"></div>
<div class="child double-bounce2"></div>
</div>
<div class="child double-bounce1"></div>
<div class="child double-bounce2"></div>
</div>
</div>
</body>
</html>

View File

@ -1,71 +1,61 @@
{{ define "content" }}{{ $path := .Path }}
<div class="box scroll">
<div class="full scroll">
<header>
<div class="content">
<div class="container">
<h1>{{ $path }}</h1>
</div>
</header>
<main class="browse">
<div class="actions">
<div class="content">
<div class="actions">
<div class="container">
{{if .CanGoUp}}<a href=".." class="up" title="Up one level"><i class="fa fa-arrow-left fa-lg"></i></a>{{end}}
<div class="go-right"><input type="file" value="Upload">
<button id="upload">Upload <i class="fa fa-cloud-upload"></i></button>
<button class="default">New <i class="fa fa-plus"></i></button></div>
</div>
<div class="go-right">
<input type="file" value="Upload">
<button id="upload">Upload <i class="fa fa-cloud-upload"></i></button>
<button class="default">New <i class="fa fa-plus"></i></button>
</div>
</div>
</div>
<div class="content">
<table>
<tr>
<th class="left">
{{if and (eq .Sort "name") (ne .Order "desc")}}
<a href="?sort=name&order=desc">Name <i class="fa fa-arrow-up"></i></a>
{{else if and (eq .Sort "name") (ne .Order "asc")}}
<a href="?sort=name&order=asc">Name <i class="fa fa-arrow-down"></i></a>
{{else}}
<a href="?sort=name&order=asc">Name</a>
{{end}}
</th>
<th class="right">
{{if and (eq .Sort "size") (ne .Order "desc")}}
<a href="?sort=size&order=desc">Size <i class="fa fa-arrow-up"></i></a>
{{else if and (eq .Sort "size") (ne .Order "asc")}}
<a href="?sort=size&order=asc">Size <i class="fa fa-arrow-down"></i></a>
{{else}}
<a href="?sort=size&order=asc">Size</a>
{{end}}
</th>
<th class="hideable right">
{{if and (eq .Sort "time") (ne .Order "desc")}}
<a href="?sort=time&order=desc">Modified <i class="fa fa-arrow-up"></i></a>
{{else if and (eq .Sort "time") (ne .Order "asc")}}
<a href="?sort=time&order=asc">Modified <i class="fa fa-arrow-down"></i></a>
{{else}}
<a href="?sort=time&order=asc">Modified</a>
{{end}}
</th>
</tr>
{{range .Items}}
<tr>
<td>
{{if .IsDir}}
<i class="fa fa-folder"></i> <a href="{{.URL}}">{{.Name}}</a>
{{else}}
{{ if canBeEdited .URL }}
<i class="fa fa-file"></i> <a class="file" href="/admin/edit{{ $path }}{{.URL}}">{{.Name}}</a>
{{ else }}
<i class="fa fa-file"></i> {{.Name}}
{{ end }}
{{ end }}
</td>
<td class="right">{{.HumanSize}}</td>
<td class="right hideable">{{.HumanModTime "01/02/2006 3:04:05 PM -0700"}}</td>
</tr>
{{end}}
</table>
<div class="container">
<table>
<tr>
<th class="left">
{{if and (eq .Sort "name") (ne .Order "desc")}}
<a href="?sort=name&order=desc">Name <i class="fa fa-arrow-up"></i></a> {{else if and (eq .Sort "name") (ne .Order "asc")}}
<a href="?sort=name&order=asc">Name <i class="fa fa-arrow-down"></i></a> {{else}}
<a href="?sort=name&order=asc">Name</a> {{end}}
</th>
<th class="right hideable">
{{if and (eq .Sort "size") (ne .Order "desc")}}
<a href="?sort=size&order=desc">Size <i class="fa fa-arrow-up"></i></a> {{else if and (eq .Sort "size") (ne .Order "asc")}}
<a href="?sort=size&order=asc">Size <i class="fa fa-arrow-down"></i></a> {{else}}
<a href="?sort=size&order=asc">Size</a> {{end}}
</th>
<th class="hideable right">
{{if and (eq .Sort "time") (ne .Order "desc")}}
<a href="?sort=time&order=desc">Modified <i class="fa fa-arrow-up"></i></a> {{else if and (eq .Sort "time") (ne .Order "asc")}}
<a href="?sort=time&order=asc">Modified <i class="fa fa-arrow-down"></i></a> {{else}}
<a href="?sort=time&order=asc">Modified</a> {{end}}
</th>
<th class="right"></th>
</tr>
{{range .Items}}
<tr>
<td>
{{if .IsDir}}
<i class="fa fa-folder"></i> <a href="{{.URL}}">{{.Name}}</a> {{else}} {{ if canBeEdited .URL }}
<i class="fa fa-file"></i> <a class="file" href="/admin/edit{{ $path }}{{.URL}}">{{.Name}}</a> {{ else }}
<i class="fa fa-file"></i> {{.Name}} {{ end }} {{ end }}
</td>
<td class="right hideable">{{.HumanSize}}</td>
<td class="right hideable">{{.HumanModTime "01/02/2006 3:04:05 PM -0700"}}</td>
<td class="right"><button class="delete"><i class="fa fa-times"></i></button></td>
</tr>
{{end}}
</table>
</div>
</main>
</div>

View File

@ -2,35 +2,35 @@
<div class="editor {{ .Class }}">
<form method="POST" action="">
<div class="box scroll">
<div class="full box scroll">
<main>
{{ if not (eq .Class "full") }}
{{ if not (eq .Class "complete") }}
<header>
<div class="content">
<h1>{{ .Name }} <span class="actions"><button class="add"><i class="fa fa-plus"></i></button></span></h1>
<div class="container">
<h1>{{ .Name }}{{ if eq .Class "frontmatter-only" }}
<span class="actions">
<button class="add"><i class="fa fa-plus"></i></button>
</span>{{ end }}
</h1>
</div>
</header>
{{ end }}
{{ if eq .Class "frontmatter-only" }}
<div class="sidebar">
<div class="content">
{{ template "frontmatter" .FrontMatter }}
{{ end }} {{ if eq .Class "frontmatter-only" }}
<div class="frontmatter">
<div class="container">
{{ template "frontmatter" .FrontMatter }}
</div>
</div>
{{ else if eq .Class "content-only" }}
<div class="container">
<div class="content">
<textarea id="content-area" name="content" class="scroll" data-mode="{{ .Mode }}">{{ .Content }}</textarea>
<div id="preview-area" class="scroll hidden"></div>
</div>
<textarea id="content-area" name="content" class="scroll" data-mode="{{ .Mode }}">{{ .Content }}</textarea>
<div id="preview-area" class="scroll hidden"></div>
</div>
{{ else }}
<div class="container">
<textarea id="content-area" name="content" class="scroll" data-mode="{{ .Mode }}">{{ .Content }}</textarea>
<div id="preview-area" class="scroll hidden"></div>
</div>
<div class="sidebar scroll">
<div class="frontmatter scroll">
<h2>Metadata</h2>
{{ template "frontmatter" .FrontMatter }}
</div>
@ -38,14 +38,16 @@
</main>
</div>
<div class="action-bar">
<div class="toolbar">
{{ if or (eq .Mode "markdown") (eq .Class "full") }}
<button id="preview" class="left">Preview</button>
{{ else }}
<span class="left"></span>
{{ end }}
<input type="submit" data-type="{{ .Class }}" data-message="{{ if eq .Class "frontmatter-only" }}The fields were put on their way.{{ else if eq .Class "content-only" }}Every byte was saved.{{ else }}Post saved with pomp and circumstance.{{ end }}" data-regenerate="false" value="Save">
<input type="submit" data-type="{{ .Class }}" data-message="{{ if eq .Class "frontmatter-only" }}Saved and regenerated.{{ else if eq .Class "content-only" }}Done. What do you want more?{{ else }}Post published. Go and share it!{{ end }}" data-regenerate="true" class="default" value="Publish">
<input type="submit" data-type="{{ .Class }}" data-message="{{ if eq .Class " frontmatter-only " }}The fields were put on their way.{{ else if eq .Class "content-only " }}Every byte was saved.{{ else }}Post saved with pomp and circumstance.{{ end }}"
data-regenerate="false" value="Save">
<input type="submit" data-type="{{ .Class }}" data-message="{{ if eq .Class " frontmatter-only " }}Saved and regenerated.{{ else if eq .Class "content-only " }}Done. What do you want more?{{ else }}Post published. Go and share it!{{ end }}" data-regenerate="true"
class="default" value="Publish">
</div>
</form>
</div>

View File

@ -1,15 +1,19 @@
{{ define "frontmatter" }}
{{ range $key, $value := . }}
{{ if or (eq $value.Type "object") (eq $value.Type "array") }}
<fieldset id="{{ $value.Name }}" data-name="{{ $value.Name }}" data-type="{{ $value.Type }}">
<h3>{{ splitCapitalize $value.Title }} <span class="actions"><button class="delete"><i class="fa fa-minus"></i></button> <button class="add"><i class="fa fa-plus"></i></button></span></h3>
{{ template "frontmatter" $value.Content }}
</fieldset>
{{ else }}
{{ if not (eq $value.Parent.Type "array") }}
<label for="{{ $value.Name }}">{{ splitCapitalize $value.Title }} <span class="actions"><button class="delete"><i class="fa fa-minus"></i></button></span></label>
{{ end }}
<input name="{{ $value.Name }}:auto" id="{{ $value.Name }}" value="{{ $value.Content }}"></input>
{{ end }}
{{ end }}
{{ define "frontmatter" }} {{ range $key, $value := . }} {{ if or (eq $value.Type "object") (eq $value.Type "array") }}
<fieldset id="{{ $value.Name }}" data-name="{{ $value.Name }}" data-type="{{ $value.Type }}">
<h3>{{ splitCapitalize $value.Title }}
<span class="actions">
<button class="delete"><i class="fa fa-minus"></i></button>
<button class="add"><i class="fa fa-plus"></i></button>
</span>
</h3>
{{ template "frontmatter" $value.Content }}
</fieldset>
{{ else }} {{ if not (eq $value.Parent.Type "array") }}
<label for="{{ $value.Name }}">{{ splitCapitalize $value.Title }}
<span class="actions">
<button class="delete"><i class="fa fa-minus"></i></button>
</span>
</label>
{{ end }}
<input name="{{ $value.Name }}:{{ $value.Type }}" id="{{ $value.Name }}" value="{{ $value.Content }}"></input>
{{ end }} {{ end }} {{ end }}