hopefully fix everything :)

pull/60/merge
Henrique Dias 2016-12-08 16:00:23 +00:00
parent 9f84c546a2
commit 5cb0900c38
2 changed files with 16 additions and 17 deletions

View File

@ -8,6 +8,7 @@ document.addEventListener('DOMContentLoaded', event => {
document.getElementById('logout').insertAdjacentHTML('beforebegin', `<a href="${link}">
<div class="action">
<i class="material-icons">settings</i>
<span>Settings</span>
</div>
</a>`);
});
@ -56,6 +57,9 @@ document.addEventListener('listing', event => {
});
document.addEventListener('editor', event => {
let container = document.getElementById('editor'),
kind = container.dataset.kind;
document.getElementById('submit').insertAdjacentHTML('afterend', `<div class="right">
<button id="publish">
<span>
@ -73,6 +77,8 @@ document.addEventListener('editor', event => {
<span>Schedule</span>
</button>`);
let button = document.querySelector('#schedule span:first-child');
document.getElementById('schedule').addEventListener('click', event => {
event.preventDefault();
@ -81,20 +87,16 @@ document.addEventListener('editor', event => {
date = document.getElementById('publishDate').value;
}
let container = document.getElementById('editor');
let kind = container.dataset.kind;
let button = document.querySelector('#schedule span:first-child');
let data = form2js(document.querySelector('form'));
let html = button.changeToLoading();
let request = new XMLHttpRequest();
request.open("PUT", window.location);
request.open("PUT", toWebDavURL(window.location.pathname));
request.setRequestHeader('Kind', kind);
request.setRequestHeader('Schedule', date);
request.send(JSON.stringify(data));
request.onreadystatechange = function() {
if (request.readyState == 4) {
button.changeToDone((request.status != 200), html);
button.changeToDone((request.status != 200 && request.status != 201), html);
}
}
});
@ -106,20 +108,19 @@ document.addEventListener('editor', event => {
if (document.getElementById('draft')) {
document.getElementById('block-draft').remove();
}
let container = document.getElementById('editor');
let kind = container.dataset.kind;
let button = document.querySelector('#publish span:first-child');
let data = form2js(document.querySelector('form'));
let html = button.changeToLoading();
let request = new XMLHttpRequest();
request.open("PUT", window.location);
let button = document.querySelector('#publish span:first-child'),
data = form2js(document.querySelector('form')),
html = button.changeToLoading(),
request = new XMLHttpRequest();
request.open("PUT", toWebDavURL(window.location.pathname));
request.setRequestHeader('Kind', kind);
request.setRequestHeader('Regenerate', "true");
request.send(JSON.stringify(data));
request.onreadystatechange = function() {
if (request.readyState == 4) {
button.changeToDone((request.status != 200), html);
button.changeToDone((request.status != 200 && request.status != 201), html);
}
}
});

View File

@ -94,8 +94,6 @@ func (h Hugo) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
}
if canBeEdited(r.URL.Path) && r.Method == http.MethodPut {
r.URL.Path = strings.Replace(r.URL.Path, h.FileManager.Configs[0].BaseURL, h.FileManager.Configs[0].WebDavURL, -1)
code, err := h.FileManager.ServeHTTP(w, r)
if err != nil {