updates
This commit is contained in:
parent
edf0a453a3
commit
d847909da8
File diff suppressed because one or more lines are too long
|
@ -2540,6 +2540,22 @@ header h1 {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
footer {
|
||||
background-color: #ddd;
|
||||
padding: 1.5em 0;
|
||||
text-align: center;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
footer a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
footer p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin: 1.5em auto;
|
||||
width: 80%;
|
||||
|
@ -2678,6 +2694,10 @@ form legend {
|
|||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
input[type="file"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
button,
|
||||
input[type="submit"] {
|
||||
border: 0;
|
||||
|
@ -2736,6 +2756,48 @@ h3:hover > button.add {
|
|||
opacity: 1;
|
||||
}
|
||||
|
||||
/* BROWSE */
|
||||
.left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.browse a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.browse table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.browse .actions {
|
||||
background-color: #455a64;
|
||||
color: #fff;
|
||||
padding: 1.5em 0;
|
||||
}
|
||||
|
||||
.actions .content {
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.actions .fa {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.actions .go-right {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.browse tr {
|
||||
line-height: 2em;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
|
||||
/* perfect-scrollbar v0.6.5 */
|
||||
.ps-container {
|
||||
-ms-touch-action: none;
|
||||
|
|
|
@ -82,6 +82,22 @@ header h1 {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
footer {
|
||||
background-color: #ddd;
|
||||
padding : 1.5em 0;
|
||||
text-align : center;
|
||||
color : rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
footer a {
|
||||
text-decoration: none;
|
||||
color : inherit;
|
||||
}
|
||||
|
||||
footer p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin : 1.5em auto;
|
||||
width : 80%;
|
||||
|
@ -220,6 +236,10 @@ form legend {
|
|||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
input[type="file"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
button,
|
||||
input[type="submit"] {
|
||||
border : 0;
|
||||
|
@ -277,5 +297,47 @@ button.add {
|
|||
h3:hover > button.add {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* BROWSE */
|
||||
.left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.browse a {
|
||||
color : inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.browse table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.browse .actions {
|
||||
background-color: #455a64;
|
||||
color : #fff;
|
||||
padding : 1.5em 0;
|
||||
}
|
||||
|
||||
.actions .content {
|
||||
margin : 0 auto;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.actions .fa {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.actions .go-right {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.browse tr {
|
||||
line-height : 2em;
|
||||
border-bottom: 1px solid rgba(0,0,0,0.03);
|
||||
}
|
||||
@import "scrollbar";
|
||||
@import "notifications";
|
File diff suppressed because one or more lines are too long
|
@ -3,10 +3,12 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
$(document).on('ready pjax:success', function() {
|
||||
// Starts the perfect scroolbar plugin
|
||||
$('.scroll').perfectScrollbar();
|
||||
|
||||
$("#preview").click(function(e) {
|
||||
e.preventDefault();
|
||||
// Toggles between preview and editing mode
|
||||
$("#preview").click(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var preview = $("#preview-area"),
|
||||
editor = $('.editor textarea');
|
||||
|
@ -40,6 +42,7 @@ $(document).on('ready pjax:success', function() {
|
|||
return false;
|
||||
});
|
||||
|
||||
// Submites any form in the page in JSON format
|
||||
$('form').submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -51,8 +54,8 @@ $(document).on('ready pjax:success', function() {
|
|||
type: 'POST',
|
||||
url: url,
|
||||
data: data,
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader('X-Regenerate', button.data("regenerate"));
|
||||
headers: {
|
||||
'X-Regenerate': button.data("regenerate")
|
||||
},
|
||||
dataType: 'json',
|
||||
encode: true,
|
||||
|
@ -71,24 +74,27 @@ $(document).on('ready pjax:success', function() {
|
|||
});
|
||||
});
|
||||
|
||||
// Log out the user sending bad credentials to the server
|
||||
$("#logout").click(function(e) {
|
||||
e.preventDefault();
|
||||
jQuery.ajax({
|
||||
type: "GET",
|
||||
url: "/admin",
|
||||
async: false,
|
||||
username: "logmeout",
|
||||
password: "123456",
|
||||
headers: {
|
||||
"Authorization": "Basic xxx"
|
||||
}
|
||||
})
|
||||
.fail(function() {
|
||||
window.location = "/";
|
||||
});
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/admin",
|
||||
async: false,
|
||||
username: "username",
|
||||
password: "password",
|
||||
headers: {
|
||||
"Authorization": "Basic xxx"
|
||||
}
|
||||
}).fail(function() {
|
||||
window.location = "/";
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Adds one more field to the current group
|
||||
// TODO: improve this function. add group/field/array/obj
|
||||
$(".add").click(function(e) {
|
||||
e.preventDefault();
|
||||
fieldset = $(this).closest("fieldset");
|
||||
|
|
21
hugo.go
21
hugo.go
|
@ -32,9 +32,16 @@ type handler struct{ Next middleware.Handler }
|
|||
func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
if middleware.Path(r.URL.Path).Matches("/admin") {
|
||||
page := utils.ParseComponents(r)[1]
|
||||
code := 400
|
||||
code := 404
|
||||
var err error
|
||||
|
||||
if page != "assets" && page != "edit" {
|
||||
if r.URL.Path[len(r.URL.Path)-1] != '/' {
|
||||
http.Redirect(w, r, r.URL.Path+"/", http.StatusTemporaryRedirect)
|
||||
return 0, nil
|
||||
}
|
||||
}
|
||||
|
||||
if page == "assets" {
|
||||
filename := strings.Replace(r.URL.Path, "/admin/", "", 1)
|
||||
file, err := assets.Asset(filename)
|
||||
|
@ -51,11 +58,17 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
|
|||
|
||||
w.Write(file)
|
||||
return 200, nil
|
||||
} else if page == "browse" {
|
||||
}
|
||||
|
||||
if page == "browse" {
|
||||
code, err = browse.Execute(w, r)
|
||||
} else if page == "edit" {
|
||||
}
|
||||
|
||||
if page == "edit" {
|
||||
code, err = edit.Execute(w, r)
|
||||
} else if page == "settings" {
|
||||
}
|
||||
|
||||
if r.URL.Path == "/admin/settings/" {
|
||||
code, err = settings.Execute(w, r)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ const (
|
|||
|
||||
var funcMap = template.FuncMap{
|
||||
"splitCapitalize": utils.SplitCapitalize,
|
||||
"isMarkdown": utils.IsMarkdownFile,
|
||||
}
|
||||
|
||||
// Page type
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
<div class="main" id="container">
|
||||
{{ template "content" . }}
|
||||
</div>
|
||||
<footer>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,61 +1,69 @@
|
|||
{{ define "content" }}
|
||||
{{ define "content" }}{{ $path := .Path }}
|
||||
<header>
|
||||
<div class="content">
|
||||
<h1>{{.Path}}</h1>
|
||||
{{ $path := .Path }}
|
||||
</div>
|
||||
<h1>{{ $path }}</h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="content">
|
||||
{{if .CanGoUp}}
|
||||
<a href=".." class="up" title="Up one level">⬑</a>
|
||||
{{else}}
|
||||
<div class="up"> </div>
|
||||
{{end}}
|
||||
<main class="browse">
|
||||
<div class="actions">
|
||||
<div class="content">
|
||||
{{if .CanGoUp}}<a href=".." class="up" title="Up one level"><i class="fa fa-arrow-left fa-lg"></i></a>{{end}}
|
||||
<div class="go-right"><input type="file" value="Upload">
|
||||
<button id="upload">Upload <i class="fa fa-cloud-upload"></i></button>
|
||||
<button class="default">New <i class="fa fa-plus"></i></button></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
{{if and (eq .Sort "name") (ne .Order "desc")}}
|
||||
<a href="?sort=name&order=desc">Name ▲</a>
|
||||
{{else if and (eq .Sort "name") (ne .Order "asc")}}
|
||||
<a href="?sort=name&order=asc">Name ▼</a>
|
||||
{{else}}
|
||||
<a href="?sort=name&order=asc">Name</a>
|
||||
{{end}}
|
||||
</th>
|
||||
<th>
|
||||
{{if and (eq .Sort "size") (ne .Order "desc")}}
|
||||
<a href="?sort=size&order=desc">Size ▲</a>
|
||||
{{else if and (eq .Sort "size") (ne .Order "asc")}}
|
||||
<a href="?sort=size&order=asc">Size ▼</a>
|
||||
{{else}}
|
||||
<a href="?sort=size&order=asc">Size</a>
|
||||
{{end}}
|
||||
</th>
|
||||
<th class="hideable">
|
||||
{{if and (eq .Sort "time") (ne .Order "desc")}}
|
||||
<a href="?sort=time&order=desc">Modified ▲</a>
|
||||
{{else if and (eq .Sort "time") (ne .Order "asc")}}
|
||||
<a href="?sort=time&order=asc">Modified ▼</a>
|
||||
{{else}}
|
||||
<a href="?sort=time&order=asc">Modified</a>
|
||||
{{end}}
|
||||
</th>
|
||||
</tr>
|
||||
{{range .Items}}
|
||||
<tr>
|
||||
<td>
|
||||
{{if .IsDir}}📂<a href="{{.URL}}">{{.Name}}</a>{{else}}
|
||||
📄<a href="/admin/edit{{ $path }}{{.URL}}">{{.Name}}</a>{{end}}
|
||||
|
||||
</td>
|
||||
<td>{{.HumanSize}}</td>
|
||||
<td class="hideable">{{.HumanModTime "01/02/2006 3:04:05 PM -0700"}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</div>
|
||||
<div class="content">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="left">
|
||||
{{if and (eq .Sort "name") (ne .Order "desc")}}
|
||||
<a href="?sort=name&order=desc">Name <i class="fa fa-arrow-up"></i></a>
|
||||
{{else if and (eq .Sort "name") (ne .Order "asc")}}
|
||||
<a href="?sort=name&order=asc">Name <i class="fa fa-arrow-down"></i></a>
|
||||
{{else}}
|
||||
<a href="?sort=name&order=asc">Name</a>
|
||||
{{end}}
|
||||
</th>
|
||||
<th class="right">
|
||||
{{if and (eq .Sort "size") (ne .Order "desc")}}
|
||||
<a href="?sort=size&order=desc">Size <i class="fa fa-arrow-up"></i></a>
|
||||
{{else if and (eq .Sort "size") (ne .Order "asc")}}
|
||||
<a href="?sort=size&order=asc">Size <i class="fa fa-arrow-down"></i></a>
|
||||
{{else}}
|
||||
<a href="?sort=size&order=asc">Size</a>
|
||||
{{end}}
|
||||
</th>
|
||||
<th class="hideable right">
|
||||
{{if and (eq .Sort "time") (ne .Order "desc")}}
|
||||
<a href="?sort=time&order=desc">Modified <i class="fa fa-arrow-up"></i></a>
|
||||
{{else if and (eq .Sort "time") (ne .Order "asc")}}
|
||||
<a href="?sort=time&order=asc">Modified <i class="fa fa-arrow-down"></i></a>
|
||||
{{else}}
|
||||
<a href="?sort=time&order=asc">Modified</a>
|
||||
{{end}}
|
||||
</th>
|
||||
</tr>
|
||||
{{range .Items}}
|
||||
<tr>
|
||||
<td>
|
||||
{{if .IsDir}}
|
||||
<i class="fa fa-folder"></i> <a href="{{.URL}}">{{.Name}}</a>
|
||||
{{else}}
|
||||
{{ if isMarkdown .URL }}
|
||||
<i class="fa fa-file"></i> <a class="file" href="/admin/edit{{ $path }}{{.URL}}">{{.Name}}</a>
|
||||
{{ else }}
|
||||
<i class="fa fa-file"></i> {{.Name}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td class="right">{{.HumanSize}}</td>
|
||||
<td class="right hideable">{{.HumanModTime "01/02/2006 3:04:05 PM -0700"}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</div>
|
||||
</main>
|
||||
{{ end }}
|
||||
|
|
|
@ -52,6 +52,10 @@ func IsInterface(sth interface{}) bool {
|
|||
return reflect.ValueOf(sth).Kind() == reflect.Interface
|
||||
}
|
||||
|
||||
func IsMarkdownFile(filename string) bool {
|
||||
return strings.HasSuffix(filename, ".markdown") || strings.HasSuffix(filename, ".md")
|
||||
}
|
||||
|
||||
func SplitCapitalize(name string) string {
|
||||
var words []string
|
||||
l := 0
|
||||
|
|
Loading…
Reference in New Issue