No edit summary Tag: sourceedit |
No edit summary Tag: sourceedit |
||
Line 76: | Line 76: | ||
-- end |
-- end |
||
return tostring( L.makeList('bulleted', o) )..table.concat( categories ) |
return tostring( L.makeList('bulleted', o) )..table.concat( categories ) |
||
− | end |
||
− | |||
− | --[==[ |
||
− | -- Bottom navigation |
||
− | {{Card navigation}}{{ #if: {{{suppress_archseries_navboxes|}}} |
||
− | | [[Category:Card pages with suppressed archseries navboxes]] |
||
− | | {{IfSemantics|{{ #arraydefine: @archseries | {{{archseries|}}}*{{{supports_archetypes|}}}*{{{anti-supports_archetypes|}}}*{{{antisupports_archetypes|}}}*{{{related_to_archseries|}}} | * | unique, sort=asc }}{{ #arrayprint: @archseries || $archseries |   |
||
− | {{Archseries navbox|$archseries|member=<!-- later -->|support=<!-- later -->|anti-support=<!-- later -->|related=<!-- later -->}} |
||
− | }}}} |
||
− | }}{{ #if: {{ #var: $counter }} | {{Counters}} |
||
− | }}{{ #if: {{ #var: $token }} | {{Tokens}} |
||
− | }} |
||
− | --]==] |
||
− | |||
− | function navigation.navboxes(args) |
||
− | local o = '' |
||
− | o = o..frame:expandTemplate{ title = 'Card navigation' } |
||
− | if args['suppress_archseries_navboxes'] then |
||
− | -- [[Category:Card pages with suppressed archseries navboxes]] |
||
− | o = o..frame:preprocess( '[[Category:Card pages with suppressed archseries navboxes]]' ) |
||
− | else |
||
− | local navboxes = { |
||
− | args['archseries'], |
||
− | args['supports_archetypes'], |
||
− | args['anti-supports_archetypes'], |
||
− | args['antisupports_archetypes'], |
||
− | args['related_to_archseries'] } |
||
− | local groups_str = table.concat(navboxes, ' * ') |
||
− | local groups = HF.unique(mw.text.split(groups_str, '*')) |
||
− | table.sort(groups) |
||
− | for _,navbox in ipairs(groups) do |
||
− | o = o..frame:expandTemplate{ |
||
− | title = 'Archseries navbox', |
||
− | args = { navbox } |
||
− | } |
||
− | end |
||
− | --[==[ |
||
− | {{IfSemantics|{{ #arraydefine: @archseries | {{{archseries|}}}*{{{supports_archetypes|}}}*{{{anti-supports_archetypes|}}}*{{{antisupports_archetypes|}}}*{{{related_to_archseries|}}} | * | unique, sort=asc }}{{ #arrayprint: @archseries || $archseries |   |
||
− | {{Archseries navbox|$archseries|member=<!-- later -->|support=<!-- later -->|anti-support=<!-- later -->|related=<!-- later -->}} |
||
− | }}}} |
||
− | --]==] |
||
− | end |
||
− | if counter then o = o..frame:expandTemplate{ title = 'Counters' } end |
||
− | if token then o = o..frame:expandTemplate{ title = 'Tokens' } end |
||
− | return o |
||
end |
end |
||
Revision as of 22:55, 14 August 2017
Module documentation
[create]
The documentation for this module is missing. Click here to create it.
local navigation = {}
----------------------------
-- Libraries of functions --
----------------------------
-- stands for High Frequency
local HF = require('Module:HF')
-- Parses invocation and template parameters, trims whitespace, and removes blanks.
local getArgs = require('Dev:Arguments').getArgs
-- Generates lists
local L = require('Dev:List')
_G.page_title = mw.title.getCurrentTitle().text
_G.t = getArgs(frame, { trim = true, removeBlanks = true, parentOnly = true })
_G.kr_release = (t['kr_sets'] or t['ko_sets']) and true
_G.ae_release = t['ae_sets'] and true
_G.tc_release = t['tc_sets'] and true
_G.na_release = t['na_sets'] and true
_G.eu_release = t['eu_sets'] and true
_G.de_release = t['de_sets'] and true
_G.it_release = t['it_sets'] and true
_G.pt_release = t['pt_sets'] and true
_G.sp_release = t['sp_sets'] and true
_G.ocg_jp = (t['jp_sets'] or t['ja_sets']) and true
_G.ocg = (ocg_jp or kr_release or ae_release or tc_release) and true
_G.tcg_en = (t['en_sets'] or na_release or eu_release or t['au_sets']) and true
_G.tcg_fr = (t['fr_sets'] or t['fc_sets']) and true
_G.tcg = (tcg_en or tcg_fr or de_release or it_release or pt_release or sp_release) and true
_G.ocg_tcg = (ocg or tcg) and true
_G.non_game = (t['type'] and (t['type']:lower() == 'illustration card' or t['type']:lower() == 'strategy card' or t['type']:lower() == 'tip card' or t['type']:lower() == 'faq card' or t['type']:lower() == 'non-game card' or t['type']:lower() == 'character card'))
---------------------------------------------------------
-- Internal functions (used in this and other Modules) --
---------------------------------------------------------
function navigation.related(args)
-- Template parameters, passed from .
local t = args
local list = {
_relatedpagelink( 'Card Rulings', t['cardgame'] or t['name'] or nil, 'Rulings' ),
_relatedpagelink( 'Card Errata', t['cardgame'] or t['name'] or nil, 'Errata' ),
_relatedpagelink( 'Card Tips', t['cardgame'] or t['name'] or nil, 'Tips' ),
_relatedpagelink( 'Card Appearances', t['cardgame'] or t['name'] or nil, 'Appearances' ),
_relatedpagelink( 'Card Trivia', t['cardgame'] or t['name'] or nil, 'Trivia' ),
_relatedpagelink( 'Card Lores', t['cardgame'] or t['name'] or nil, 'Lores' ),
_relatedpagelink( 'Card Artworks', t['cardgame'] or t['name'] or nil, 'Artworks' ),
_relatedpagelink( 'Card Names', t['cardgame'] or t['name'] or nil, 'Names' ),
}
local hlist = L.makeList( 'horizontal' , list )
return tostring(hlist)
end
function navigation.external(args)
local o = {}
local categories = {}
if (args['yugioh_site'] or args['yugioh_site_raw'] or args['appears_in_dm'] or args['appears_in_cm'] or args['appears_in_gx'] or args['appears_in_5d'] or args['appears_in_zx'] or args['appears_in_av'] or args['appears_in_vr']) and not ( args['yugioh_site'] and args['yugioh_site']:lower() == 'none' ) then
for _,list_item in ipairs( _yugioh_site(args) ) do
table.insert( o, list_item )
end
end
if ocg_tcg --and not ( non_game or token_counter or args['cardgame'] or (args['image'] and args['image']:match('-BD-JP-')) )
then
table.insert( o, _yugioh_card_db(args) )
end
-- if tcg_en
--and (not non_game) and (not args['cardgame'])
-- then
table.insert( o, _yugioh_prices(args) )
-- end
-- if ocg_tcg
--and (not non_game)
-- then
for _,list_item in ipairs( _ygo_card_de(args) ) do
table.insert( o, list_item )
end
-- end
return tostring( L.makeList('bulleted', o) )..table.concat( categories )
end
------------------------------------------------
-- Local functions (only used in this Module) --
------------------------------------------------
function _relatedpagelink( namespace, value, label, section, itype )
local pagename = HF.NP()
local link
local ask = mw.smw.ask{ ('[[%s %s for::%s]]'):format(namespace, (itype or 'page'), pagename), link='none' } and mw.smw.ask{ ('[[%s %s for::%s]]'):format(namespace, (itype or 'page'), pagename), link='none' }[1][1] or nil
if value then
link = namespace..':'..value
elseif not pagename:match('=') and ask then
link = ask
else
link = namespace..':'..pagename
end
if section then link = link .. '#' .. section end
return HF.Link( link, label or namespace or '' )
end
function _dblink( release, db_id, f_db_id, locale, Language)
if release and f_db_id then
return HF.Category('Card pages with a suppressed ' .. Language .. ' Yugioh-Card database ID')
elseif release and db_id then
local URI = mw.uri.new{
protocol = 'http',
host = 'www.db.yugioh-card.com',
path = '/yugiohdb/card_search.action',
query = { ['ope'] = '2', ['cid'] = db_id, ['request_locale'] = locale }
}
mw.smw.set{ Language..' database ID='..db_id }
return HF.ExternalLink( URI, locale )
else
return nil
end
end
function _yugioh_site(args)
return {
HF.ExternalLink( 'http://www.yugioh.com/cards/'..(args['yugioh_site_raw'] or (args['yugioh_site'] or page_title):gsub("%'",''):gsub(',',''):gsub('&',''):gsub('!',''):gsub('%.',''):gsub('%"',''):gsub(':',''):gsub('/',''):gsub('#',''):gsub('%s+', '-'):lower()), 'yugioh.com' ),
args['yugioh_site'] and ('("%s")'):format(args['yugioh_site'])..HF.Category('Pages with an overwritten yugioh.com link'),
args['yugioh_site_raw'] and ('<span class="sysop-show">(<code>%s</code>)</span>'):format(args['yugioh_site_raw'])..HF.Category('Pages with an overwritten yugioh.com link')
}
end
function _yugioh_card_db(args)
local db_id = args['database_id']
local has_db_id = (ocg_jp or tcg_en or tcg_fr or de_release or it_release or sp_release) and true
if db_id == nil and has_db_id
then
table.insert( categories, '<includeonly>'..HF.Category('Card pages needing a Yugioh-Card database ID')..'</includeonly>' )
elseif db_id:lower() == 'none' then
table.insert( categories, HF.Category('Card pages without a Yugioh-Card database ID') )
elseif type(db_id) ~= 'number' then
table.insert( categories, HF.Category('Pages with an invalid Yugioh-Card database ID') )
else
local YCCD_list = {
_dblink( ocg_jp, db_id, args['ja_database_id'], 'ja', 'Japanese'),
ocg_jp
and '('..
HF.ExternalLink(
'http://www.db.yugioh-card.com/yugiohdb/faq_search.action?ope=4&cid='..db_id..'&request_locale=ja',
'rulings')
..')',
_dblink( tcg_en, db_id, args['en_database_id'], 'en', 'English'),
_dblink( tcg_fr, db_id, args['fr_database_id'], 'fr', 'French'),
_dblink( de_release, db_id, args['de_database_id'], 'de', 'German'),
_dblink( it_release, db_id, args['it_database_id'], 'it', 'Italian'),
_dblink( sp_release, db_id, args['es_database_id'], 'es', 'Spanish')
}
mw.smw.set{ 'Database ID='..db_id }
return
'Yugioh-Card card database: '..db_id..' ('..
tostring(L.makelist( 'horizontal' , YCCD_list ))
..')'
end
end
function _yugioh_prices(args)
local link = HF.ExternalLink(tostring(mw.uri.new{
protocol = 'http',
host = 'yugiohprices.com',
path = '/card_price',
query = {
['name'] = mw.uri.encode(
args['yugiohprices']
or (args['name'] and args['name']:gsub('#','') or HF.NP() ))
}
}), 'YugiohPrices')
return link..(
(args['yugiohprices'] and args['yugiohprices']:lower() == 'none' )
and HF.Category() or ''
)
end
function _ygo_card_de(args)
local english = HF.ExternalLink( tostring(mw.uri.new{
protocol = 'http',
host = 'en.ygo-card.de',
path = '/result_links.php',
query = {
['htm_name'] = mw.uri.encode( args['ygocard'] or ( args['name'] or page_title )),
['suche'] = 'true'
}
}), 'YGO-Card.de' )..((args['ygocard-de'] == args['ygocard'] or
args['ygocard-de'] == args['name'] or
args['ygocard-de'] == page_title or
args['ygocard-de'] == 'none') and '' or ' (English)')
local german = args['de_name']
and HF.ExternalLink( tostring(mw.uri.new{
protocol = 'http',
host = 'de.ygo-card.de',
path = '/result_links.php',
query = {
['htm_name'] = mw.uri.encode( args['ygocard-de'] or args['de_name'] or '' ),
['suche'] = 'true'
}
}), 'YGO-Card.de' )..' (German)'
return {
english,--..(args['ygocard'] and HF.Category('Card pages with overridden YGO-Card.de English links')),
german--..(args['ygocard'] and HF.Category('Card pages with overridden YGO-Card.de German links')),
}
end
function _counters()
end
function _tokens()
end
-------------------------------------------------
-- Output (send it back to whatever called it) --
-------------------------------------------------
return navigation