ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit 1444733bdcd4f45f2e2a9aec619efe5868b2d3e1
parent 2776fef553fabe98fab83f48646a816238f5d02b
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Thu, 23 Aug 2018 10:36:29 -0400

Add a reset function

Diffstat:
Mferron/site.lua | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/ferron/site.lua b/ferron/site.lua @@ -15,14 +15,14 @@ function site.listsites() if path.isdir(s) then sites_list[#sites_list+1] = s:match("^.+/(.+)$") end - end + end return sites_list end function site.getsiteinfos(sitename) package.path = package.path .. ";sites/".. sitename .."/?.lua" - + local site = Ferron.sites .. sitename local site_config = require "site-config" local site_infos = {} @@ -32,7 +32,7 @@ function site.getsiteinfos(sitename) path = site, siteconfig = site_config, pagestable = {}, - } + } return site_infos end @@ -56,7 +56,7 @@ function site.setsite() until (tableutils.haskey(sites_list, tonumber(whichsite))) == true Ferron.site = site.getsiteinfos(sites_list[tonumber(whichsite)]) - Ferron.site.siteconfig.baseurl = (Ferron.devmode == true and Ferron.site.siteconfig.urldev or Ferron.site.siteconfig.url) + Ferron.site.siteconfig.baseurl = (Ferron.devmode == true and Ferron.site.siteconfig.urldev or Ferron.site.siteconfig.url) return Ferron.site end @@ -70,17 +70,14 @@ function site.makesite() sample = Ferron.sites .. "ferron-ssg.tld", } - -- print(inspect(newsite)) - -- os.exit('1') - io.write("How do you want names your new website? \n") io.write("Please enter that name below... \n") io.flush() newsite.name = io.read() newsite.location = Ferron.sites .. newsite.name - - path.copy(newsite.sample .. "/*", path.mkdir(newsite.location), {delay = true; recurse = true}) + + path.copy(newsite.sample .. "/*", path.mkdir(newsite.location), {delay = true; recurse = true}) if path.isdir(newsite.location) then return print("Your new website is ready to be cutomize here '" .. newsite.location .. "'!") @@ -89,4 +86,9 @@ function site.makesite() end end +function site.reset() + -- Reset the `public_html/` folder of the selected site + fileutils.emptydirectory(Ferron.site.path .. Ferron.site.siteconfig.paths.html .. "/") +end + return site