This commit is contained in:
Henrique Dias 2015-09-27 19:49:58 +01:00
parent 8f94827723
commit b1f13f1a4a
4 changed files with 24 additions and 14 deletions

View File

@ -9,15 +9,17 @@ import (
// Config is the add-on configuration set on Caddyfile // Config is the add-on configuration set on Caddyfile
type Config struct { type Config struct {
Styles string Styles string
Args []string
Hugo bool Hugo bool
Args []string
Command string Command string
Content string
} }
// ParseCMS parses the configuration file // ParseCMS parses the configuration file
func ParseCMS(c *setup.Controller) (*Config, error) { func ParseCMS(c *setup.Controller) (*Config, error) {
conf := &Config{Hugo: true} conf := &Config{Hugo: true, Content: "content"}
for c.Next() { for c.Next() {
for c.NextBlock() { for c.NextBlock() {
@ -40,6 +42,13 @@ func ParseCMS(c *setup.Controller) (*Config, error) {
if err != nil { if err != nil {
return conf, err return conf, err
} }
case "content":
if !c.NextArg() {
return nil, c.ArgErr()
}
conf.Content = c.Val()
conf.Content = strings.TrimPrefix(conf.Content, "/")
conf.Content = strings.TrimSuffix(conf.Content, "/")
case "command": case "command":
if !c.NextArg() { if !c.NextArg() {
return nil, c.ArgErr() return nil, c.ArgErr()

View File

@ -7,16 +7,6 @@ import (
"github.com/hacdias/staticmin/config" "github.com/hacdias/staticmin/config"
) )
type editor struct {
Name string
Class string
IsPost bool
Mode string
Content string
FrontMatter interface{}
Config *config.Config
}
// ServeHTTP serves the editor page // ServeHTTP serves the editor page
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) { func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
filename := strings.Replace(r.URL.Path, "/admin/edit/", "", 1) filename := strings.Replace(r.URL.Path, "/admin/edit/", "", 1)

View File

@ -16,6 +16,16 @@ import (
"github.com/spf13/hugo/parser" "github.com/spf13/hugo/parser"
) )
type editor struct {
Name string
Class string
IsPost bool
Mode string
Content string
FrontMatter interface{}
Config *config.Config
}
// GET handles the GET method on editor page // GET handles the GET method on editor page
func GET(w http.ResponseWriter, r *http.Request, c *config.Config, filename string) (int, error) { func GET(w http.ResponseWriter, r *http.Request, c *config.Config, filename string) (int, error) {
// Check if the file format is supported. If not, send a "Not Acceptable" // Check if the file format is supported. If not, send a "Not Acceptable"

View File

@ -20,7 +20,8 @@
<nav> <nav>
<ul> <ul>
<li><a href="/"><i class="fa fa-home fa-lg"></i> Home</a></li> <li><a href="/"><i class="fa fa-home fa-lg"></i> Home</a></li>
<li><a data-pjax href="/admin/browse/content/"><i class="fa fa-newspaper-o"></i> Content</a></li> {{ if and (Defined . "Config")}}<li><a data-pjax href="/admin/browse/{{ .Config.Content }}/"><i class="fa fa-newspaper-o"></i> Content</a></li>{{ end }}
{{ if and (Defined . "User") }}<li><a data-pjax href="/admin/browse/{{ .Config.User }}/"><i class="fa fa-newspaper-o"></i> Content</a></li>{{ end }}
<li><a data-pjax href="/admin/browse/"><i class="fa fa-folder-o"></i> Browse</a></li> <li><a data-pjax href="/admin/browse/"><i class="fa fa-folder-o"></i> Browse</a></li>
<li><a data-pjax href="/admin/settings/"><i class="fa fa-cog"></i> Settings</a></li> <li><a data-pjax href="/admin/settings/"><i class="fa fa-cog"></i> Settings</a></li>
<li><a data-pjax id="logout" href="#logout"><i class="fa fa-sign-out"></i> Logout</a></li> <li><a data-pjax id="logout" href="#logout"><i class="fa fa-sign-out"></i> Logout</a></li>