Documentation ¶
Overview ¶
Package ciigo is a program to write static web server with embedded files using the asciidoc markup languages.
For more information see the README file at the page repository https://sr.ht/~shulhan/ciigo.
Index ¶
Constants ¶
const (
// DefaultRoot define default Root value for ConvertOptions.
DefaultRoot = `.`
)
Variables ¶
var Version = `0.15.0`
Version define the latest tagged release of this module.
Functions ¶
func Convert ¶
func Convert(opts ConvertOptions) (err error)
Convert all markup files inside directory "dir" recursively into HTML files using ConvertOptions HTMLTemplate file as base template. If HTMLTemplate is empty it will default to use embedded HTML template. See template_index_html.go for template format.
func GoEmbed ¶ added in v0.7.0
func GoEmbed(opts EmbedOptions) (err error)
GoEmbed generate a static Go file that embed all files inside Root except the one that being excluded explicitly by ConvertOptions Exclude.
It convert all markup files inside directory "dir" into HTML files, recursively, and then embed them into Go file defined by EmbedOptions.GoFileName.
If HTMLTemplate option is empty it default to use embedded HTML template. See template_index_html.go for template format.
func Serve ¶
func Serve(opts ServeOptions) (err error)
Serve the content under directory "ServeOptions.ConvertOptions.Root" using HTTP server at specific "ServeOptions.Address".
func Watch ¶ added in v0.5.0
func Watch(opts ConvertOptions) (err error)
Watch any changes on markup files on directory Root recursively and changes on the HTML template file. If there is new or modified markup files it will convert them into HTML files using HTML template automatically.
If the HTML template file modified, it will re-convert all markup files. If the HTML template file deleted, it will replace them with internal, default HTML template.
Types ¶
type Ciigo ¶ added in v0.14.0
Ciigo provides customizable and reusable instance of ciigo for embedding, converting, and/or serving HTTP server. This type is introduced so one can add HTTP handler or endpoint along with serving the files.
func (*Ciigo) Convert ¶ added in v0.14.0
func (ciigo *Ciigo) Convert(opts ConvertOptions) (err error)
Convert all markup files inside directory [ConvertOptions.Root] recursively into HTML files using [ConvertOptions.HTMLTemplate] file as base template. If HTMLTemplate is empty it use the default embedded HTML template. See template_index_html.go for template format.
func (*Ciigo) GoEmbed ¶ added in v0.14.0
func (ciigo *Ciigo) GoEmbed(embedOpts EmbedOptions) (err error)
GoEmbed embed the file system (directories and files) inside the [ConvertOptions.Root] into a Go code. One can exclude files by writing regular expression in [ConvertOptions.Exclude].
func (*Ciigo) InitHTTPServer ¶ added in v0.14.0
func (ciigo *Ciigo) InitHTTPServer(opts ServeOptions) (err error)
InitHTTPServer create an HTTP server to serve HTML files in directory defined in "ConvertOptions.Root".
The address parameter is optional, if not set its default to ":8080". The htmlTemplate parameter is optional, if not set its default to embedded HTML template.
func (*Ciigo) Watch ¶ added in v0.14.0
func (ciigo *Ciigo) Watch(convertOpts ConvertOptions) (err error)
Watch start a watcher on [ConvertOptions.Root] directory that monitor any changes to markup files and convert them to HTML files.
type ConvertOptions ¶ added in v0.6.0
type ConvertOptions struct { // Root directory where its content will be embedded into Go source // code. // Default to DefaultRoot if its empty. Root string // Exclude define regular expresion to exclude certain paths from // being scanned. Exclude []string // HTMLTemplate the HTML template to be used when converting markup // file into HTML. // If empty it will default to use embedded HTML template. // See template_index_html.go for template format. HTMLTemplate string // contains filtered or unexported fields }
ConvertOptions define the options to use on Convert function.
type Converter ¶ added in v0.9.0
type Converter struct {
// contains filtered or unexported fields
}
Converter a single, reusable AsciiDoc converter.
func NewConverter ¶ added in v0.9.0
NewConverter create and initialize Converter with HTML template. If htmlTemplate is empty, it will use the internal, predefined template.
func (*Converter) SetHTMLTemplateFile ¶ added in v0.11.0
SetHTMLTemplateFile set the HTML template from file.
func (*Converter) ToHTMLFile ¶ added in v0.11.0
func (converter *Converter) ToHTMLFile(fmarkup *FileMarkup) (err error)
ToHTMLFile convert the AsciiDoc file to HTML.
type EmbedOptions ¶ added in v0.7.0
type EmbedOptions struct { ConvertOptions memfs.EmbedOptions }
EmbedOptions define the options for calling GoEmbed function.
type FileMarkup ¶ added in v0.10.0
type FileMarkup struct {
// contains filtered or unexported fields
}
FileMarkup contains the markup path and its kind.
func NewFileMarkup ¶ added in v0.10.0
func NewFileMarkup(filePath string, fi os.FileInfo) (fmarkup *FileMarkup, err error)
NewFileMarkup create new FileMarkup instance form file in "filePath". The "fi" option is optional, if its nil it will Stat-ed manually.
type ServeOptions ¶ added in v0.6.0
type ServeOptions struct { // Mfs contains pointer to variable generated from Generate. // This option is used to use embedded files for serving on HTTP. Mfs *memfs.MemFS // Address to listen and serve for HTTP request. Address string ConvertOptions // If true, the serve command generate index.html automatically if its // not exist in the directory. // The index.html contains the list of files inside the requested // path. EnableIndexHTML bool // IsDevelopment if set to true, it will serve the ConvertOptions.Root // directory directly and watch all asciidoc files for changes and // convert it. // This is like running Watch, Convert and Serve at the same time. IsDevelopment bool }
ServeOptions contains the options to use on Serve function.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
ciigo
ciigo is a CLI to convert, embed, and/or serve a directory that contains markup files, as HTML files.
|
ciigo is a CLI to convert, embed, and/or serve a directory that contains markup files, as HTML files. |
internal
|
|
cmd/ciigo-example
Program ciigo-example provide an example on how to build a binary that include the static, generated .go file.
|
Program ciigo-example provide an example on how to build a binary that include the static, generated .go file. |