mirror of
https://notabug.org/scuti/pleroma-comments
synced 2025-01-24 12:12:13 +05:30
set directory for avatars in config.lua
This commit is contained in:
parent
4ab3993fa8
commit
799e7ae0bd
@ -1,8 +1,27 @@
|
|||||||
|
|
||||||
-- can't resolve seggfault on luasec, luasocket'
|
|
||||||
-- local https = "wget"
|
|
||||||
local json = require("cjson")
|
local json = require("cjson")
|
||||||
|
|
||||||
|
pleroma_avatar_save_path = nil -- location of downloaded images
|
||||||
|
pleroma_avatar_path = nil -- prepended to image file, written on page
|
||||||
|
-- to configure, put above vars in a file named 'config.lua'
|
||||||
|
pcall(
|
||||||
|
function ()
|
||||||
|
dofile("config.lua")
|
||||||
|
end
|
||||||
|
)
|
||||||
|
--[[
|
||||||
|
|
||||||
|
if these variables are still `nil` after `dofile()` then
|
||||||
|
the script will look for it in the yaml header.
|
||||||
|
|
||||||
|
note: lua filters can not access variables defined on the command line,
|
||||||
|
e.g `pandoc -V foo="bar"`
|
||||||
|
and it may not be ideal to define paths in yaml headers,
|
||||||
|
i.e changing the path for avatars on a website would involve editing each
|
||||||
|
manuscript.
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
-- for testing
|
-- for testing
|
||||||
function printTable(t)
|
function printTable(t)
|
||||||
if t then
|
if t then
|
||||||
@ -347,17 +366,22 @@ function Meta(meta)
|
|||||||
return -- abort
|
return -- abort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- if both are defined, then do not hotlink avatars
|
||||||
|
if not pleroma_avatar_save_path then
|
||||||
|
pleroma_avatar_save_path = meta["pleroma-avatar-save-path"]
|
||||||
|
end
|
||||||
|
if not pleroma_avatar_path then
|
||||||
|
pleroma_avatar_path = meta["pleroma-avatar-path"]
|
||||||
|
end
|
||||||
-- most servers appear to serve hotilnked avatars however
|
-- most servers appear to serve hotilnked avatars however
|
||||||
-- images will be missing in case of downtime or shutdown
|
-- images will be missing in case of downtime or shutdown
|
||||||
local is_hotlink = true
|
-- OR a user has changed their avatar and the old avatar gets deleted
|
||||||
-- where to save downloaded avatars
|
|
||||||
local pleroma_avatar_save_path = meta["pleroma-avatar-save-path"]
|
-- var currently unused
|
||||||
-- (page) path written on the page-
|
-- local is_hotlink = true
|
||||||
local pleroma_avatar_path = meta["pleroma-avatar-path"]
|
-- if pleroma_avatar_save_path and pleroma_avatar_path then
|
||||||
-- if both are defined, then do not hotlink avatars
|
-- is_hotlink = false
|
||||||
if pleroma_avatar_save_path and pleroma_avatar_path then
|
-- end
|
||||||
is_hotlink = false
|
|
||||||
end
|
|
||||||
|
|
||||||
local all_replies = {}
|
local all_replies = {}
|
||||||
local hrefs = {}
|
local hrefs = {}
|
||||||
@ -385,11 +409,9 @@ function Meta(meta)
|
|||||||
local c, i, l = write_comments(
|
local c, i, l = write_comments(
|
||||||
all_replies,
|
all_replies,
|
||||||
"https://" .. host,
|
"https://" .. host,
|
||||||
"images/avatars/"
|
pleroma_avatar_path
|
||||||
)
|
)
|
||||||
printTable(i)
|
get_images(i, l, pleroma_avatar_save_path)
|
||||||
printTable(l)
|
|
||||||
get_images(i, l, "test/images/avatars/")
|
|
||||||
meta["pleroma-comments"] = c
|
meta["pleroma-comments"] = c
|
||||||
meta["pleroma-comments-count"] = #c
|
meta["pleroma-comments-count"] = #c
|
||||||
meta["pleroma-has-comments"] = (#c > 0)
|
meta["pleroma-has-comments"] = (#c > 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user