可在模块:Citebody/doc创建此模块的帮助文档
local p = {}
local b = require("Module:Basic")
function p.tumblr(frame)
local args = frame.args
local id = args[1]
local url_text = args["url_text"]
local content_text = args["content_text"]
local arc = args["arc"]
local blog = args["blog"]
local publishing_time = args["publishing_time"]
local archive_time = args["archive_time"]
local result = ""
if b.empty(arc) then
local url = 'https://arc.utcwiki.com/tumblr/api/v1/posts/show?id=' .. id .. '&wiki=1&only=blog_name,first_archive_time,publishing_time'
local data = mw.ext.externalData.getExternalData{ url = url }
local arc_result = data.__json.response.posts[1]
blog = arc_result["blog_name"]
publishing_time = os.date("%Y年%m月%d日", arc_result["data"]["timestamp"])
archive_time = os.date("%Y年%m月%d日", arc_result["first_archive_timestamp"])
end
blog = blog:gsub("^%l", mw.ustring.upper)
if b.empty(content_text) then
result = "“" .. content_text .. "”<br>——"
end
if not b.empty(url_text) then
url_text = id
end
result = result .. "[https://" .. blog .. ".tumblr.com/" .. id .. " " .. url_text .. "]" .. "," .. blog .. ",发布于" .. publishing_time
if b.empty(arc) then
result = result .. "," .. "[https://arc.utcwiki.com/tumblr/" .. id .. " 存档]于" .. archive_time
end
result = result .. "。"
return result
end
return p