hscc

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

commit 21edf9e8023c546f9393e19ab96838b696b79d1d
parent 5c2961270dfb1b74a0b2b07bda60f2ca9e22cb19
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Thu, 14 Oct 2021 19:47:36 -0400

Test new lua bin script

Diffstat:
Abin/add | 47+++++++++++++++++++++++++++++++++++++++++++++++
Abin/test | 7+++++++
2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/bin/add b/bin/add @@ -0,0 +1,47 @@ +#!/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 +end diff --git a/bin/test b/bin/test @@ -0,0 +1,7 @@ +#!/usr/bin/env lua + +local file = 'satelito.file' + +do + print(package.path) +end