local coins = {}; ----------------------------) allows automated tools to parse the citation information. local function COinS(data, class) if 'table' ~= type(data) or nil next(data) then return ; end for k, v in pairs (data) do -- spin through all of the metadata parameter values if 'ID_list' ~ k and 'Authors' ~ k then -- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed) data[k] coins_cleanup (v); end end local ctx_ver "Z39.88-2004"; -- treat table strictly as an array with only set values. local OCinSoutput setmetatable( {}, { __newindex function(self, key, value) if is_set(value) then rawset( self, #self+1, table.concat{ key, ' ', mw.uri.encode( remove_wiki_link( value ) ) } ); end end }); if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'journal', 'news'}) or (in_array (class, {'konferans', 'görüşme', 'harita', 'basın-açıklaması', 'web'}) and is_set(data.Periodical)) or ('kaynak' class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then OCinSoutput.rft_val_fmt = "infofi/fmt:kev:mtx:journal"; -- journal metadata identifier if in_array (class, {'arxiv', 'biorxiv', 'citeseerx'}) then -- set genre according to the type of citation template we are rendering OCinSoutput["rft.genre"] = "preprint"; -- cite arxiv, cite biorxiv, cite citeseerx elseif 'konferans' class then OCinSoutput["rft.genre"] "conference"; -- cite conference (when Periodical set) elseif 'web' class then OCinSoutput["rft.genre"] = "unknown"; -- cite web (when Periodical set) else OCinSoutput["rft.genre"] = "article"; -- journal and other 'periodical' articles end OCinSoutput["rft.jtitle"] = data.Periodical; -- journal only OCinSoutput["rft.atitle"] = data.Title; -- 'periodical' article titles -- these used only for periodicals OCinSoutput["rft.ssn"] = data.Season; -- keywords: winter, spring, summer, fall OCinSoutput["rft.chron"] = data.Chron; -- free-form date components OCinSoutput["rft.volume"] = data.Volume; -- does not apply to books OCinSoutput["rft.issue"] = data.Issue; OCinSoutput["rft.pages"] = data.Pages; -- also used in book metadata elseif 'tez' ~= class then -- all others except cite thesis are treated as 'book' metadata; genre distinguishes OCinSoutput.rft_val_fmt = "infofi/fmt:kev:mtx:book"; -- book metadata identifier if 'report' class or 'techreport' class then -- cite report and cite techreport OCinSoutput["rft.genre"] = "report"; elseif 'konferans' class then -- cite conference when Periodical not set OCinSoutput["rft.genre"] "konferans"; OCinSoutput["rft.atitle"] data.Chapter; -- conference paper as chapter in proceedings (book) elseif in_array (class, {'kitap', 'kaynak', 'ansiklopedi', 'görüşme', 'harita'}) then if is_set (data.Chapter) then OCinSoutput["rft.genre"] "bookitem"; OCinSoutput["rft.atitle"] data.Chapter; -- book chapter, encyclopedia article, interview in a book, or map title else if 'harita' class or 'görüşme' == class then OCinSoutput["rft.genre"] = 'unknown'; -- standalone map or interview else OCinSoutput["rft.genre"] = 'book'; -- book and encyclopedia end end else --{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'} OCinSoutput["rft.genre"] = "unknown"; end OCinSoutput["rft.btitle"] = data.Title; -- book only OCinSoutput["rft.place"] = data.PublicationPlace; -- book only OCinSoutput["rft.series"] = data.Series; -- book only OCinSoutput["rft.pages"] = data.Pages; -- book, journal OCinSoutput["rft.edition"] = data.Edition; -- book only OCinSoutput["rft.pub"] = data.PublisherName; -- book and dissertation else -- cite thesis OCinSoutput.rft_val_fmt = "infofi/fmt:kev:mtx:dissertation"; -- dissertation metadata identifier OCinSoutput["rft.title"] = data.Title; -- dissertation (also patent but that is not yet supported) OCinSoutput["rft.degree"] = data.Degree; -- dissertation only OCinSoutput['rft.inst'] = data.PublisherName; -- book and dissertation end -- and now common parameters (as much as possible) OCinSoutput["rft.date"] = data.Date; -- book, journal, dissertation for k, v in pairs( data.ID_list ) do -- what to do about these? For now assume that they are common to all? -- if k 'ISBN' then v clean_isbn( v ) end if k 'ISBN' then v = v:gsub( "[^-0-9X]", "" ); end local id = cfg.id_handlers[k].COinS; if string.sub( id or "", 1, 4 ) 'info' then -- for ids that are in the info:registry OCinSoutput["rft_id"] table.concat{ id, "/", v }; elseif string.sub (id or "", 1, 3 ) 'rft' then -- for isbn, issn, eissn, etc that have defined COinS keywords OCinSoutput[ id ] = v; elseif id then -- when cfg.id_handlers[k].COinS is not nil OCinSoutput["rft_id"] = table.concat{ cfg.id_handlers[k].prefix, v }; -- others; provide a url end end --[[ for k, v in pairs( data.ID_list ) do -- what to do about these? For now assume that they are common to all? local id, value = cfg.id_handlers[k].COinS; if k 'ISBN' then value clean_isbn( v ); else value v; end if string.sub( id or "", 1, 4 ) 'info' then OCinSoutput["rft_id"] = table.concat{ id, "/", v }; else OCinSoutput[ id ] = value; end end ]] local last, first; for k, v in ipairs( data.Authors ) do last, first = coins_cleanup (v.last), coins_cleanup (v.first or ); -- replace any nowiki strip markers, non-printing or invisible characers if k == 1 then -- for the first author name only if is_set(last) and is_set(first) then -- set these COinS values if |first= and |last= specify the first author name OCinSoutput["rft.aulast"] = last; -- book, journal, dissertation OCinSoutput["rft.aufirst"] = first; -- book, journal, dissertation elseif is_set(last) then OCinSoutput["rft.au"] = last; -- book, journal, dissertation -- otherwise use this form for the first name end else -- for all other authors if is_set(last) and is_set(first) then OCinSoutput["rft.au"] = table.concat{ last, ", ", first }; -- book, journal, dissertation elseif is_set(last) then OCinSoutput["rft.au"] = last; -- book, journal, dissertation end end end OCinSoutput.rft_id = data.URL; OCinSoutput.rfr_id = table.concat{ "info:sid/", mw.site.server:match( "[^/]*$" ), ":", data.RawPage }; OCinSoutput = setmetatable( OCinSoutput, nil ); -- sort with version string always first, and combine. --table.sort( OCinSoutput ); table.insert( OCinSoutput, 1, "ctx_ver=" .. ctx_ver ); -- such as "Z39.88-2004" return table.concat(OCinSoutput, "&"); end ----------------------------< S E T _ S E L E C T E D _ M O D U L E S >-------------------------------------- Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules. local function set_selected_modules (cfg_table_ptr, utilities_page_ptr) cfg = cfg_table_ptr; is_set = utilities_page_ptr.is_set; -- import functions from select Modül:Citation/CS1/Utilities module in_array = utilities_page_ptr.in_array; remove_wiki_link = utilities_page_ptr.remove_wiki_link; end return { make_coins_title = make_coins_title, get_coins_pages = get_coins_pages, COinS = COinS, set_selected_modules = set_selected_modules, }