This is a server built with Hono to run Moka, a small wiki engine contained in a single file. Moka is created by m15o, originally hosted at moka.pub. I made this val so I can host it myself. You can remix this val as a starter template to host your own Moka on Val Town.
- Click the Remix button on this val.
- Open the Environment variables menu on the left, and enter two variables:
- for the
VAL_API_TOKENvariable, you need to go to Settings > API Tokens and create a new API token. Give it a descriptive name so that you remember what this token is for. For the Permissions, give Read-only permission to Users, and Read and write permission to Vals. Click Create Token and copy the token, then paste as the value to yourVAL_API_TOKENvariable. PASSWORDis the password you will have to enter to log in. This way, only you can post entries to your Moka (everyone can see the edit button on every page and open the editor, but they can't publish the changes without logging in first). So create a password as usual and enter it to this variable.
- for the
- In
main.ts, click the ⫶ three dot menu (next to the green HTTP button) and choose Open HTTP endpoint to see your new Moka instance in a new tab. You're likely going to see a long url you won't be able to remember. No worries, you can change that with a custom subdomain (like mine) later (see Val Town docs). - Click login and enter the password you created before. You should be redirected back to the landing page of your Moka. Now you can make edits to your heart's content and publish them.
For more information on how Moka works and how to use it, read the manual.
Moka can also be used offline. Just download moka.html and open it with a browser. Everything is contained in that single file. When you make edits, you'll have the option to save your updated file or export the entries.
This used to be a Glitch project 🥀. I archived the project here, and even updated beforehand to make sure it can run on localhost.
Because vals don't have direct access to the file system (you can't use Node's fs module here), I used to hack this with inelegant regex and blob to faithfully mimic Moka's behavior as a quine, but after a long winding journey I finally found a way to update the source file directly just like on a local server with write access to the file system, thanks to Val Town SDK.