Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigureMessages(b *i18n.Builder)
- func GitRepoKey(r *http.Request) string
- func RunGitHookIfInvoked()
- type Builder
- func (b *Builder) AddGitRepo(repo *GitRepo) *Builder
- func (b *Builder) AddMount(m *Mount) *Builder
- func (b *Builder) DavPath() string
- func (b *Builder) FS() hackpadfs.FS
- func (b *Builder) GitHandler() http.Handler
- func (b *Builder) GitKeyPath(name, key string) string
- func (b *Builder) GitMountPaths() (paths []string)
- func (b *Builder) GitPath(name string) string
- func (b *Builder) GitRepos() []*GitRepo
- func (b *Builder) Install(p *presets.Builder) (err error)
- func (b *Builder) Model() *presets.ModelBuilder
- func (b *Builder) OnAccess(f func(r *http.Request, kind string)) *Builder
- func (b *Builder) SetFS(fs hackpadfs.FS) *Builder
- func (b *Builder) WebDavHandler() (h http.Handler)
- type GitAccess
- type GitReceive
- type GitRepo
- type Messages
- type Mount
- type MountAccess
- type RefUpdate
Constants ¶
const ( AccessWebDAV = "webdav" AccessGit = "git" )
The kinds of access OnAccess is told.
const GitKeyPattern = "{key}"
GitKeyPattern ends the Name of a repository of each key (GitRepo).
const MessagesKey i18n.ModuleKey = "rvq-admin/fs-tools"
const ZeroID = "0000000000000000000000000000000000000000"
ZeroID is the id of no commit: the Old of a ref created, the New of one deleted.
Variables ¶
var ( Messages_en_US = &Messages{ ModuleDescription: "The file system tools: browsing the files and reaching them through WebDAV.", FileSystem: "File System", WebDavAccessTemplate: "Access the files through the WEBDAV protocol at the URL: <code class='text-primary'>%s" + "</code>, using your user login and password.", WebDavProtocolTitle: "WEBDAV Protocol", WebDavProtocolSoftwareExample: "<div class='mt-2'>Some programs for WEBDAV protocol access: " + "<a href='https://winscp.net/eng/index.php' target='_blank'>WinSCP</a> (Windows); " + "Dolphin and Nautilus (Linux). </div>", } Messages_pt_BR = &Messages{ ModuleDescription: "As ferramentas do sistema de arquivos: navegar pelos arquivos e acessá-los por WebDAV.", FileSystem: "Sistema de Arquivos", WebDavAccessTemplate: "Acesse os arquivos através do protocolo WEBDAV, pela URL: <code class='text-primary'>%s" + "</code>, usando seu login e senha de usuário.", WebDavProtocolTitle: "Protocolo WEBDAV", WebDavProtocolSoftwareExample: "<div class='mt-2'>Alguns programas para acesso de Protocolo WEBDAV: " + "<a href='https://winscp.net/eng/index.php' target='_blank'>WinSCP</a> (Windows); " + "Dolphin and Nautilus (Linux). </div>", } )
var EnvDirs = osenv.Get("RVQ_FSTOOLS_DIRS", "Directories available for webdav service. Values separated by "+
"semi collon. Value format is MODE,MOUNT_POINT,LOCAL_PATH, when MODE=[r or w (default)]."+
" Example: 'r,/media,data/media;w,/writable,/x/media'", "")
var ErrNotHook = errors.New("not run as a git hook")
ErrNotHook is RunGitHook's error when the application was not run as a hook.
Functions ¶
func ConfigureMessages ¶
func GitRepoKey ¶
GitRepoKey is the key of the repository of r, of a GitRepo of each key ("drafts/{key}": the <key> of <admin>/drafts/<key>.git); "" for one of its own.
func RunGitHookIfInvoked ¶
func RunGitHookIfInvoked()
RunGitHookIfInvoked runs the application as the hook of a push, when git ran it so (a repository of GitHandler): it tells the server the push and exits — with the server's answer, its message shown to whoever pushed. Otherwise it returns at once. Call it first thing in main.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (*Builder) AddGitRepo ¶
AddGitRepo serves a git repository at <admin>/<Name>.git (GitHandler).
func (*Builder) GitHandler ¶
GitHandler serves the repositories added (AddGitRepo), each at its path (GitPath) — a mux of its own for the paths <admin>/<name>.git/…, each request by the user of its login (HTTP Basic, as the WebDAV) — or the secure key as its password: the administrator (login.SecureKeyBasicAuthMiddleware). nil when there is none.
func (*Builder) GitKeyPath ¶
GitKeyPath is the path of the repository of key of name ("drafts/{key}"): <admin>/drafts/<key>.git.
func (*Builder) GitMountPaths ¶
GitMountPaths are the paths GitHandler serves, each ending in "/": a repository's (<admin>/<name>.git/), or the folder of the repositories of each key (<admin>/<base>/) — to mount it on another mux.
func (*Builder) Model ¶
func (b *Builder) Model() *presets.ModelBuilder
func (*Builder) OnAccess ¶
OnAccess is told each request of the WebDAV (AccessWebDAV) and of the git (AccessGit), once its user is told (login.AuthOf: how): the log of its sessions.
func (*Builder) WebDavHandler ¶
type GitAccess ¶
type GitAccess int
GitAccess is what a request asks of a git repository: to read it (clone, fetch) or to write in it (push).
type GitReceive ¶
type GitReceive struct {
Request *http.Request
Dir string
// GitDir is the git directory of the repository (absolute).
GitDir string
Updates []RefUpdate
Env []string
}
GitReceive is a push being received: its request, the repository (Dir) and the refs it changes. Env is the environment of git in the hook — with it, git sees the objects of the push, not yet in the repository before it is accepted (the quarantine).
type GitRepo ¶
type GitRepo struct {
// Name is its name in the URL: "site-files" is <admin>/site-files.git.
// Ending in "/{key}", it is a repository of each key: "drafts/{key}" is
// <admin>/drafts/<key>.git, the key told by GitRepoKey.
Name string
// Dir is the repository of the request (its .git, or the directory
// holding it): one of each user, say.
Dir func(r *http.Request) (string, error)
// Allowed says whether the request may read the repository, or write in
// it; nil allows all (to whoever logged in).
Allowed func(r *http.Request, a GitAccess) bool
// Middleware wraps the repository's handler, after the login and before
// the permission: making the user's repository the first time, say.
Middleware []func(http.Handler) http.Handler
// Config is the configuration of git for it, "key=value"
// ("receive.denyCurrentBranch=updateInstead").
Config []string
// Env is more of git's environment, "KEY=value" (GIT_WORK_TREE, over a
// core.worktree that names another machine's path); the hooks' commands
// (GitReceive.Git) have its GIT_WORK_TREE too.
Env []string
// PreReceive is asked before a push is accepted: an error refuses it —
// nothing written —, its message shown to whoever pushed.
PreReceive func(ctx context.Context, rc *GitReceive) error
// PostReceive is told of a push accepted: its refs updated.
PostReceive func(ctx context.Context, rc *GitReceive)
}
GitRepo is a git repository served by HTTP (git's smart protocol), at <admin>/<Name>.git: cloned and pushed to by the users of the admin, by their login.
type Messages ¶
type Messages struct {
ModuleDescription string `i18n:"hint='Says what the module is, for whoever translates its texts.'"`
FileSystem string `i18n:"hint='Title of the file system tools page.'"`
WebDavAccessTemplate h.RawHTML `` /* 126-byte string literal not displayed */
WebDavProtocolTitle string `i18n:"label='WebDAV protocol title', hint='Title of the section about the WebDAV protocol.'"`
WebDavProtocolSoftwareExample h.RawHTML `i18n:"type=html, label='WebDAV programs', hint='Programs that access files through WebDAV, with their links (HTML).'"`
}
func GetMessages ¶
type Mount ¶
type Mount struct {
Name string
Dir func(r *http.Request) (string, error)
Allowed func(r *http.Request, a MountAccess) bool
// Hidden says whether the path, in the mount ("/.git/config"), is not
// served.
Hidden func(p string) bool
}
Mount is a directory of each request, shown in the WebDAV at /Name: the draft of the user's files, say. Dir is the directory of the request; Allowed says whether the request may do what it asks (MountAccess: the path, the destination of a COPY or a MOVE, its method in r). Hidden paths (".git") are not served.
type MountAccess ¶
MountAccess is what a request asks of a mount: its path in it ("/a.css"), where a COPY or a MOVE puts it, in the same mount ("" otherwise), and whether it changes the files (Write; r.Method says how).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package user_docs is the documentation of github.com/go-rvq/rvq/admin/packages/fs-tools for whoever uses the admin (userdocs), in en/ and pt-BR/.
|
Package user_docs is the documentation of github.com/go-rvq/rvq/admin/packages/fs-tools for whoever uses the admin (userdocs), in en/ and pt-BR/. |