Module:Citation/CS1: Difference between revisions

sync with sandbox. Addresses format / type positioning, CITEREF encoding, and error categorization
m>Dragons flight
(sync to sandbox, addressing hyphen links, authormask, bolding, etc.)
m>Dragons flight
(sync with sandbox. Addresses format / type positioning, CITEREF encoding, and error categorization)
Line 320: Line 320:
     local P4 = args[4] or ""
     local P4 = args[4] or ""
     local P5 = args[5] or ""
     local P5 = args[5] or ""
     return "CITEREF" .. P1 .. P2 .. P3 .. P4 .. P5
      
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = "";
    end
   
    return "CITEREF" .. encoded;
end
end


Line 708: Line 715:
     local DateIn = Date
     local DateIn = Date
      
      
    -- Test if cite web is called without giving a URL
     if ( URL == nil or URL == '' ) and
     if ( URL == nil or URL == '' ) and
             ( ChapterURL == nil or ChapterURL == '' ) and
             ( ChapterURL == nil or ChapterURL == '' ) and
Line 714: Line 720:
             ( ConferenceURL == nil or ConferenceURL == '' ) and                 
             ( ConferenceURL == nil or ConferenceURL == '' ) and                 
             ( TranscriptURL == nil or TranscriptURL == '' ) then
             ( TranscriptURL == nil or TranscriptURL == '' ) then
        -- Test if cite web is called without giving a URL
         if ( config.CitationClass == "web" ) then
         if ( config.CitationClass == "web" ) then
             table.insert( z.error_categories, 'Pages using web citations with no URL' );
             table.insert( z.error_categories, 'Pages using web citations with no URL' );
Line 722: Line 730:
             end
             end
         end
         end
        -- Test if accessdate is given without giving a URL
         if ( AccessDate ~= nil and AccessDate ~= '' ) then
         if ( AccessDate ~= nil and AccessDate ~= '' ) then
             table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
             table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
Line 730: Line 740:
                 MessageTail = MessageTail .. "Accessdate used without URL";  
                 MessageTail = MessageTail .. "Accessdate used without URL";  
             end
             end
        end     
   
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( "File format specified without giving a URL" );
         end         
         end         
     end     
     end     
Line 934: Line 950:
     if ( SSRN ~= nil and SSRN ~="") then
     if ( SSRN ~= nil and SSRN ~="") then
         SSRN = sepc .." " .. externallinkid({label="SSRN",link="Social Science Research Network",prefix="http://ssrn.com/abstract=",id=SSRN}) else SSRN = "" end
         SSRN = sepc .." " .. externallinkid({label="SSRN",link="Social Science Research Network",prefix="http://ssrn.com/abstract=",id=SSRN}) else SSRN = "" end
    if ( ZBL ~= nil and ZBL ~="") then
        ZBL = sepc .." " .. externallinkid({label="Zbl",link="Zentralblatt MATH",prefix="http://www.zentralblatt-math.org/zmath/en/search/?format=complete&q=an:",id=ZBL}) else ZBL = "" end
     if ( URL ~= nil and URL ~="") then
     if ( URL ~= nil and URL ~="") then
      URL = " " .. "[" .. URL .. " " .. nowiki(URL) .. "]";
        URL = " " .. "[" .. URL .. " " .. nowiki(URL) .. "]";
      table.insert( z.error_categories, "Pages with citations having bare URLs" );
        table.insert( z.error_categories, "Pages with citations having bare URLs" );
      if config.CitationClass == "web" then
        if config.CitationClass == "web" then
          URL = URL .. " <span class='error'>No <code>title=</code> specified</span>"
            table.insert( z.error_categories, "Pages using web citations with no title" );
      else
            URL = URL .. " <span class='error'>No <code>title=</code> specified</span>"
          URL = URL .. hiddencomment("Bare URL here");
        else
      end       
            URL = URL .. hiddencomment("Bare URL needs a title");
        end       
     else
     else
      URL = ""
        URL = ""
     end
     end
    if ( ZBL ~= nil and ZBL ~="") then
 
        ZBL = sepc .." " .. externallinkid({label="Zbl",link="Zentralblatt MATH",prefix="http://www.zentralblatt-math.org/zmath/en/search/?format=complete&q=an:",id=ZBL}) else ZBL = "" end
     if ( Quote and Quote ~="" ) then  
     if ( Quote and Quote ~="" ) then  
         if Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"' then
         if Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"' then
Line 958: Line 977:
         Quote = ""  
         Quote = ""  
     end
     end
   
     local Archived
     local Archived
     if ( nil ~= ArchiveURL and "" ~= ArchiveURL ) then
     if ( nil ~= ArchiveURL and "" ~= ArchiveURL ) then
Line 1,025: Line 1,045:
     -- Several of the above rely upon detecting this as nil, so do it last.
     -- Several of the above rely upon detecting this as nil, so do it last.
     if ( Periodical ~= nil and Periodical ~="" ) then  
     if ( Periodical ~= nil and Periodical ~="" ) then  
         if ( Title and Title ~= "") then  
         if ( Title and Title ~= "" ) or ( TitleNote and TitleNote ~= "" ) then  
             Periodical = sepc .. " ''" .. safeforitalics(Periodical) .. "''"
             Periodical = sepc .. " ''" .. safeforitalics(Periodical) .. "''"
         else  
         else  
Line 1,040: Line 1,060:
         Periodical ~= "" ) then
         Periodical ~= "" ) then
         if (Others ~= "") then Others = Others .. sepc .. " " end
         if (Others ~= "") then Others = Others .. sepc .. " " end
         tcommon = safejoin( {Others, Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
         tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
     elseif ( config.CitationClass == "citation" ) or (config.CitationClass == "encyclopaedia" ) then
     elseif ( config.CitationClass == "citation" ) or (config.CitationClass == "encyclopaedia" ) then
         tcommon = safejoin( {Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
         tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
     else  
     else  
         tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
         tcommon = safejoin( {Title, TitleNote, Series, Conference, Periodical, Format, TitleType, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
     end
     end
      
      
Line 1,159: Line 1,179:
      
      
     if string.len(text:gsub("<span[^>/]*>.-</span>", ""):gsub("%b<>","")) <= 2 then
     if string.len(text:gsub("<span[^>/]*>.-</span>", ""):gsub("%b<>","")) <= 2 then
         table.insert( z.error_categories, 'Pages with empty citations' );
         z.error_categories = { 'Pages with empty citations' };
         text = '<span class="error">Citation is empty</span>';
         text = '<span class="error">Citation is empty</span>';
        MessageTail = '';
     end
     end
      
      
Anonymous user