ferron

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

init.lua (1300B)


      1 --
      2 -- Ferron SSG
      3 --
      4 
      5 -- Get lua_modules in the package.path
      6 require 'ferron.setpaths'
      7 
      8 -- Required Modules
      9 local lfs = require 'lfs'
     10 local site = require 'ferron.site'
     11 local content = require 'ferron.content'
     12 local link = require 'ferron.link'
     13 local makepages = require('ferron.page').makepages
     14 local movestatic = require('ferron.static').init
     15 local plugin =  require 'ferron.plugin'
     16 local tb = require 'ferron.utilities.table-utils'
     17 
     18 -- App's Globals
     19 -- Init the main namespace
     20 Ferron = {
     21   devmode = (arg[2] == '--dev' and true or false),
     22 
     23   site = {
     24     pagestable = {},
     25   },
     26 }
     27 
     28 if arg[1] == 'build' then
     29   do
     30     local sitename
     31     local lastbuild
     32 
     33     if arg[2] ~= '--dev' then
     34       sitename = arg[2]
     35     else
     36       sitename = arg[3]
     37     end
     38 
     39     tb.build{
     40       makepages(site.setsite(sitename)),
     41       link.makeshorts(),
     42       movestatic()
     43     }
     44 
     45     -- Write the last build time in a file
     46     lastbuild = assert(io.open(lfs.currentdir() .. '/lastbuild', 'w+'))
     47     lastbuild:write(os.time())
     48     lastbuild:close()
     49 
     50     return
     51   end
     52 end
     53 
     54 if arg[1] == 'create' then
     55   return content.setcontent(site.setsite())
     56 end
     57 
     58 if arg[1] == 'start' then
     59   return site.startsite()
     60 end
     61 
     62 if arg[1] == 'plugin' and type(arg[2]) == 'string' and arg[2] ~= '' then
     63   return plugin.run(site.setsite(), arg[2])
     64 end