| Age | Commit message (Collapse) | Author |
|
The `-base-path` option set the URL prefix for serving HTTP request.
This allow serving the content under the prefix other than "/".
The `-shutdown-idle` option set the duration when server will stop
accepting new connections and shutting down.
This option can be helpful to reduce the resources on local environment.
|
|
At this point, all of the fields in the struct ServeOptions is the
same with [lib/http.ServerOptions] except IsDevelopment and
ConvertOptions.
For field IsDevelopment we keep in the struct.
For field ConvertOptions we remove it and let the caller pass it on
Serve function or InitHTTPServer method.
|
|
This allow request for .adoc/.md get redirected to .html in production
environment, as we have in https://golang-id.org/proposal/ .
|
|
During serve, onGet method, if the node does not exist and the request
path end with .adoc or .md, redirect the client to the .html location
with status 303 (StatusSeeOther).
|
|
The field Listener allow passing [net.Listener] instance for accepting
HTTP connection.
One of the use case is to activate the ciigo serve using systemd.socket(5).
|
|
Previously, with direct embed, every time we change the CSS or index
template, we need to restart the "ciigo serve" command.
Using memfs make us easy to update and see the changes directly, without
restarting the server.
|
|
This update have changes on [lib/http.FSHandler] that return second
parameter, status code.
|
|
|
|
In development mode, where [ServeOptions.IsDevelopment] is set to true
or when running "ciigo serve", the ciigo HTTP server will check if the
new markup file is newer than HTML file when user press refresh or
reload on the browser.
If its newer, it will convert the markup file and return the new content
of HTML file.
|
|
The Ciigo type 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.
|
|
When memfs not initialized using New, the [memfs.MemFS.PathNodes] will
be nil.
This cause any Get on new file will return 404.
|
|
If the requested path is directory and no "index.html" file exist in
that directory, ciigo server will render list of files as "index.html"
automatically.
|
|
|
|
|
|
Unfortunately, this breaks some API and exported fields, but its better
than creating revive.toml file to add an exception.
Some breaking changes,
* Field [ConvertOptions.HtmlTemplate] become [ConvertOptions.HTMLTemplate]
* Method [Converter.SetHtmlTemplateFile] become
[Converter.SetHTMLTemplateFile]
* Method [Converter.ToHtmlFile] become [Converter.ToHTMLFile]
|
|
With the latest update on lib/memfs, we can stop the watcher internally.
|
|
This is to provide the timestamp to each log output.
|
|
This is to allow user to click the address in terminal that support
it.
|
|
The HTML template in the ServeOptions should not read when ciigo.Serve
running on non-development environment.
|
|
|
|
Replace any usage of ":=" with explicit variable declaration for better
types clarity.
|
|
The purpose of Converter is to provide a single, reusable converter
for AsciiDoc file or content.
|
|
This changes update the embedded Go file on cmd/ciigo-example and
rename field Development on MemFS Options.
|
|
While at it, replace any use of ioutil with os/io package.
|
|
|
|
See https://kilabit.info/journal/2022/gpl/ for more information.
|
|
In commit 06d03f6afe37 we skip converting files if the generated HTML
is newer than adoc file.
This cause an issue where the template file changes during Watch or
Serve, but the HTML files is not regenerated.
|
|
If the IsDevelopment option set to true, the serve function will serve
the 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.
|
|
|
|
Previously, when user call ciigo.Watch(), and the markup file changes,
the onChangeFileMarkup method will print an error "xyz not found" which
cause the markup file not converted.
This is caused by watcher.fileMarkups is empty.
This changes fix this issue by initializing the fileMarkups field using
listFileMarkups, so the next callback to onChangeFileMarkup can detect
the changed file and convert it.
|
|
|
|
This upgrade affect the Server due to field Memfs has been removed from
lib/http.Server.
|
|
The ConvertOptions now has the Exclude field that can contains regular
expression. If the Exclude is not empty, it will be compiled and use
in Convert, Generate, Watch, and Serve; to ignore specific paths
being scanned.
|
|
Previously, we pass four parameters to Serve function: the instance
to memfs.MemFS, the root directory, the address to listen, and
path to HTML template.
In case we need to add new parameter in the future, the Serve function
signature will changes and this is not good for consumer of API.
This commit changes the Serve function parameters to ServeOptions
so we can add optional parameter in the future without changes to its
signature.
|
|
|
|
The library, non-main packages, should never call Fatal or panic,
its up to the main package or the caller on how to handle it.
While at it, fix the returned error to use log prefix and the error
value, remove the "ciigo: " prefix.
|
|
Now that we have the watcher which task are to watch the asciidoc
files and template files, we can use it in server to minimize duplicate
code.
This changes refactoring the htmlGenerator to initialize the HTML
template from internal or memfs, so the caller did not need to check by
itself.
|
|
This is to minimize recreating the fileHTML for the same fileMarkup,
and to simplify operation that require fileMarkup and fileHTML at the
same time.
|
|
This changes affect exported function Generate and Serve.
Previously, the Generate() function accept three options: dir, out,
and htmlTemplate; this commit changes the parameter into single struct
Options with two additional options: GenPackageName and GenVarName.
The GenPackageName allow to set the package name in Go generate source
code, default to "main" if not set.
The GenVarName set the instance of memfs.MemFS where the embedded
files will be stored.
On the Serve() function, we add parameter to pass the instance of
memfs.MemFS (the one that passed on GenVarName).
|
|
|
|
Previously to serve the generated content we call two fucntions:
NewServer() and Server.Start().
This changes unexported the internal server, and expose only the
Serve() function with the same parameter as NewServer().
|
|
The parameter for template either in Convert or Generate functions or
in CLI now become pure optional, not default to "templates/html.tmpl"
anymore.
This will minimize steps for user to setup or run the library or program.
|
|
|
|
This is to make it consistent with fileHTML.
|
|
|
|
The internal search template require the HTML generator to be initialized
with HTML template that provide when running "go generate". Without
the template, the internal search function will not work.
|
|
The search function is available through internal API "/_internal/search"
with single parameter "q" that contains one or more words to search.
|
|
Here are the usage of CLI,
ciigo [-template <file>] convert <dir>
Scan the "dir" recursively to find markup files (.adoc or .md) and
convert them into HTML files.
The template "file" is optional, default to "templates/html.tmpl" in
the current directory.
ciigo [-template <file>] [-out <file>] generate <dir>
Convert all markup files inside directory "dir" recursively and then
embed them into ".go" source file.
The output file is optional, default to "ciigo_static.go" in current
directory.
ciigo [-template <file>] [-address <ip:port>] serve <dir>
Serve all files inside directory "dir" using HTTP server, watch
changes on markup files and convert them to HTML files automatically.
If the address is not set, its default to ":8080".
|
|
Previously the default root directory to be served by ciigo is
"content" directory inside the top directory.
This change allow ciigo to serve any directory pointed by first parameter
in NewServer(), and if its empty default to "content".
|
|
Due to the popularity of markdown format, we decide to support converting
markdown file in ciigo.
While at it ignore all files or directories that start with dot, which
are hidden file in unix-like system.
|