mdview

package
v1.20240717.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedSocketType = errors.New("unsupported socket type.")

Functions

func TmplFileType

func TmplFileType(name string) string

Types

type DummyGetter

type DummyGetter struct{}

func (DummyGetter) Get

func (DummyGetter) Get(string) string

type DummySetter

type DummySetter struct{}

func (DummySetter) Set

func (DummySetter) Set(string, string)

type DumpWrite

type DumpWrite struct {
	// contains filtered or unexported fields
}

func NewDumpWrite

func NewDumpWrite(out io.Writer, eout io.Writer) *DumpWrite

func (*DumpWrite) Error

func (w *DumpWrite) Error(msg string, code int)

func (*DumpWrite) Header

func (w *DumpWrite) Header() Setter

func (*DumpWrite) ServeFile

func (hw *DumpWrite) ServeFile(fsys fs.FS, file string)

func (*DumpWrite) Write

func (w *DumpWrite) Write(buf []byte) (int, error)

func (*DumpWrite) WriteHeader

func (w *DumpWrite) WriteHeader(code int)

type Getter

type Getter interface {
	Get(string) string
}

type HttpWrite

type HttpWrite struct {
	// contains filtered or unexported fields
}

func NewHttpWriter

func NewHttpWriter(w http.ResponseWriter, r *http.Request) *HttpWrite

func (*HttpWrite) Error

func (hw *HttpWrite) Error(msg string, code int)

func (*HttpWrite) Header

func (hw *HttpWrite) Header() Setter

func (*HttpWrite) ServeFile

func (hw *HttpWrite) ServeFile(fsys fs.FS, file string)

func (*HttpWrite) Write

func (hw *HttpWrite) Write(buf []byte) (int, error)

func (*HttpWrite) WriteHeader

func (hw *HttpWrite) WriteHeader(code int)

type HttpWriter

type HttpWriter interface {
	Header() Setter
	Write([]byte) (int, error)
	Error(string, int)
	WriteHeader(int)
	ServeFile(fsys fs.FS, file string)
}

type MdView

type MdView struct {
	SystemFS fs.FS

	SocketType string
	SocketPath string

	CacheControl string
	UrlTopPath   string
	UrlLibPath   string

	DocumentRoot upath.UPath

	IndexName    string
	OriginTmpl   *template.Template
	HtmlTmpl     *template.Template
	MainTmplName string
	SvgIconPath  upath.UPath
	Md2Html      *md2html.Md2Html

	MimeExtTable   *mtable.MimeExtTable
	MarkdownExt    []string
	MarkdownConfig *md2html.MdConfig

	ThemeStyle   string
	LocationNavi string

	DirectoryViewMode       string
	DirectoryViewRoots      []upath.UPath
	DirectoryViewHidden     []*regexp.Regexp
	DirectoryViewPathHidden []*regexp.Regexp
	TimeStampFormat         string
	DirViewStamp            *dirview.DirViewStamp

	TextViewMode string

	ConfigModTime time.Time
	TemplateTag   []byte
}

func NewMdView

func NewMdView(cfg *MdViewConfig) (*MdView, error)

func (*MdView) Dump

func (mdv *MdView) Dump(out, eout io.Writer, req_path string)

func (*MdView) Handler

func (mdv *MdView) Handler(w http.ResponseWriter, r *http.Request)

func (*MdView) ListenAndServe

func (mdv *MdView) ListenAndServe(cc task.Canceller) error

func (*MdView) MakeEtag

func (mdv *MdView) MakeEtag(t time.Time) string

func (*MdView) Serve

func (mdv *MdView) Serve(cc task.Canceller, lstn net.Listener) error

func (*MdView) SumTemplate

func (mdv *MdView) SumTemplate() ([]byte, error)

func (*MdView) TmplSvgIcon

func (mdv *MdView) TmplSvgIcon(name string) string

type MdViewConfig

type MdViewConfig struct {
	SocketType   string
	SocketPath   string
	CacheControl string `toml:",omitempty"`

	UrlTopPath string `toml:",omitempty"`
	UrlLibPath string `toml:",omitempty"`

	DocumentRoot upath.UPath
	IndexName    string `toml:",omitempty"`
	TmplPaths    []upath.UPath
	IconPath     upath.UPath `toml:",omitempty"`
	MainTmpl     string      `toml:",omitempty"`

	MimeExtTable   upath.Import[*mtable.MimeExtTable] `toml:",omitempty"`
	MarkdownExt    []string                           `toml:",omitempty"`
	MarkdownConfig upath.Import[*md2html.MdConfig]    `toml:",omitempty"`

	ThemeStyle   string `toml:",omitempty"`
	LocationNavi string `toml:",omitempty"`

	DirectoryViewMode       string
	DirectoryViewRoots      []upath.UPath `toml:",omitempty"`
	DirectoryViewHidden     []string      `toml:",omitempty"`
	DirectoryViewPathHidden []string      `toml:",omitempty"`
	TimeStampFormat         string        `toml:",omitempty"`

	TextViewMode string `toml:",omitempty"`

	SystemFS fs.FS     `toml:"-"`
	ModTime  time.Time `toml:"-"`
}

func NewMdViewConfig

func NewMdViewConfig(file string) (*MdViewConfig, error)

func NewMdViewConfigFS

func NewMdViewConfigFS(fsys fs.FS, file string) (*MdViewConfig, error)

type Setter

type Setter interface {
	Set(string, string)
}

type TmplOnce

type TmplOnce = func(string) bool
var DummyTmplOnce TmplOnce = func(string) bool { return true }

func NewTmplOnce

func NewTmplOnce() TmplOnce

Jump to

Keyboard shortcuts

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