/** TODO: Instead of maintaining pages here in code, create a more generic approach. */ page_entries :: (html_diet: [..][]string) { my_entries := commit_make("entries", html_diet); page: Page_Metadata; page.template = "entries_all"; page.file_name = "allposts"; page.commits = .[ my_entries ]; page.dont_create_nav_button = true; page_create_body(page); } page_entries_limited :: (html_diet: [..][]string) { html := array_copy(html_diet); html.count = min(html.count, PAGE_ENTRIES_MAX); entries_counts := string.[ tprint("%", PAGE_ENTRIES_MAX), tprint("%", html_diet.count), ]; my_entries := commit_make("entries", html); counters := commit_make("max_entries", entries_counts); page: Page_Metadata; page.name = "Home"; page.template = "entries_limited"; page.url = "/"; page.file_name = "index"; page.commits = .[ my_entries, counters ]; page_create_body(page); } page_entry :: (entry: Entry, html: []string) { make_css_style :: (width: string) -> string { return tprint("style=\"max-width: %px;\"", width); } fp := tprint("%/%", DIR_WWW_POSTS, entry.uri); content := commit_make("entry", html); css := ifx entry.width then make_css_style(entry.width) else ""; style := commit_make("css", css); page: Page_Metadata; page.name = entry.title; page.template = "entry"; page.file_name = fp; page.commits = .[ content, style ]; page.dont_create_nav_button = true; page.store_on_top_level = false; page_create_body(page); } /** Create and save the individual posts to disk */ page_entries_to_disk :: (entries: []Entry, html: [..][]string) { for entries { page_entry(it, html[it_index]); } } page_rss :: (entries: []Entry) -> string { rss_items := rss_make_items(entries); rss_channel := rss_make_channel(rss_items); return rss_channel; } page_overview :: (html: [..][]string) { content := commit_make("entries", html); page: Page_Metadata; page.template = "overview"; page.file_name = "allitems"; page.commits = .[ content ]; page.dont_create_nav_button = true; page_create_body(page); } page_overview_limited :: (html: [..][]string) { html_new := array_copy(html); html_new.count = min(html.count, PAGE_OVERVIEW_ITEMS_MAX); items_counts := string.[ tprint("%", PAGE_OVERVIEW_ITEMS_MAX), tprint("%", html.count), ]; content := commit_make("entries", html_new); counters := commit_make("max_items", items_counts); page: Page_Metadata; page.name = "Overview"; page.template = "overview_limited"; page.url = "overview"; page.file_name = "overview"; page.commits = .[ content, counters ]; page_create_body(page); } page_privacy :: () { log("coconut.png - because of context cringe"); page := generic_page_make("privacy", "privacy", "privacy", dont_add_to_navbar=true); page_create_body(page); } page_search :: () { page := blank_page_make("Search", "search", "search", "search", false); page_create_body(page); } page_search_for_server :: () { page := blank_page_make("Search", "search", "search_results", "search", true); page_create_body(page); }