Hugo improvements and such
parent
5479236532
commit
87fc8db54f
|
@ -26,7 +26,6 @@ type hugo struct {
|
||||||
// Indicates if we should clean public before a new publish.
|
// Indicates if we should clean public before a new publish.
|
||||||
CleanPublic bool `description:"Indicates if the public folder should be cleaned before publishing the website."`
|
CleanPublic bool `description:"Indicates if the public folder should be cleaned before publishing the website."`
|
||||||
|
|
||||||
// TODO: AllowPublish
|
|
||||||
// TODO: admin interface to cgange options
|
// TODO: admin interface to cgange options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +66,10 @@ func (h hugo) BeforeAPI(c *filemanager.RequestContext, w http.ResponseWriter, r
|
||||||
|
|
||||||
// If we are creating a file built from an archetype.
|
// If we are creating a file built from an archetype.
|
||||||
if r.Header.Get("Archetype") != "" {
|
if r.Header.Get("Archetype") != "" {
|
||||||
|
if !c.User.AllowNew {
|
||||||
|
return http.StatusForbidden, nil
|
||||||
|
}
|
||||||
|
|
||||||
filename := filepath.Join(string(c.User.FileSystem), r.URL.Path)
|
filename := filepath.Join(string(c.User.FileSystem), r.URL.Path)
|
||||||
filename = strings.TrimPrefix(filename, "/")
|
filename = strings.TrimPrefix(filename, "/")
|
||||||
archetype := r.Header.Get("archetype")
|
archetype := r.Header.Get("archetype")
|
||||||
|
@ -92,6 +95,10 @@ func (h hugo) BeforeAPI(c *filemanager.RequestContext, w http.ResponseWriter, r
|
||||||
|
|
||||||
// If we are trying to regenerate the website.
|
// If we are trying to regenerate the website.
|
||||||
if r.Header.Get("Regenerate") == "true" {
|
if r.Header.Get("Regenerate") == "true" {
|
||||||
|
if !c.User.Permissions["allowPublish"] {
|
||||||
|
return http.StatusForbidden, nil
|
||||||
|
}
|
||||||
|
|
||||||
filename := filepath.Join(string(c.User.FileSystem), r.URL.Path)
|
filename := filepath.Join(string(c.User.FileSystem), r.URL.Path)
|
||||||
filename = strings.TrimPrefix(filename, "/")
|
filename = strings.TrimPrefix(filename, "/")
|
||||||
|
|
||||||
|
@ -120,6 +127,10 @@ func (h hugo) BeforeAPI(c *filemanager.RequestContext, w http.ResponseWriter, r
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Header.Get("Schedule") != "" {
|
if r.Header.Get("Schedule") != "" {
|
||||||
|
if !c.User.Permissions["allowPublish"] {
|
||||||
|
return http.StatusForbidden, nil
|
||||||
|
}
|
||||||
|
|
||||||
return h.schedule(c, w, r)
|
return h.schedule(c, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,8 @@
|
||||||
!data.store.state.loading &&
|
!data.store.state.loading &&
|
||||||
data.store.state.req.metadata !== undefined &&
|
data.store.state.req.metadata !== undefined &&
|
||||||
data.store.state.req.metadata !== null &&
|
data.store.state.req.metadata !== null &&
|
||||||
data.store.state.user.allowEdit)
|
data.store.state.user.allowEdit &
|
||||||
// TODO: add allowPublish
|
data.store.state.user.permissions.allowPublish)
|
||||||
},
|
},
|
||||||
click: function (event, data, route) {
|
click: function (event, data, route) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -113,7 +113,8 @@
|
||||||
return (data.store.state.req.kind === 'editor' &&
|
return (data.store.state.req.kind === 'editor' &&
|
||||||
!data.store.state.loading &&
|
!data.store.state.loading &&
|
||||||
data.store.state.req.metadata !== undefined &&
|
data.store.state.req.metadata !== undefined &&
|
||||||
data.store.state.req.metadata !== null)
|
data.store.state.req.metadata !== null &&
|
||||||
|
data.store.state.user.permissions.allowPublish)
|
||||||
},
|
},
|
||||||
click: function (event, data, route) {
|
click: function (event, data, route) {
|
||||||
document.getElementById('save-button').click()
|
document.getElementById('save-button').click()
|
||||||
|
|
|
@ -296,20 +296,17 @@ func (m *FileManager) RegisterPermission(name string, value bool) error {
|
||||||
m.DefaultUser.Permissions[name] = value
|
m.DefaultUser.Permissions[name] = value
|
||||||
|
|
||||||
for _, u := range m.Users {
|
for _, u := range m.Users {
|
||||||
if u.Permissions == nil {
|
|
||||||
u.Permissions = map[string]bool{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bypass the user if it is already defined.
|
// Bypass the user if it is already defined.
|
||||||
if _, ok := u.Permissions[name]; ok {
|
if _, ok := u.Permissions[name]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if u.Permissions == nil {
|
||||||
|
u.Permissions = m.DefaultUser.Permissions
|
||||||
|
}
|
||||||
|
|
||||||
if u.Admin {
|
if u.Admin {
|
||||||
u.Permissions[name] = true
|
u.Permissions[name] = true
|
||||||
} else {
|
|
||||||
u.Permissions[name] = value
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err := m.db.Save(u)
|
err := m.db.Save(u)
|
||||||
|
|
Loading…
Reference in New Issue