commit 1f43a7829711f06700643c0e431581225400b40e
parent 93cc81b7f347a41e5beda8a8d8e28e3099fc7082
Author: Hugo Soucy <hugo@soucy.cc>
Date: Tue, 18 Dec 2018 20:41:54 -0500
Refactor listsites & makesite functions
Diffstat:
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/ferron/site.lua b/ferron/site.lua
@@ -1,4 +1,3 @@
-local path = require "path"
local lfs = require "lfs"
local config = require "ferron.config"
local tableutils = require "ferron.utilities.table-utils"
@@ -21,11 +20,21 @@ function site.listsites()
-- Create a simple array with the directory name of the sites
local sites_list = {}
- for s in path.each(site.location .. "*", "f", {delay = true; reverse = true;}) do
- if fileutils.isDirectory(s) then
- sites_list[#sites_list+1] = s:match("^.+/(.+)$")
- end
- end
+ tableutils.each(
+ function(s)
+ if fileutils.isDirectory(site.location .. s)
+ and s ~= "."
+ and s ~= ".."
+ then
+ sites_list[#sites_list+1] = s
+ end
+ end,
+ tableutils.settable(lfs.dir(site.location))
+ )
+
+ print(inspect(sites_list))
+
+ os.exit("1")
return sites_list
end
@@ -95,7 +104,9 @@ function site.makesite()
newsite.name = io.read()
newsite.location = site.location .. newsite.name
- path.copy(newsite.sample .. "/*", fileutils.mkdir(newsite.location), {delay = true; recurse = true})
+ fileutils.mkdir(newsite.location)
+
+ os.execute("cp -Rp " .. newsite.sample .. "/*" .. " " .. newsite.location)
if fileutils.isDirectory(newsite.location) then
return print("Your new website is ready to be cutomize here '" .. newsite.location .. "'!")