pre.xgo 936 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. fmt := import("fmt")
  2. paths := import("paths")
  3. html := import("html").Renderer()
  4. ht := import("./htm")
  5. htmExt := func(c){
  6. if c.is_compo {
  7. return
  8. }
  9. c.pp.print(`<!doctype html><html>`)
  10. head := html.head()
  11. if c.title {
  12. head.add(html.title().body("SRPG-WIKI - " + string(c.title)))
  13. }
  14. for _, script in c.scripts {
  15. head.add(html.script({
  16. src: script
  17. }))
  18. }
  19. head.add(
  20. html.link({
  21. rel: "stylesheet",
  22. href: "/web/main.css"
  23. }).final(),
  24. html.script({
  25. //src: `https://unpkg.com/htmx.org@1.9.2`
  26. src: "/web/script/main.js"
  27. }),
  28. html.meta({
  29. content: "width=device-width,initial-scale=1",
  30. name: "viewport"
  31. }).final()
  32. )
  33. c.pp.print(head)
  34. c.pp.print(`<body>`)
  35. if c.no_header {
  36. } else{
  37. ht.print_header(c)
  38. }
  39. if c.not_main {
  40. } else {
  41. c.pp.print("<main id=\"main\">")
  42. }
  43. }
  44. exts := {
  45. ".htm": htmExt,
  46. ".html": htmExt
  47. }
  48. export func(c){
  49. ext := c.fext
  50. cl := exts[ext]
  51. if cl {
  52. cl(c)
  53. }
  54. }