Documentation ¶
Index ¶
- Constants
- Variables
- func EmptyHandler(w http.ResponseWriter, r *http.Request)
- func FileResponse(w http.ResponseWriter, r *http.Request, filePath string)
- func JSONErrorResponse(w http.ResponseWriter, err error)
- func JSONResponse(w http.ResponseWriter, d interface{}, c int)
- func NewStaticHandler(staticPath string) http.Handler
- func NewSuffixHandler(path, suffix string) func(string) http.Handler
- func UserFromContext(ctx context.Context) string
- type APIHandler
- func (api *APIHandler) AddGraphHandler(graphPath string) error
- func (api *APIHandler) AddMisatoHandler(misatoPath string) error
- func (api *APIHandler) AddUploadHandler(imagePath, videoPath string) error
- func (api *APIHandler) BuildComplete(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) BuildGraph(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) GetFolderArray(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) GetMDFile(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) GetMDMeta(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) GetMetasArray(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) GetNavArray(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) GetTagsArray(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) ImageUpload(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) Images(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) Init()
- func (api *APIHandler) MarkdownUpload(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) Milestone(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) Misato(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) MisatoSearch(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) Ok(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) OpenMDFile(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) SearchMDFiles(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) VideoUpload(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) Videos(w http.ResponseWriter, r *http.Request)
- func (api *APIHandler) Watcher(w http.ResponseWriter, r *http.Request)
- type AntNode
- type ContextKey
- type Info
- type Mapping
- type Msg
- type Node
- type SearchMatch
- type Server
- type SuffixFS
- type TreeStructure
- type UpdateMessage
Constants ¶
const (
CERTPREFIX = "LeL-server"
)
Variables ¶
var ( ErrNotCleanPath = errors.New("Path is not clean") ErrHasNoMDExtension = errors.New("Wrong Extension - only MD files are accecpted") ErrFolderCreation = errors.New("Error when creating a new folder !") ErrTagParsing = errors.New("Tags could not be parsed !") ErrNoReference = errors.New("No Reference found ") ErrNoContent = errors.New("No Content found") )
Error codes returned by failures to parse an expression.
var ( ErrNoDirectoryListing = errors.New("No Directory Listing ") ErrOnlyValidExtension = errors.New("Only request allowed extensions") )
var ( Routes = &Mapping{ Config: map[string]string{ "Get": "/notes/get", "Meta": "/notes/meta", "Open": "/notes/open", "Ok": "/core/ok", "Navigation": "/core/nav", "Folder": "/core/folder", "Tags": "/core/tags", "Metas": "/core/metas", "Milestone": "/core/milestones", "Videos": "/core/videos", "Images": "/core/images", "Search": "/core/search", "Watcher": "/core/channel", "GraphView": "/feat/graph/get", "ImageUpload": "/feat/upload/image", "VideoUpload": "/feat/upload/video", "MarkdownUpload": "/feat/upload/md", "Misato": "/feat/misato", "MisatoSearch": "/feat/misato/search", }, } )
Functions ¶
func EmptyHandler ¶
func EmptyHandler(w http.ResponseWriter, r *http.Request)
func FileResponse ¶
func FileResponse(w http.ResponseWriter, r *http.Request, filePath string)
MDResponse handles the ServeFile most likely be used for md files
func JSONErrorResponse ¶
func JSONErrorResponse(w http.ResponseWriter, err error)
JSONErrorResponse returns a static response Object
func JSONResponse ¶
func JSONResponse(w http.ResponseWriter, d interface{}, c int)
copied from https://github.com/gophish/gophish/blob/master/controllers/api/response.go JSONResponse attempts to set the status code, c, and marshal the given interface, d, into a response that is written to the given ResponseWriter.
func NewStaticHandler ¶
NewStaticHandler returns a new Static Fileserver
func NewSuffixHandler ¶
NewImageHandler creates a new http.Handler for serving pictures
func UserFromContext ¶
Types ¶
type APIHandler ¶
type APIHandler struct { Notes string ExecutablePath string // contains filtered or unexported fields }
APIHandler contains all handler funcs for api calls
func NewAPIHandler ¶
func NewAPIHandler(notes, executablePath string, auth map[string]string, mode string) (*APIHandler, error)
NewAPIHandler creates a new router for the api calls also performs basic validation and creates the environment if necessary
func (*APIHandler) AddGraphHandler ¶
func (api *APIHandler) AddGraphHandler(graphPath string) error
AddGraphHandler adds a handler for graph interaction
func (*APIHandler) AddMisatoHandler ¶
func (api *APIHandler) AddMisatoHandler(misatoPath string) error
AddMisatoHandler returns a new misatohandler logger
func (*APIHandler) AddUploadHandler ¶
func (api *APIHandler) AddUploadHandler(imagePath, videoPath string) error
AddImageHandler returns an image filehandler
func (*APIHandler) BuildComplete ¶
func (api *APIHandler) BuildComplete(w http.ResponseWriter, r *http.Request)
BuildComplete builds the complete graph TODO Optimization updating the graph is currently not implemented
func (*APIHandler) BuildGraph ¶
func (api *APIHandler) BuildGraph(w http.ResponseWriter, r *http.Request)
BuildGraph builds the current state of the graph currently not supported
func (*APIHandler) GetFolderArray ¶
func (api *APIHandler) GetFolderArray(w http.ResponseWriter, r *http.Request)
GetFolderArray returns an json array containing a plain structures
func (*APIHandler) GetMDFile ¶
func (api *APIHandler) GetMDFile(w http.ResponseWriter, r *http.Request)
GetFile returns the md file in the notedir
func (*APIHandler) GetMDMeta ¶
func (api *APIHandler) GetMDMeta(w http.ResponseWriter, r *http.Request)
GetMDMeta returns the Metadata from the requested path
func (*APIHandler) GetMetasArray ¶
func (api *APIHandler) GetMetasArray(w http.ResponseWriter, r *http.Request)
GetMetasArray returns all meta information from all the files
func (*APIHandler) GetNavArray ¶
func (api *APIHandler) GetNavArray(w http.ResponseWriter, r *http.Request)
GetNavArray returns an json object containing the file structure of notes
func (*APIHandler) GetTagsArray ¶
func (api *APIHandler) GetTagsArray(w http.ResponseWriter, r *http.Request)
GetTagsArray returns all tags as an array :)
func (*APIHandler) ImageUpload ¶
func (api *APIHandler) ImageUpload(w http.ResponseWriter, r *http.Request)
ImageUpload handles image uploaded as json PUT {}
func (*APIHandler) Images ¶
func (api *APIHandler) Images(w http.ResponseWriter, r *http.Request)
Images returns a list of images
func (*APIHandler) Init ¶
func (api *APIHandler) Init()
Init initialize the APIHandler through routes registration
func (*APIHandler) MarkdownUpload ¶
func (api *APIHandler) MarkdownUpload(w http.ResponseWriter, r *http.Request)
MarkdownUpload handels upload TODO raceconditions !
func (*APIHandler) Milestone ¶
func (api *APIHandler) Milestone(w http.ResponseWriter, r *http.Request)
GetMilestone returns all the milestones or create a new one GET structure=fast POST {}
func (*APIHandler) Misato ¶
func (api *APIHandler) Misato(w http.ResponseWriter, r *http.Request)
Misato searches all misatoFiles for a specific timeframe
func (*APIHandler) MisatoSearch ¶
func (api *APIHandler) MisatoSearch(w http.ResponseWriter, r *http.Request)
MisatoSearch searches all misatoFiles for a specific searchword
func (*APIHandler) Ok ¶
func (api *APIHandler) Ok(w http.ResponseWriter, r *http.Request)
Ok returns the ok alive message this can be used to test the connection and especially the API token
func (*APIHandler) OpenMDFile ¶
func (api *APIHandler) OpenMDFile(w http.ResponseWriter, r *http.Request)
EditFile opens the File in an editor and create
func (*APIHandler) SearchMDFiles ¶
func (api *APIHandler) SearchMDFiles(w http.ResponseWriter, r *http.Request)
SearchMDFiles searches all mdfiles based on the search String. Returns all match names
func (*APIHandler) ServeHTTP ¶
func (api *APIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP starts serving the API
func (*APIHandler) VideoUpload ¶
func (api *APIHandler) VideoUpload(w http.ResponseWriter, r *http.Request)
VideoUpload handles video uploaded as multi form
func (*APIHandler) Videos ¶
func (api *APIHandler) Videos(w http.ResponseWriter, r *http.Request)
Videos return a list of video names based on requested criteria GET structue=fast,start=1572445498,stop=1572445498
func (*APIHandler) Watcher ¶
func (api *APIHandler) Watcher(w http.ResponseWriter, r *http.Request)
Websocket to start changing handler
type AntNode ¶
type AntNode struct { Title string `json:"title"` Value string `json:"value"` Key string `json:"key"` Children []*AntNode `json:"children,omitempty"` // Other map[string]interface{} `json:"other,omitempty"` }
AntNode is a node representation for the ant framwork https://ant.design/components/tree/
type ContextKey ¶
type ContextKey string
var ( AuthTokenPrefix = "Token " ContextUserKey ContextKey = "user" )
type Node ¶
type Node struct { Content []string `json:"content"` Children map[string]*Node `json:"nodes"` TagType string `json:"type"` // additionalData Context map[string]interface{} `json:"ctx,omitempty"` }
Tag defines a Tag
func (*Node) ConvertToAnt ¶
ConvertToAnt converts the node to the format, where trees can be built
type SearchMatch ¶
type SearchMatch struct { Origin string `json:"path"` Match string `json:"match"` Key string `json:"key"` Context *misato.CLILog `json:"ctx,omitempty"` }
SearchMatch contains all information based on path, match and context ..
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the webserver in order to display all entries
func NewServer ¶
func NewServer(sConf *config.ServerConfig, pConf *config.ProjectConfig) (s *Server, err error)
NewServer creates a new Server based on the configs
func (*Server) Base ¶
func (s *Server) Base(w http.ResponseWriter, r *http.Request)
Base returns the app template for vue js
type TreeStructure ¶
type TreeStructure struct {
Root *Node
}
TagStructure contains all tags in a treeStructure
func NewTreeStructure ¶
func NewTreeStructure() *TreeStructure
NewTagStructure returns a new tagstructure starting with the root node
func (*TreeStructure) AddItem ¶
func (s *TreeStructure) AddItem(origin, item string, additional map[string]interface{})
func (*TreeStructure) AddItems ¶
func (s *TreeStructure) AddItems(origin string, items ...string)
AddItems adds items to the structure, items will be seperated based on content
func (*TreeStructure) BuildAntGraph ¶
func (s *TreeStructure) BuildAntGraph() []*AntNode
BuildAntGraph builds a node
type UpdateMessage ¶
UpdateMessage contains all data, which is sent to the client
func (*UpdateMessage) ToJson ¶
func (um *UpdateMessage) ToJson() ([]byte, error)
ToJson returns the bytes representation of the UpdateMessage