gemwriter/env.lua

98 lines
2.8 KiB
Lua

local env = {}
-- App information
env.app = {
name = "gemwriter",
exec_name = "gemwriter",
version = "0.3",
last_updated = "2022-08-06",
}
env.defaults = {
config_dir = "$HOME/.config/" .. env.app.exec_name,
config_files = {
atom_entry = "atom.entry.xml",
atom_header = "atom.header.xml",
config = "config.toml",
index = "index.gmi",
page = "page.gmi",
post = "post.gmi",
},
lang_opts = { "en_US", "fr_FR" },
post_slug = "untitled",
post_slug_date_format = "%Y-%m-%d",
-- Atom feed date format
post_date_format = "%Y-%m-%dT%H:%M:%SZ",
post_ext = ".gmi",
post_file_pattern = "[%/](%d%d%d%d%-%d%d%-%d%d)(.*)[%.](%a*)",
page_slug = os.date("%Y%m%d-%H%M%S"),
}
-- Command-line keywords
env.cli_opts = {
config = "config",
page = "page",
post = "post",
index = "index",
publish = "publish",
help = "help",
version = "version",
}
-- Configurable settings
env.toml_vars = {
general = "general",
capsules = "capsules",
}
env.general = {
app_lang = "en_US",
main_capsule = "main",
}
env.capsules = {
main = {
author = "Gem",
title = "Gemlog",
subtitle = "A Gemini log",
url = "gemini://domain.tld",
log_url = "gemini://domain.tld/log",
capsule_dir = env.defaults.config_dir .. "/capsule",
gemlog_dir = env.defaults.config_dir .. "/capsule/log",
gen_index_page = true,
index_page = "index.gmi",
gen_atom_feed = true,
atom_feed = "atom.xml",
transfer_mode = "scp",
scp_exec = "/usr/bin/scp",
scp_target = "/path/to/remote/capsule",
rsync_exec = "/usr/bin/rsync",
rsync_options = "-avz",
rsync_dest = "/path/to/remote/capsule",
},
}
env.defaults_toml = [[
[]] .. env.toml_vars.general .. [[]
app_lang = "]] .. env.general.app_lang .. [["
main_capsule = "]] .. env.general.main_capsule .. [["
[]] .. env.toml_vars.capsules .. "." .. env.general.main_capsule .. [[]
author = "]] .. env.capsules.main.author .. [["
title = "]] .. env.capsules.main.title .. [["
subtitle = "]] .. env.capsules.main.subtitle .. [["
url = "]] .. env.capsules.main.url .. [["
log_url = "]] .. env.capsules.main.log_url .. [["
capsule_dir = "]] .. env.capsules.main.capsule_dir .. [["
gemlog_dir = "]] .. env.capsules.main.gemlog_dir .. [["
gen_index_page = "]] .. tostring(env.capsules.main.gen_index_page) .. [["
index_page = "]] .. env.capsules.main.index_page .. [["
gen_atom_feed = "]] .. tostring(env.capsules.main.gen_atom_feed) .. [["
atom_feed = "]] .. env.capsules.main.atom_feed .. [["
transfer_mode = "]] .. env.capsules.main.transfer_mode .. [["
scp_exec = "]] .. env.capsules.main.scp_exec .. [["
scp_target = "]] .. env.capsules.main.scp_target .. [["
rsync_exec = "]] .. env.capsules.main.rsync_exec .. [["
rsync_options = "]] .. env.capsules.main.rsync_options .. [["
rsync_dest = "]] .. env.capsules.main.rsync_dest .. [["
]]
return env