aboutsummaryrefslogtreecommitdiff
path: root/watcher.go
AgeCommit message (Collapse)Author
2025-01-07all: auto convert markup when HTTP client request GET to HTML fileShulhan
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.
2025-01-07all: refactoring to use [watchfs/v2]Shulhan
The [watchfs/v2] bring new enhancements that watching only single file instead of all markup files for changes. This minimize number of goroutine calling os.Stat on each markup files being watched on directory.
2024-09-28all: introduce new type CiigoShulhan
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.
2024-03-05all: replace module "share" with "pakakeh.go"Shulhan
2023-12-10all: fix all warnings reported by linter reviveShulhan
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]
2023-11-09all: update comment on newWatcherShulhan
2023-11-09all: add method to stop watcherShulhan
With the latest update on lib/memfs, we can stop the watcher internally.
2023-10-13all: print log message with log packageShulhan
This is to provide the timestamp to each log output.
2023-05-14all: rewrite watcher tests using lib/test.DataShulhan
Instead of using another template, use the embedded template when generating HTML. In this way we can see how the generated HTML looks like.
2023-05-14all: bring back support for MarkdownShulhan
I use two remote repositories: GitHub and SourceHut. GitHub support rendering README using asciidoc while SourceHut not. This cause the repository that use README.adoc rendered as text in SourceHut which make the repository page less readable. Also, the pkg.go.dev now render README but only support Markdown. Since we cannot control the SourceHut and go.dev, the only option is to support converting Markdown in ciigo so I can write README using Markdown and the rest of documentation using Asciidoc.
2022-08-06all: cleaning up codesShulhan
2022-08-01all: clean up codesShulhan
Replace any usage of ":=" with explicit variable declaration for better types clarity.
2022-08-01all: export the Converter method to reload HTML templateShulhan
The SetHtmlTemplateFile set or changes the HTML template used by Converter to convert AsciiDoc to HTML.
2022-08-01all: export convert method in Converter as ToHtmlFileShulhan
This is the first public API provided for Converter, as promised in the previous commit.
2022-08-01all: export internal htmlGenerator as ConverterShulhan
The purpose of Converter is to provide a single, reusable converter for AsciiDoc file or content.
2022-05-19all: reformat all files using latest goimportsShulhan
While at it, replace any use of ioutil with os/io package.
2022-03-09all: update the watcher affected by changes on share moduleShulhan
In the share module, the DirWatcher and Watcher has been moved to package memfs and the way to consumed the changes is not through callback again but through channel.
2022-03-04all: re-licensing ciigo under GPL-3.0 or laterShulhan
See https://kilabit.info/journal/2022/gpl/ for more information.
2022-02-19all: realign all structsShulhan
Changes, * fileMarkup: realign from 56 to 48 bytes (-8 bytes) * htmlGenerator: realign from 32 to 24 bytes (-8 bytes) * watcher: realign from 48 to 40 bytes (-8 bytes)
2022-02-19all: fix adoc files not re-converted when template file changesShulhan
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.
2021-10-17all: fix empty fileMarkups on watcherShulhan
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.
2021-10-08all: update share module to latest versionShulhan
This update affect the Watcher due to changes on FileState.
2021-04-07all: replace any mention of asciidoc with markupShulhan
2021-04-03all: add option to exclude certain paths using regular expressionShulhan
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.
2021-04-03all: exclude common file and directories names for being watchedShulhan
By default, any hidden files on Unix like system, which start with dot '.' should not be watched for any changes. So does "node_modules" from npm and "vendor" directory which may contains many unrelated files.
2021-04-03all: change the Convert function to use type ConvertOptionsShulhan
Previously, we pass the directory to be scanned for asciidoc markup files and path to HTML template on Convert function. Adding new option to Convert will cause changes on the Convert signature. To prevent this, we changes the Convert signature from multiple parameters into single parameter ConvertOptions. While at it, change the variable name HTMLTemplate to HtmlTemplate.
2021-02-21all: return error instead of call log.Fatal on non main packagesShulhan
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.
2021-02-21all: rewrite to use the watcherShulhan
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.
2021-02-21all: implement Watch functionalityShulhan
The Watch function, watch any changes on asciidoc files on directory "dir" recursively and changes on the HTML template file. If there is new or modified asciidoc files it will convert them into HTML files using HTML template automatically. If the HTML template file modified, it will re-convert all asciidoc files. If the HTML template file deleted, it will replace them with internal, default HTML template.