website
The website for https://crystal-china.org
Development dependencies
- Crystal
- pg
- bun
- podman (or docker)
Development
-
First, install Crystal. You can check out the instructions here: https://crystal-lang.org/install/
-
Run
crystal run script/setup.cr, Just make sure you’ve gotpgandbuninstalled before running this. -
Finally, run
lucky dev, and you're all set!
Deployment
The application is deployed as a static binary with its frontend assets baked in. Markdown documents deliberately remain outside the binary so they can be updated without recompiling the application.
-
Run
bun run prodto build and precompress the frontend assets intopublic/assets. -
Build the static binary with
script/build_amd64_static_binary.sh. This requires Podman or Docker.Alternatively, use the sb_static script with Zig. See Use Zig CC as an alternative linker for details.
-
Synchronize
public/markdowns/withrsync -a --delete(apply--deleteonly to that directory) andpublic/sitemap.xmlwithrsync -a. The Markdown directory must exist before starting the new binary because the application readsnavigation.ymlduring startup. -
Copy
bin/crystal_chinaandbin/tasksto the server and configure the environment in.env; see .env.sample. The deployed application has the following relevant structure:. ├── .env ├── bin │ ├── crystal_china │ └── tasks └── public ├── markdowns │ ├── navigation.yml │ └── ... └── sitemap.xml -
Run
bin/tasks db.migrateandbin/tasks db.sync_doc_contentto populate the PGroonga-backed document search index. The sync task is safe to rerun after Markdown changes. -
Add a systemd service to start the server. See crystal_china.service. Procodile can be used instead.
-
Optionally, use Nginx as a reverse proxy. Configuration examples are available in the nginx folder.
Updating documentation
- Edit files under
public/markdowns/and updatenavigation.ymlwhen the page should appear in the Sidebar and Pager. - Synchronize the complete directory with
rsync -a --delete public/markdowns/ .../public/markdowns/so removed Markdown files also disappear from the server. - Run
bin/tasks db.sync_doc_contenton the server to update searchable content, then refresh the document page. Recompiling or restarting the application is not required.
A Markdown file omitted from navigation.yml remains directly accessible and searchable, but it will not appear in the Sidebar or Pager. Visiting a document also syncs its content into the search index.
Contributing
- Fork it (https://github.com/zw963/website/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Billy.Zheng - creator and maintainer
website
- 5
- 1
- 2
- 0
- 20
- 2 days ago
- September 2, 2024
MIT License
Sat, 03 Oct 2026 14:52:05 GMT