Module:Make Wikisource link
Appearance
| 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. |
| 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. |
| This module depends on the following other modules: |
This module creates a link to a page at Wikisource. It is intended to be called from {{Wikisource/outer core}}; you probably should not use it anywhere else.
If the template is used in mainspace and no link at Wikidata is found, it sometimes populates Category:Wikisource templates with missing id. In the following cases, it will not populate the category:
|nocat=yesis provided- "Year in topic" articles (e.g. 1871 in Canada)
- "Decade in topic" articles (e.g. 2020s in music)
- The article is a list (title begins with
List) - Disambiguation page and set index articles
- Articles about species. Note that there is no all included species category, so we make use of Category:Articles with 'species' microformats to check whether the article is about a species.
If none of the above are true, the category is populated.
Usage
{{#invoke:Make Wikisource link|makeLink}}
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.getSourceName(frame)
local args = getArgs(frame)
local lang = args['explicit-lang-param'] or args['implicit-lang-param'] or 'en'
-- if we have a language parameter, we look at the second unnamed parameter for the source title
local checkIndex = args['implicit-lang-param'] and 2 or 1
if args[checkIndex] then
-- we have a source title parameter, so return that
return args[checkIndex]
else
-- now we check Wikidata
-- there's probably a better way to do this
local wikidataSitelink = mw.wikibase.getSitelink(
wikibase.getEntityIdForCurrentPage() or '',
lang .. 'wikisource'
)
if wikidataSitelink then
return wikidataSitelink
else
-- if Wikidata returns nothing, search for the {{PAGENAME}}
return 'Special:Search/' .. mw.title.getCurrentTitle().text
end
end
end
return p