Submit

Back to the channels

#primate

  1. phaleth there's gonna be a police lurking and banning startups for life in the cyberspace https://freebsdfoundation.org/blog/getting-ready-for-the-cyber-resilience-act/
  2. blue heh
  3. blue the biggest security risk for freebsd is probably having been infiltrated by woke activists
  4. blue btw phaleth
  5. blue https://nevet.repopack.app/features
  6. blue I got it working
  7. phaleth cool, it responds with a json, no clue what the data is about
  8. phaleth freebsd foundation is just posting about that on their blog
  9. phaleth the message is that companies will be required to make their SBOM public, but still, might wanna read that blogpost anyway
  10. blue yeah
  11. blue isn't publishing SBOM good though?
  12. blue like, it shows you're up to date on your supply chain
  13. phaleth not sure, possibly it could required also for websites
  14. blue is that bad?
  15. blue anyway I always try to use as few deps as possible, I doubt that's gonna affect us greatly
  16. blue it's only gonna affect the deps-narcos :P
  17. phaleth me too, but the thing is that software still decays
  18. blue true
  19. phaleth maybe a good time to start thinking about SSG for primate? at least for Svelte so that primate website can be processed
  20. phaleth and markdown and the other few deps
  21. blue what's your understanding of SSG? producing only HTML at build time, instead of a .js bundle?
  22. blue it's probably better from a security POV...
  23. phaleth producing a jamstack site, where html, css and js are separate
  24. phaleth js should still leverage the dynamic import trickery client side and also fetch APIs and all the other relevant browser APIs
  25. blue yeah but what's the advantage of that versus the default monothilic build target?
  26. blue monolithic*
  27. phaleth the advantage is that everything happens client side and all responses from APIs and other resources are merely static and always predictable, there is no database, no session, no anything on a remote place
  28. phaleth and so there is no possibility to compromise the remote site
  29. phaleth cause you know the remote site has dependencies to do all of it's dynamic processing
  30. blue but the current primate website doesn't have any session/database anyway
  31. phaleth and those can decay and so become compromised
  32. blue hm, fair
  33. phaleth well, but it still requires a server side runtime for dynamic processing
  34. blue yeah, I agree, the only thing here is that the server side runtime is basically almost an nginx replacement at this stage
  35. blue there's almost no dynamism happening
  36. phaleth if the website was static and ran only on say caddy then there are two deps, caddy and golang
  37. blue mhm, true
  38. blue so you want a --target=static for primate that generates an HTML file for every route?
  39. blue these HTML files all embed the same JS and CSS
  40. phaleth don't remember how the primate cli works, but yeah
  41. blue the only real question is how fetch-browsing then works. currently when you click a link in primate, it'll get you JSON for the next page
  42. phaleth html should not embed anything if possible, it's a waste of cache opportunites for browsers
  43. blue what if we generated *one* html file, but that would contain embedded json?
  44. blue hm, still wouldn't work for search engines
  45. phaleth since the json is static it's fine and json should not be cached anyway, but js and css and images are different story and should be separate
  46. blue so what about this
  47. blue we generate many html files, one per page. they contain all the HTML needed to show the page + js (for example, for switching between light/dark scheme)
  48. phaleth but consider adding content hashes to json filenames as well and then it makes sense to cache those
  49. blue but in addition, we generate a content.json containing all the content, again
  50. blue so that when you click, it can replace it
  51. phaleth content-1489g47sdf8.json
  52. blue only problem is that json file would be huge
  53. blue since we don't have svelte anymore in this scenario, we have no way of saying "this is the dynamic part"
  54. phaleth well, I'd say smaller than html
  55. phaleth by about 30%
  56. blue how? it would contain the HTML for every page
  57. phaleth ah, I thought it'd only have the data, but that's fine too
  58. phaleth then it's equal to the size of current html
  59. blue so my question is how do you do fetch browsing in this scenario. or well in this case client-based browsing, no additional requests after the first one
  60. phaleth hmm, nope
  61. phaleth jamstack is about making aditional request for anything via say fetch API, but only as long as that anything is not dynamically processed
  62. phaleth it can be a static pre-rendered json file
  63. phaleth with response headers so the browser can aggresively cache it: content-4gf59d4sg8.json
  64. blue yeah but how do you see this working. I access primate.run/docs, I get the full HTML. then I click on /docs/quickstart, what happens?
  65. phaleth html loads js file in the header and js fetches json
  66. phaleth in the header to avoid layout shifting
  67. blue so the js fetches content-quickstart-somehash.json?
  68. blue and what does that contain?
  69. phaleth yup, only when on that page
  70. phaleth could be html
  71. phaleth might as well ditch svelte and use htmx at this point
  72. blue indeed
  73. blue if you're getting the whole HTML, you'll lose things like scrolling state on the left bar
  74. blue I'm not sure SSGs have thought this through properly
  75. blue if you collapse the svelte world into a dumb html world, you can't replace custom nodes anymore
  76. blue well you could, but you'd again need some js logic for that
  77. phaleth can manage the state client side using other means than just js if needed
  78. blue so you're building a UI again
  79. phaleth I think htmx has that figured out too
  80. blue hm, I have a different proposition. we keep svelte, but it's running only on the client
  81. phaleth but anyway, it's not a problem of svelte, cause originally svelte was a client side only framework
  82. phaleth yeah, svelte is fine
  83. blue and instead of fetching JSON for every click, it fetches a combined all-data.json on the first request. after that there is no subsequent request to the server, at all
  84. phaleth might as well ditch it and use poly again, cause of svelte 5's server side stuff
  85. blue this combined json contains per data for the list of components and their data
  86. blue per page*
  87. phaleth yeah, but that's a lot of data and you'll see SEO penalties
  88. blue why? the SEO doesn't need the JSON file
  89. blue the SEO sees the html, the json can be loaded lazily
  90. blue and primate.run can work completely offline, too
  91. phaleth those tricks you describe used to work in the past, but not anymore, bots are way more clever nowadays
  92. blue you just need the original request, then you're done
  93. phaleth and of course any documentation site should work completely online and be servable using: python -m http.server
  94. phaleth original request?
  95. blue yes
  96. blue I do GET /docs, I get the HTML for docs, and also the /data.json which contains all component data I need for every other page
  97. blue so the website can work completely offline after the first request
  98. phaleth yeah, but again that data.json combined is huge
  99. phaleth ah, you mean if the server goes down
  100. phaleth that scenario is not possible
  101. blue I mean if I'm offline
  102. blue I can also literally save the HTML file and it works
  103. phaleth well then get better interwebz and do not browser primate.run when going through the tunnel or something
  104. blue heh
  105. phaleth also if you go offline
  106. blue I wonder how big that data.json would get: you know, it only references a list of components and their data. it just contains the inner HTML for docs, and the data for the navbar
  107. blue maybe 1-2 MB?
  108. phaleth and the site is properly split as I described above, and you have visited the page you navigate previously, you will get a cache hit
  109. phaleth so the page should load for you
  110. blue yes, that would work under the scenario I'm proposing jsut the same
  111. phaleth and if you are in doubt you can always employ what some jamstack sites do, that is a service worker
  112. blue yes
  113. phaleth the bigger the site grows the bigger the data will get
  114. blue let me ask chatccp
  115. phaleth clanker will tell you to use hugo
  116. blue I'm not using hugo, hugo is dumb
  117. blue all SSGs are total garbage. there's no way to edit posts in an editor in the browser and they all expect you to have nvim
  118. blue that's why I'm building priss, so I can edit primate blog posts in the browser and get direct feedback on how it looks
  119. blue those SSGs aren't able to separate mentally the build phase from the run phase
  120. blue what I want is wordpress comfort during/before build phase, and SSGs comfort during run phase
  121. blue somehow nobody had that idea until now
  122. phaleth heh, yeah, hugo is just re-doing everything and depends on many things so it has to be run from within docker build
  123. phaleth I think only the zig SSG framework checks if a page is already rendered using some sort of hashing tricks, but prolly not
  124. phaleth but I don't remember it's name
  125. phaleth zine
  126. blue so the idea of priss is, you have dev mode. like `npx primate`. during that, you can access an in-browser editor that allows you to create content (pages/posts). you also get immediate feedback when editing their markdown (splitscreen).
  127. blue during build though, this whole /admin area doesn't exist, like at all. we just generate those HTML pages. so unlike wordpress it's not possible to edit pages while the site is running
  128. phaleth you mean edit the page from devtools of the web browser?
  129. blue no, I mean edit the page inside your browser
  130. phaleth that'd be cool, just no idea how it'd work
  131. phaleth ok, but then you need some kind of editor like wordpress has
  132. phaleth i forgot the name of that react thing
  133. blue split screen: textarea on your left, preview on your right
  134. blue yes that's no problem. this component is only used in the /admin area. the /admin area doesn't get bundled into the built website
  135. blue you mean tinymce or whatever
  136. phaleth sounds too complicated, someone like me would just use IDE to edit markdown and have esbuild to reload in the web browser
  137. phaleth I think wordpress calls their editor gutenberg
  138. phaleth but it's a huge pile of react code
  139. blue yeah but someone like you isn't the target audience
  140. phaleth :)
  141. phaleth I mean for starters it's fine to just use a code editor and have esbuild wrapper run in a console
  142. blue it's fine, but I wanna do more than that with priss
  143. blue btw chatgpt said it's better to split the jsons
  144. blue you win :(
  145. blue something something prefetching
  146. phaleth yeah, well, jamstack is a super old concept that just works
  147. blue `You can keep “SPA feel” by prefetching the next page’s JSON on hover/viewport and caching in-memory (and/or Cache Storage).`
  148. phaleth even nowadays with all the nextjs or whatever bullshit rendering strategies
  149. phaleth yup, browser already know what to do, just setup the HTTP server properly is the answer
  150. blue for fully offline, it said it's better use a serviceworker and add --target=static:offline
  151. blue `Generate a service worker that precaches all HTML + page-data + assets (or a configurable subset)`
  152. phaleth also prefetching on hover is an old trick at this point
  153. blue yeah it sounds dumb to me though
  154. phaleth and service workers also work well in all browsers
  155. phaleth yeah, I'd not do prefetching on hover, thinking of mobile, anyway
  156. blue yeah that's dumb
  157. phaleth using on hover is dumb
  158. phaleth except for changing colors slightly
  159. blue so I guess we'll do --target=static, and that generates docs/index.html, docs/start/index.html, and docs.json and docs-start.json
  160. blue svelte becomes clientonly
  161. blue the only thing I need to consider is if I move primate website to priss, what's the frontend of choice for priss
  162. blue ideally should be chooseable
  163. phaleth I'd recommend doing just svelte for now and bother with something else when somebody asks
  164. blue k
  165. blue phaleth: https://github.com/primate-run/primate/issues/253
  166. nevet Proposal: `--target=static` (SSG output + client-only runtime) · Issue #253 · primate-run/primate
  167. blue I went over it and removed most of the ai slurp
  168. blue it had some interesting ideas like 4)
  169. blue the proposal is mostly aligned with your suggestion, anyway
  170. phaleth heh, nice
  171. phaleth yeah, if json is embeded to html then there is no need to configure the HTTP server to add cache headers to json mimetype
  172. blue well yeah, it's just the current page
  173. phaleth right
  174. phaleth what's weird that it suggest to use script tag for the json with type="applicaton/json", I'd recommend to use template tag https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template
  175. nevet <template>: The Content Template element - HTML | MDN
  176. blue but template doesn't contain data, I think that's the difference
  177. phaleth hmm? I mean the json could be inside template tag instead of the script tag
  178. phaleth script element will get evaluated by the browser
  179. blue how does that help you? I thought <template> should be reused
  180. blue in combination with <slot>
  181. phaleth hmm, nope, you can put template on the page as a data container for say JS to grab the data later
  182. phaleth slot is a webcomponent tag I think
  183. phaleth the purpose of template tag is that it's not being rendered
  184. phaleth and so browsers don't bother with it too much, except putting it to DOM
  185. blue ah, that's cool
  186. blue could you add a comment about that at the issue?
  187. phaleth I can try logging into github, yeah
  188. blue cool
  189. blue awesome
  190. blue phaleth: I need to prioritise stuff for 0.37
  191. blue perhaps you can help
  192. phaleth well, that's easy, use primate for anything and whenever you run into a bug or something that you need then just update primate, rcompat or the rest
  193. phaleth like for example the thing we ran into yesterday that package.json is required at runtime for a prod app
  194. blue ya

Search posts