« Module:Documentation » : différence entre les versions

De Lagny-sur-Marne Wiki
Aller à la navigation Aller à la recherche
0x010D (discussion | contributions)
grrr
0x010D (discussion | contributions)
corrige
Ligne 24 : Ligne 24 :


         return frame:preprocess(table.concat(corps))
         return frame:preprocess(table.concat(corps))
       
     end
     end


Ligne 38 : Ligne 39 :
         else
         else
             --On est dans une sous-page
             --On est dans une sous-page
             if frame:preprocess('{{SUBPAGENAME}}') == 'Documentation' or 'Bac à sable' or 'Test' then
             nom = frame:preprocess('{{SUBPAGENAME}}')
            if nom == 'Documentation' or nom == 'Bac à sable' or nom == 'Test' then
                 return frame:preprocess('{{#rel2abs:../Documentation}}')
                 return frame:preprocess('{{#rel2abs:../Documentation}}')
             else
             else
Ligne 101 : Ligne 103 :
         local contenu = {}
         local contenu = {}
         if args.contenu then
         if args.contenu then
             table.insert(contenu, '\n')
             table.insert(contenu, '__NOEDITSECTION__\n')
             table.insert(contenu, args.contenu)
             table.insert(contenu, args.contenu)
         else
         else
Ligne 115 : Ligne 117 :
             end
             end
         end
         end
         table.insert(contenu, '<nowiki /><div style="clear:both" />\n')
         table.insert(contenu, '\n<nowiki /><div style="clear:both" />\n')
         return table.concat(contenu)
         return table.concat(contenu)
     end
     end
Ligne 123 : Ligne 125 :
          
          
         if args.contenu then
         if args.contenu then
             table.insert(notice, '<div class="dablink plainlinks" style="border-top:1px solid #aaa; margin: 1em 0 0;">')
             table.insert(notice, '<div class="plainlinks" style="border-top:1px solid #aaa; margin: 1em 0 0;">')
             table.insert(notice, '<p style="margin-bottom:0; padding-left:1em; font-style:italic;">\n')
             table.insert(notice, '<p style="margin-bottom:0; padding-left:1em; font-style:italic;">\n')
              
              
Ligne 137 : Ligne 139 :
         else
         else
             if args[1] and p.ifexist(args[1], frame) or p.ifexist(p.docname(frame), frame) then
             if args[1] and p.ifexist(args[1], frame) or p.ifexist(p.docname(frame), frame) then
                 table.insert(notice, '<div class="dablink plainlinks" style="border-top:1px solid #aaa; margin: 1em 0 0;">')
                 table.insert(notice, '<div class="plainlinks" style="border-top:1px solid #aaa; margin: 1em 0 0;">')
                 table.insert(notice, '<p style="margin-bottom:0; padding-left:1em; font-style:italic;">')
                 table.insert(notice, '<p style="margin-bottom:0; padding-left:1em; font-style:italic;">')
                 table.insert(notice, 'La [[Aide:Comment documenter un modèle ?|documentation]] de ce ')
                 table.insert(notice, 'La [[Aide:Comment documenter un modèle ?|documentation]] de ce ')
Ligne 162 : Ligne 164 :
                 table.insert(notice, ')</span>.<br />')
                 table.insert(notice, ')</span>.<br />')
             else
             else
                 table.insert(notice, '<div class="dablink plainlinks">')
                 table.insert(notice, '<div class="plainlinks">')
                 table.insert(notice, '<p style="margin-bottom:0; padding-left:1em; font-style:italic;">')
                 table.insert(notice, '<p style="margin-bottom:0; padding-left:1em; font-style:italic;">')
             end
             end
Ligne 226 : Ligne 228 :
             end
             end
             table.insert(notice, '.<br />Veuillez placer les catégories dans la sous-page ')
             table.insert(notice, '.<br />Veuillez placer les catégories dans la sous-page ')
             table.insert(notice, '[[')
             table.insert(notice, '<span class="plainlinks">[')
             if args[1] then
            table.insert(notice, '{{fullurl:')
                 table.insert(notice, args[1])
             if args[1] and p.ifexist(args[1], frame) or p.ifexist(p.docname(frame), frame) then
                 if args[1] then
                    table.insert(notice, args[1])
                else
                    table.insert(notice, p.docname(frame))
                end
                table.insert(notice, '|action=edit')
               
             else
             else
                 table.insert(notice, p.docname(frame))
                 if args[1] then
                    table.insert(notice, args[1])
                else
                    table.insert(notice, p.docname(frame))
                end
                table.insert(notice, '|action=edit&preload=Modèle:Documentation/Preload')
             end
             end
             table.insert(notice, '|/Documentation]].')
             table.insert(notice, ' /Documentation}}].')
         end
         end
         table.insert(notice, '</p></div></div>')
         table.insert(notice, '</p></div></div>')

