diff --git a/gtc_gen.v b/gtc_gen.v
index 883c0f1..96317fa 100644
--- a/gtc_gen.v
+++ b/gtc_gen.v
@@ -11,17 +11,16 @@ const (
)
struct Cfg {
- base_directory string = '${os.getenv('HOME')}/.gtc_gen'
- editor string = os.getenv('EDITOR')
+ base_directory string = '${os.getenv('HOME')}/.gtc_gen'
application_name string = 'gtc_gen'
- about_file string = '${os.getenv('HOME')}/.gtc_gen.about'
- auth string = genv('GTC_GEN_AUTH', 'unknown')
- mail string = genv('GTC_GEN_MAIL', 'unknown@example.org')
- site_name string = genv('GTC_GEN_SITE', 'gtc_gen -site')
- target string = genv('GTC_GEN_TARGET', './site')
- url string = genv('GTC_GEN_URL', 'https://example.org')
- entries_dir string = os.join_path(genv('GTC_GEN_TARGET', './site'),'entries')
- copyleft string = 'License: CC-BY-SA-4.0'
+ about_file string = '${os.getenv('HOME')}/.gtc_gen.about'
+ auth string = genv('GTC_GEN_AUTH', 'unknown')
+ mail string = genv('GTC_GEN_MAIL', 'unknown@example.org')
+ site_name string = genv('GTC_GEN_SITE', 'gtc_gen -site')
+ target string = genv('GTC_GEN_TARGET', './site')
+ url string = genv('GTC_GEN_URL', 'https://example.org')
+ entries_dir string = os.join_path(genv('GTC_GEN_TARGET', './site'),'entries')
+ copyleft string = genv('GTC_GEN_LICENSE', 'License: CC-BY-SA-4.0')
}
fn main() {
@@ -29,21 +28,17 @@ fn main() {
if !os.is_dir(c.base_directory) {os.mkdir(c.base_directory) or {panic(err)}}
if os.args.len != 2 { help() }
match os.args[1] {
- 'a' { os.execvp(c.editor,
- [os.join_path(c.base_directory, '${now().unix}.post')])
- or { panic(err) } }
+ 'a' { os.execvp(genv('EDITOR', 'vi'), [os.join_path(c.base_directory, '${now().unix}.post')]) or { panic(err) } }
'm' { c.make() }
else { help() }
}
}
-fn genv(k string, d string) string {
- if os.getenv(k) != '' { return os.getenv(k) } else {return d}
-}
+fn genv(k string, d string) string { if os.getenv(k) != '' { return os.getenv(k) } else {return d} }
fn parse_links(input string) string {
mut re := regex.regex_opt(query) or { panic(err) }
- mut output := ''
+ mut output := input
for l in re.find_all_str(input) {output=input.replace(l, "${l}")}
return output
}
@@ -54,7 +49,10 @@ fn (c Cfg) make_entries_list() string {
for p in posts {
content := os.read_file(p) or { panic(err) }
lines := content.split_into_lines()
- if lines.len < 1 { continue }
+ if lines.len < 1 {
+ println("$p has no lines")
+ continue
+ }
name := p.split('/').last().trim('.post')
ts := time.unix(name.int())
title := lines[0].capitalize()
@@ -90,7 +88,7 @@ fn help() {
println("gtc_gen - made by sarmonsiill \n
\tgtc_gen a\tadd a new post\n\tgtc_gen m\ttranspile posts
\n--\nEnvironment variables\n\n\tGTC_GEN_AUTH\tname of author
-\tGTC_GEN_MAIL\temail of author\n\tGTC_GEN_SITE\tsite title
+\tGTC_GEN_MAIL\temail of author\n\tGTC_GEN_SITE\tsite title\n\tGTC_GEN_LICENSE\tlicense of the content
\tGTC_GEN_TARGET\tsite output\n\tGTC_GEN_URL\tdomain of the site. incl https://
\nFirst line of the post will become the header. Filename will become timestamp.
posts are stored in \$HOME/.gtc_gen\n~/.gtc_gen.about is uses as an about -section on the index.")