Jump to content

Module:Load WikiProject Modules and Module:Load WikiProject Modules/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
No edit summary
 
mNo edit summary
 
Line 1: Line 1:
local p = {}
local p = {}


local function standardicon(modulename)
function standardicon(modulename)
index = {}
-- 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'
local index = {
index['About us'] = 'Information Noun 176431.svg'
['default'] = 'Beta icon.svg', -- default if nothing matches
['About'] = 'Information Noun 176431.svg',
index['Alerts'] = 'Bell icon.svg'
['About us'] = 'Information Noun 176431.svg',
index['Article alerts'] = 'Bell icon.svg'
['Alerts'] = 'Bell icon.svg',
index['Article Alerts'] = 'Bell icon.svg'
['Article alerts'] = 'Bell icon.svg',
index['Partners'] = 'Handshake noun.svg'
['Article Alerts'] = 'Bell icon.svg',
index['Partnerships'] = 'Handshake noun.svg'
['Partners'] = 'Handshake noun.svg',
index['Discussions'] = 'Speechbubbles icon.svg'
index['Events'] = 'Simpleicons Business calendar-with-a-clock-time-tools.svg' -- Is this PD-shapes?
['Partnerships'] = 'Handshake noun.svg',
['Discussions'] = 'Speechbubbles icon.svg',
index['External Links'] = 'Link icon.svg'
index['External links'] = 'Link icon.svg'
['Events'] = 'Simpleicons Business calendar-with-a-clock-time-tools.svg', -- Is this PD-shapes?
['External Links'] = 'Link icon.svg',
index['Links'] = 'Link icon.svg'
['External links'] = 'Link icon.svg',
index['Maps'] = 'MapPin.svg'
['Links'] = 'Link icon.svg',
index['Metrics'] = 'ArticleCheck.svg'
['Maps'] = 'MapPin.svg',
index['Assessments'] = 'ArticleCheck.svg'
['Metrics'] = 'ArticleCheck.svg',
index['News'] = 'Calendar icon 2.svg'
['Assessments'] = 'ArticleCheck.svg',
index['Offline App'] = 'Offline logo.svg'
['News'] = 'Calendar icon 2.svg',
index['Press'] = 'Cite newspaper.svg'
['Offline App'] = 'Offline logo.svg',
index['Recent changes'] = 'Clock icon.svg'
['Press'] = 'Cite newspaper.svg',
index['Recent Changes'] = 'Clock icon.svg'
['Recent changes'] = 'Clock icon.svg',
index['Recognized content'] = 'RibbonPrize.svg'
['Recent Changes'] = 'Clock icon.svg',
index['Recognized Content'] = 'RibbonPrize.svg'
index['Related Projects'] = 'Contributions icon.svg' -- Not for use for the update bot, special use case, that expands the page
['Recognized content'] = 'RibbonPrize.svg',
['Recognized Content'] = 'RibbonPrize.svg',
index['Related WikiProjects'] = 'Contributions icon.svg'
index['Requests'] = 'Quotes icon.svg'
['Related Projects'] = 'Contributions icon.svg', -- Not for use for the update bot, special use case, that expands the page
['Related WikiProjects'] = 'Contributions icon.svg',
index['Research'] = 'Microscope icon (black OCL).svg'
['Requests'] = 'Quotes icon.svg',
index['Resources'] = 'Cite book.svg'
['Research'] = 'Microscope icon (black OCL).svg',
index['Showcase'] = 'RibbonPrize.svg'
['Resources'] = 'Cite book.svg',
index['Tasks'] = 'ListBullet.svg'
['Showcase'] = 'RibbonPrize.svg',
index['Tools'] = 'Octicons-tools-minor.svg'
['Tasks'] = 'ListBullet.svg',
index['Translations'] = 'Translation icon.svg'
['Tools'] = 'Octicons-tools-minor.svg',
index['Watchlist'] = 'OpenEye icon.svg'
['Translations'] = 'Translation icon.svg',
index['Worklists'] = 'ListBullet.svg'
['Watchlist'] = 'OpenEye icon.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 'Beta icon.svg' -- default if nothing matches
return index['default']
end
end


local function editlinktest(modulename)
function editlinktest(modulename)
local no_edit_links = {'Discussions', 'Alerts', 'Showcase', 'Related WikiProjects'} -- no edit link for these standard modules
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)
local title = ''
title = ''
local intro = ''
intro = ''
local image = ''
image = ''
local color = '#6af' -- default value
color = '#6af' -- default value
local displaymode = 'normal' -- default value
displaymode = 'normal' -- default value
local modules = {}
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
toc_args = {width = 80, height = 55} -- passed into Image Array module
local toc_args = {
toc_args['font-size'] = '100%'
width = 80,
toc_args['margin'] = 0
height = 55,
body = ""
['font-size'] = '100%',
['margin'] = 0
} -- passed into Image Array module
local body = ""
-- Load a Table of Contents entry, transclude module, for each named module
-- Load a Table of Contents entry, transclude module, for each named module
local counter = 0
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 == "womeninred" then
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 Women in Red/" .. module
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 = 'https://en.wikipedia.org/wiki/Wikipedia:' .. string.gsub(moduletitle, ' ', '_') .. '?action=edit' .. preload .. editintro
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
toc = "<div style='margin-bottom:4em;'>" .. frame:expandTemplate{ title='Image_array', args = toc_args } .. "</div><div style='clear:both;'></div>"
local toc = "<div style='margin-bottom:4em;'>" .. require('Module:Image array')._imagearray(toc_args) .. "</div><div style='clear:both;'></div>"


-- Adding header
-- Adding header
local header = "__NOTOC__\n<div style='display: flex; flex-flow: row wrap;'>" -- top container
header = "__NOTOC__\n<div style='display: flex; display: -webkit-flex; flex-flow: row wrap; -webkit-flex-flow: row wrap;'>" -- top container
if displaymode == "womeninred" then
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 == "womeninred" then
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 participants box', args = { } }
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