ഘടകം:Iucnഈ ഘടകത്തിന്റെ വിവരണം ഘടകം:Iucn/വിവരണം എന്ന താളിൽ നിർമ്മിക്കാവുന്നതാണ് local p = {}
local data = { -- these data entries will ultimately go in data subpage or series of data subpages **NOT USED**
iucn = {
['_template'] = "cite journal", -- use cite journal
['_exclude'] = "amended, url" , -- do not pass these to {{cite journal}}
--_alias-map: associate {{IUCN}}-specific parameter names with cs1|2-standard parameter names
['_alias-map'] = "assessors : authors, vassessors : vauthors, assessor# : last#, assessor#-link : author#-link,assessor-link# : author-link#, assessorlink# : authorlink#, assessor#-mask : author#-mask, assessor-mask# : author-mask#, assessormask# : authormask#, display-assessors : display-authors, displayassessors : displayauthors, last-assessor-amp : last-author-amp, lastassessoramp : lastauthoramp, assessment_year : year, taxon : title, downloaded : access-date"
}
}
local function getArgs (frame, args)
local parents = mw.getCurrentFrame():getParent()
for k,v in pairs(parents.args) do
--check content
if v and v ~= "" then
args[k]=v --parents.args[k]
end
end
end
--[[ function p.cite() - function wrapping {{cite journal}}
takes cite journal parameters but updates old style url using electronic page number
page should be in format e.T13922A45199653
the url uses 13922/45199653
so we need to extract the number between T and A and the number after A
the target url is https://www.iucnredlist.org/species/13922/45199653
usage: {{#invoke:iucn|cite}}
template: {{Template:Cite iucn}}
--]]
function p.cite(frame)
--local parents = mw.getCurrentFrame():getParent()
local templateArgs = {}
getArgs (frame, templateArgs)
--we only want to make changes if there is old-style url, i.e. one containing "/details/"
local url = templateArgs['url'] or ""
local old = string.find( url, "details" , 1, true)
if old then
local page = templateArgs['page'] or ""
local speciesID = string.match( page, "T(%d+)A" )
local speciesAssessment = string.match( page, "A(%d+)" )
if speciesID and speciesAssessment then -- set new style url
templateArgs['url'] = "https://www.iucnredlist.org/species/" .. speciesID .. '/' .. speciesAssessment
end
end
if templateArgs['amended'] then templateArgs['trans-title']=templateArgs['amended'] end -- use translated title parameter to add amended text, e.g. "amended version of 2016 assessment", which will be added in square brackets after title
return frame:expandTemplate{ title = 'cite journal', args = templateArgs }
--return frame:expandTemplate{ title = 'cite journal', args = parents.args }
end
-- version using template wrapper for cite journal
function p.cite2(frame)
-- now use wrapper template
--[[this doesn't work
frame.args['_alias-map'] = "assessors : authors, vassessors : vauthors, assessor# : last#, assessor#-link : author#-link,assessor-link# : author-link#, assessorlink# : authorlink#, assessor#-mask : author#-mask, assessor-mask# : author-mask#, assessormask# : authormask#, display-assessors : display-authors, displayassessors : displayauthors, last-assessor-amp : last-author-amp, lastassessoramp : lastauthoramp, assessment_year : year, taxon : title, downloaded : access-date"
frame.args['_template'] = "cite journal"
but the following does ]]
local wrapperArgs ={}
wrapperArgs['_template'] = "cite journal"
--|_exclude=id, version, new, IUCN_Year, iucn_year, criteria-version <!-- do not pass these to {{cite journal}} -->
wrapperArgs['_exclude'] = "amended, url" -- exclude url (from parent) as we wanted updated version
--|_alias-map= <!-- associate {{IUCN}}-specific parameter names with cs1|2-standard parameter names -->
wrapperArgs['_alias-map'] = "assessors : authors, vassessors : vauthors, assessor# : last#, assessor#-link : author#-link,assessor-link# : author-link#, assessorlink# : authorlink#, assessor#-mask : author#-mask, assessor-mask# : author-mask#, assessormask# : authormask#, display-assessors : display-authors, displayassessors : displayauthors, last-assessor-amp : last-author-amp, lastassessoramp : lastauthoramp, assessment_year : year, taxon : title, downloaded : access-date"
local templateArgs = {} -- need a copy to alter and pass to citation template
getArgs (frame, templateArgs)
--we only want to make changes if there is old-style url, i.e. one containing "/details/"
local url = templateArgs['url'] or ""
local replace = string.find( url, "details" , 1, true) -- replace url if contains "details"
if url == "" and templateArgs['page'] then replace = true end -- if no url and page number available,
if replace then
local page = templateArgs['page'] or ""
local speciesID = string.match( page, "T(%d+)A" )
local speciesAssessment = string.match( page, "A(%d+)" )
if speciesID and speciesAssessment then -- set new style url
wrapperArgs['url'] = "https://www.iucnredlist.org/species/" .. speciesID .. '/' .. speciesAssessment
end
else
wrapperArgs['url']=templateArgs['url']
end
if url == "" and templateArgs['id'] then -- use oldstyle url
wrapperArgs['url'] = "http://oldredlist.iucnredlist.org/details/" .. templateArgs['id']
wrapperArgs['journal'] = '[[IUCN Red List of Threatened Species]]'
wrapperArgs['volume'] = 'Version ' .. templateArgs['version']
end
if templateArgs['amended'] then wrapperArgs['trans-title']=templateArgs['amended'] end -- use translated title parameter to add amended text, e.g. "amended version of 2016 assessment", which will be added in square brackets after title
--wrapperArgs['trans-title'] = templateArgs['trans-title']
frame.args=wrapperArgs --set the wrapper arguments
local wrapper = require("Module:Template wrapper/sandbox")
--local xframe = frame --mw.clone(frame) --mw.getCurrentFrame()
--frame.args.metatable['_template'] = "cite journal"
--local parents = xframe:getParent() --mw.getCurrentFrame():getParent()
--parents.args['_template'] = "cite journal"
--mw.logObject(frame)
--return mw.dumpObject(wrapperArgs)
return wrapper.wrap(frame)
end
--[[ function to replace iucn templates
test template: Template:IUCN/sandbox/lua
usage: {{#invoke:iucn|main}}
--]]
function p.main(frame)
local templateArgs = {} -- need a copy to alter and pass to citation template
getArgs (frame, templateArgs)
-- local parents = mw.getCurrentFrame():getParent()
local reference = ""
local taxon =templateArgs['taxon']
reference = '{{cite journal |title=' .. taxon
local maxAssessors = 20
local assessorNumber =0
-- if 'assessor' instead of 'assessor1'
if templateArgs['assessor'] then templateArgs['assessor1'] = templateArgs['assessor'] end
if templateArgs['assessor-link'] then templateArgs['assessor-link1'] = templateArgs['assessor-link'] end
while assessorNumber < maxAssessors do -- use the last number determined in the preprocessing
assessorNumber = assessorNumber + 1 -- so we start with 1
local assessorName = templateArgs['assessor'..tostring(assessorNumber)] or ""
if assessorName ~= "" then
reference = reference .. ' |author' .. assessorNumber .. '=' .. assessorName
end
local assessorLink = templateArgs['assessor-link'..tostring(assessorNumber)]
or templateArgs['assessor'..tostring(assessorNumber)..'link']
or templateArgs['assessorlink'..tostring(assessorNumber)]or ""
if assessorLink ~= "" then
reference = reference .. ' |authorlink' .. assessorNumber .. '=' .. assessorLink
end
end
local year = templateArgs['year']
local id = templateArgs['id']
local assessment = templateArgs['assessment'] or ""
local version = templateArgs['version']
local doi = templateArgs['doi'] or ""
local accessdate = templateArgs['accessdate'] or ""
reference = reference ..
' |year=' .. year
" |version=''Version ".. version .. "''" ..
' |journal=[[The IUCN Red List of Threatened Species]]' ..
' |accessdate='.. accessdate ..
' |doi='.. doi
if assessment ~= "" then
reference = reference .. '|url=https://www.iucnredlist.org/species/'.. id .. '/' .. assessment
else -- if there is no assessment number, use oldredlist.iucnredlist.org version
-- an alternative might be to use archive.org in case this cite is dropped
reference = reference .. '|url=http://oldredlist.iucnredlist.org/details/'.. id .. '/0'
end
reference = reference .. ' |publisher=[[International Union for Conservation of Nature]]}}'
return frame:preprocess(reference)
--return reference
end
return p
|
Index:
pl ar de en es fr it arz nl ja pt ceb sv uk vi war zh ru af ast az bg zh-min-nan bn be ca cs cy da et el eo eu fa gl ko hi hr id he ka la lv lt hu mk ms min no nn ce uz kk ro simple sk sl sr sh fi ta tt th tg azb tr ur zh-yue hy my ace als am an hyw ban bjn map-bms ba be-tarask bcl bpy bar bs br cv nv eml hif fo fy ga gd gu hak ha hsb io ig ilo ia ie os is jv kn ht ku ckb ky mrj lb lij li lmo mai mg ml zh-classical mr xmf mzn cdo mn nap new ne frr oc mhr or as pa pnb ps pms nds crh qu sa sah sco sq scn si sd szl su sw tl shn te bug vec vo wa wuu yi yo diq bat-smg zu lad kbd ang smn ab roa-rup frp arc gn av ay bh bi bo bxr cbk-zam co za dag ary se pdc dv dsb myv ext fur gv gag inh ki glk gan guw xal haw rw kbp pam csb kw km kv koi kg gom ks gcr lo lbe ltg lez nia ln jbo lg mt mi tw mwl mdf mnw nqo fj nah na nds-nl nrm nov om pi pag pap pfl pcd krc kaa ksh rm rue sm sat sc trv stq nso sn cu so srn kab roa-tara tet tpi to chr tum tk tyv udm ug vep fiu-vro vls wo xh zea ty ak bm ch ny ee ff got iu ik kl mad cr pih ami pwn pnt dz rmy rn sg st tn ss ti din chy ts kcg ve
Portal di Ensiklopedia Dunia