Module:Librivox book: Difference between revisions

Content deleted Content added
No edit summary
update image display for dark mode per TPER
 
(18 intermediate revisions by 5 users not shown)
Line 1:
local p = {}
 
function p.book(frame)
 
 
local pframe = frame:getParent()
Line 9 ⟶ 8:
local tname = "Librivox book" -- name of calling template. Change if template rename.
 
local title = nil -- display and search title (default: article name w/out dab)
local dtitle = nil -- display title (default: title)
local stitle = nil -- search title (default: title)
Line 21 ⟶ 20:
id = trimArg(args.id)
if id then
error("Error in {{Template:" .. tname .. "}}, - id argument not supported. Please- please see documentation useat {{[[Template:Librivox author}}]]")
end
 
title = trimArg(args.title)
if not title then
title = mw.title.getCurrentTitle().text:gsub('%s+%([^%(]-%)$', '') -- Current page name without the final parentheses
dtitle = title
stitle = dtitle
else
dtitle = title
stitle = dtitle
end
local dtitle = mw.ustring.gsub(dtitletitle,"'%s+%([^%(]-%)$"', ""'') -- removeRemove disambiguationthe ()final disambig paren
stitle = dtitle
 
if trimArg(args.stitle) then
stitle = trimArg(args.stitle)
if not trimArg(args.title) then -- For when used outside main article space
dtitle = titlestitle
end
end
if trimArg(args.dtitle) then
Line 42 ⟶ 41:
end
 
local dtitle = mw.ustring.gsub(dtitle,"%s+%([^%(]-%)$", "") -- remove disambiguation ()
local stitle = mw.ustring.gsub(stitle,"%s+%([^%(]-%)$", "")
local stitle = mw.ustring.gsub(stitle," ", "+") -- replace "<space>" with "+"
 
Line 56 ⟶ 53:
end
 
local url = "[[ImageFile:Speaker Icon.svg|20px15px|class=skin-invert-image|link=|alt=]] " .. "[" .. urlhead .. "title=" .. stitle .. "&author=" .. lname .. "&reader=&keywords=&genre_id=0&status=all&project_type=either&recorded_language=&sort_order=catalog_date&search_page=1&search_form=advanced" .. " " .. italic .. dtitle .. italic .. "]" .. " " .. tagline
 
return url