Submit

Back to the channels

#primate

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

Search posts