├── .gitignore ├── urbit └── app │ ├── staticsite │ └── index.html │ └── staticsite.hoon ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /urbit/app/staticsite/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

It works!

5 |

A paragraph, for you.

6 | 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Notice:** This is nowhere near current and should only be considered for the purpose of mounting static HTML pages in archival subnetworks (eg. galaxies, stars, and planets pinned to Vere version 0.10.0). As of November 2023, no such archival project exists, though one could certainly imagine it. 2 | 3 | # urbit-static-page 4 | 5 | Basic template for mounting a static website (HTML+CSS+JS) to an [Urbit](https://urbit.org) ship v.0.10.0 or higher. 6 | 7 | [![awesome urbit badge](https://img.shields.io/badge/~-awesome%20urbit-lightgrey)](https://github.com/urbit/awesome-urbit) 8 | 9 | ## Overview 10 | 11 | As of Urbit v0.8.0, the eyre vane (HTTP server) of Arvo no longer automatically mounts everything in the `/web` folder. It now works through the declaration of endpoints. 12 | 13 | This is a boilerplate for that, using a static Gall agent, current as of v.0.10.0+. 14 | 15 | This boilerplate will mount everything in /app/staticsite to "/~staticsite" on your ship's HTTP server. If your ship is `~sampel-palnet` and you have enabled [DNS proxying](https://urbit.org/using/operations/using-your-ship/#planets-and-stars), your site will be available on `http://sampel-palnet.arvo.network/~staticsite`. 16 | 17 | You can also set any domain name to your ship's IP address, if you prefer. 18 | 19 | ### Usage 20 | 21 | 1. Clone this repo. 22 | 2. If you want to rename the app or the endpoint, you can do either respectively by renaming `staticsite.hoon` and the `staticsite` folder, for the app; and all mentions of `~staticsite` in the former `staticsite.hoon` for the endpoint. Feel free to add your HTML, CSS, and JS files to the folder when ready. 23 | 3. Copy everything in `urbit/app` to your Urbit ship's pier, within its respective /app folder. 24 | 4. `|commit %home` and `|start %your-app-name`. 25 | 5. e m b r a c e g e o c i t i e s 26 | 27 | ### Future updates 28 | 29 | - [ ] Mounting arbitrary pngs 30 | 31 | ## Acknowledgements 32 | 33 | This was one of my first projects on Urbit. Thank you to `~tacryt-socryp`, `~palfun-folsup` and `~novlud-padtyv` for mentoring. 34 | -------------------------------------------------------------------------------- /urbit/app/staticsite.hoon: -------------------------------------------------------------------------------- 1 | /+ *server, default-agent, verb 2 | :: 3 | %+ verb | 4 | ^- agent:gall 5 | |_ =bowl:gall 6 | +* this . 7 | def ~(. (default-agent this %|) bowl) 8 | :: 9 | ++ on-init 10 | ^- (quip card:agent:gall _this) 11 | :_ this 12 | [%pass / %arvo %e %connect [~ /'~staticsite'] %staticsite]~ 13 | :: 14 | ++ on-save on-save:def 15 | ++ on-load on-load:def 16 | ++ on-poke 17 | |= [=mark =vase] 18 | ^- (quip card:agent:gall _this) 19 | ?. ?=(%handle-http-request mark) 20 | (on-poke:def mark vase) 21 | =+ !<([eyre-id=@ta =inbound-request:eyre] vase) 22 | :_ this 23 | %+ give-simple-payload:app eyre-id 24 | |^ :: exclusively handle get requests. try to load the requested file from 25 | :: clay, under /app/staticsite. if the requested file doesn't exist, or 26 | :: it's a different kind of request, respond with 404. 27 | :: 28 | ?. ?=(%'GET' method.request.inbound-request) 29 | not-found:gen 30 | =/ =request-line 31 | %- parse-request-line 32 | url.request.inbound-request 33 | =/ ext=@ta 34 | (fall ext.request-line %html) 35 | =/ file=(unit octs) 36 | ?. ?=([%'~staticsite' *] site.request-line) ~ 37 | (get-file-at /app/[dap.bowl] t.site.request-line ext) 38 | ?~ file not-found:gen 39 | ?+ ext not-found:gen 40 | %html (html-response:gen u.file) 41 | %css (css-response:gen u.file) 42 | %js (js-response:gen u.file) 43 | == 44 | :: 45 | ++ get-file-at 46 | |= [base=path file=path ext=@ta] 47 | ^- (unit octs) 48 | :: only support html, css and js files for now. 49 | :: other filetypes might need more work to get as octs. 50 | :: 51 | ?. ?=(?(%html %css %js) ext) 52 | ~ 53 | =/ =path 54 | :* (scot %p our.bowl) 55 | q.byk.bowl 56 | (scot %da now.bowl) 57 | (snoc (weld base file) ext) 58 | == 59 | ?. .^(? %cu path) 60 | ~ 61 | %- some 62 | %- as-octs:mimes:html 63 | .^(@ %cx path) 64 | -- 65 | :: 66 | ++ on-watch 67 | |= =path 68 | ^- (quip card:agent:gall _this) 69 | ?: ?=([%http-response *] path) 70 | [~ this] 71 | (on-watch:def path) 72 | :: 73 | ++ on-leave on-leave:def 74 | ++ on-peek on-peek:def 75 | ++ on-agent on-agent:def 76 | ++ on-arvo 77 | |= [=wire =sign-arvo] 78 | ^- (quip card:agent:gall _this) 79 | ?. ?=(%bound +<.sign-arvo) 80 | (on-arvo:def wire sign-arvo) 81 | [~ this] 82 | :: 83 | ++ on-fail on-fail:def 84 | -- 85 | --------------------------------------------------------------------------------