Documentation
¶
Index ¶
- Constants
- func ApplyPatch(textToPatch string, patchesText string) (patched string, err error)
- func CreateFile(path string, content string)
- func CreatePatch(oldText string, newText string) (patches string, err error)
- func DeleteFileOrFolder(path string) (bool, error)
- func ReadFile(path string) (string, error)
- func UpdateFileFromForm(file *multipart.FileHeader, targetPath string) error
- func WriteFile(path string, data []byte) (err error)
- type AutomergeSyncManager
- type DSSyncManager
- type Document
- type EditRequest
- type ErrorResult
- type FileWatcher
- type InitialContentRequest
- type MkDocsConfig
- type MkDocsConfigTheme
- type MkDocsConfigThemePalette
- type NewDocumentRequest
- type NewSectionRequest
- type RenameDocumentRequest
- type RenameResourceRequest
- type RenameSectionRequest
- type Resource
- type RestService
- func (rs *RestService) GetResourceDescription(c echo.Context) (err error)
- func (rs *RestService) RegisterWebsocketHandler(websocketConnectionManager *WebsocketConnectionManager)
- func (rs *RestService) ReturnError(c echo.Context, e error) (err error)
- func (rs *RestService) ReturnNotFound(c echo.Context, id string) (err error)
- func (rs *RestService) Start()
- type Section
- type SocketEntityBase
- type SyncManager
- type SyncRequest
- type TreeManager
- func (tm *TreeManager) CreateDocument(parentSectionId string, documentName string) (document *Document, err error)
- func (tm *TreeManager) CreateItemTree()
- func (tm *TreeManager) CreateResource(parentSectionId string, resourceName string, content string) (resource *Resource, err error)
- func (tm *TreeManager) CreateResourceFromMultipart(parentSectionId string, resourceName string, src multipart.File) (resource *Resource, err error)
- func (tm *TreeManager) CreateSection(parentSection *Section, sectionName string) (section *Section, err error)
- func (tm *TreeManager) DeleteItem(id string, itemType string) (success bool, err error)
- func (tm *TreeManager) GetDocument(id string) *Document
- func (tm *TreeManager) GetResource(id string) *Resource
- func (tm *TreeManager) GetSection(id string) *Section
- func (tm *TreeManager) RenameDocument(document *Document, name string) (doc *Document, err error)
- func (tm *TreeManager) RenameResource(resource *Resource, name string) (res *Resource, err error)
- func (tm *TreeManager) RenameSection(section *Section, name string) (sec *Section, err error)
- type WebsocketConnectionManager
- func (wcm *WebsocketConnectionManager) HandleNewConnection(c echo.Context, documentId string) (err error)
- func (wcm *WebsocketConnectionManager) IsClientConnected(documentId string) bool
- func (wcm *WebsocketConnectionManager) SetOnClientDisconnectedListener(f func(client *websocket.Conn, documentId string, remainingConnections uint))
- func (wcm *WebsocketConnectionManager) SetOnIncomingEditRequestMessageListener(f func(client *websocket.Conn, request EditRequest) error)
- func (wcm *WebsocketConnectionManager) SetOnNewClientListener(f func(client *websocket.Conn, document *Document) error)
- func (wcm *WebsocketConnectionManager) SetOnSyncRequestMessageListener(f func(client *websocket.Conn, request SyncRequest) error)
Constants ¶
const ( TypeSection = "section" TypeDocument = "document" TypeResource = "resource" )
const ( TypeInitialContent = "initial-content" TypeEditRequest = "edit-request" TypeSyncRequest = "sync-request" )
const (
ContentPath = "content"
)
const (
EndpointPathAlive = "/alive/"
)
Variables ¶
This section is empty.
Functions ¶
func ApplyPatch ¶
ApplyPatch applies a list of patches in the form of a string to a given text
func CreateFile ¶
CreateFile create a new file with the given content
func CreatePatch ¶
CreatePatch detect diff and create patch from diff
func DeleteFileOrFolder ¶
DeleteFileOrFolder delete a file from disk
func UpdateFileFromForm ¶
func UpdateFileFromForm(file *multipart.FileHeader, targetPath string) error
UpdateFileFromForm update the content of an existing file
Types ¶
type AutomergeSyncManager ¶
type AutomergeSyncManager struct {
// contains filtered or unexported fields
}
AutomergeSyncManager manages processing of SyncRequests from clients
func NewAutomergeSyncManager ¶
func NewAutomergeSyncManager( treeManager *TreeManager, ) *AutomergeSyncManager
func (*AutomergeSyncManager) IsItemBeingEditedRecursive ¶
func (sm *AutomergeSyncManager) IsItemBeingEditedRecursive(s *Section) (err error)
func (*AutomergeSyncManager) SetWebsocketConnectionManager ¶
func (sm *AutomergeSyncManager) SetWebsocketConnectionManager(manager *WebsocketConnectionManager)
type DSSyncManager ¶
type DSSyncManager struct { // ServerShadows client connection -> server shadow ServerShadows map[*websocket.Conn]string // contains filtered or unexported fields }
DSSyncManager manages processing of EditRequests from clients
func NewSyncManager ¶
func NewSyncManager( treeManager *TreeManager, ) *DSSyncManager
func (*DSSyncManager) IsItemBeingEditedRecursive ¶
func (sm *DSSyncManager) IsItemBeingEditedRecursive(s *Section) (err error)
func (*DSSyncManager) SetWebsocketConnectionManager ¶
func (sm *DSSyncManager) SetWebsocketConnectionManager(manager *WebsocketConnectionManager)
type Document ¶
type Document struct { Type string `json:"type" xml:"type" form:"type" query:"type"` ID string `json:"id" xml:"id" form:"id" query:"id"` Name string `json:"name" xml:"name" form:"name" query:"name"` Path string `json:"-" xml:"-" form:"-" query:"-"` Filesize int64 `json:"filesize" xml:"filesize" form:"filesize" query:"filesize"` ModTime time.Time `json:"modtime" xml:"modtime" form:"modtime" query:"modtime"` Content string `json:"-" xml:"-" form:"-" query:"-"` SubUrl string `json:"url" xml:"url" form:"url" query:"url"` }
type EditRequest ¶
type EditRequest struct { Type string `json:"type" xml:"type" form:"type" query:"type"` RequestId string `json:"requestId" xml:"requestId" form:"requestId" query:"requestId"` DocumentId string `json:"documentId" xml:"documentId" form:"documentId" query:"documentId"` Patches string `json:"patches" xml:"patches" form:"patches" query:"patches"` ShadowChecksum string `json:"shadowChecksum" xml:"shadowChecksum" form:"shadowChecksum" query:"shadowChecksum"` }
type ErrorResult ¶
type FileWatcher ¶
type FileWatcher struct {
// contains filtered or unexported fields
}
func NewFileWatcher ¶
func NewFileWatcher(path string, action func(s string)) *FileWatcher
func (*FileWatcher) WatchDirRecursive ¶
func (fw *FileWatcher) WatchDirRecursive()
watches all files and folders in the given path recursively
type InitialContentRequest ¶
type InitialContentRequest struct { Type string `json:"type" xml:"type" form:"type" query:"type"` RequestId string `json:"requestId" xml:"requestId" form:"requestId" query:"requestId"` DocumentId string `json:"documentId" xml:"documentId" form:"documentId" query:"documentId"` Content string `json:"content" xml:"content" form:"content" query:"content"` }
type MkDocsConfig ¶
type MkDocsConfig struct { Copyright string `yaml:"copyright"` EditUri string `yaml:"edit_uri"` Extra map[string]interface{} `yaml:",inline"` ExtraCss []string `yaml:"extra_css"` MarkdownExtensions []interface{} `yaml:"markdown_extensions"` RepoName string `yaml:"repo_name"` RepoUrl string `yaml:"repo_url"` SiteAuthor string `yaml:"site_author"` SiteDescription string `yaml:"site_description"` SiteDir string `yaml:"site_dir"` SiteName string `yaml:"site_name"` SiteUrl string `yaml:"site_url"` Theme MkDocsConfigTheme `yaml:"theme"` }
type MkDocsConfigTheme ¶
type MkDocsConfigTheme struct { Name string `yaml:"name"` Palette MkDocsConfigThemePalette `yaml:"palette"` CustomDir string `yaml:"custom_dir"` }
type NewDocumentRequest ¶
type NewSectionRequest ¶
type RenameDocumentRequest ¶
type RenameDocumentRequest struct {
Name string `json:"name" xml:"name" form:"name" query:"name" validate:"required"`
}
type RenameResourceRequest ¶
type RenameResourceRequest struct {
Name string `json:"name" xml:"name" form:"name" query:"name" validate:"required"`
}
type RenameSectionRequest ¶
type RenameSectionRequest struct {
Name string `json:"name" xml:"name" form:"name" query:"name" validate:"required"`
}
type Resource ¶
type Resource struct { Type string `json:"type" xml:"type" form:"type" query:"type"` ID string `json:"id" xml:"id" form:"id" query:"id"` Name string `json:"name" xml:"name" form:"name" query:"name"` Path string `json:"-" xml:"-" form:"-" query:"-"` Filesize int64 `json:"filesize" xml:"filesize" form:"filesize" query:"filesize"` ModTime time.Time `json:"modtime" xml:"modtime" form:"modtime" query:"modtime"` }
type RestService ¶
type RestService struct {
// contains filtered or unexported fields
}
func NewRestService ¶
func NewRestService( treeManager *TreeManager, syncManager SyncManager, ) *RestService
func (*RestService) GetResourceDescription ¶
func (rs *RestService) GetResourceDescription(c echo.Context) (err error)
GetResourceDescription returns the description of a single resource with the given id (if found)
func (*RestService) RegisterWebsocketHandler ¶
func (rs *RestService) RegisterWebsocketHandler(websocketConnectionManager *WebsocketConnectionManager)
func (*RestService) ReturnError ¶
func (rs *RestService) ReturnError(c echo.Context, e error) (err error)
return the error message of an error
func (*RestService) ReturnNotFound ¶
func (rs *RestService) ReturnNotFound(c echo.Context, id string) (err error)
return a "not found" message
type Section ¶
type Section struct { Type string `json:"type" xml:"type" form:"type" query:"type"` ID string `json:"id" xml:"id" form:"id" query:"id"` Name string `json:"name" xml:"name" form:"name" query:"name"` Path string `json:"-" xml:"-" form:"-" query:"-"` Subsections *[]*Section `json:"subsections" xml:"subsections" form:"subsections" query:"subsections"` Documents *[]*Document `json:"documents" xml:"documents" form:"documents" query:"documents"` Resources *[]*Resource `json:"resources" xml:"resources" form:"resources" query:"resources"` }
type SocketEntityBase ¶
type SyncManager ¶
type SyncRequest ¶
type SyncRequest struct { Type string `json:"type" xml:"type" form:"type" query:"type"` RequestId string `json:"requestId" xml:"requestId" form:"requestId" query:"requestId"` DocumentId string `json:"documentId" xml:"documentId" form:"documentId" query:"documentId"` // *automerge.Doc as base64 encoded string DocumentState string `json:"documentState" xml:"documentState" form:"documentState" query:"documentState"` // *automerge.SyncMessage as base64 encoded string SyncMessage string `json:"syncMessage" xml:"syncMessage" form:"syncMessage" query:"syncMessage"` }
func (SyncRequest) GetSyncMessageBytes ¶
func (s SyncRequest) GetSyncMessageBytes() ([]byte, error)
type TreeManager ¶
type TreeManager struct { // DocumentTree an in memory representation of the mkdocs file structure DocumentTree Section // contains filtered or unexported fields }
func NewTreeManager ¶
func NewTreeManager() *TreeManager
func (*TreeManager) CreateDocument ¶
func (tm *TreeManager) CreateDocument(parentSectionId string, documentName string) (document *Document, err error)
CreateDocument creates a new document as a child of the given parent section id and the given name
func (*TreeManager) CreateItemTree ¶
func (tm *TreeManager) CreateItemTree()
CreateItemTree traverses the mkdocs directory and puts all files into a tree representation
func (*TreeManager) CreateResource ¶
func (*TreeManager) CreateResourceFromMultipart ¶
func (*TreeManager) CreateSection ¶
func (tm *TreeManager) CreateSection(parentSection *Section, sectionName string) (section *Section, err error)
CreateSection creates a new section with the given name as a child of the given parent section
func (*TreeManager) DeleteItem ¶
func (tm *TreeManager) DeleteItem(id string, itemType string) (success bool, err error)
DeleteItem deletes a file/folder with the given ID and type from disk
func (*TreeManager) GetDocument ¶
func (tm *TreeManager) GetDocument(id string) *Document
GetDocument finds a document with the given id in the document tree
func (*TreeManager) GetResource ¶
func (tm *TreeManager) GetResource(id string) *Resource
GetResource finds a resource with the given id in the document tree
func (*TreeManager) GetSection ¶
func (tm *TreeManager) GetSection(id string) *Section
GetSection finds a document with the given id in the document tree
func (*TreeManager) RenameDocument ¶
func (tm *TreeManager) RenameDocument(document *Document, name string) (doc *Document, err error)
func (*TreeManager) RenameResource ¶
func (tm *TreeManager) RenameResource(resource *Resource, name string) (res *Resource, err error)
func (*TreeManager) RenameSection ¶
func (tm *TreeManager) RenameSection(section *Section, name string) (sec *Section, err error)
type WebsocketConnectionManager ¶
type WebsocketConnectionManager struct {
// contains filtered or unexported fields
}
func NewWebsocketConnectionManager ¶
func NewWebsocketConnectionManager( treeManager *TreeManager, ) *WebsocketConnectionManager
func (*WebsocketConnectionManager) HandleNewConnection ¶
func (wcm *WebsocketConnectionManager) HandleNewConnection(c echo.Context, documentId string) (err error)
handle new websocket connections
func (*WebsocketConnectionManager) IsClientConnected ¶
func (wcm *WebsocketConnectionManager) IsClientConnected(documentId string) bool
func (*WebsocketConnectionManager) SetOnClientDisconnectedListener ¶
func (wcm *WebsocketConnectionManager) SetOnClientDisconnectedListener(f func(client *websocket.Conn, documentId string, remainingConnections uint))
func (*WebsocketConnectionManager) SetOnIncomingEditRequestMessageListener ¶
func (wcm *WebsocketConnectionManager) SetOnIncomingEditRequestMessageListener(f func(client *websocket.Conn, request EditRequest) error)
func (*WebsocketConnectionManager) SetOnNewClientListener ¶
func (wcm *WebsocketConnectionManager) SetOnNewClientListener(f func(client *websocket.Conn, document *Document) error)
func (*WebsocketConnectionManager) SetOnSyncRequestMessageListener ¶
func (wcm *WebsocketConnectionManager) SetOnSyncRequestMessageListener(f func(client *websocket.Conn, request SyncRequest) error)