This is an old revision of this page, as edited by Yodin(talk | contribs) at 11:23, 14 November 2024(sync with live module). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.Revision as of 11:23, 14 November 2024 by Yodin(talk | contribs)(sync with live module)
This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
Usage
There is currently 1 template that invokes this module, {{Librivox book}}.
localp={}functionp.book(frame)localpframe=frame:getParent()localargs=pframe.argslocaltname="Librivox book"-- name of calling template. Change if template rename.localtitle=nil-- display and search title (default: article name w/out dab)localdtitle=nil-- display title (default: title)localstitle=nil-- search title (default: title)locallname=nil-- last namelocalid=nil-- unsupported argumentlocalauthor=nil-- authorlocaltagline="public domain audiobook at [[LibriVox]]"localurlhead="https://librivox.org/search?"localitalic="''"id=trimArg(args.id)ifidthenerror("Error in Template:"..tname.." - id argument not supported - please see documentation at [[Template:Librivox author]]")endtitle=trimArg(args.title)ifnottitlethentitle=mw.title.getCurrentTitle().textenddtitle=mw.ustring.gsub(title,'%s+%([^%(]-%)$','')-- Remove the final disambig parenstitle=dtitleiftrimArg(args.stitle)thenstitle=trimArg(args.stitle)ifnottrimArg(args.title)then-- For when used outside main article spacedtitle=stitleendendiftrimArg(args.dtitle)thendtitle=trimArg(args.dtitle)italic=""endlocalstitle=mw.ustring.gsub(stitle," ","+")-- replace "<space>" with "+"author=trimArg(args.author)ifnotauthorthenlname=""else--- Split name into words, count words, set name to last wordlocalN=mw.text.split(author," ")locall,count=mw.ustring.gsub(author,"%S+","")lname=N[count]endlocalurl="[[File:Speaker Icon.svg|15px|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.."]".." "..taglinereturnurlendfunctiontrimArg(arg)ifarg==""orarg==nilthenreturnnilelsereturnmw.text.trim(arg)endendreturnp