Template for creating and developing ZeroNet sites.
This project provides a template for creating and developing ZeroNet sites.
It supports NPM dependencies and it uses Gulp and Browserify for bundling scripts. It also supports SASS and automatic deployments with Travis CI.
You must have Git and Node.js installed on your computer. It is recommended that use the latest versions.
It is also recommended to also install Python and ZeroNet for easier developing and deploying. Currently, only Python 2.7 is supported but Python 3 version of ZeroNet is in development.
If you don't already have your own ZeroNet site, you should create it from ZeroNet. Details are available in ZeroNet documentation. You must have a site's address and a private key.
You can then clone or fork this repository and install dependencies. It already contains an example site and code with ZeroFrame API.
$ git clone https://github.com/filips123/ZeroTemplate.git my-new-site
$ cd my-new-site
$ yarnYou should commit changes to develop branch.
You should edit package.json to provide your own information and dependencies needed for your site.
It is also recommended to update README.md to provide information about your site. You can then edit the files and add your own code.
Each site must have valid src/content.json. Details about are it availible in ZeroNet documentation.
You should copy address and signers_sign (and other keys related with addressed and signatures) from original content.json that was generated at site creation.
It is recommended that it doesn't contain modified, files, files_optional and signs because they will be auto-generated on each siteSign.
The site is contained in src/ directory.
Scripts are stored in src/js/ and each site must contain the main script (src/js/index.js). Styles are stored in src/css/ and src/sass.
It is recommended that scripts follow Standard style. You can run linting with yarn lint.
Your index.html (or any other HTML file) should include JS from js/all.js?lang={lang}&site_modified={site_modified} and CSS from css/all.css?site_modified={site_modified}. Additional query parameters will ensure that the files will be correctly updated.
You can build the site with yarn build. This will bundle all scripts and styles and copy static files to dist/. You can then copy that directory to your site directory in ZeroNet, sign the changes and publish them.
After you finish your changes, you can run yarn deploy. This will automatically build, sign and publish your site which may take a few minutes.
Local Python copy of ZeroNet is required for this task. You must set a path to it (location of zeronet.py file) with --zeronet argument.
$ yarn deploy --zeronet=/path/to/zeronetDuring deploy, you will be asked for your site's private key. You must enter it to finish deploy.
You can also specify your private key with --privkey argument. Note that your private key will then be visible in command's output.
$ yarn deploy --zeronet=/path/to/zeronet --privkey=sEcReTkEyYou can also use continuous deployment with Travis CI.
During development, any changes must be committed to develop branch. When you want to release them, you will just have to merge it into master and publish the changes. Travis CI will then automatically install ZeroNet, sign the changes and publish your site.
To make this working, you will have to (securely) set ZERONET_PRIVKEY environment variable in Travis CI. It must contain your private key.