Skip to content

Commit 238bfa8

Browse files
committed
GD and LuaSocket are not strictly required anymore - only when needed. Fixed improper error handling in getImageDimensions(). Some cleanup.
1 parent d2c8832 commit 238bfa8

File tree

6 files changed

+473
-209
lines changed

6 files changed

+473
-209
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright © 2018 Marcus 'ReFreezed' Thunström
3+
Copyright © 2018-2021 Marcus 'ReFreezed' Thunström
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

main.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exec lua "$0" "$@"
99
--=
1010
--= MIT License
1111
--=
12-
--= Copyright © 2018 Marcus 'ReFreezed' Thunström
12+
--= Copyright © 2018-2021 Marcus 'ReFreezed' Thunström
1313
--=
1414
--= Permission is hereby granted, free of charge, to any person obtaining a copy
1515
--= of this software and associated documentation files (the "Software"), to deal
@@ -31,16 +31,16 @@ exec lua "$0" "$@"
3131
--=
3232
--============================================================]]
3333

34-
local folder = debug.getinfo(1, "S").source :gsub("^@", "") :gsub("[^/\\]+$", "")
35-
package.path = folder.."src/?.lua;"..folder.."lib/?.lua;"..package.path
34+
local dir = debug.getinfo(1, "S").source :gsub("^@", "") :gsub("[^/\\]+$", "")
35+
package.path = dir .. "src/?.lua;" .. dir .. "lib/?.lua;" .. package.path
3636

3737
math.randomseed(os.time())
3838
math.random() -- Gotta kickstart the randomness.
3939

4040
require"globals"
4141
require"functions"
4242

43-
_G.args = {...}
43+
_G.args = arg
4444

4545
local ok, err = xpcall(
4646
function()

src/app.lua

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
--=
1111
--============================================================]]
1212

13+
io.stdout:setvbuf("no")
14+
io.stderr:setvbuf("no")
15+
1316

1417

1518
-- Parse arguments.
@@ -21,7 +24,7 @@ local command = args[i] or error("[arg] Missing command.")
2124
i = i+1
2225

2326
_G.ignoreModificationTimes = false
24-
_G.autobuild = false
27+
_G.autobuild = false
2528

2629
----------------------------------------------------------------
2730

@@ -176,10 +179,10 @@ elseif command == "build" then
176179
local arg = args[i]
177180

178181
if arg == "--force" or arg == "-f" then
179-
ignoreModificationTimes = true
182+
_G.ignoreModificationTimes = true
180183

181184
elseif arg == "--autobuild" or arg == "-a" then
182-
autobuild = true
185+
_G.autobuild = true
183186

184187
elseif arg == "--drafts" or arg == "-d" then
185188
includeDrafts = true
@@ -243,7 +246,7 @@ end
243246
--==============================================================
244247

245248
scriptEnvironmentGlobals = {
246-
_WEBGEN_VERSION = _WEBGEN_VERSION,
249+
_WEBGEN_VERSION = WEBGEN_VERSION,
247250
DATA_FILE_EXTENSIONS = DATA_FILE_EXTENSIONS,
248251
IMAGE_EXTENSIONS = IMAGE_EXTENSIONS,
249252

@@ -302,7 +305,7 @@ scriptEnvironmentGlobals = {
302305

303306
-- Lua libraries.
304307
lfs = lfs,
305-
socket = socket,
308+
socket = socket, -- May be nil.
306309

307310
-- Site objects. (Create at site generation.)
308311
site = nil,
@@ -844,7 +847,7 @@ scriptEnvironment = setmetatable({}, {
844847
--==============================================================
845848

846849
local function buildWebsite()
847-
local startTime = socket.gettime()
850+
local startTime = getTimeBetter()
848851

849852
oncePrints = {}
850853
resetSiteVariables()
@@ -961,7 +964,7 @@ local function buildWebsite()
961964
end
962965

963966
-- Validate config.baseUrl
964-
local parsedUrl = socket.url.parse(site.baseUrl.v)
967+
local parsedUrl = require"url".parse(site.baseUrl.v)
965968

966969
if site.baseUrl.v == "" then
967970
errorf("config.baseUrl is missing or empty.", site.baseUrl.v)
@@ -1233,7 +1236,7 @@ local function buildWebsite()
12331236
logprint("Error: Context stack is not empty after generation. (Depth is %d)", #contextStack)
12341237
end
12351238

1236-
local endTime = socket.gettime()
1239+
local endTime = getTimeBetter()
12371240

12381241
printf(("-"):rep(64))
12391242
printf("Files: %d", outputFileCount)
@@ -1260,7 +1263,7 @@ if autobuild then
12601263
local lastDirTree = nil
12611264

12621265
while true do
1263-
socket.sleep(AUTOBUILD_MIN_INTERVAL)
1266+
sleep(AUTOBUILD_MIN_INTERVAL)
12641267

12651268
local dirTree = {}
12661269
local somethingChanged = false

0 commit comments

Comments
 (0)