Module:Set gallery

--[[   ###########    # Var list:    ###########    ->  G                       //  ;    ->  A                       //  getArgs;    ->  F                       //  Auxiliary functions;    ---    # Data:    ->  data                    //  Loads Module:Set gallery/data values;    ->  rg_list                 //  Region code list;    ->  region_list             //  Region list;    ->  ln_list                 //  Language code list;    ->  language_list           //  Language list;    ->  ed_list                 //  Edition code list;    ->  edition_list            //  Edition list;    ->  medium_list             //  Medium list;    ->  rarity_list             //  Rarity list;    --    # General:    ->  parameters              //  Table with the parameters values;    ->  PAGENAME                //  ;    ->  NAMESPACE               //  ;    ---    # Set info:    ->  _rg                     //  Region code;    ->  _region                 //  Region name;    ->  _ln                     //  Language code;    ->  _language               //  Language name;    ->  _ed                     //  Edition code;    ->  _edition                //  Edition name;    ->  _medium                 //  Medium (OCG or TCG);    ->  _nameSet                //  Set name;    ->  _nameSet_localized      //  Localized set name;    ->  _abbr                   //  ;    ->  _rarity                 //  ;    ->  _alt                    //  ;    --    # Display:    ->  display_nameSet         //  Display set name (linked);    ->    # Flags:    ->  notEnglish              //  Boolean;    ->  italics                 //  Italicize;    --    # Aux:    ->  nameSet_parts           //  Array with «_nameSet» split by «(»;    ################    # Function list:    ################    -    # MW:    ->  split                   //  mw.text.split;    ->  trim                    //  mw.text.trim;    ---    # Main:    ->  main                    //  For ;    ->      --    # Aux:    ->  localized_name          //  Get localized name;    ->  link                    //  Link;

]] -- -- Start: -- local G = {};

-- -- Load data: local data         = mw.loadData( 'Module:Set gallery/data' ); -- # Assign: local rg_list      = data.rg_list; local region_list  = data.region_list; local ln_list      = data.ln_list; local language_list = data.language_list; local ed_list      = data.ed_list; local edition_list = data.edition_list; local medium_list  = data.medium_list; local rarity_list  = data.rarity_list;

- -- Load modules: local A = require( 'Dev:Arguments' ).getArgs; --local F = require( 'Module:Set gallery/functions' );   --  Load auxiliary functions.

- -- Aux mw functions: local split = mw.text.split; local trim = mw.text.trim;

-- -- Main function: function G.main( frame ) local parameters = A(frame, { trim = true, removeBlanks = true, --parentOnly = true }); -- Fetch parameter's values. -- { '1' or 'gallery', 'region' , 'set' , 'abbr' , 'rarity' , 'alt' } local PAGENAME  = mw.title.getCurrentTitle.text;     -- local NAMESPACE = mw.title.getCurrentTitle.nsText;   -- -- Region and language: local _rg      = parameters['region'] and parameters['region'].lower   --  Either use , or PAGENAME.match( 'CG%-(%a*)%-?' ).lower;   --  Or fetch from the pagename. local _region  = region_list[_rg] or region_list['default']; local _ln      = ln_list[_rg]; local _language = language_list[_ln]; local _ed      = PAGENAME.match( 'CG%-%a*%-?(%a*)' ).lower; local _edition = edition_list[_ed];    --  NOTE: can be nil! local _medium  = medium_list[_rg] or 'TCG'; -- Flags: local flag_notEnglish = _ln ~= 'en'; local flag_italics   = ((_ln == 'ja') or (_ln == 'zh') or (_ln == 'ko')) and 'normal' or 'italic'; -   --  Set info: -- # Set name: local _nameSet = parameters['set']; if _nameSet == nil then local nameSet_parts = split( PAGENAME, ' %(' );       if nameSet_parts[3] == nil or nameSet_parts[3] == '' then            _nameSet = nameSet_parts[1];  -- Set name doesn't contain dab text.        else            _nameSet = nameSet_parts[1] ..' ('.. nameSet_parts[2]; -- Set name contains dab text. end end local _nameSet_localized --= F.localized_name( _nameSet, _language ); local display_nameSet   --= F.link( _nameSet ); -- # Set abbreviation: local _abbr = parameters['abbr']; -- # Genral card info: local _rarity = parameters['rarity']; local _alt   = parameters['alt']; local debug = mw.html.create( 'ul' ) :tag('li'):tag('code'):wikitext('PAGENAME'):done:wikitext(': '..PAGENAME):done :tag('li'):tag('code'):wikitext('NAMESPACE'):done:wikitext(': '..NAMESPACE):done :tag('li'):tag('code'):wikitext('_rg'):done:wikitext(': '.._rg):done :tag('li'):tag('code'):wikitext('_region'):done:wikitext(': '.._region):done :tag('li'):tag('code'):wikitext('_ln'):done:wikitext(': '.._ln):done :tag('li'):tag('code'):wikitext('_language'):done:wikitext(': '.._language):done :tag('li'):tag('code'):wikitext('_ed'):done:wikitext(': '.._ed):done :tag('li'):tag('code'):wikitext('_edition'):done:wikitext(': '..tostring(_edition)):done :tag('li'):tag('code'):wikitext('_medium'):done:wikitext(': '.._medium):done :tag('li'):tag('code'):wikitext('_nameSet'):done:wikitext(': '.._nameSet):done :tag('li'):tag('code'):wikitext('_nameSet_localized'):done:wikitext(': '..tostring(_nameSet_localized)):done :tag('li'):tag('code'):wikitext('_alt'):done:wikitext(': '..tostring(_alt)):done :tag('li'):wikitext('Flags'):done :tag('li'):tag('code'):wikitext('flag_notEnglish'):done:wikitext(': '..tostring(flag_notEnglish)):done :tag('li'):tag('code'):wikitext('flag_italics'):done:wikitext(': '..flag_italics):done :done return debug; end

return G;