יחידה:Sister project links – הבדלי גרסאות
אין תקציר עריכה |
אין תקציר עריכה |
||
| (4 גרסאות ביניים של אותו משתמש אינן מוצגות) | |||
| שורה 8: | שורה 8: | ||
}, | }, | ||
['chabadtext'] = { | ['chabadtext'] = { | ||
['logo']=' | ['logo']='חבדטקסט.png', | ||
['projectName'] = 'חב"דטקסט', | ['projectName'] = 'חב"דטקסט', | ||
['description']='טקסט', | ['description']='טקסט', | ||
| שורה 15: | שורה 15: | ||
}, | }, | ||
['chabadquote'] = { | ['chabadquote'] = { | ||
['logo']=' | ['logo']='חבדציטוט.png', | ||
['projectName'] = 'חב"דציטוט', | ['projectName'] = 'חב"דציטוט', | ||
['description']='ציטוטים', | ['description']='ציטוטים', | ||
| שורה 23: | שורה 23: | ||
} | } | ||
function render(frame) | |||
local args = require('Module:Arguments').getArgs(frame) | local args = require('Module:Arguments').getArgs(frame) | ||
local title = mw.title.getCurrentTitle().text | local title = mw.title.getCurrentTitle().text | ||
local projectLinks = {} | local projectLinks = {} | ||
local entity = mw.wikibase and mw.wikibase.getEntityObject() | |||
if args['חב"דפדיה'] then | if args['חב"דפדיה'] then | ||
local t = mw.clone(projectsTemplate['cphe']) | local t = mw.clone(projectsTemplate['cphe']) | ||
| שורה 50: | שורה 34: | ||
t['pageName'] = args['חב"דפדיה'] | t['pageName'] = args['חב"דפדיה'] | ||
t['pageDisplay'] = args['שם חב"דפדיה'] or title | t['pageDisplay'] = args['שם חב"דפדיה'] or title | ||
table.insert(projectLinks, t) | table.insert(projectLinks, t) | ||
end | end | ||
local projects = { | local projects = { | ||
{arg='חב"דציטוט', template='chabadquote'}, | { | ||
{arg='חב"דטקסט', template='chabadtext'} | arg='חב"דציטוט', | ||
template='chabadquote', | |||
name='chabadquote' | |||
}, | |||
{ | |||
arg='חב"דטקסט', | |||
template='chabadtext', | |||
name='chabadtext' | |||
} | |||
} | } | ||
for | for i, proj in ipairs(projects) do | ||
if args[proj.arg] then | if entity~=nil and (not args[proj['arg']] or args[proj['arg']]==nil) and proj['name'] then | ||
local t = mw.clone(projectsTemplate[proj | args[proj['arg']] = mw.wikibase.sitelink(entity, proj['name']) | ||
t | args['שם ' .. proj['arg']] = title | ||
t | end | ||
if args[proj['arg']] then | |||
local t = mw.clone(projectsTemplate[proj['template']]) | |||
t['pageName'] = args[proj['arg']] | |||
t['pageDisplay'] = args['שם ' .. proj['arg']] or t['pageName'] | |||
table.insert(projectLinks, t) | table.insert(projectLinks, t) | ||
end | end | ||
local i = 2 | local i = 2 | ||
local additionalArg = mw.ustring.format('%s %i', proj | local additionalArg = mw.ustring.format('%s %i', proj['arg'], i) | ||
while args[additionalArg] do | while args[additionalArg] do | ||
local t = mw.clone(projectsTemplate[proj | local t = mw.clone(projectsTemplate[proj['template']]) | ||
t | t['pageName'] = args[additionalArg] | ||
t | 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 | additionalArg = mw.ustring.format('%s %i', proj['arg'], i) | ||
end | end | ||
end | end | ||
local float = 'float: left;' | local float = 'float: left;' | ||
if args['1'] == 'ימין' then float = ' | if args['1'] == 'ימין' then | ||
float = '' | |||
end | |||
local templatestyles = frame:extensionTag{ | local templatestyles = frame:extensionTag{ | ||
name='templatestyles', args={src='יחידה:Sister project links/styles.css'} | name = 'templatestyles', | ||
args = { src = 'יחידה:Sister project links/styles.css' } | |||
} | } | ||
local root = mw.html.create('table') | local root = mw.html.create('table') | ||
root:addClass('sistersitebox'):addClass('plainlinks'):addClass('noprint') | root | ||
:addClass('sistersitebox') | |||
:addClass('plainlinks') | |||
:addClass('noprint') | |||
:cssText('margin: 0 1em 0.5em 0;' .. float) | :cssText('margin: 0 1em 0.5em 0;' .. float) | ||
root:tag('tr'):tag('th'):css('text-align','center'):wikitext('מיזמי | root:tag('tr'):tag('th'):css('text-align', 'center'):wikitext('מיזמי חב"דמדיה') | ||
local cat = '' | local cat = '' | ||
| שורה 108: | שורה 102: | ||
end | end | ||
return | return tostring(root) .. templatestyles .. cat | ||
end | end | ||
return { render = render } | 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 | |||
} | |||