Skip to content

Commit

Permalink
Fixed --fullpaths not always showing correct paths.
Browse files Browse the repository at this point in the history
Added links to website.
Updated changelog.
  • Loading branch information
ReFreezed committed Jun 1, 2021
1 parent 25e4351 commit 5480582
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 26 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CSS files can also include code.
- [Windows](#windows)
- [Universal](#universal)
- [Build Website](#build-website)
- [Documentation](https://github.com/ReFreezed/LuaWebGen/wiki)
- [Documentation](http://luawebgen.refreezed.com/docs/)



Expand Down Expand Up @@ -80,6 +80,8 @@ Page layout template, `page.html`:
{{ include"footer" }}
```

See more examples in the [examples folder](https://github.com/ReFreezed/LuaWebGen/tree/master/examples).



## Installation / Usage
Expand Down Expand Up @@ -134,7 +136,7 @@ lua path/to/webgen.lua command [options]
### Build Website

To generate a new empty website, run something like this from the
[command line](https://github.com/ReFreezed/LuaWebGen/wiki/Command-Line):
[command line](http://luawebgen.refreezed.com/docs/command-line/):

```batch
webgen new site "my-website"
Expand All @@ -143,7 +145,7 @@ webgen new page "blog/first-post.md"
webgen build
```

LuaWebGen uses this [folder structure](https://github.com/ReFreezed/LuaWebGen/wiki/Home#folder-structure) for a website project:
LuaWebGen uses this [folder structure](http://luawebgen.refreezed.com/docs/#folder-structure) for a website project:

```
my-website/ -- Root of the website project.
Expand All @@ -159,6 +161,6 @@ my-website/ -- Root of the website project.

Everything in the *content* folder will be processed and end up in the *output* folder.

See the [wiki](https://github.com/ReFreezed/LuaWebGen/wiki) for the full documentation.
See the [website](http://luawebgen.refreezed.com/docs/) for the full documentation.


13 changes: 13 additions & 0 deletions build/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Changelog
LuaWebGen

v1.4 (2021-06-01)
- Added syntax for heredoc strings.
- Added functions: percent(), urlRaw().
- Added options: --baseurloverride, --meta, --fullpaths, --nogc.
- Added better example sites.
- Better support for when baseUrl is pointing to a subdirectory. (url(), {{url}} and other related code now fixes relative paths.)
- include() can now take take extra arguments for the target layout to receive.
- A warning is printed when page.date hasn't been updated for a page (except for index and special pages).
- Much faster getImageDimensions() for most images.
- Fixed "#" in redirection targets getting messed up and messing other stuff up.
- Fixed config.rewriteOutputPath() sometimes having the wrong context.
- Fixed a couple of error messages missing some information.

v1.3.1 (2021-05-25)
- Fixed non-page templates not getting processed before pages.
- Added minimal example site.
Expand Down
11 changes: 7 additions & 4 deletions build/README.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
LuaWebGen
Developed by Marcus 'ReFreezed' Thunström

Website: https://github.com/ReFreezed/LuaWebGen
Documentation: https://github.com/ReFreezed/LuaWebGen/wiki
Website: http://luawebgen.refreezed.com/
Documentation: http://luawebgen.refreezed.com/docs/
Repository: https://github.com/ReFreezed/LuaWebGen

1. Disclaimer
2. Installation / Usage
Expand Down Expand Up @@ -98,8 +99,8 @@ Everything in the 'content' folder will be processed and end up in the
(Note: The 'output' folder is automatically cleaned from files and folders that
do not exist in the 'content' folder, so don't save files in the 'output' folder!)

See the wiki for the full documentation:
https://github.com/ReFreezed/LuaWebGen/wiki
See the website for the full documentation:
http://luawebgen.refreezed.com/docs/



Expand Down Expand Up @@ -140,6 +141,8 @@ Page layout template, page.html:

{{include"footer"}}

See more examples in the [repository](https://github.com/ReFreezed/LuaWebGen/tree/master/examples).



==============================================================================
2 changes: 1 addition & 1 deletion build/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.1
1.4.0
4 changes: 2 additions & 2 deletions examples/testsite/layouts/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
{{ site.title }}
</title>

<link rel="canonical" href="{{ page.permalink }}">
<link rel="canonical" href="{{ url(page.permalink) }}">

<link rel="alternate" type="application/rss+xml" href="{{ site.baseUrl.."feed.rss" }}" title="{{ site.title }}">
<link rel="alternate" type="application/rss+xml" href="{{ url(site.baseUrl.."feed.rss") }}" title="{{ site.title }}">

<link rel="stylesheet" href="{{ /css/style.css }}">

Expand Down
10 changes: 5 additions & 5 deletions src/app.lua2p
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,17 @@ local function setup()
elseif arg == "--verbose" then
_G.verbosePrint = true

elseif arg == "--meta" then -- @Doc?
elseif arg == "--meta" then
_G.outputMetaprograms = true

elseif arg == "--nogc" then -- @Doc?
elseif arg == "--nogc" then
_G.enableGc = false
collectgarbage("stop")

elseif arg == "--fullpaths" then -- @Doc?
elseif arg == "--fullpaths" then
_G.useFullPaths = true

elseif arg == "--baseurloverride" then -- @Doc?
elseif arg == "--baseurloverride" then
i = i + 1
_G.baseUrlOverride = programArguments[i] or errorNoPos("[Arguments] Missing URL after '%s'.", argRaw)
arg = arg .. '"' .. baseUrlOverride .. '"'
Expand Down Expand Up @@ -1072,7 +1072,7 @@ local function setup()
scriptEnvironmentGlobals.echoRaw(s:format(...))
end,

include = function(htmlFileBasename, ...) -- @Doc: Extra arguments.
include = function(htmlFileBasename, ...)
assertContext("template", "include")
if htmlFileBasename:find"^/" then
errorf(2, "Filename is not valid: %s", htmlFileBasename)
Expand Down
18 changes: 8 additions & 10 deletions src/functions.lua2p
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,6 @@ do
-- stringResult = parseAndRunTemplate( page, path, template, fileType=fromPage, useCache, onPageInit=nil, packedArguments=nil )
-- onPageInit = function( wrappedPage )
function _G.parseAndRunTemplate(page, path, template, fileType, useCache, onPageInit, args)
-- timestampPrintVerbose("--> Template(start): %s", maybeFullPath(path))
local result

if template == "" and not onPageInit then
Expand Down Expand Up @@ -864,7 +863,6 @@ do
end
end

-- timestampPrintVerbose("--> Template(finish): %s", maybeFullPath(path))
return result
end

Expand Down Expand Up @@ -991,7 +989,7 @@ function _G.writeOutputFile(category, pathRel, url, data, modTime, sourcePath)
if site._fileProcessors[extLower] then
!PUSH_CONTEXT "none"
local sourceSitePathRel = (sourcePath ~= "") and pathToSitePath(sourcePath) or ""
data = site._fileProcessors[extLower](data, sourceSitePathRel) -- @Doc sourceSitePathRel?
data = site._fileProcessors[extLower](data, sourceSitePathRel)
!POP_CONTEXT()

if type(data) ~= "string" then
Expand Down Expand Up @@ -1901,10 +1899,10 @@ function _G.generateFromTemplateString(page, template, modTime, onPageInit)
local pathRelOut = page._pathOut

if page._isGenerated then
errorf(2, "Page has already generated. (%s)", maybeFullPath(pathRel))
errorf(2, "Page has already generated. (%s)", maybeFullPath(page._contentRealPath))
end
if page._isGenerating or site._pagesGenerating[pathRelOut] then
errorf(2, "Recursive page generation detected. (You may want to call lock() in '%s')", maybeFullPath(pathRel))
errorf(2, "Recursive page generation detected. (You may want to call lock() in '%s')", maybeFullPath(page._contentRealPath))
end

page._isGenerating = true
Expand All @@ -1914,7 +1912,7 @@ function _G.generateFromTemplateString(page, template, modTime, onPageInit)
local ext = getExtension(filename)
local extLower = ext:lower()

timestampPrintVerbose("--> Processing(start): %s", maybeFullPath(pathRel))
timestampPrintVerbose("--> Processing(start): %s", maybeFullPath(page._contentRealPath))
local result

if page.isPage.v then
Expand All @@ -1927,7 +1925,7 @@ function _G.generateFromTemplateString(page, template, modTime, onPageInit)
(page.isDraft.v and not includeDrafts ) or -- Is draft?
(datetimeToTime(page.publishDate:g()) > nowTime) -- Is in future?
then
timestampPrintVerbose("--> Processing(abort): %s", maybeFullPath(pathRel))
timestampPrintVerbose("--> Processing(abort): %s", maybeFullPath(page._contentRealPath))

page._isSkipped = true
site._outputFileSkippedPageCount = site._outputFileSkippedPageCount + 1
Expand All @@ -1939,7 +1937,7 @@ function _G.generateFromTemplateString(page, template, modTime, onPageInit)

if not (page.isIndex.v or page.isSpecial.v) and not page._dateHasBeenUpdated then
-- @UX: Should there be an option to disable this? Maybe an option for suppressing all warnings?
timestampPrintWarning("%s did not update page.date.", maybeFullPath(pathRel))
timestampPrintWarning("%s did not update page.date.", maybeFullPath(page._contentRealPath))
end

page.content.v = pageContent
Expand All @@ -1959,7 +1957,7 @@ function _G.generateFromTemplateString(page, template, modTime, onPageInit)
result = parseAndRunTemplate(page, page._contentRealPath, template, nil, false, onPageInit, nil)
end

timestampPrintVerbose("--> Processing(finish): %s", maybeFullPath(pathRel))
timestampPrintVerbose("--> Processing(finish): %s", maybeFullPath(page._contentRealPath))

writeOutputFile(page._category, pathRelOut, page.url.v, result, modTime, pathRel)
page._isGenerated = true
Expand Down Expand Up @@ -2129,7 +2127,7 @@ function _G.getLayoutTemplate(page)

local template, err = getFileContentsText(path)
if not template then
errorf("%s: Could not load layout '%s'. (%s)", maybeFullPath(page._path), page.layout.v, err)
errorf("%s: Could not load layout '%s'. (%s)", maybeFullPath(page._contentRealPath), page.layout.v, err)
end

site._layoutTemplates[path] = template
Expand Down

0 comments on commit 5480582

Please sign in to comment.