יחידה:Sister project links: הבדלים בין גרסאות בדף
מראה
מאין תקציר עריכה |
מ גרסה אחת של הדף wikipedia:he:יחידה:Sister_project_links יובאה |
||
| (17 גרסאות ביניים של 3 משתמשים אינן מוצגות) | |||
| שורה 15: | שורה 15: | ||
}, | }, | ||
['wikiquote'] = { | ['wikiquote'] = { | ||
['logo']=' | ['logo']='Wikiquote-logo.svg', | ||
['projectName'] = 'ויקיציטוט', | ['projectName'] = 'ויקיציטוט', | ||
['description']='ציטוטים', | ['description']='ציטוטים', | ||
['display']=' | ['display']='וויקיציטוט', | ||
['projectPrefix']='q' | ['projectPrefix']='q' | ||
}, | }, | ||
['wikibooks'] = { | ['wikibooks'] = { | ||
['logo']=' | ['logo']='Wikibooks-logo.svg', | ||
['projectName'] = 'ויקיספר', | ['projectName'] = 'ויקיספר', | ||
['description']='ספר לימוד', | ['description']='ספר לימוד', | ||
['display']='וויקיספר', | ['display']='וויקיספר', | ||
['projectPrefix']='b' | ['projectPrefix']='b' | ||
} | }, | ||
['wikisource'] = { | |||
['logo']='Wikisource-logo.svg', | |||
['projectName'] = 'ויקיטקסט', | |||
['description']='טקסט', | |||
['display']='וויקיטקסט', | |||
['projectPrefix']='s' | |||
}, | |||
['wikinews'] = { | |||
['logo']='Wikinews-logo.svg', | |||
['projectName'] = 'ויקיחדשות', | |||
['description']='דיווחים', | |||
['display']='וויקיחדשות', | |||
['projectPrefix']='n' | |||
}, | |||
['wikivoyage'] = { | |||
['logo']='Wikivoyage-Logo-v3-icon - mirrored.svg', | |||
['projectName'] = 'ויקימסע', | |||
['description']='מדריך למטייל', | |||
['display']='וויקימסע', | |||
['projectPrefix']='voy' | |||
}, | |||
['commons'] = { | |||
['logo']='Commons-logo.svg', | |||
['projectName'] = 'ויקישיתוף', | |||
['description']='תמונות ומדיה', | |||
['display']='וויקישיתוף', | |||
['projectPrefix']='commons' | |||
}, | |||
['wikispecies'] = { | |||
['logo']='Wikispecies-logo.svg', | |||
['projectName'] = 'ויקימינים', | |||
['description']='טקסונומיה', | |||
['display']='וויקימינים', | |||
['projectPrefix']='wikispecies' | |||
}, | |||
['meta'] = { | |||
['logo']='Wikimedia Community Logo.svg', | |||
['projectName'] = 'מטא-ויקי', | |||
['description']='דפי מיזמים', | |||
['display']='מטא-ויקי', | |||
['projectPrefix']='m' | |||
}, | |||
['mediawiki'] = { | |||
['logo']='MediaWiki-2020-logo.svg', | |||
['projectName'] = 'מדיה-ויקי', | |||
['description']='דפי התוכנה', | |||
['display']='מדיה-ויקי', | |||
['projectPrefix']='mw' | |||
} | |||
-- TODO: add other projects | |||
} | } | ||
function render(frame) | function render(frame) | ||
local args = require('Module:Arguments').getArgs(frame) | |||
local title = mw.title.getCurrentTitle().text | |||
local projectLinks = {} | local projectLinks = {} | ||
local entity = mw.wikibase.getEntityIdForCurrentPage() | local entity = mw.wikibase.getEntityIdForCurrentPage() | ||
| שורה 39: | שורה 90: | ||
local t = projectsTemplate['wikipedia'] | local t = projectsTemplate['wikipedia'] | ||
t['projectPrefix'] = args['ויקיפדיה'] | t['projectPrefix'] = args['ויקיפדיה'] | ||
t['pageDisplay'] = args['שם ויקיפדיה'] or | t['pageDisplay'] = args['שם ויקיפדיה'] or title | ||
table.insert(projectLinks, t) | table.insert(projectLinks, t) | ||
end | end | ||
| שורה 45: | שורה 96: | ||
local t = projectsTemplate['wikipedia'] | local t = projectsTemplate['wikipedia'] | ||
t['projectPrefix'] = args['ויקיפדיה 2'] | t['projectPrefix'] = args['ויקיפדיה 2'] | ||
t['pageDisplay'] = args['שם ויקיפדיה 2'] or | t['pageDisplay'] = args['שם ויקיפדיה 2'] or title | ||
table.insert(projectLinks, t) | table.insert(projectLinks, t) | ||
end | end | ||
| שורה 63: | שורה 114: | ||
template='wikibooks', | template='wikibooks', | ||
name='hewikibooks' | name='hewikibooks' | ||
}, | |||
{ | |||
arg='ויקיטקסט', | |||
template='wikisource', | |||
name='hewikisource' | |||
}, | |||
{ | |||
arg='ויקיחדשות', | |||
template='wikinews', | |||
name='hewikinews' | |||
}, | |||
{ | |||
arg='ויקימסע', | |||
template='wikivoyage', | |||
name='hewikivoyage' | |||
}, | |||
{ | |||
arg='ויקישיתוף', | |||
template='commons', | |||
name='commons' | |||
}, | |||
{ | |||
arg='ויקימינים', | |||
template='wikispecies', | |||
name='specieswiki' | |||
}, | |||
{ | |||
arg='מטא-ויקי', | |||
template='meta', | |||
}, | |||
{ | |||
arg='מדיה-ויקי', | |||
template='mediawiki' | |||
} | } | ||
} | } | ||
for i, proj in ipairs(projects) do | for i, proj in ipairs(projects) do | ||
if not args[proj['arg']] | -- fetch link from wikidata if not specific | ||
if entity~=nil and (not args[proj['arg']] or args[proj['arg']]==nil) and proj['name'] then | |||
if proj['name'] == 'commons' then | |||
local commonCat = mw.wikibase.getBestStatements( entity, 'P373' ) | |||
commonCat = commonCat and commonCat[1] and commonCat[1].mainsnak and commonCat[1].mainsnak.datavalue and commonCat[1].mainsnak.datavalue.value | |||
if commonCat~=nil and commonCat~='' then | |||
commonCat = mw.ustring.format('Category:%s', commonCat) | |||
end | |||
args[proj['arg']] = commonCat | |||
args['שם ' .. proj['arg']] = title | |||
else | |||
args[proj['arg']] = mw.wikibase.sitelink(entity, proj['name']) | |||
end | |||
end | end | ||
if args[proj['arg']] then | if args[proj['arg']] then | ||
local t = projectsTemplate[proj['template']] | local t = projectsTemplate[proj['template']] | ||
local defaultDisplayName = args[proj['arg']] | |||
if proj['arg'] == 'ויקישיתוף' then | |||
defaultDisplayName = title | |||
end | |||
t['pageName'] = args[proj['arg']] | t['pageName'] = args[proj['arg']] | ||
t['pageDisplay'] = args['שם ' .. proj['arg']] or | t['pageDisplay'] = args['שם ' .. proj['arg']] or defaultDisplayName | ||
table.insert(projectLinks, t) | table.insert(projectLinks, t) | ||
else | else | ||
end | end | ||
local i = 2 | local i = 2 | ||
local additionalArg = mw.ustring.format('%s %i', proj['arg'], i) | |||
local t = projectsTemplate[' | while args[additionalArg] do | ||
t['pageName'] = args[ | local t = mw.clone( projectsTemplate[proj['template']] ) | ||
t['pageDisplay'] = args['שם ' | t['pageName'] = args[additionalArg] | ||
t['pageDisplay'] = args[mw.ustring.format('שם %s %i', proj['arg'], i)] or t['pageName'] | |||
table.insert(projectLinks, t) | table.insert(projectLinks, t) | ||
i=i+1 | i=i+1 | ||
additionalArg = mw.ustring.format('%s %i', proj['arg'], i) | |||
end | end | ||
end | end | ||
local float = 'float: left;' | |||
if args['1'] == 'ימין' then | |||
float = '' | |||
end | |||
local root = mw.html.create('table') | local root = mw.html.create('table') | ||
root:addClass('toccolours') | root:addClass('toccolours') | ||
| שורה 93: | שורה 201: | ||
:addClass('plainlinks') | :addClass('plainlinks') | ||
:addClass('noprint') | :addClass('noprint') | ||
:cssText(' | :cssText('margin: 0 1em 0.5em 0;' .. float) | ||
root:tag('tr'):tag('th'):css('text-align', 'center'): | root:tag('tr'):tag('th'):css('text-align', 'center'):wikitext('מיזמי [[קרן ויקימדיה]]') | ||
for k,v in pairs(projectLinks) do | for k,v in pairs(projectLinks) do | ||
| שורה 103: | שורה 211: | ||
function renderProject(projectTemplate) | function renderProject(projectTemplate) | ||
return mw.html.create | return mw.html.create('div') | ||
:addClass('sisterwikilinkT') | :addClass('sisterwikilinkT') | ||
:wikitext(mw.ustring.format("[[File: | :wikitext(mw.ustring.format("[[File:%s|20px|link=|%s]] %s ב%s: '''[[:%s:%s|%s]]'''", | ||
projectTemplate['logo'], projectTemplate['projectName'], | projectTemplate['logo'], projectTemplate['projectName'], | ||
projectTemplate['description'], projectTemplate['display'], | projectTemplate['description'], projectTemplate['display'], | ||
גרסה אחרונה מ־06:51, 4 באפריל 2022
ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:Sister project links/תיעוד
local projectsTemplate = {
['wikipedia'] = {
['logo']='Wikipedia-logo-v2.svg',
['projectName'] = 'ויקיפדיה',
['description']='[[ויקיפדיה]]',
['display']='שפה זו',
['pageName'] = ''
},
['wiktionary'] = {
['logo']='Wiktionary-logo-he.png',
['projectName'] = 'ויקימילון',
['description']='ערך מילוני',
['display']='וויקימילון',
['projectPrefix']='wikt'
},
['wikiquote'] = {
['logo']='Wikiquote-logo.svg',
['projectName'] = 'ויקיציטוט',
['description']='ציטוטים',
['display']='וויקיציטוט',
['projectPrefix']='q'
},
['wikibooks'] = {
['logo']='Wikibooks-logo.svg',
['projectName'] = 'ויקיספר',
['description']='ספר לימוד',
['display']='וויקיספר',
['projectPrefix']='b'
},
['wikisource'] = {
['logo']='Wikisource-logo.svg',
['projectName'] = 'ויקיטקסט',
['description']='טקסט',
['display']='וויקיטקסט',
['projectPrefix']='s'
},
['wikinews'] = {
['logo']='Wikinews-logo.svg',
['projectName'] = 'ויקיחדשות',
['description']='דיווחים',
['display']='וויקיחדשות',
['projectPrefix']='n'
},
['wikivoyage'] = {
['logo']='Wikivoyage-Logo-v3-icon - mirrored.svg',
['projectName'] = 'ויקימסע',
['description']='מדריך למטייל',
['display']='וויקימסע',
['projectPrefix']='voy'
},
['commons'] = {
['logo']='Commons-logo.svg',
['projectName'] = 'ויקישיתוף',
['description']='תמונות ומדיה',
['display']='וויקישיתוף',
['projectPrefix']='commons'
},
['wikispecies'] = {
['logo']='Wikispecies-logo.svg',
['projectName'] = 'ויקימינים',
['description']='טקסונומיה',
['display']='וויקימינים',
['projectPrefix']='wikispecies'
},
['meta'] = {
['logo']='Wikimedia Community Logo.svg',
['projectName'] = 'מטא-ויקי',
['description']='דפי מיזמים',
['display']='מטא-ויקי',
['projectPrefix']='m'
},
['mediawiki'] = {
['logo']='MediaWiki-2020-logo.svg',
['projectName'] = 'מדיה-ויקי',
['description']='דפי התוכנה',
['display']='מדיה-ויקי',
['projectPrefix']='mw'
}
-- TODO: add other projects
}
function render(frame)
local args = require('Module:Arguments').getArgs(frame)
local title = mw.title.getCurrentTitle().text
local projectLinks = {}
local entity = mw.wikibase.getEntityIdForCurrentPage()
if args['ויקיפדיה'] then
local t = projectsTemplate['wikipedia']
t['projectPrefix'] = args['ויקיפדיה']
t['pageDisplay'] = args['שם ויקיפדיה'] or title
table.insert(projectLinks, t)
end
if args['ויקיפדיה 2'] then
local t = projectsTemplate['wikipedia']
t['projectPrefix'] = args['ויקיפדיה 2']
t['pageDisplay'] = args['שם ויקיפדיה 2'] or title
table.insert(projectLinks, t)
end
local projects = {
{
arg='ויקימילון',
template='wiktionary',
name='hewiktionary'
},
{
arg='ויקיציטוט',
template='wikiquote',
name='hewikiquote'
},
{
arg='ויקיספר',
template='wikibooks',
name='hewikibooks'
},
{
arg='ויקיטקסט',
template='wikisource',
name='hewikisource'
},
{
arg='ויקיחדשות',
template='wikinews',
name='hewikinews'
},
{
arg='ויקימסע',
template='wikivoyage',
name='hewikivoyage'
},
{
arg='ויקישיתוף',
template='commons',
name='commons'
},
{
arg='ויקימינים',
template='wikispecies',
name='specieswiki'
},
{
arg='מטא-ויקי',
template='meta',
},
{
arg='מדיה-ויקי',
template='mediawiki'
}
}
for i, proj in ipairs(projects) do
-- fetch link from wikidata if not specific
if entity~=nil and (not args[proj['arg']] or args[proj['arg']]==nil) and proj['name'] then
if proj['name'] == 'commons' then
local commonCat = mw.wikibase.getBestStatements( entity, 'P373' )
commonCat = commonCat and commonCat[1] and commonCat[1].mainsnak and commonCat[1].mainsnak.datavalue and commonCat[1].mainsnak.datavalue.value
if commonCat~=nil and commonCat~='' then
commonCat = mw.ustring.format('Category:%s', commonCat)
end
args[proj['arg']] = commonCat
args['שם ' .. proj['arg']] = title
else
args[proj['arg']] = mw.wikibase.sitelink(entity, proj['name'])
end
end
if args[proj['arg']] then
local t = projectsTemplate[proj['template']]
local defaultDisplayName = args[proj['arg']]
if proj['arg'] == 'ויקישיתוף' then
defaultDisplayName = title
end
t['pageName'] = args[proj['arg']]
t['pageDisplay'] = args['שם ' .. proj['arg']] or defaultDisplayName
table.insert(projectLinks, t)
else
end
local i = 2
local additionalArg = mw.ustring.format('%s %i', proj['arg'], i)
while args[additionalArg] do
local t = mw.clone( projectsTemplate[proj['template']] )
t['pageName'] = args[additionalArg]
t['pageDisplay'] = args[mw.ustring.format('שם %s %i', proj['arg'], i)] or t['pageName']
table.insert(projectLinks, t)
i=i+1
additionalArg = mw.ustring.format('%s %i', proj['arg'], i)
end
end
local float = 'float: left;'
if args['1'] == 'ימין' then
float = ''
end
local root = mw.html.create('table')
root:addClass('toccolours')
:addClass('sistersitebox')
:addClass('plainlinks')
:addClass('noprint')
:cssText('margin: 0 1em 0.5em 0;' .. float)
root:tag('tr'):tag('th'):css('text-align', 'center'):wikitext('מיזמי [[קרן ויקימדיה]]')
for k,v in pairs(projectLinks) do
root:tag('tr'):tag('td'):node(renderProject(v))
end
return root
end
function renderProject(projectTemplate)
return mw.html.create('div')
:addClass('sisterwikilinkT')
:wikitext(mw.ustring.format("[[File:%s|20px|link=|%s]] %s ב%s: '''[[:%s:%s|%s]]'''",
projectTemplate['logo'], projectTemplate['projectName'],
projectTemplate['description'], projectTemplate['display'],
projectTemplate['projectPrefix'], projectTemplate['pageName'], projectTemplate['pageDisplay']))
end
return {
render=render
}