menus

package
v0.0.0-...-307aa89 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2017 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = gocaveman.ErrNotFound

Functions

func NewAdminMenusViewFS

func NewAdminMenusViewFS(prefix string) http.FileSystem

func NewDefaultAdminMenusViewFS

func NewDefaultAdminMenusViewFS() http.FileSystem

Types

type FileMenus

type FileMenus struct {
	Fs  afero.Fs
	Dir string
}

func NewFileMenus

func NewFileMenus(fs afero.Fs, dir string) *FileMenus

func (*FileMenus) DeleteMenu

func (f *FileMenus) DeleteMenu(id string) error

func (*FileMenus) MenuIDs

func (f *FileMenus) MenuIDs() ([]string, error)

func (*FileMenus) ReadMenu

func (f *FileMenus) ReadMenu(id string) (*MenuItem, error)

func (*FileMenus) WriteMenu

func (f *FileMenus) WriteMenu(id string, menu *MenuItem) error
type MenuAPIHandler struct {
	Menus  MenusReaderWriter
	Prefix string
}

func NewMenuAPIHandler

func NewMenuAPIHandler(menus MenusReaderWriter) *MenuAPIHandler
func (h *MenuAPIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type MenuItem struct {
	Text     string      `json:"text"`
	Link     string      `json:"link"`
	Children []*MenuItem `json:"children"`
	Parent   *MenuItem   `json:"-"`
	// TODO: should we also have Prev and Next???
	// Data interface{} // FIXME: this probably should be map[string]interface{} to encourage best practices; i was thinking this could be a struct before but i think that's unlikely because it won't survive being marshalled both ways in JSON so we just pick something simple and workable, even if less flexible
	Data map[string]interface{} `json:"data"`
}

func NewMenuItem

func NewMenuItem(link string, text string) *MenuItem
type MenusReader interface {
	// FIXME: add context?????
	MenuIDs() ([]string, error)
	ReadMenu(id string) (*MenuItem, error)
}
type MenusReaderWriter interface {
	MenusReader
	MenusWriter
}
type MenusWriter interface {
	// NewMenu(id string) (*Menu, error)
	DeleteMenu(id string) error
	WriteMenu(id string, menu *MenuItem) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL