Difference between revisions of "Module:PastWikithons"
From BASAbaliWiki
Line 17: | Line 17: | ||
local div = mw.html.create( 'div' ) | local div = mw.html.create( 'div' ) | ||
div:addClass('wikithon-list-legacy') | div:addClass('wikithon-list-legacy') | ||
+ | div:addClass('bali-wikiton-list') | ||
-- https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/README.md | -- https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/README.md | ||
-- build list of unique wikithons names | -- build list of unique wikithons names | ||
+ | |||
local result = mw.smw.ask { | local result = mw.smw.ask { | ||
'[[Category:Article]]', | '[[Category:Article]]', | ||
Line 26: | Line 28: | ||
mainlabel = '-' | mainlabel = '-' | ||
} | } | ||
+ | |||
if result and #result then | if result and #result then | ||
for num, entityData in pairs( result ) do | for num, entityData in pairs( result ) do | ||
Line 34: | Line 37: | ||
end | end | ||
end | end | ||
+ | |||
+ | for k, v in pairs( competitions ) do | ||
+ | local wikithonDiv = div:tag('div') | ||
+ | wikithonDiv:addClass('bali-wikiton') | ||
+ | local wikithonTags = wikithonDiv:tag('div') | ||
+ | wikithonTags:addClass('bali-tags') | ||
+ | local wikithonRow = wikithonDiv:tag('div') | ||
+ | wikithonRow:addClass('bali-wikiton__row') | ||
+ | local rowText = wikithonRow:tag('div') | ||
+ | rowText:addClass('bali-wikiton__text') | ||
+ | local rowLink = rowText:tag('a') | ||
+ | rowLink:attr('href', '#') | ||
+ | rowLink:attr('title', '') | ||
+ | rowLink:attr('target', '_blank') | ||
+ | rowLink:wikitext('Test') | ||
+ | local rowBtn = rowText:tag('span') | ||
+ | rowBtn:addClass('bali-wikiton__button') | ||
+ | local btnLink = rowBtn:tag('a') | ||
+ | btnLink:attr('href', '') | ||
+ | btnLink:attr('target', '_blank') | ||
+ | btnLink:attr('title', '') | ||
+ | end | ||
+ | |||
-- fetch wikithons artiles per wikithon | -- fetch wikithons artiles per wikithon | ||
+ | --[=====[ | ||
for k, v in pairs( competitions ) do | for k, v in pairs( competitions ) do | ||
local competition = k | local competition = k | ||
Line 54: | Line 81: | ||
end | end | ||
end | end | ||
+ | --]=====] | ||
return div | return div | ||
end | end | ||
return p | return p |
Revision as of 13:58, 9 July 2024
Documentation for this module may be created at Module:PastWikithons/doc
local p = {} local competitions = {} function addToSet(set, key) set[key] = true end function removeFromSet(set, key) set[key] = nil end function setContains(set, key) return set[key] ~= nil end function p.display( frame ) local div = mw.html.create( 'div' ) div:addClass('wikithon-list-legacy') div:addClass('bali-wikiton-list') -- https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/README.md -- build list of unique wikithons names local result = mw.smw.ask { '[[Category:Article]]', '[[Competition::+]]', '?Competition', limit = 10, mainlabel = '-' } if result and #result then for num, entityData in pairs( result ) do local c = entityData['Competition'] if not setContains(competitions, c) then addToSet(competitions, c) end end end for k, v in pairs( competitions ) do local wikithonDiv = div:tag('div') wikithonDiv:addClass('bali-wikiton') local wikithonTags = wikithonDiv:tag('div') wikithonTags:addClass('bali-tags') local wikithonRow = wikithonDiv:tag('div') wikithonRow:addClass('bali-wikiton__row') local rowText = wikithonRow:tag('div') rowText:addClass('bali-wikiton__text') local rowLink = rowText:tag('a') rowLink:attr('href', '#') rowLink:attr('title', '') rowLink:attr('target', '_blank') rowLink:wikitext('Test') local rowBtn = rowText:tag('span') rowBtn:addClass('bali-wikiton__button') local btnLink = rowBtn:tag('a') btnLink:attr('href', '') btnLink:attr('target', '_blank') btnLink:attr('title', '') end -- fetch wikithons artiles per wikithon --[=====[ for k, v in pairs( competitions ) do local competition = k local ulWikithon = div:tag('ul') ulWikithon:addClass('wikithon-list-legacy--item') ulWikithon:wikitext(competition) local result = mw.smw.ask { '[[Category:Article]]', '[[Competition::' .. competition ..']]', limit = 10, mainlabel = 'origin' } if result and #result then for num, entityData in pairs( result ) do local liPage = ulWikithon:tag('li') liPage:addClass('wikithon-list-legacy--page') liPage:wikitext(entityData.origin) end end end --]=====] return div end return p