updates and remove main.css

This commit is contained in:
Henrique Dias
2015-09-18 19:12:47 +01:00
parent 0549bd73eb
commit a569ccc32a
10 changed files with 216 additions and 3489 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+62
View File
@@ -0,0 +1,62 @@
#loading {
position : fixed;
height : calc(100% - 3em);
width : 100%;
top : 3em;
background-color: rgba(0,0,0,0.6);
z-index : 99999999;
display : none;
}
.double-bounce {
width : 5em;
height : 5em;
margin : 0 auto;
position : relative;
top : 50%;
transform: translateY(-50%);
}
.double-bounce .child {
width : 100%;
height : 100%;
border-radius : 50%;
background-color : #fff;
opacity : .6;
position : absolute;
top : 0;
left : 0;
-webkit-animation: doubleBounce 2s infinite ease-in-out;
animation : doubleBounce 2s infinite ease-in-out;
}
.double-bounce .double-bounce2 {
-webkit-animation-delay: -1.0s;
animation-delay : -1.0s;
}
@-webkit-keyframes doubleBounce {
0%,
100% {
-webkit-transform: scale(0);
transform : scale(0);
}
50% {
-webkit-transform: scale(1);
transform : scale(1);
}
}
@keyframes doubleBounce {
0%,
100% {
-webkit-transform: scale(0);
transform : scale(0);
}
50% {
-webkit-transform: scale(1);
transform : scale(1);
}
}
+6 -1
View File
@@ -98,6 +98,10 @@ footer p {
margin: 0;
}
main {
width: 100%;
}
.content {
margin : 1.5em auto;
width : 80%;
@@ -392,4 +396,5 @@ h3:hover > button.add {
border-bottom: 1px solid rgba(0,0,0,0.03);
}
@import "scrollbar";
@import "notifications";
@import "notifications";
@import "animations";
+1 -1
View File
File diff suppressed because one or more lines are too long
+12 -5
View File
@@ -3,9 +3,9 @@ $(document).ready(function() {
});
$(document).on('ready pjax:success', function() {
$('textarea.auto-size').textareaAutoSize();
// Starts the perfect scroolbar plugin
$('.scroll').perfectScrollbar();
$('textarea.auto-size').textareaAutoSize();
// Toggles between preview and editing mode
$("#preview").click(function(event) {
@@ -48,17 +48,17 @@ $(document).on('ready pjax:success', function() {
event.preventDefault();
var data = JSON.stringify($(this).serializeJSON()),
url = $(this).attr('action'),
button = $(this).find("input[type=submit]:focus");
console.log(data)
$.ajax({
type: 'POST',
url: url,
url: window.location,
data: data,
headers: {
'X-Regenerate': button.data("regenerate")
'X-Regenerate': button.data("regenerate"),
'X-Content-Type': button.data("type")
},
dataType: 'json',
encode: true,
@@ -104,4 +104,11 @@ $(document).on('ready pjax:success', function() {
fieldset.append("<input name=\"" + fieldset.attr("name") + "\" id=\"" + fieldset.attr("name") + "\" value=\"\"></input><br>");
return false;
});
});
});
$(document).on('pjax:send', function() {
$('#loading').fadeIn()
})
$(document).on('pjax:complete', function() {
$('#loading').fadeOut()
})
+56 -18
View File
@@ -2,6 +2,7 @@ package editor
import (
"bytes"
"encoding/json"
"errors"
"io/ioutil"
"log"
@@ -29,16 +30,48 @@ func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
filename := strings.Replace(r.URL.Path, "/admin/edit/", "", 1)
if r.Method == "POST" {
// TODO: review post saving
/*
// Get the JSON information sent using a buffer
rawBuffer := new(bytes.Buffer)
rawBuffer.ReadFrom(r.Body)
// Get the JSON information sent using a buffer
rawBuffer := new(bytes.Buffer)
rawBuffer.ReadFrom(r.Body)
// Creates the raw file "map" using the JSON
var rawFile map[string]interface{}
json.Unmarshal(rawBuffer.Bytes(), &rawFile)
// Creates the raw file "map" using the JSON
var rawFile map[string]interface{}
json.Unmarshal(rawBuffer.Bytes(), &rawFile)
// Initializes the file content to write
var file []byte
switch r.Header.Get("X-Content-Type") {
case "frontmatter-only":
frontmatter := strings.TrimPrefix(filepath.Ext(filename), ".")
var mark rune
switch frontmatter {
case "toml":
mark = rune('+')
case "json":
mark = rune('{')
case "yaml":
mark = rune('-')
default:
return 400, nil
}
f, err := parser.InterfaceToFrontMatter(rawFile, mark)
if err != nil {
log.Print(err)
return 500, err
}
file = f
case "content-only":
// The main content of the file
mainContent := rawFile["content"].(string)
mainContent = "\n\n" + strings.TrimSpace(mainContent)
file = []byte(mainContent)
case "full":
// The main content of the file
mainContent := rawFile["content"].(string)
mainContent = "\n\n" + strings.TrimSpace(mainContent)
@@ -59,19 +92,24 @@ func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
json.Indent(frontMatterBuffer, jsonFrontmatter, "", " ")
// Generates the final file
file := new(bytes.Buffer)
file.Write(frontMatterBuffer.Bytes())
file.Write([]byte(mainContent))
f := new(bytes.Buffer)
f.Write(frontMatterBuffer.Bytes())
f.Write([]byte(mainContent))
file = f.Bytes()
default:
return 400, nil
}
err = ioutil.WriteFile(filename, file.Bytes(), 0666)
// Write the file
err := ioutil.WriteFile(filename, file, 0666)
if err != nil {
log.Print(err)
return 500, err
}
if err != nil {
log.Print(err)
return 500, err
}
w.Header().Set("Content-Type", "application/json")
w.Write([]byte("{}")) */
w.Header().Set("Content-Type", "application/json")
w.Write([]byte("{}"))
} else {
// Check if the file format is supported. If not, send a "Not Acceptable"
// header and an error
+7
View File
@@ -25,5 +25,12 @@
<div id="main">
{{ template "content" . }}
</div>
<div id="loading">
<div class="double-bounce">
<div class="child double-bounce1"></div>
<div class="child double-bounce2"></div>
</div>
</div>
</body>
</html>
+68 -65
View File
@@ -1,69 +1,72 @@
{{ define "content" }}{{ $path := .Path }}
<header>
<div class="box scroll">
<header>
<div class="content">
<h1>{{ $path }}</h1>
</div>
</header>
<main class="browse">
<div class="actions">
<div class="content">
{{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>
<div class="content">
<h1>{{ $path }}</h1>
</div>
</header>
<main class="browse">
<div class="actions">
<div class="content">
{{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>
<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>
</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>
</main>
</main>
</div>
{{ end }}
+3 -2
View File
@@ -1,4 +1,5 @@
{{ define "content" }}
<div class="editor {{ .Class }}">
<form method="POST" action="">
<div class="box scroll">
@@ -43,8 +44,8 @@
{{ else }}
<span class="left"></span>
{{ end }}
<input type="submit" data-message="Post saved." data-regenerate="false" value="Save">
<input type="submit" data-message="Post published successfully." 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>