בדוקי עריכות אוטומטית, אינטערפעיס רעדאקטארן, אינטערפעיס אדמיניסטראַטאָרן, סיסאפן, מייבאים, מעדכנים, מייבא, אספקלריה רעדאקטארן
46,363
רעדאגירונגען
(אפדעיט, כאטש כ'ווייס נישט צו ס'טוט אויף, מסתמא נישט...) |
(אפדעיט) |
||
| שורה 22: | שורה 22: | ||
for k,v in pairs(self.templateParams) do | for k,v in pairs(self.templateParams) do | ||
if mw.ustring.match( k, '-ויקינתונים') then | if mw.ustring.match( k, '-ויקינתונים') then | ||
templateDocumentation = templateDocumentation .. '[[ | templateDocumentation = templateDocumentation .. '[[קאַטעגאָריע:תבניות מידע שמשתמשות בוויקינתונים]]' | ||
break | break | ||
end | end | ||
| שורה 236: | שורה 236: | ||
if #headerDataNoSpace >0 then | if #headerDataNoSpace >0 then | ||
table.insert(tempTemplateStructure, self.templateStructure[lastHeaderIndex]) | table.insert(tempTemplateStructure, self.templateStructure[lastHeaderIndex]) | ||
end end | end | ||
end | |||
lastHeaderIndex = nil | lastHeaderIndex = nil | ||
end | end | ||
| שורה 252: | שורה 253: | ||
function Infobox:renderInfobox() | function Infobox:renderInfobox() | ||
self:removeEmptyHeaders() | self:removeEmptyHeaders() | ||
-- sub infobox | -- sub infobox | ||
if self.args.subtemplate then | if self.args.subtemplate then | ||
| שורה 306: | שורה 307: | ||
valueArg = '[[File:' .. valueArg .. imgSuffix | valueArg = '[[File:' .. valueArg .. imgSuffix | ||
end | end | ||
elseif args.imgDesc~=nil and #args.imgDesc>0 and not mw.ustring.match(args.imgDesc, '%[%[ | elseif args.imgDesc~=nil and #args.imgDesc>0 and not mw.ustring.match(args.imgDesc, '%[%[קאַטעגאָריע:ערכים להחלפת תמונה בחופשית%]%]$') then | ||
if mw.ustring.match(valueArg, '^ *%[%[[Ff]ile:') or | if mw.ustring.match(valueArg, '^ *%[%[[Ff]ile:') or | ||
mw.ustring.match(valueArg, '^ *%[%[[Ii]mage:') or | |||
mw.ustring.match(valueArg, '^ *%[%[קובץ:') or | |||
mw.ustring.match(valueArg, '^ *%[%[טעקע:') or | mw.ustring.match(valueArg, '^ *%[%[טעקע:') or | ||
mw.ustring.match(valueArg, '^ *%[%[תמונה:') then | mw.ustring.match(valueArg, '^ *%[%[תמונה:') then | ||
valueArg = mw.ustring.gsub(valueArg, "%]%]$", "") | valueArg = mw.ustring.gsub(valueArg, "%]%]$", "") | ||
local imgSuffix = '|' .. args.imgDesc .. ']]' | local imgSuffix = '|' .. args.imgDesc .. ']]' | ||
valueArg = valueArg .. imgSuffix | valueArg = valueArg .. imgSuffix | ||
end | end | ||
end | end | ||
return valueArg | return valueArg, args.imgDesc | ||
end | end | ||
end | end | ||
| שורה 333: | שורה 334: | ||
function splitMaintainceCategory(value) | function splitMaintainceCategory(value) | ||
local maintainceCats = nil | local maintainceCats = nil | ||
local hasData = #(mw.ustring.gsub(value, '%[%[ | local hasData = #(mw.ustring.gsub(value, '%[%[קאַטעגאָריע:.-%]%]', ''))>0 | ||
if not hasData then | if not hasData then | ||
maintainceCats = value | maintainceCats = value | ||
| שורה 406: | שורה 407: | ||
table.insert(wikidataOptions['qualifiers'], v) | table.insert(wikidataOptions['qualifiers'], v) | ||
end | end | ||
wikidataOptions['default-value'] = templateParams[missingParam..'-ויקינתונים-פרטים-ברירת מחדל'] or nil | |||
end | end | ||
if templateParams[missingParam..'-ויקינתונים-תמונה-גודל']~=nil then | if templateParams[missingParam..'-ויקינתונים-תמונה-גודל']~=nil then | ||
| שורה 426: | שורה 428: | ||
wikidataOptions['allowMulti'] = true | wikidataOptions['allowMulti'] = true | ||
wikidataOptions['seperator'] = templateParams[missingParam..'-ויקינתונים-מרובה-הפרדה'] | wikidataOptions['seperator'] = templateParams[missingParam..'-ויקינתונים-מרובה-הפרדה'] | ||
wikidataOptions['sort'] = templateParams[missingParam..'-ויקינתונים-מרובה-מיון'] or nil | wikidataOptions['sort'] = { templateParams[missingParam..'-ויקינתונים-מרובה-מיון'] } or nil | ||
paramsData = {} | paramsData = {} | ||
-- split multiple params to include all of them (e.g: "P1,P2") | -- split multiple params to include all of them (e.g: "P1,P2") | ||
| שורה 445: | שורה 447: | ||
end | end | ||
end | end | ||
templateArg.data = table.concat(paramsData, wikidataOptions['seperator']) | if wikidataOptions['seperator'] == '*' and #paramsData>1 then | ||
templateArg.data = '*' .. table.concat( paramsData, '\n*' ) | |||
else | |||
templateArg.data = table.concat(paramsData, wikidataOptions['seperator']) | |||
end | |||
inWikidata = templateArg.data and #(templateArg.data)>0 | inWikidata = templateArg.data and #(templateArg.data)>0 | ||
elseif templateParams[missingParam..'-ויקינתונים-פשוט'] then | elseif templateParams[missingParam..'-ויקינתונים-פשוט'] then | ||
| שורה 480: | שורה 486: | ||
return inWikidata, maintainceCats | return inWikidata, maintainceCats | ||
end | end | ||
--[[ | --[[ | ||
| שורה 538: | שורה 543: | ||
end | end | ||
end | end | ||
end | end | ||
| שורה 565: | שורה 569: | ||
args.subtitlestyle = templateParams['תת כותרת תבנית-עיצוב'] | args.subtitlestyle = templateParams['תת כותרת תבנית-עיצוב'] | ||
args.subtitleclass = templateParams['תת כותרת תבנית-מחלקה'] | args.subtitleclass = templateParams['תת כותרת תבנית-מחלקה'] | ||
args.rightImage = getValueOrWikidataImage{ | |||
args.rightImageDesc = templateParams['כיתוב ימין'] | |||
args.rightImage, args.rightImageDesc = getValueOrWikidataImage{ | |||
valueArg=templateParams['תמונה ימין'], | valueArg=templateParams['תמונה ימין'], | ||
wikidataArg=templateParams['תמונה ימין-ויקינתונים'], | wikidataArg=templateParams['תמונה ימין-ויקינתונים'], | ||
width='100x80', | width='100x80', | ||
imgDesc=args.rightImageDesc, | |||
args=args | args=args | ||
} | } | ||
args. | |||
args.leftImage = getValueOrWikidataImage{ | args.leftImageDesc = templateParams['כיתוב שמאל'] | ||
args.leftImage, args.leftImageDesc = getValueOrWikidataImage{ | |||
valueArg=templateParams['תמונה שמאל'], | valueArg=templateParams['תמונה שמאל'], | ||
wikidataArg=templateParams['תמונה שמאל-ויקינתונים'], | wikidataArg=templateParams['תמונה שמאל-ויקינתונים'], | ||
width='100x80', | width='100x80', | ||
imgDesc=args.leftImageDesc, | |||
args=args | args=args | ||
} | } | ||
args.imageDesc = templateParams['כיתוב'] | args.imageDesc = templateParams['כיתוב'] | ||
if templateParams['תמונה ללא שאיבה אוטומטית'] == 'כן' then | if templateParams['תמונה ללא שאיבה אוטומטית'] == 'כן' then | ||
args.image = getValueOrWikidataImage{ | args.image, args.imageDesc = getValueOrWikidataImage{ | ||
valueArg=templateParams['תמונה'], | valueArg=templateParams['תמונה'], | ||
wikidataArg=templateParams['תמונה-ויקינתונים'], | wikidataArg=templateParams['תמונה-ויקינתונים'], | ||
| שורה 589: | שורה 598: | ||
} | } | ||
else | else | ||
args.image = getValueOrWikidataImage{ | args.image, args.imageDesc = getValueOrWikidataImage{ | ||
valueArg=templateParams['תמונה'], | valueArg=templateParams['תמונה'], | ||
wikidataArg=templateParams['תמונה-ויקינתונים'] or 'P18', | wikidataArg=templateParams['תמונה-ויקינתונים'] or 'P18', | ||
| שורה 620: | שורה 629: | ||
local labelPrefix = 'תווית' | local labelPrefix = 'תווית' | ||
local dataPrefix = 'מידע' | local dataPrefix = 'מידע' | ||
local parameterDataPrefix = 'מידע-פרמטרי' | |||
local subheader = 'כותרת' | local subheader = 'כותרת' | ||
local labelDataPrefix = 'תווית-מידע' | local labelDataPrefix = 'תווית-מידע' | ||
| שורה 640: | שורה 650: | ||
else | else | ||
local labelName = templateParams[labelPrefix..i] | local labelName = templateParams[labelPrefix..i] | ||
local dataTemplate = templateParams[dataPrefix..i] | local dataTemplate = templateParams[dataPrefix..i] or templateParams[parameterDataPrefix..i] | ||
if dataTemplate then | if dataTemplate then | ||
-- if parameter contains only category with no value, replace with with nil and add the value to maintaince category | -- if parameter contains only category with no value, replace with with nil and add the value to maintaince category | ||
| שורה 650: | שורה 660: | ||
end | end | ||
if labelName and dataTemplate then | if labelName and dataTemplate then | ||
--label | if dataTemplate == templateParams[parameterDataPrefix..i] then | ||
local hasContent = templateArgs[dataTemplate] and #templateArgs[dataTemplate]>0 | |||
-- + and use explicit wikidata replace the content with such if available from wikidata | |||
local isExplicitWikidataParam = templateParams[dataTemplate..explicitWikidata] | |||
local isExplicitWikidataEnabled = false | |||
if isExplicitWikidataParam then | |||
isExplicitWikidataEnabled = templateArgs[dataTemplate]~=nil and mw.ustring.match(templateArgs[dataTemplate], '^ *+$') | |||
end | |||
local skipContent = false | |||
if hasContent and not isExplicitWikidataEnabled then | |||
dataTemplate = templateArgs[dataTemplate] | |||
else | |||
if isExplicitWikidataParam and not isExplicitWikidataEnabled then | |||
skipContent = true | |||
end | |||
dataTemplate = '{{{' ..dataTemplate.. '}}}' | |||
end | |||
if not skipContent then | |||
table.insert(templateStructure, {label=labelName, data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix], | |||
labelstyle=templateParams[labelPrefix..i..styleSuffix], indic=indic}) | |||
end | |||
else | |||
table.insert(templateStructure, {label=labelName, data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix], | |||
labelstyle=templateParams[labelPrefix..i..styleSuffix], indic=indic}) | labelstyle=templateParams[labelPrefix..i..styleSuffix], indic=indic}) | ||
end | |||
elseif labelName and not dataTemplate then | elseif labelName and not dataTemplate then | ||
--skip it. no only label [use subheader] | --skip it. no only label [use subheader] | ||
elseif not labelName and dataTemplate then | elseif not labelName and dataTemplate then | ||
-- | if dataTemplate == templateParams[parameterDataPrefix..i] then | ||
local hasContent = templateArgs[dataTemplate] and #templateArgs[dataTemplate]>0 | |||
-- + and use explicit wikidata replace the content with such if available from wikidata | |||
local isExplicitWikidataParam = templateParams[dataTemplate..explicitWikidata] | |||
local isExplicitWikidataEnabled = false | |||
if isExplicitWikidataParam then | |||
isExplicitWikidataEnabled = templateArgs[dataTemplate]~=nil and mw.ustring.match(templateArgs[dataTemplate], '^ *+$') | |||
end | |||
local skipContent = false | |||
if hasContent and not isExplicitWikidataEnabled then | |||
dataTemplate = templateArgs[dataTemplate] | |||
else | |||
if isExplicitWikidataParam and not isExplicitWikidataEnabled then | |||
skipContent = true | |||
end | |||
dataTemplate = '{{{' ..dataTemplate.. '}}}' | |||
end | |||
if not skipContent then | |||
table.insert(templateStructure, {data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix], indic=indic}) | |||
end | |||
else | |||
table.insert(templateStructure, {data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix], indic=indic}) | |||
end | |||
else | else | ||
local label_data_names = templateParams[labelDataPrefix..i] | local label_data_names = templateParams[labelDataPrefix..i] | ||
| שורה 683: | שורה 736: | ||
table.insert(templateStructure, {label=labelName, data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix], | table.insert(templateStructure, {label=labelName, data=dataTemplate, rowstyle=templateParams[rowStylePrefix..i], rowclass=templateParams[rowStyleClassPrefix..i], datastyle=templateParams[dataPrefix..i..styleSuffix], | ||
labelstyle=templateParams[labelPrefix..i..styleSuffix], indic=indic}) | labelstyle=templateParams[labelPrefix..i..styleSuffix], indic=indic}) | ||
end | end | ||
end | end | ||
end | end | ||
| שורה 705: | שורה 758: | ||
-- otherwise if the template isn't full or if there is a Wikidata-beats tag - them try to use wikidata to fill it | -- otherwise if the template isn't full or if there is a Wikidata-beats tag - them try to use wikidata to fill it | ||
local m = mw.ustring.match(v.data, '\{\{\{(.-)\}\}\}') | local m = mw.ustring.match(v.data, '\{\{\{(.-)\}\}\}') | ||
if v.label and templateParams[v.label..'-ויקינתונים-גובר'] then | |||
m = templateParams[v.label..'-ויקינתונים-גובר'] | |||
end | |||
if m then | if m then | ||
m = mw.uri.decode( m ) -- some templates may add encoding and are preprocessed before | m = mw.uri.decode( m ) -- some templates may add encoding and are preprocessed before | ||
local before = v.data | |||
local inWikidata, maintainceCats = fillMissingParamFromWikidata(m, templateParams, v, args.entityId, frame) | local inWikidata, maintainceCats = fillMissingParamFromWikidata(m, templateParams, v, args.entityId, frame) | ||
if (v.data==nil or v.data=="") and v.label and templateParams[v.label..'-ויקינתונים-גובר'] then | |||
v.data = before | |||
inWikidata = true | |||
end | |||
if maintainceCats then | if maintainceCats then | ||
table.insert(wikidataCats, maintainceCats) | table.insert(wikidataCats, maintainceCats) | ||
רעדאגירונגען