Content deleted Content added
fixes and updates |
Add "Edit At Wikidata" link if using ID from Wikidata. Tested first with /sandbox and preview in article. |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 12:
local url = nil
local tagline = "at [[Project Gutenberg]]"
local urlheadname = "
local urlheadnumb = "
local urlhead = nil
Line 19:
id = trimArg(args[1]) or trimArg(args.id)
if not id then
local bestP1938 = mw.wikibase.getBestStatements(mw.wikibase.getEntityIdForCurrentPage(), 'P1938')[1]
error("Parameter id is missing. See [[Template:" .. tname .. "]] documentation")▼
if bestP1938 and bestP1938.mainsnak.snaktype == 'value' then
else▼
id = bestP1938.mainsnak.datavalue.value
if tonumber(id) then -- it's a number▼
local entity = mw.wikibase.getEntityObject() or {}
urlhead = urlheadnumb▼
tagline = tagline .. " [[File:OOjs UI icon edit-ltr-progressive.svg |frameless |text-top |10px |alt=Edit this at Wikidata |link=https://www.wikidata.org/wiki/" .. entity.id .. "#P1938|Edit this at Wikidata]]"
else
error("Parameter id is missing. See [[Template:" .. tname .. "]] documentation")
urlhead = urlheadname▼
id = mw.ustring.gsub(id," ", "+")▼
end
end
▲ else
end
-- Argument |name=
Line 90 ⟶ 96:
url = "[" .. urlhead .. id .. " " .. prefix .. italic .. name .. italic .. "] " .. tagline
return url
end
function p.Canada(frame)
local pframe = frame:getParent()
local args = pframe.args
local tname = "FadedPage" -- name of calling template. Change if template is renamed.
local id = nil -- ID for author, eg. http://fadedpage.com/csearch.php?author=Shortt%2C%20Adam .. the id = Shortt, Adam
-- ID for book titles, eg. http://fadedpage.com/showbook.php?pid=20160704 .. the id = 20160704
local name = nil -- display name on Wikipedia (default: article title)
local author = nil -- flag if an author (default: no)
local url = nil
local urlhead = "https://fadedpage.com/"
local urlbook = "showbook.php?pid="
local urlauth = "csearch.php?author="
local prefix = ""
local tagline = "at [[Distributed Proofreaders Canada|Faded Page]] (Canada)"
local italic = "''"
-- Argument |id=
id = trimArg(args[1]) or trimArg(args.id)
if not id then
▲ error("Parameter id is missing. See [[Template:" .. tname .. "]] documentation")
end
-- Argument |name=
name = trimArg(args[2]) or trimArg(args.name)
if not name then
name = mw.title.getCurrentTitle().text:gsub('%s+%([^%(]-%)$', '') -- Current page name without the final parentheses
end
-- Argument |author=
author = trimArg(args.author)
if author then
if mw.ustring.lower(author) == "yes" then
id = mw.uri.encode( id, "PATH" ) -- handle spaces within id argument string
prefix = "Works by "
italic = ""
url = "[" .. urlhead .. urlauth .. id .. " " .. prefix .. italic .. name .. italic .. "] " .. tagline
return url
end
end
url = "[" .. urlhead .. urlbook .. id .. " " .. prefix .. italic .. name .. italic .. "] " .. tagline
return url
|