pre.xgo 977 B

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