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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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);
}
}

View File

@ -98,6 +98,10 @@ footer p {
margin: 0;
}
main {
width: 100%;
}
.content {
margin : 1.5em auto;
width : 80%;
@ -393,3 +397,4 @@ h3:hover > button.add {
}
@import "scrollbar";
@import "notifications";
@import "animations";

File diff suppressed because one or more lines are too long

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,
@ -105,3 +105,10 @@ $(document).on('ready pjax:success', function() {
return false;
});
});
$(document).on('pjax:send', function() {
$('#loading').fadeIn()
})
$(document).on('pjax:complete', function() {
$('#loading').fadeOut()
})

View File

@ -2,6 +2,7 @@ package editor
import (
"bytes"
"encoding/json"
"errors"
"io/ioutil"
"log"
@ -29,8 +30,6 @@ 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)
@ -39,6 +38,40 @@ func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
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,11 +92,16 @@ 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)
@ -71,7 +109,7 @@ func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
}
w.Header().Set("Content-Type", "application/json")
w.Write([]byte("{}")) */
w.Write([]byte("{}"))
} else {
// Check if the file format is supported. If not, send a "Not Acceptable"
// header and an error

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>

View File

@ -1,4 +1,6 @@
{{ define "content" }}{{ $path := .Path }}
<div class="box scroll">
<header>
<div class="content">
<h1>{{ $path }}</h1>
@ -66,4 +68,5 @@
</table>
</div>
</main>
</div>
{{ end }}

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>