OPgen is a small command line tool that can generate one-page websites (flat file). Organize your pages in separate files and OPgen will collect their content and insert them in your template (index.mustache).
Example:
http://formvalidator.net/
- Clone this project where suiteable on your server.
- Run
$ pip install pystache
. - That's it! Add your own pages to the pages directory and generate the website by calling
$ python generator.py
in your console. Use the flag-w
if you want OPgen to automatically generate the website when you make an edit to your project.
Usage: python generator.py [<flags>]
Options:
-h, --help show this help message and exit
--template=TEMPLATE File to use as template [index.mustache]
--file=FILE Name of the generated file [index.html]
--pages=PAGES Directory where the pages are located [pages]
-w, --watch Start monitoring file changes and generate the one-page
html file on the fly
Use the event pageChange
or beforePageChange
to detect when the visitor has navigated to a new page
$(window).on('pageChange', function(evt, page, args, section) {
// new page is entered
});
The website will change to a "mobile" state when the window width is lower than 400px. Use the event viewModeChange
to
detect when this happens.
$(window).on('viewModeChange', function(evt, newMode) {
// new mode will be either 'mobile' or 'desktop'
});
Set the js variable preventViewModeChange
to false if you want to prevent the view-mode change entirely.