<<
path:
root/public/blog.git/html/src/gen/pages.jai
blob: a745b84fa38b71dac613b61580dfbd64269b7044
[raw]
[clear marker]
2/** TODO: Instead of maintaining pages here in code, create a more generic approach. */
5page_entries :: (html_diet: [..][]string) {
6 my_entries := commit_make("entries", html_diet);
9 page.template = "entries_all";
10 page.file_name = "allposts";
11 page.commits = .[ my_entries ];
12 page.dont_create_nav_button = true;
14 page_create_body(page);
17page_entries_limited :: (html_diet: [..][]string) {
18 html := array_copy(html_diet);
19 html.count = min(html.count, PAGE_ENTRIES_MAX);
21 entries_counts := string.[
22 tprint("%", PAGE_ENTRIES_MAX),
23 tprint("%", html_diet.count),
26 my_entries := commit_make("entries", html);
27 counters := commit_make("max_entries", entries_counts);
31 page.template = "entries_limited";
33 page.file_name = "index";
34 page.commits = .[ my_entries, counters ];
36 page_create_body(page);
39page_entry :: (entry: Entry, html: []string) {
41 make_css_style :: (width: string) -> string {
42 return tprint("style=\"max-width: %px;\"", width);
45 fp := tprint("%/%", DIR_WWW_POSTS, entry.uri);
46 content := commit_make("entry", html);
48 css := ifx entry.width then make_css_style(entry.width) else "";
49 style := commit_make("css", css);
52 page.name = entry.title;
53 page.template = "entry";
55 page.commits = .[ content, style ];
56 page.dont_create_nav_button = true;
57 page.store_on_top_level = false;
59 page_create_body(page);
62/** Create and save the individual posts to disk */
63page_entries_to_disk :: (entries: []Entry, html: [..][]string) {
65 page_entry(it, html[it_index]);
69page_rss :: (entries: []Entry) -> string {
70 rss_items := rss_make_items(entries);
71 rss_channel := rss_make_channel(rss_items);
75page_overview :: (html: [..][]string) {
76 content := commit_make("entries", html);
79 page.template = "overview";
80 page.file_name = "allitems";
81 page.commits = .[ content ];
82 page.dont_create_nav_button = true;
84 page_create_body(page);
87page_overview_limited :: (html: [..][]string) {
88 html_new := array_copy(html);
89 html_new.count = min(html.count, PAGE_OVERVIEW_ITEMS_MAX);
91 items_counts := string.[
92 tprint("%", PAGE_OVERVIEW_ITEMS_MAX),
93 tprint("%", html.count),
96 content := commit_make("entries", html_new);
97 counters := commit_make("max_items", items_counts);
100 page.name = "Overview";
101 page.template = "overview_limited";
102 page.url = "overview";
103 page.file_name = "overview";
104 page.commits = .[ content, counters ];
106 page_create_body(page);
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);
116 page := blank_page_make("Search", "search", "search", "search", false);
117 page_create_body(page);
120page_search_for_server :: () {
121 page := blank_page_make("Search", "search", "search_results", "search", true);
122 page_create_body(page);