Module:Load WikiProject Modules and Module:Load WikiProject Modules/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
No edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
function standardicon(modulename) |
|||
⚫ | |||
-- Take modulename as input, returns corresponding icon filename |
-- Take modulename as input, returns corresponding icon filename |
||
-- Returns default icon if no icon is defined |
-- Returns default icon if no icon is defined |
||
-- Grow the library! Add default icons as needed by adding this line below: |
-- Grow the library! Add default icons as needed by adding this line below: |
||
-- ['MODULENAME'] = 'FILE NAME.ext' |
-- index['MODULENAME'] = 'FILE NAME.ext' |
||
index['About'] = 'Information Noun 176431.svg' |
|||
⚫ | |||
index['About us'] = 'Information Noun 176431.svg' |
|||
⚫ | |||
index['Alerts'] = 'Bell icon.svg' |
|||
index['Article alerts'] = 'Bell icon.svg' |
|||
index['Article Alerts'] = 'Bell icon.svg' |
|||
index['Partners'] = 'Handshake noun.svg' |
|||
index['Partnerships'] = 'Handshake noun.svg' |
|||
index['Discussions'] = 'Speechbubbles icon.svg' |
|||
⚫ | |||
['Partnerships'] = 'Handshake noun.svg', |
|||
index['External Links'] = 'Link icon.svg' |
|||
index['External links'] = 'Link icon.svg' |
|||
⚫ | |||
index['Links'] = 'Link icon.svg' |
|||
index['Maps'] = 'MapPin.svg' |
|||
index['Metrics'] = 'ArticleCheck.svg' |
|||
index['Assessments'] = 'ArticleCheck.svg' |
|||
index['News'] = 'Calendar icon 2.svg' |
|||
index['Offline App'] = 'Offline logo.svg' |
|||
index['Press'] = 'Cite newspaper.svg' |
|||
index['Recent changes'] = 'Clock icon.svg' |
|||
index['Recent Changes'] = 'Clock icon.svg' |
|||
index['Recognized content'] = 'RibbonPrize.svg' |
|||
index['Recognized Content'] = 'RibbonPrize.svg' |
|||
⚫ | |||
['Recognized content'] = 'RibbonPrize.svg', |
|||
index['Related WikiProjects'] = 'Contributions icon.svg' |
|||
⚫ | |||
⚫ | |||
index['Research'] = 'Microscope icon (black OCL).svg' |
|||
index['Resources'] = 'Cite book.svg' |
|||
index['Showcase'] = 'RibbonPrize.svg' |
|||
index['Tasks'] = 'ListBullet.svg' |
|||
index['Tools'] = 'Octicons-tools-minor.svg' |
|||
index['Translations'] = 'Translation icon.svg' |
|||
index['Watchlist'] = 'OpenEye icon.svg' |
|||
index['Worklists'] = 'ListBullet.svg' |
|||
⚫ | |||
['Worklists'] = 'ListBullet.svg', |
|||
} |
|||
for t, fn in pairs(index) do |
for t, fn in pairs(index) do |
||
if t == modulename then |
if t == modulename then |
||
Line 48: | Line 45: | ||
end |
end |
||
end |
end |
||
⚫ | |||
return index['default'] |
|||
end |
end |
||
function editlinktest(modulename) |
|||
no_edit_links = {'Discussions', 'Alerts', 'Showcase', 'Related WikiProjects'} -- no edit link for these standard modules |
|||
for _, l in pairs(no_edit_links) do |
for _, l in pairs(no_edit_links) do |
||
Line 63: | Line 60: | ||
function p.build(frame) |
function p.build(frame) |
||
title = '' |
|||
intro = '' |
|||
image = '' |
|||
color = '#6af' -- default value |
|||
displaymode = 'normal' -- default value |
|||
modules = {} |
|||
local id |
|||
for key, value in pairs(frame:getParent().args) do -- iterate through arguments, pick out values |
for key, value in pairs(frame:getParent().args) do -- iterate through arguments, pick out values |
||
if key == 'title' then |
if key == 'title' then |
||
Line 89: | Line 85: | ||
-- Rendering table of contents and body |
-- Rendering table of contents and body |
||
⚫ | |||
⚫ | |||
⚫ | |||
width = 80, |
|||
⚫ | |||
height = 55, |
|||
⚫ | |||
⚫ | |||
['margin'] = 0 |
|||
⚫ | |||
⚫ | |||
-- Load a Table of Contents entry, transclude module, for each named module |
-- Load a Table of Contents entry, transclude module, for each named module |
||
counter = 0 |
|||
local moduletitle |
|||
local moduletitle_encoded |
|||
for _, module in pairs(modules) do |
for _, module in pairs(modules) do |
||
counter = counter + 1 |
counter = counter + 1 |
||
toc_args['image' .. counter] = standardicon(module) |
toc_args['image' .. counter] = standardicon(module) |
||
toc_args['alt' .. counter] = module |
toc_args['alt' .. counter] = module |
||
if displaymode == " |
if displaymode == "writing" then |
||
if module == "Metrics" or module == "Showcase" or module == "About us" or module == "Press" or module == "Research" or module == "External links" then |
if module == "Metrics" or module == "Showcase" or module == "About us" or module == "Press" or module == "Research" or module == "External links" then |
||
toc_args['link' .. counter] = "Wikipedia:WikiProject |
toc_args['link' .. counter] = "Wikipedia:WikiProject Writing/" .. module |
||
else |
else |
||
toc_args['link' .. counter] = "#" .. module |
toc_args['link' .. counter] = "#" .. module |
||
Line 138: | Line 129: | ||
end |
end |
||
-- Create notice |
-- Create notice |
||
create_url = ' |
create_url = '//en.wikipedia.org/wiki/Wikipedia:' .. string.gsub(moduletitle, ' ', '_') .. '?action=edit' .. preload .. editintro |
||
create_button = frame:expandTemplate{ title = 'Template:Clickable button 2', args = {'Create Module', url = create_url, class = 'mw-ui-progressive' } } |
create_button = frame:expandTemplate{ title = 'Template:Clickable button 2', args = {'Create Module', url = create_url, class = 'mw-ui-progressive' } } |
||
body = body .. '[[Wikipedia:' .. moduletitle .. ']] does not exist. ' .. create_button |
body = body .. '[[Wikipedia:' .. moduletitle .. ']] does not exist. ' .. create_button |
||
Line 148: | Line 139: | ||
toc_args['perrow'] = counter -- sets length of image array to the number of icons |
toc_args['perrow'] = counter -- sets length of image array to the number of icons |
||
⚫ | |||
⚫ | |||
-- Adding header |
-- Adding header |
||
header = "__NOTOC__\n<div style='display: flex; display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap;'>" -- top container |
|||
if displaymode == " |
if displaymode == "writing" then |
||
header = header .. "<div style='flex: 1 0; border-top: solid .7em " .. color .. ";'>" -- intro |
header = header .. "<div style='flex: 1 0; -webkit-flex: 1 0; border-top: solid .7em " .. color .. ";'>" -- intro |
||
else |
else |
||
header = header .. "<div style='flex: 1 0; padding-bottom: 3em; border-top: solid .7em " .. color .. ";'>" -- intro |
header = header .. "<div style='flex: 1 0; -webkit-flex: 1 0; padding-bottom: 3em; border-top: solid .7em " .. color .. ";'>" -- intro |
||
end |
end |
||
-- Adding project icon |
-- Adding project icon |
||
Line 164: | Line 154: | ||
header = header .. "<div style='font-size: 120%; padding: 0;'>" -- header |
header = header .. "<div style='font-size: 120%; padding: 0;'>" -- header |
||
header = header .. "<h1 style='font-weight: bold; border-bottom: none; margin:0; padding-top:0.5em;'>" .. title .. "</h1></div>" |
header = header .. "<h1 style='font-weight: bold; border-bottom: none; margin:0; padding-top:0.5em;'>" .. title .. "</h1></div>" |
||
if displaymode == " |
if displaymode == "writing" then |
||
header = header .. toc |
header = header .. toc |
||
end |
end |
||
Line 176: | Line 166: | ||
header = header .. "</div>" |
header = header .. "</div>" |
||
-- Adding member box |
-- Adding member box |
||
header = header .. "<div style='flex: 0 1 20em;'>" |
header = header .. "<div style='flex: 0 1; -webkit-flex: 0 20em;'>" |
||
header = header .. frame:expandTemplate{ title = 'WPX |
header = header .. frame:expandTemplate{ title = 'WPX member box', args = { } } |
||
header = header .. "</div>" |
header = header .. "</div>" |
||
-- Closing off header |
-- Closing off header |
||
header = header .. "</div>" |
header = header .. "</div></div>" |
||
-- Assembling parts |
-- Assembling parts |
||
local contents |
|||
if displaymode == "womeninred" then |
if displaymode == "womeninred" then |
||
contents = header .. body |
contents = header .. body |
||
Line 190: | Line 179: | ||
end |
end |
||
return contents |
return contents |
||
end |
|||
function p.invoke(frame) |
|||
return p.build(frame:newChild{title = frame:getTitle()}) |
|||
end |
end |
||