Logo

index : blog

---

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/blog.git/html/src/gen/pages.jai blob: a745b84fa38b71dac613b61580dfbd64269b7044 [raw] [clear marker]

        
0
1
2/** TODO: Instead of maintaining pages here in code, create a more generic approach. */
3
4
5page_entries :: (html_diet: [..][]string) {
6 my_entries := commit_make("entries", html_diet);
7
8 page: Page_Metadata;
9 page.template = "entries_all";
10 page.file_name = "allposts";
11 page.commits = .[ my_entries ];
12 page.dont_create_nav_button = true;
13
14 page_create_body(page);
15}
16
17page_entries_limited :: (html_diet: [..][]string) {
18 html := array_copy(html_diet);
19 html.count = min(html.count, PAGE_ENTRIES_MAX);
20
21 entries_counts := string.[
22 tprint("%", PAGE_ENTRIES_MAX),
23 tprint("%", html_diet.count),
24 ];
25
26 my_entries := commit_make("entries", html);
27 counters := commit_make("max_entries", entries_counts);
28
29 page: Page_Metadata;
30 page.name = "Home";
31 page.template = "entries_limited";
32 page.url = "/";
33 page.file_name = "index";
34 page.commits = .[ my_entries, counters ];
35
36 page_create_body(page);
37}
38
39page_entry :: (entry: Entry, html: []string) {
40
41 make_css_style :: (width: string) -> string {
42 return tprint("style=\"max-width: %px;\"", width);
43 }
44
45 fp := tprint("%/%", DIR_WWW_POSTS, entry.uri);
46 content := commit_make("entry", html);
47
48 css := ifx entry.width then make_css_style(entry.width) else "";
49 style := commit_make("css", css);
50
51 page: Page_Metadata;
52 page.name = entry.title;
53 page.template = "entry";
54 page.file_name = fp;
55 page.commits = .[ content, style ];
56 page.dont_create_nav_button = true;
57 page.store_on_top_level = false;
58
59 page_create_body(page);
60}
61
62/** Create and save the individual posts to disk */
63page_entries_to_disk :: (entries: []Entry, html: [..][]string) {
64 for entries {
65 page_entry(it, html[it_index]);
66 }
67}
68
69page_rss :: (entries: []Entry) -> string {
70 rss_items := rss_make_items(entries);
71 rss_channel := rss_make_channel(rss_items);
72 return rss_channel;
73}
74
75page_overview :: (html: [..][]string) {
76 content := commit_make("entries", html);
77
78 page: Page_Metadata;
79 page.template = "overview";
80 page.file_name = "allitems";
81 page.commits = .[ content ];
82 page.dont_create_nav_button = true;
83
84 page_create_body(page);
85}
86
87page_overview_limited :: (html: [..][]string) {
88 html_new := array_copy(html);
89 html_new.count = min(html.count, PAGE_OVERVIEW_ITEMS_MAX);
90
91 items_counts := string.[
92 tprint("%", PAGE_OVERVIEW_ITEMS_MAX),
93 tprint("%", html.count),
94 ];
95
96 content := commit_make("entries", html_new);
97 counters := commit_make("max_items", items_counts);
98
99 page: Page_Metadata;
100 page.name = "Overview";
101 page.template = "overview_limited";
102 page.url = "overview";
103 page.file_name = "overview";
104 page.commits = .[ content, counters ];
105
106 page_create_body(page);
107}
108
109page_privacy :: () {
110 log("coconut.png - because of context cringe");
111 page := generic_page_make("privacy", "privacy", "privacy", dont_add_to_navbar=true);
112 page_create_body(page);
113}
114
115page_search :: () {
116 page := blank_page_make("Search", "search", "search", "search", false);
117 page_create_body(page);
118}
119
120page_search_for_server :: () {
121 page := blank_page_make("Search", "search", "search_results", "search", true);
122 page_create_body(page);
123}
124
125
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit