2121 error, errorf, fileError, errorNoPos
2222 F, formatBytes, formatTemplate
2323 generateFromTemplateString, generateFromTemplateFile, generateRedirection
24+ generateNonPages
2425 generatorMeta
2526 getCwd
2627 getDirectory, getFilename, getExtension, getBasename
735736 -- stringResult = parseAndRunTemplate( page, path, template, fileType=fromPage, useCache, onPageInit=nil )
736737 -- onPageInit = function( wrappedPage )
737738 function _G.parseAndRunTemplate(page, path, template, fileType, useCache, onPageInit)
738- if template == "" and not onPageInit then return "" end
739+ -- timestampPrintVerbose("--> Template(start): %s", path)
740+ local result
739741
740- fileType = (fileType or site._fileTypes[page._extension])
742+ if template == "" and not onPageInit then
743+ result = ""
741744
742- !local PRINT_RESULT = DEV and 1==0
743- local result
745+ else
746+ fileType = (fileType or site._fileTypes[page._extension])
744747
745- if fileType == "markdown" then
746- result = _parseAndRunTemplate(page, path, template, useCache, onPageInit, true)
747- result = markdownToHtml(result)
748- result = trimNewlines(result).."\n" -- :Beautify
749- !if PRINT_RESULT then __LUA` print"-- HTML --" print(result) print"-- /HTML --" ` end
748+ !local PRINT_RESULT = DEV and 1==0
750749
751- elseif fileType == "html" then
752- result = _parseAndRunTemplate(page, path, template, useCache, onPageInit, true)
753- result = trimNewlines(result).."\n" -- :Beautify
754- !if PRINT_RESULT then __LUA` print"-- HTML --" print(result) print"-- /HTML --" ` end
750+ if fileType == "markdown" then
751+ result = _parseAndRunTemplate(page, path, template, useCache, onPageInit, true)
752+ result = markdownToHtml(result)
753+ result = trimNewlines(result).."\n" -- :Beautify
754+ !if PRINT_RESULT then __LUA` print"-- HTML --" print(result) print"-- /HTML --" ` end
755755
756- elseif fileType == "xml " then
757- result = _parseAndRunTemplate(page, path, template, useCache, onPageInit, true)
758- result = trimNewlines(result).."\n" -- :Beautify
759- !if PRINT_RESULT then __LUA` print"-- XML --" print(result) print"-- /XML --" ` end
756+ elseif fileType == "html " then
757+ result = _parseAndRunTemplate(page, path, template, useCache, onPageInit, true)
758+ result = trimNewlines(result).."\n" -- :Beautify
759+ !if PRINT_RESULT then __LUA` print"-- HTML --" print(result) print"-- /HTML --" ` end
760760
761- else
762- result = _parseAndRunTemplate(page, path, template, useCache, onPageInit, false)
763- result = trimNewlines(result).."\n" -- :Beautify
764- !if PRINT_RESULT then __LUA` print"-- result --" print(result) print"-- /result --" ` end
761+ elseif fileType == "xml" then
762+ result = _parseAndRunTemplate(page, path, template, useCache, onPageInit, true)
763+ result = trimNewlines(result).."\n" -- :Beautify
764+ !if PRINT_RESULT then __LUA` print"-- XML --" print(result) print"-- /XML --" ` end
765+
766+ else
767+ result = _parseAndRunTemplate(page, path, template, useCache, onPageInit, false)
768+ result = trimNewlines(result).."\n" -- :Beautify
769+ !if PRINT_RESULT then __LUA` print"-- result --" print(result) print"-- /result --" ` end
770+ end
765771 end
766772
773+ -- timestampPrintVerbose("--> Template(finish): %s", path)
767774 return result
768775 end
769776
@@ -1750,6 +1757,7 @@ function _G.generateFromTemplateString(page, template, modTime, onPageInit)
17501757 local ext = getExtension(filename)
17511758 local extLower = ext:lower()
17521759
1760+ timestampPrintVerbose("--> Processing(start): %s", page._path)
17531761 local result
17541762
17551763 if page.isPage.v then
@@ -1762,6 +1770,8 @@ function _G.generateFromTemplateString(page, template, modTime, onPageInit)
17621770 (page.isDraft.v and not includeDrafts ) or -- Is draft?
17631771 (datetimeToTime(page.publishDate:g()) > nowTime) -- Is in future?
17641772 then
1773+ timestampPrintVerbose("--> Processing(abort): %s", page._path)
1774+
17651775 page._isSkipped = true
17661776 site._outputFileSkippedPageCount = site._outputFileSkippedPageCount + 1
17671777
@@ -1787,13 +1797,17 @@ function _G.generateFromTemplateString(page, template, modTime, onPageInit)
17871797 result = parseAndRunTemplate(page, page._pathForError, template, nil, false, onPageInit)
17881798 end
17891799
1800+ timestampPrintVerbose("--> Processing(finish): %s", page._path)
1801+
17901802 writeOutputFile(page._category, page._pathOut, page.url.v, result, modTime, page._path)
17911803 page._isGenerated = true
17921804
17931805 page._isGenerating = false
17941806 site._pagesGenerating[page._pathOut] = nil
17951807end
17961808
1809+ -- generateFromTemplateFile( page )
1810+ -- Does nothing for skipped pages, or pages that are currently generating but are safely locked.
17971811function _G.generateFromTemplateFile(page)
17981812 if page._isSkipped then return end
17991813 if page._isGenerating and page._isLocked then return end -- Allowed recursion.
@@ -1892,6 +1906,16 @@ end
18921906
18931907
18941908
1909+ function _G.generateNonPages()
1910+ for _, page in ipairs(site._nonPagePages) do
1911+ if not page._isGenerated then
1912+ generateFromTemplateFile(page) -- Note that this template may trigger generation of actual pages at some point before it finishes (e.g. by calling subpages()).
1913+ end
1914+ end
1915+ end
1916+
1917+
1918+
18951919function _G.indexOf(t, v)
18961920 for i, item in ipairs(t) do
18971921 if item == v then return i end
@@ -2221,7 +2245,8 @@ function _G.newSite()
22212245
22222246 _scripts = newScriptFolderReader(DIR_SCRIPTS),
22232247
2224- _pages = {--[[ page1, ... ]]},
2248+ _pages = {--[[ page1, ... ]]}, -- Page with isPage==true.
2249+ _nonPagePages = {--[[ page1, ... ]]}, -- Page with isPage==false.
22252250 _pagesGenerating = {--[[ [pathRelOut1]=true, ... ]]},
22262251
22272252 _writtenOutputEntries = {--[[ { path=pathRel1, pathOut=pathOutputRel1, url=url1 }, ... ]]},
0 commit comments