Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/pietrasagh/Tohaomg
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} --create object (table) to be returned function p.main(frame) args = frame:getParent().args; --get all the parameters given in template call: {{Template|arg[1]|arg[2]|etc}} res = {'{| class="wikitable"\n! Article\n! Good articles\n! Featured articles\n'} --table storing text, which this module returns for k1, page_title in ipairs(args) do --iterate over each given argument item = mw.wikibase.getEntity(mw.wikibase.getEntityIdForTitle(page_title), 'enwiki'); --get information from Wikidata item connected to the page good, featured = {}, {} --create empty tables for good and featured articles if item then --continue if item exists for k2, site_info in pairs(item.sitelinks) do --iterate over each given site x = mw.text.split(site_info.site, 'wiki') --split site name into two parts: before 'wiki' and after 'wiki' language_code, tail = x[1], x[2] --'x' now is a table of two values, first is two-letter language code, the second is a tail after 'wiki' language_code = language_code:gsub('_', '-') --replace underscores with dashes in language codes if site_info.badges and tail=='' then --continue if page has any badges and it is wikipedia (not other project) --if badge has values 'good article', 'good list' or 'recommended article', then add the page to the list of good articles if (site_info.badges[1]=='Q17437798' or site_info.badges[1]=='Q51759403' or site_info.badges[1]=='Q17559452') then table.insert(good, '[[:'..language_code..':'..site_info.title..'|'..language_code..']]') --if badge has values 'featured article' or 'featured list', then add the page to the list of featured articles elseif site_info.badges and (site_info.badges[1]=='Q17437796' or site_info.badges[1]=='Q17506997') then table.insert(featured, '[[:'..language_code..':'..site_info.title..'|'..language_code..']]') else end --if badge matches none of those values, just skip it end end end --make a row for the current page table.insert(res, '|-\n| [[:en:'..page_title..']]\n| '..table.concat(good, ', ')..'\n| '..table.concat(featured, ', ')..'\n') end table.insert(res, '|}') --insert table ending return frame:preprocess(table.concat(res)); --return the resulting string, which we get by joining all string in the 'res' table end return p; --return object
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/pietrasagh/Tohaomg/doc
(
edit
)