mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
updates
This commit is contained in:
parent
b81ec9ecdf
commit
886f396d8f
@ -0,0 +1,7 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
//alert("hugo is working");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
@ -1,4 +1,7 @@
|
|||||||
{{ define "content" }}
|
{{ define "content" }}
|
||||||
|
<link rel="stylesheet" href="{{ .BaseURL }}/_hugointernal/css/styles.css">
|
||||||
|
<script src="{{ .BaseURL }}/_hugointernal/js/application.js"></script>
|
||||||
|
|
||||||
<div class="editor container {{ .Class }}">
|
<div class="editor container {{ .Class }}">
|
||||||
{{ if eq .Class "complete" }}
|
{{ if eq .Class "complete" }}
|
||||||
<h1><textarea id="site-title">{{ .Name }}</textarea></h1>
|
<h1><textarea id="site-title">{{ .Name }}</textarea></h1>
|
||||||
@ -11,7 +14,7 @@
|
|||||||
|
|
||||||
{{ if eq .Class "frontmatter-only" }}
|
{{ if eq .Class "frontmatter-only" }}
|
||||||
<div class="frontmatter blocks">
|
<div class="frontmatter blocks">
|
||||||
{{ template "frontmatter" .FrontMatter }}
|
{{ template "options" .FrontMatter }}
|
||||||
<p class="actions">
|
<p class="actions">
|
||||||
<button class="add">Add field</button>
|
<button class="add">Add field</button>
|
||||||
</p>
|
</p>
|
||||||
@ -24,7 +27,7 @@
|
|||||||
{{ else }}
|
{{ else }}
|
||||||
<div class="frontmatter">
|
<div class="frontmatter">
|
||||||
<div class="blocks">
|
<div class="blocks">
|
||||||
{{ template "frontmatter" .FrontMatter }}
|
{{ template "options" .FrontMatter}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="actions">
|
<p class="actions">
|
||||||
|
@ -1,23 +1,19 @@
|
|||||||
{{ define "frontmatter" }}
|
{{ define "options" }}
|
||||||
{{ range $key, $value := . }}
|
{{ range $key, $value := . }}
|
||||||
|
|
||||||
{{ if or (eq $value.Type "object") (eq $value.Type "array") }}
|
{{ if or (eq $value.Type "object") (eq $value.Type "array") }}
|
||||||
<fieldset id="{{ $value.Name }}" data-type="{{ $value.Type }}">
|
<fieldset id="{{ $value.Name }}" data-type="{{ $value.Type }}">
|
||||||
<h3>{{ SplitCapitalize $value.Title }}</h3>
|
<h3>{{ SplitCapitalize $value.Title }}</h3>
|
||||||
<span class="actions">
|
|
||||||
<button class="add">+</button>
|
<button class="add">+</button>
|
||||||
<button class="delete">−</button>
|
<button class="delete" data-delete="{{ $value.Name }}">−</button>
|
||||||
</span>
|
{{ template "options" $value.Content }}
|
||||||
{{ template "frontmatter" $value.Content }}
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
|
||||||
{{ if not (eq $value.Parent.Type "array") }}
|
{{ if not (eq $value.Parent.Type "array") }}
|
||||||
<div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}">
|
<div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}">
|
||||||
<label for="{{ $value.Name }}">{{ SplitCapitalize $value.Title }}</label>
|
<label for="{{ $value.Name }}">{{ SplitCapitalize $value.Title }}</label>
|
||||||
<span class="actions">
|
<button class="delete" data-delete="block-{{ $value.Name }}">−</button>
|
||||||
<button class="delete">−</button>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
@ -36,7 +32,7 @@
|
|||||||
{{ if not (eq $value.Parent.Type "array") }}</div>{{ end }}
|
{{ if not (eq $value.Parent.Type "array") }}</div>{{ end }}
|
||||||
|
|
||||||
{{ if eq $value.Parent.Type "array" }}
|
{{ if eq $value.Parent.Type "array" }}
|
||||||
<span class="actions"><button class="delete">−</button></span></div>
|
<button class="delete" data-delete="{{ $value.Name }}">−</button></div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
2
get.go
2
get.go
@ -19,6 +19,7 @@ type editor struct {
|
|||||||
IsPost bool
|
IsPost bool
|
||||||
Mode string
|
Mode string
|
||||||
Content string
|
Content string
|
||||||
|
BaseURL string
|
||||||
FrontMatter interface{}
|
FrontMatter interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ func (h Hugo) GET(w http.ResponseWriter, r *http.Request, filename string) (int,
|
|||||||
data.Mode = strings.TrimPrefix(filepath.Ext(filename), ".")
|
data.Mode = strings.TrimPrefix(filepath.Ext(filename), ".")
|
||||||
data.Name = strings.Replace(filename, h.Config.Root, "", 1)
|
data.Name = strings.Replace(filename, h.Config.Root, "", 1)
|
||||||
data.IsPost = false
|
data.IsPost = false
|
||||||
|
data.BaseURL = h.Config.BaseURL
|
||||||
data.Mode = sanitizeMode(data.Mode)
|
data.Mode = sanitizeMode(data.Mode)
|
||||||
|
|
||||||
var parserPage parser.Page
|
var parserPage parser.Page
|
||||||
|
29
hugo.go
29
hugo.go
@ -7,6 +7,7 @@
|
|||||||
package hugo
|
package hugo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -16,6 +17,9 @@ import (
|
|||||||
"github.com/mholt/caddy/caddyhttp/httpserver"
|
"github.com/mholt/caddy/caddyhttp/httpserver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AssetsURL is the base url of the assets
|
||||||
|
const AssetsURL = "/_hugointernal"
|
||||||
|
|
||||||
// Hugo contais the next middleware to be run and the configuration
|
// Hugo contais the next middleware to be run and the configuration
|
||||||
// of the current one.
|
// of the current one.
|
||||||
type Hugo struct {
|
type Hugo struct {
|
||||||
@ -29,6 +33,11 @@ type Hugo struct {
|
|||||||
func (h Hugo) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
|
func (h Hugo) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Check if the current request if for this plugin
|
// Check if the current request if for this plugin
|
||||||
if httpserver.Path(r.URL.Path).Matches(h.Config.BaseURL) {
|
if httpserver.Path(r.URL.Path).Matches(h.Config.BaseURL) {
|
||||||
|
// Check if we are asking for the assets
|
||||||
|
if httpserver.Path(r.URL.Path).Matches(h.Config.BaseURL + AssetsURL) {
|
||||||
|
return h.ServeAssets(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
// If the url matches exactly with /{admin}/settings/, redirect
|
// If the url matches exactly with /{admin}/settings/, redirect
|
||||||
// to the page of the configuration file
|
// to the page of the configuration file
|
||||||
if r.URL.Path == h.Config.BaseURL+"/settings/" {
|
if r.URL.Path == h.Config.BaseURL+"/settings/" {
|
||||||
@ -114,3 +123,23 @@ func (h Hugo) ShouldHandle(r *http.Request) bool {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServeAssets provides the needed assets for the front-end
|
||||||
|
func (h Hugo) ServeAssets(w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
|
// gets the filename to be used with Assets function
|
||||||
|
filename := strings.Replace(r.URL.Path, h.Config.BaseURL+AssetsURL, "public", 1)
|
||||||
|
file, err := Asset(filename)
|
||||||
|
if err != nil {
|
||||||
|
return http.StatusNotFound, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the file extension and its mimetype
|
||||||
|
extension := filepath.Ext(filename)
|
||||||
|
mediatype := mime.TypeByExtension(extension)
|
||||||
|
|
||||||
|
// Write the header with the Content-Type and write the file
|
||||||
|
// content to the buffer
|
||||||
|
w.Header().Set("Content-Type", mediatype)
|
||||||
|
w.Write(file)
|
||||||
|
return 200, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user