#!/usr/bin/env luajit local page, entry_list = {}, {} local eval = function (state, action_list) for _, action in ipairs (action_list) do action (state) end end title = function (title) page.title = title end description = function (desc) page.description = desc end game = function (details) table.insert (entry_list, function (page) local entry = {} eval (entry, details) table.insert (page, entry) end) end name = function (name) return function (entry) entry.name = name end end id = function (id) return function (entry) entry.id = id end end released_on = function (date) return function (entry) entry.date = date end end cover = function (file) return function (entry) entry.cover = file end end mature_themes = function (entry) entry.mature_themes = true end flavor_text = function (text) return function (entry) entry.flavor_text = text end end content_description = function (desc) return function (entry) entry.content_description = desc end end credits = function (credits) return function (entry) entry.credits = {} eval (entry.credits, credits) end end downloads = function (downloads) return function (entry) entry.downloads = {} eval (entry.downloads, downloads) end end link = { to = function (to) return { says = function (says) return function (list) table.insert (list, {says = says, to = to}) end end } end } require "entries" eval (page, entry_list) local html_shell = [[ %s

%s

%s

%s


%s
]] local html_entry = [[

& %s &

%s

%s

%s

%s

credits

%s
]] local html_credit = [[

🐑 %s 🐑

]] local html_link = [[%s]] local to_html_downloads = function (downloads) local html_downloads = {} for _, link in ipairs (downloads) do table.insert (html_downloads, html_link :format (link.to, link.says)) end return table.concat (html_downloads, " / ") end local to_html_credits = function (credits) local html_credits = {} for _, link in ipairs (credits) do table.insert (html_credits, html_credit :format (link.to, link.says)) end return table.concat (html_credits, "\n") end local to_html_entry_name_list = function (page) local html_entry_name_list = {} for _, entry in ipairs (page) do table.insert (html_entry_name_list, html_link :format ("#" .. entry.id, entry.name)) end return table.concat (html_entry_name_list, " / ") end local to_html = function (page) local html_entry_list = {} for _, entry in ipairs (page) do local html = html_entry :format ( entry.id, entry.id, entry.name, entry.id, entry.date, entry.cover, entry.flavor_text, entry.content_description, to_html_downloads (entry.downloads or {}), to_html_credits (entry.credits or {}) ) table.insert (html_entry_list, html) end return html_shell :format ( page.title, page.title, page.description, to_html_entry_name_list (page), table.concat (html_entry_list, "
\n") ) end local filter_mature_themes = function (page) local filtered_page = { title = page.title ; description = page.description ; } for _, entry in ipairs (page) do if not entry.mature_themes then table.insert (filtered_page, entry) end end return filtered_page end local write_page = function (info) local html = to_html (info.page) local file = io.open (info.file, "w+") file:write (html) file:close () end local atom_shell = [[ games by and Games made by and https://www.sheeeeeeeep.art/games/%s %sT00:00:00Z %s ]] local atom_entry = [[ %s https://www.sheeeeeeeep.art/games/%s#%s %sT00:00:00Z and NULL ]] local write_atom = function (info) local atom_entries = {} for _, entry in ipairs (info.page) do table.insert (atom_entries, atom_entry:format ( entry.name, info.section, entry.id, info.section, entry.id, entry.date ) ) end local xml = atom_shell:format ( info.file, info.section, os.date ("%Y-%m-%d"), table.concat (atom_entries, "\n") ) local file = io.open (info.file, "w+") file:write (xml) file:close () end table.sort (page, function (a, b) return a.date > b.date end) local filtered_page = filter_mature_themes (page) write_page { page = page ; file = "games.html" ; } write_page { page = filtered_page ; file = "games-filtered.html" ; } write_atom { section = "games.html" ; page = page ; file = "games.atom.xml" ; } write_atom { section = "games-filtered.html" ; page = filtered_page ; file = "games-filtered.atom.xml" ; }