diff --git a/assets/public/js/application.js b/assets/public/js/application.js
index 1b47c715..98ae8d96 100644
--- a/assets/public/js/application.js
+++ b/assets/public/js/application.js
@@ -8,6 +8,7 @@ document.addEventListener('DOMContentLoaded', event => {
document.getElementById('logout').insertAdjacentHTML('beforebegin', `
settings
+ Settings
`);
});
@@ -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', `
`);
+ 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,21 +108,20 @@ 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);
}
}
});
-});
+});
\ No newline at end of file
diff --git a/hugo.go b/hugo.go
index 30de0d98..741d1070 100644
--- a/hugo.go
+++ b/hugo.go
@@ -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 {