close #71; fix bugs

This commit is contained in:
Henrique Dias
2016-06-07 18:15:55 +01:00
parent acc4c92b15
commit 4cd72ca58d
11 changed files with 38 additions and 32 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,10 +1,14 @@
var basePath = "/";
$(document).ready(function() {
basePath += window.location.pathname.split('/')[0];
// Log out the user sending bad credentials to the server
$("#logout").click(function(event) {
event.preventDefault();
$.ajax({
type: "GET",
url: "/admin",
url: basePath + "",
async: false,
username: "username",
password: "password",

View File

@@ -247,7 +247,7 @@ $(document).on('page:browse', function() {
}
if (filename.substring(0, 1) != "/") {
filename = window.location.pathname.replace("/admin/browse/", "") + '/' + filename;
filename = window.location.pathname.replace(basePath + "/browse/", "") + '/' + filename;
}
var content = {
@@ -323,7 +323,7 @@ $(document).on('page:browse', function() {
}
var request = new XMLHttpRequest();
request.open("POST", "/admin/git");
request.open("POST", basePath + "/git");
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
request.send(JSON.stringify({
command: value

View File

@@ -103,6 +103,8 @@ $(document).on('page:editor', function() {
regenerate: button.data("regenerate")
}
console.log(JSON.stringify(data));
var request = new XMLHttpRequest();
request.open("POST", window.location);
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
@@ -155,7 +157,6 @@ $(document).on('page:editor', function() {
input = input.replace(/\[/, '\\[');
input = input.replace(/\]/, '\\]');
block.append('<div id="' + newID + '-' + $('#' + input + ' > div').length + '" data-type="array-item"><input name="' + newID + ':auto" id="' + newID + '"></input><span class="actions"> <button class="delete">&#8722;</button></span></div></div>');
console.log('New array item added.');
}
// Main add button, after all blocks
@@ -241,8 +242,6 @@ $(document).on('page:editor', function() {
template = template.replace("${type}", type);
newItem.after(template);
newItem.remove();
console.log('"' + blockID + '" block of type "' + type + '" added.');
}
return false;
@@ -260,7 +259,6 @@ $(document).on('page:editor', function() {
name = button.parent().parent().attr("for") || button.parent().parent().attr("id") || button.parent().parent().parent().attr("id");
name = name.replace(/\[/, '\\[');
name = name.replace(/\]/, '\\]');
console.log(name)
$('label[for="' + name + '"]').fadeOut().remove();
$('#' + name).fadeOut().remove();

View File

@@ -9,23 +9,21 @@
<title>{{ if Defined . "Name" }}{{ .Name }}{{ end }}</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/admin/assets/css/main.min.css">
{{ if and (Defined . "Config")}}{{ if not (eq .Config.Styles "") }}<link rel="stylesheet" href="{{ .Config.Styles }}">{{ end }}{{ end }}
{{ if and (Defined . "User") }}{{ if not (eq .User.Styles "") }}<link rel="stylesheet" href="{{ .User.Styles }}">{{ end }}{{ end }}
<link rel="stylesheet" href="{{ if and (Defined . "User") }}{{ .User.Admin }}{{ else }}{{ .Config.Admin }}{{ end }}/assets/css/main.min.css">
{{ if not (eq .Config.Styles "") }}<link rel="stylesheet" href="{{ .Config.Styles }}">{{ end }}
<script src="/admin/assets/js/plugins.min.js"></script>
<script src="{{ if and (Defined . "User") }}{{ .User.Admin }}{{ else }}{{ .Config.Admin }}{{ end }}/assets/js/plugins.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script>
<script src="/admin/assets/js/app.min.js"></script>
<script src="{{ if and (Defined . "User") }}{{ .User.Admin }}{{ else }}{{ .Config.Admin }}{{ end }}/assets/js/app.min.js"></script>
</head>
<body>
<nav>
<ul class="container">
<li><a href="/"><i class="fa fa-home fa-lg"></i><span> Go to website</span></a></li>
<li><a data-pjax href="/admin/browse/content/"><i class="fa fa-newspaper-o"></i><span> Content</span></a></li>
<li><a data-pjax href="/admin/browse/"><i class="fa fa-folder-o"></i><span> Browse</span></a></li>
<li><a data-pjax href="/admin/settings/"><i class="fa fa-cog"></i><span> Settings</span></a></li>
<li><a data-pjax href="{{ if and (Defined . "User") }}{{ .User.Admin }}{{ else }}{{ .Config.Admin }}{{ end }}/browse/content/"><i class="fa fa-newspaper-o"></i><span> Content</span></a></li>
<li><a data-pjax href="{{ if and (Defined . "User") }}{{ .User.Admin }}{{ else }}{{ .Config.Admin }}{{ end }}/browse/"><i class="fa fa-folder-o"></i><span> Browse</span></a></li>
<li><a data-pjax href="{{ if and (Defined . "User") }}{{ .User.Admin }}{{ else }}{{ .Config.Admin }}{{ end }}/settings/"><i class="fa fa-cog"></i><span> Settings</span></a></li>
<li><a data-pjax id="logout" href="#logout"><i class="fa fa-sign-out"></i><span> Logout</span></a></li>
</ul>
</nav>

View File

@@ -1,4 +1,6 @@
{{ define "content" }}{{ $path := .Path }}
{{ define "content" }}
{{ $path := .Path }}
{{ $admin := .User.Admin }}
<main class="browse">
<div class="actions">
@@ -42,12 +44,12 @@
<td>
{{if .IsDir}}
<i class="fa fa-folder"></i> <a data-pjax class="filename" href="{{.URL}}">{{.Name}}</a> {{else}} {{ if CanBeEdited .URL }}
<i class="fa fa-file"></i> <a data-pjax class="file filename" href="/admin/edit{{ $path }}{{.URL}}">{{.Name}}</a> {{ else }}
<i class="fa fa-file"></i> <a data-pjax class="file filename" href="{{ $admin }}/edit{{ $path }}{{.URL}}">{{.Name}}</a> {{ else }}
<i class="fa fa-file"></i> <span class="filename">{{.Name}}</span> {{ end }} {{ end }}
</td>
<td class="right hideable">{{.HumanSize}}</td>
<td class="right hideable">{{.HumanModTime "01/02/2006 3:04:05 PM"}}</td>
<td class="right"><button data-file="/admin/browse{{ $path }}{{.URL}}" data-message="File renamed." class="rename">&#9998;</button> <button data-file="/admin/browse{{ $path }}{{.URL}}" data-message="File deleted." class="delete">&#10006;</button></td>
<td class="right"><button data-file="{{ $admin }}/browse{{ $path }}{{.URL}}" data-message="File renamed." class="rename">&#9998;</button> <button data-file="{{ $admin }}/browse{{ $path }}{{.URL}}" data-message="File deleted." class="delete">&#10006;</button></td>
</tr>
{{end}}
</table>