Jump to content
Wikipedia The Free Encyclopedia

Module:Gutenberg

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
This module is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
Warning This Lua module is used on approximately 12,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
This module uses the Wikidata property:

Usage

There are currently 3 templates that invoke this module, {{Gutenberg author}}, {{Gutenberg Australia}} and {{FadedPage}} (Canada)

The above documentation is transcluded from Module:Gutenberg/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.

 localp={}

 functionp.author(frame)

 localpframe=frame:getParent()
 localargs=pframe.args

 localtname="Gutenberg author"-- name of calling template. Change if template is renamed.

 localid=nil-- author name, or number. Name goes to search page, number goes direct to author page 
 localname=nil-- display name on Wikipedia (default: article title)
 localurl=nil
 localtagline="at [[Project Gutenberg]]"
 localurlheadname="https://www.gutenberg.org/author/"
 localurlheadnumb="https://www.gutenberg.org/ebooks/author/"
 localurlhead=nil

 -- Argument |id=
 id=trimArg(args[1])ortrimArg(args.id)
 ifnotidthen
 localbestP1938=mw.wikibase.getBestStatements(mw.wikibase.getEntityIdForCurrentPage(),'P1938')[1]
 ifbestP1938andbestP1938.mainsnak.snaktype=='value'then
 id=bestP1938.mainsnak.datavalue.value
 localentity=mw.wikibase.getEntityObject()or{}
 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")
 end
 end
 iftonumber(id)then-- it's a number
 urlhead=urlheadnumb
 else
 urlhead=urlheadname
 id=mw.ustring.gsub(id," ","+")
 end

 -- Argument |name=
 name=trimArg(args[2])ortrimArg(args.name)
 ifnotnamethen
 name=mw.title.getCurrentTitle().text:gsub('%s+%([^%(]-%)$','')-- Current page name without the final parentheses
 end

 -- Argument |coda=
 iftrimArg(args.coda)then
 tagline=tagline.." "..trimArg(args.coda)
 end

 url="["..urlhead..id.." Works by "..name.."] "..tagline

 returnurl

 end

 functionp.Australia(frame)

 localpframe=frame:getParent()
 localargs=pframe.args

 localtname="Gutenberg Australia"-- name of calling template. Change if template is renamed.

 localid=nil-- ID. eg. http://gutenberg.net.au/plusfifty-n-z.html#shanks .. the ID = plusfifty-n-z.html#shanks
 -- ID is the same for linking an individual book title, or all books by the author.
 localname=nil-- display name on Wikipedia (default: article title)
 localauthor=nil-- flag if an author (default: no)
 localurl=nil
 localurlhead="http://gutenberg.net.au/"
 localprefix=""
 localtagline="at [[Project Gutenberg Australia]]"
 localitalic="''"

 -- Argument |id=
 id=trimArg(args[1])ortrimArg(args.id)
 ifnotidthen
 error("Parameter id is missing. See [[Template:"..tname.."]] documentation")
 end

 -- Argument |name=
 name=trimArg(args[2])ortrimArg(args.name)
 ifnotnamethen
 name=mw.title.getCurrentTitle().text:gsub('%s+%([^%(]-%)$','')-- Current page name without the final parentheses
 end

 -- Argument |author=
 author=trimArg(args.author)
 ifauthorthen
 ifmw.ustring.lower(author)=="yes"then
 prefix="Works by "
 italic=""
 end
 end

 -- Argument |coda=
 iftrimArg(args.coda)then
 tagline=tagline.." "..trimArg(args.coda)
 end

 url="["..urlhead..id.." "..prefix..italic..name..italic.."] "..tagline

 returnurl

 end

 functionp.Canada(frame)

 localpframe=frame:getParent()
 localargs=pframe.args

 localtname="FadedPage"-- name of calling template. Change if template is renamed.

 localid=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
 localname=nil-- display name on Wikipedia (default: article title)
 localauthor=nil-- flag if an author (default: no)
 localurl=nil
 localurlhead="https://fadedpage.com/"
 localurlbook="showbook.php?pid="
 localurlauth="csearch.php?author="
 localprefix=""
 localtagline="at [[Distributed Proofreaders Canada|Faded Page]] (Canada)"
 localitalic="''"

 -- Argument |id=
 id=trimArg(args[1])ortrimArg(args.id)
 ifnotidthen
 error("Parameter id is missing. See [[Template:"..tname.."]] documentation")
 end

 -- Argument |name=
 name=trimArg(args[2])ortrimArg(args.name)
 ifnotnamethen
 name=mw.title.getCurrentTitle().text:gsub('%s+%([^%(]-%)$','')-- Current page name without the final parentheses
 end

 -- Argument |author=
 author=trimArg(args.author)
 ifauthorthen
 ifmw.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
 returnurl
 end
 end

 url="["..urlhead..urlbook..id.." "..prefix..italic..name..italic.."] "..tagline

 returnurl

 end

 functiontrimArg(arg)

 ifarg==""orarg==nilthen
 returnnil
 else
 returnmw.text.trim(arg)
 end

 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /