hscc

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

commit 4e1b7f82c18e575959abd303b0cddd3df6b6ef30
parent 0a241d9f20d3b31885633d71d1cddefe46ba9cc2
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Mon, 18 Oct 2021 18:19:33 -0400

Indent

Diffstat:
Mbin/add | 106++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Mbin/bookmark | 160++++++++++++++++++++++++++++++++++++++++----------------------------------------
2 files changed, 142 insertions(+), 124 deletions(-)

diff --git a/bin/add b/bin/add @@ -1,47 +1,65 @@ #!/usr/bin/env lua do - -- - package.path = package.path .. ';'.. arg[0]:match("(.*/)") ..'/?.lua' - -- - local lustache = require 'lustache' - local file = require 'satelito.file' - --local slugify = require 'utils.slugify' - - local page_title - local page_lua_file - local page_md_file - local page_name - local page_dir - - -- Set the TITLE of the page - repeat - io.write('Please enter the title of the page: \n') - io.flush() - - page_title=io.read() - - tostring(page_title) - until string.len(page_title) > 0 - - -- Set the structure of the data file - local page_model = { - title = page_title, - date = os.date('%Y-%m-%d'), - datetime = os.date('%H:%M:%S') - } - - -- Render the markdown file - page_md_file = lustache:render(file.read('archetypes/page.md.mustache'), page_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/' - - -- Make the lua file - file.write(page_dir .. page_name .. '.lua', page_lua_file) - -- Make the markdown file - file.write(page_dir .. page_name .. '.md', page_md_file) - - return + -- + package.path = package.path .. ';'.. arg[0]:match("(.*/)") ..'/?.lua' + -- + local lustache = require 'lustache' + 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 + + -- Set the TITLE of the page + repeat + io.write('Please enter the title of the page: \n') + io.flush() + + page_title=io.read() + + tostring(page_title) + until string.len(page_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() + + tostring(page_keywords) + until string.len(page_keywords) > 0 + + -- Convert to table + for keyword in string.gmatch(page_keywords, '([^,]+)') do + table.insert(page_keywords_table, keyword) + end + + -- Set the structure of the data file + local page_model = { + title = page_title, + date = os.date('%Y-%m-%d'), + datetime = os.date('%H:%M:%S'), + keywords = page_keywords_table + } + + -- Render the markdown file + page_md_file = lustache:render(file.read('archetypes/page.md.mustache'), page_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/' + + -- Make the lua file + file.write(page_dir .. page_name .. '.lua', page_lua_file) + -- Make the markdown file + file.write(page_dir .. page_name .. '.md', page_md_file) + + return end diff --git a/bin/bookmark b/bin/bookmark @@ -1,83 +1,83 @@ #!/usr/bin/env lua do - -- - package.path = package.path .. ';'.. arg[0]:match("(.*/)") ..'/?.lua' - -- - local inspect = require 'inspect' - local lustache = require 'lustache' - local file = require 'utils.file' - local slugify = require 'utils.slugify' - - local bookmark_title - local bookmark_url - local bookmark_keywords - local bookmark_keywords_table = {} - local bookmark_lua_file - local bookmark_md_file - local bookmark_name - local bookmark_dir - - -- Set the TITLE of the bookmark - repeat - io.write('Please enter the title of the bookmark: \n') - io.flush() - - bookmark_title=io.read() - - tostring(bookmark_title) - until string.len(bookmark_title) > 0 - - -- Set the URL of the bookmark - repeat - io.write('Please enter the URL of the bookmark: \n') - io.flush() - - bookmark_url=io.read() - - tostring(bookmark_url) - until string.len(bookmark_url) > 0 - - -- Set the KEYWORDS of the bookmark - repeat - io.write('Please enter the KEYWORDS of the bookmark: \n') - io.flush() - - bookmark_keywords=io.read() - - tostring(bookmark_keywords) - until string.len(bookmark_keywords) > 0 - - -- Convert to table - for keyword in string.gmatch(bookmark_keywords, '([^,]+)') do - table.insert(bookmark_keywords_table, keyword) - end - - --print(inspect(table.pack(bookmark_keywords_table))) - - -- Set the structure of the data file - local bookmark_model = { - title = bookmark_title, - url = bookmark_url, - date = os.date('%Y-%m-%d'), - datetime = os.date('%H:%M:%S'), - posttype = "bookmark", - keywords = bookmark_keywords_table - } - - -- Render the markdown file - bookmark_md_file = lustache:render(file.read('archetypes/bookmark.md.mustache'), bookmark_model) - - -- Render the lua data file - bookmark_lua_file = lustache:render(file.read('archetypes/bookmark.lua.mustache'), bookmark_model) - bookmark_name = slugify(bookmark_title) - bookmark_dir = 'content/' .. os.date('%Y') .. '/mp/' - - -- Make the directory - file.mkdir(bookmark_dir) - -- Make the lua file - file.write(bookmark_dir .. bookmark_name .. '.lua', bookmark_lua_file) - -- Make the lua file - file.write(bookmark_dir .. bookmark_name .. '.md', bookmark_md_file) - - return + -- + package.path = package.path .. ';'.. arg[0]:match("(.*/)") ..'/?.lua' + -- + local inspect = require 'inspect' + local lustache = require 'lustache' + local file = require 'utils.file' + local slugify = require 'utils.slugify' + + local bookmark_title + local bookmark_url + local bookmark_keywords + local bookmark_keywords_table = {} + local bookmark_lua_file + local bookmark_md_file + local bookmark_name + local bookmark_dir + + -- Set the TITLE of the bookmark + repeat + io.write('Please enter the title of the bookmark: \n') + io.flush() + + bookmark_title=io.read() + + tostring(bookmark_title) + until string.len(bookmark_title) > 0 + + -- Set the URL of the bookmark + repeat + io.write('Please enter the URL of the bookmark: \n') + io.flush() + + bookmark_url=io.read() + + tostring(bookmark_url) + until string.len(bookmark_url) > 0 + + -- Set the KEYWORDS of the bookmark + repeat + io.write('Please enter the KEYWORDS of the bookmark: \n') + io.flush() + + bookmark_keywords=io.read() + + tostring(bookmark_keywords) + until string.len(bookmark_keywords) > 0 + + -- Convert to table + for keyword in string.gmatch(bookmark_keywords, '([^,]+)') do + table.insert(bookmark_keywords_table, keyword) + end + + --print(inspect(table.pack(bookmark_keywords_table))) + + -- Set the structure of the data file + local bookmark_model = { + title = bookmark_title, + url = bookmark_url, + date = os.date('%Y-%m-%d'), + datetime = os.date('%H:%M:%S'), + posttype = "bookmark", + keywords = bookmark_keywords_table + } + + -- Render the markdown file + bookmark_md_file = lustache:render(file.read('archetypes/bookmark.md.mustache'), bookmark_model) + + -- Render the lua data file + bookmark_lua_file = lustache:render(file.read('archetypes/bookmark.lua.mustache'), bookmark_model) + bookmark_name = slugify(bookmark_title) + bookmark_dir = 'content/' .. os.date('%Y') .. '/mp/' + + -- Make the directory + file.mkdir(bookmark_dir) + -- Make the lua file + file.write(bookmark_dir .. bookmark_name .. '.lua', bookmark_lua_file) + -- Make the lua file + file.write(bookmark_dir .. bookmark_name .. '.md', bookmark_md_file) + + return end