updates and remove main.css
This commit is contained in:
parent
0549bd73eb
commit
a569ccc32a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -98,6 +98,10 @@ footer p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
margin : 1.5em auto;
|
margin : 1.5em auto;
|
||||||
width : 80%;
|
width : 80%;
|
||||||
|
@ -393,3 +397,4 @@ h3:hover > button.add {
|
||||||
}
|
}
|
||||||
@import "scrollbar";
|
@import "scrollbar";
|
||||||
@import "notifications";
|
@import "notifications";
|
||||||
|
@import "animations";
|
File diff suppressed because one or more lines are too long
|
@ -3,9 +3,9 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('ready pjax:success', function() {
|
$(document).on('ready pjax:success', function() {
|
||||||
|
$('textarea.auto-size').textareaAutoSize();
|
||||||
// Starts the perfect scroolbar plugin
|
// Starts the perfect scroolbar plugin
|
||||||
$('.scroll').perfectScrollbar();
|
$('.scroll').perfectScrollbar();
|
||||||
$('textarea.auto-size').textareaAutoSize();
|
|
||||||
|
|
||||||
// Toggles between preview and editing mode
|
// Toggles between preview and editing mode
|
||||||
$("#preview").click(function(event) {
|
$("#preview").click(function(event) {
|
||||||
|
@ -48,17 +48,17 @@ $(document).on('ready pjax:success', function() {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
var data = JSON.stringify($(this).serializeJSON()),
|
var data = JSON.stringify($(this).serializeJSON()),
|
||||||
url = $(this).attr('action'),
|
|
||||||
button = $(this).find("input[type=submit]:focus");
|
button = $(this).find("input[type=submit]:focus");
|
||||||
|
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: url,
|
url: window.location,
|
||||||
data: data,
|
data: data,
|
||||||
headers: {
|
headers: {
|
||||||
'X-Regenerate': button.data("regenerate")
|
'X-Regenerate': button.data("regenerate"),
|
||||||
|
'X-Content-Type': button.data("type")
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
encode: true,
|
encode: true,
|
||||||
|
@ -105,3 +105,10 @@ $(document).on('ready pjax:success', function() {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on('pjax:send', function() {
|
||||||
|
$('#loading').fadeIn()
|
||||||
|
})
|
||||||
|
$(document).on('pjax:complete', function() {
|
||||||
|
$('#loading').fadeOut()
|
||||||
|
})
|
|
@ -2,6 +2,7 @@ package editor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -29,8 +30,6 @@ func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
filename := strings.Replace(r.URL.Path, "/admin/edit/", "", 1)
|
filename := strings.Replace(r.URL.Path, "/admin/edit/", "", 1)
|
||||||
|
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
// TODO: review post saving
|
|
||||||
/*
|
|
||||||
// Get the JSON information sent using a buffer
|
// Get the JSON information sent using a buffer
|
||||||
rawBuffer := new(bytes.Buffer)
|
rawBuffer := new(bytes.Buffer)
|
||||||
rawBuffer.ReadFrom(r.Body)
|
rawBuffer.ReadFrom(r.Body)
|
||||||
|
@ -39,6 +38,40 @@ func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
var rawFile map[string]interface{}
|
var rawFile map[string]interface{}
|
||||||
json.Unmarshal(rawBuffer.Bytes(), &rawFile)
|
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
|
// The main content of the file
|
||||||
mainContent := rawFile["content"].(string)
|
mainContent := rawFile["content"].(string)
|
||||||
mainContent = "\n\n" + strings.TrimSpace(mainContent)
|
mainContent = "\n\n" + strings.TrimSpace(mainContent)
|
||||||
|
@ -59,11 +92,16 @@ func Execute(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
json.Indent(frontMatterBuffer, jsonFrontmatter, "", " ")
|
json.Indent(frontMatterBuffer, jsonFrontmatter, "", " ")
|
||||||
|
|
||||||
// Generates the final file
|
// Generates the final file
|
||||||
file := new(bytes.Buffer)
|
f := new(bytes.Buffer)
|
||||||
file.Write(frontMatterBuffer.Bytes())
|
f.Write(frontMatterBuffer.Bytes())
|
||||||
file.Write([]byte(mainContent))
|
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 {
|
if err != nil {
|
||||||
log.Print(err)
|
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.Header().Set("Content-Type", "application/json")
|
||||||
w.Write([]byte("{}")) */
|
w.Write([]byte("{}"))
|
||||||
} else {
|
} else {
|
||||||
// Check if the file format is supported. If not, send a "Not Acceptable"
|
// Check if the file format is supported. If not, send a "Not Acceptable"
|
||||||
// header and an error
|
// header and an error
|
||||||
|
|
|
@ -25,5 +25,12 @@
|
||||||
<div id="main">
|
<div id="main">
|
||||||
{{ template "content" . }}
|
{{ template "content" . }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="loading">
|
||||||
|
<div class="double-bounce">
|
||||||
|
<div class="child double-bounce1"></div>
|
||||||
|
<div class="child double-bounce2"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
{{ define "content" }}{{ $path := .Path }}
|
{{ define "content" }}{{ $path := .Path }}
|
||||||
|
|
||||||
|
<div class="box scroll">
|
||||||
<header>
|
<header>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>{{ $path }}</h1>
|
<h1>{{ $path }}</h1>
|
||||||
|
@ -66,4 +68,5 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{{ define "content" }}
|
{{ define "content" }}
|
||||||
|
|
||||||
<div class="editor {{ .Class }}">
|
<div class="editor {{ .Class }}">
|
||||||
<form method="POST" action="">
|
<form method="POST" action="">
|
||||||
<div class="box scroll">
|
<div class="box scroll">
|
||||||
|
@ -43,8 +44,8 @@
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<span class="left"></span>
|
<span class="left"></span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<input type="submit" data-message="Post saved." data-regenerate="false" value="Save">
|
<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-message="Post published successfully." data-regenerate="true" class="default" value="Publish">
|
<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>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue