hscc

Soure code of <https://hugo.soucy.cc>.
git clone git://soucy.cc/hscc.git
Log | Files | Refs

commit a6cc7724f8b7eb5d059e80c68f02afabd0839847
parent b313af458f605f9c25ef8e3f6daae069f04cf795
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Mon, 22 Nov 2021 22:41:38 -0500

Continue the add script

Diffstat:
Mbin/add | 49+++++++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/bin/add b/bin/add @@ -7,59 +7,60 @@ do local file = require 'satelito.file' local slugify = require 'satelito.lib.slugify' - local page_title - local page_lua_file - local page_keywords - local page_keywords_table = {} - local page_md_file - local page_name - local page_dir + local content_title + local content_url + local content_lua_file + local content_keywords + local content_keywords_table = {} + local content_md_file + local content_name + local content_dir -- Set the TITLE of the page repeat io.write('Please enter the title of the page: \n') io.flush() - page_title=io.read() + content_title=io.read() - tostring(page_title) - until string.len(page_title) > 0 + tostring(content_title) + until string.len(content_title) > 0 -- Set the KEYWORDS of the note repeat io.write('Please enter the KEYWORDS of the note: \n') io.flush() - page_keywords=io.read() + content_keywords=io.read() - tostring(page_keywords) - until string.len(page_keywords) > 0 + tostring(content_keywords) + until string.len(content_keywords) > 0 -- Convert to table - for keyword in string.gmatch(page_keywords, '([^,]+)') do - table.insert(page_keywords_table, keyword) + for keyword in string.gmatch(content_keywords, '([^,]+)') do + table.insert(content_keywords_table, keyword) end -- Set the structure of the data file - local page_model = { - title = page_title, + local content_model = { + title = content_title, date = os.date('%Y-%m-%d'), datetime = os.date('%H:%M:%S'), - keywords = page_keywords_table + keywords = content_keywords_table } -- Render the markdown file - page_md_file = lustache:render(file.read('archetypes/page.md.mustache'), page_model) + content_md_file = lustache:render(file.read('archetypes/page.md.mustache'), content_model) -- Render the lua data file - page_lua_file = lustache:render(file.read('archetypes/page.lua.mustache'), page_model) - page_name = page_title - page_dir = 'content/' + content_lua_file = lustache:render(file.read('archetypes/page.lua.mustache'), content_model) + content_name = content_title + content_dir = 'content/' -- Make the lua file - file.write(page_dir .. page_name .. '.lua', page_lua_file) + file.write(content_dir .. content_name .. '.lua', content_lua_file) -- Make the markdown file - file.write(page_dir .. page_name .. '.md', page_md_file) + file.write(content_dir .. content_name .. '.md', content_md_file) return end