Version du 10 juin 2013 à 20:00

--Ce module implemente le modèle Modèle:Méta documentation de modèle.

local p = {}

   function p.corps(frame)
       local args = frame:getParent().args
       local corps = {}
       
       --Bandeau pour les sous-pages /Bac à sable
       if frame:preprocess('Documentation') == 'Bac à sable' then

table.insert(corps, '

')
           table.insert(corps, 'Modèle:Sous-page de bac à sable')
       end
       --Génération de la documentation
       table.insert(corps, p.entete(frame, args))
       table.insert(corps, p.contenu(frame, args))
       table.insert(corps, p.notice(frame, args))
       --Code HTML brute
       if args.raw then
           return frame:preprocess('' .. table.concat(corps) .. '')
       end
       return frame:preprocess(table.concat(corps))
       
   end
   function p.ifexist(page, frame)
       if not page then return false end
       if frame:preprocess() == '1' then return true end
       return false
   end
   
   function p.docname(frame)
       --On n'est pas dans une sous-page
       if frame:preprocess('Documentation') == frame:preprocess('Documentation') then
           return frame:preprocess('Module:Documentation/Documentation')
       else
           --On est dans une sous-page
           nom = frame:preprocess('Documentation')
           if nom == 'Documentation' or nom == 'Bac à sable' or nom == 'Test' then
               return frame:preprocess('Documentation')
           else
               return frame:preprocess('Module:Documentation/Documentation')
           end
       end
   end
   function p.entete(frame, args)
local entete = {'
') table.insert(entete, '
')
       if not args.contenu then
           table.insert(entete, '[[')
           if args[1] then
               if p.ifexist(args[1], frame) then
                   table.insert(entete, '{{fullurl:')
                   table.insert(entete, args[1])
                   table.insert(entete, '|action=edit modifier}}]] [Modèle:Purger le cache')
               else
                   table.insert(entete, '{{fullurl:')
                   table.insert(entete, args[1])
                   table.insert(entete, '|action=edit&preload=Modèle:Documentation/Preload créer}}]')
               end
           else
               if p.ifexist(p.docname(frame), frame) then
                   table.insert(entete, '{{fullurl:')
                   table.insert(entete, p.docname(frame))
                   table.insert(entete, '|action=edit modifier}}]] [Modèle:Purger le cache')
               else
                   table.insert(entete, '{{fullurl:')
                   table.insert(entete, p.docname(frame))
                   table.insert(entete, '|action=edit&preload=Modèle:Documentation/Preload créer}}]')
               end
           end
           table.insert(entete, ']')
       end
       table.insert(entete, 'Documentation du modèle')
       table.insert(entete, ' ')
       if args.titre then
           table.insert(entete, args.titre)
       else
           table.insert(entete, 'Documentation')
       end
table.insert(entete, '
')
       return table.concat(entete)
   end
   function p.contenu(frame, args)
       local contenu = {}
       if args.contenu then
           table.insert(contenu, '\n')
           table.insert(contenu, args.contenu)
       else
           table.insert(contenu, '')
           --Évite toute récursion
           if args[1]
           and frame:preprocess('Module:Documentation') ~= frame:preprocess()
           and p.ifexist(args[1], frame) then
               table.insert(contenu, '{{' .. args[1] .. '}}')
           elseif frame:preprocess('Module:Documentation') ~= frame:preprocess('%27_.._p.docname(frame)_.._%27')
           and p.ifexist(p.docname(frame), frame) then
               table.insert(contenu, 'Modèle:' .. p.docname(frame) .. '')
           end
       end
table.insert(contenu, '\n
\n')
       return table.concat(contenu)
   end
   
   function p.notice(frame, args)
       local notice = {}
       
       if args.contenu then
table.insert(notice, '