Try to fix Hugo
Former-commit-id: 7c530392c2696d200147ea878e6da0321888a52b [formerly 24028571fda891d65ebacba15317ec1f15d348ec] [formerly 9e210d5046e518fe37991711f9412d3390f3fbfe [formerly d20079bc4e
]]
Former-commit-id: 39987e08efd3cb9af30043983f896bbea2299012 [formerly c1c6d86b39e23ccb6e9d9ffd10d88b8de7355e2a]
Former-commit-id: e45d76537a24cf5dcd978e687ddc5819ab4a4e60
This commit is contained in:
parent
b2f6f95916
commit
de9cf466c7
2
build.sh
2
build.sh
|
@ -11,5 +11,3 @@ npm run build
|
|||
|
||||
# Embed the assets using rice
|
||||
rice embed-go
|
||||
cd ./plugins
|
||||
rice embed-go
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
|
||||
// setup configures a new FileManager middleware instance.
|
||||
func setup(c *caddy.Controller) error {
|
||||
plugins.RegisterHugo()
|
||||
|
||||
configs, err := parse(c)
|
||||
if err != nil {
|
||||
return err
|
|
@ -76,8 +76,6 @@ func setupViper() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
plugins.RegisterHugo()
|
||||
|
||||
setupViper()
|
||||
flag.Parse()
|
||||
|
||||
|
|
|
@ -10,20 +10,14 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
rice "github.com/GeertJohan/go.rice"
|
||||
"github.com/hacdias/filemanager"
|
||||
"github.com/hacdias/varutils"
|
||||
"github.com/robfig/cron"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrHugoNotFound = errors.New("It seems that tou don't have 'hugo' on your PATH")
|
||||
ErrUnsupportedFileType = errors.New("The type of the provided file isn't supported for this action")
|
||||
)
|
||||
|
||||
func RegisterHugo() {
|
||||
func init() {
|
||||
filemanager.RegisterPlugin("hugo", filemanager.Plugin{
|
||||
JavaScript: rice.MustFindBox("./assets/").MustString("hugo.js"),
|
||||
JavaScript: hugoJavaScript,
|
||||
CommandEvents: []string{"before_publish", "after_publish"},
|
||||
Permissions: []filemanager.Permission{
|
||||
{
|
||||
|
@ -35,6 +29,11 @@ func RegisterHugo() {
|
|||
})
|
||||
}
|
||||
|
||||
var (
|
||||
ErrHugoNotFound = errors.New("It seems that tou don't have 'hugo' on your PATH")
|
||||
ErrUnsupportedFileType = errors.New("The type of the provided file isn't supported for this action")
|
||||
)
|
||||
|
||||
// Hugo is a hugo (https://gohugo.io) plugin.
|
||||
type Hugo struct {
|
||||
// Website root
|
||||
|
@ -49,6 +48,7 @@ type Hugo struct {
|
|||
CleanPublic bool `name:"Clean Public"`
|
||||
}
|
||||
|
||||
// Find finds the hugo executable in the path.
|
||||
func (h *Hugo) Find() error {
|
||||
var err error
|
||||
if h.Exe, err = exec.LookPath("hugo"); err != nil {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
'use strict';
|
||||
package plugins
|
||||
|
||||
const hugoJavaScript = `'use strict';
|
||||
|
||||
(function () {
|
||||
if (window.plugins === undefined || window.plugins === null) {
|
||||
|
@ -10,8 +12,8 @@
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
let request = new window.XMLHttpRequest()
|
||||
request.open('POST', `${data.store.state.baseURL}/api/hugo${url}`, true)
|
||||
request.setRequestHeader('Authorization', `Bearer ${data.store.state.jwt}`)
|
||||
request.open('POST', data.store.state.baseURL + "/api/hugo" + url, true)
|
||||
request.setRequestHeader('Authorization', "Bearer " + data.store.state.jwt)
|
||||
request.setRequestHeader('Regenerate', 'true')
|
||||
|
||||
request.onload = () => {
|
||||
|
@ -32,8 +34,8 @@
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
let request = new window.XMLHttpRequest()
|
||||
request.open('POST', `${data.store.state.baseURL}/api/hugo${url}`, true)
|
||||
request.setRequestHeader('Authorization', `Bearer ${data.store.state.jwt}`)
|
||||
request.open('POST', data.store.state.baseURL + "/api/hugo" + url, true)
|
||||
request.setRequestHeader('Authorization',"Bearer " + data.store.state.jwt)
|
||||
request.setRequestHeader('Archetype', encodeURIComponent(type))
|
||||
|
||||
request.onload = () => {
|
||||
|
@ -54,8 +56,8 @@
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
let request = new window.XMLHttpRequest()
|
||||
request.open('POST', `${data.store.state.baseURL}/api/hugo${file}`, true)
|
||||
request.setRequestHeader('Authorization', `Bearer ${data.store.state.jwt}`)
|
||||
request.open('POST', data.store.state.baseURL + "/api/hugo" + file, true)
|
||||
request.setRequestHeader('Authorization', "Bearer " + data.store.state.jwt)
|
||||
request.setRequestHeader('Schedule', date)
|
||||
|
||||
request.onload = () => {
|
||||
|
@ -222,4 +224,4 @@
|
|||
}
|
||||
]
|
||||
})
|
||||
})()
|
||||
})()`
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue