יחידה:Sister project links: הבדלים בין גרסאות בדף
מאין תקציר עריכה |
מ גרסה אחת של הדף wikipedia:he:יחידה:Sister_project_links יובאה |
||
| (18 גרסאות ביניים של 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() | ||
| שורה 40: | שורה 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 | ||
| שורה 46: | שורה 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 | ||
| שורה 64: | שורה 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') | ||
| שורה 94: | שורה 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 | ||
| שורה 104: | שורה 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'], | ||