Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.

Änderungen

Zur Navigation springen Zur Suche springen
4.232 Bytes hinzugefügt ,  17:35, 24. Jan. 2018
2018-01-22
Zeile 1: Zeile 1: −
local TemplateData = { serial = "2017-11-06",
+
local TemplateData = { serial = "2018-01-22",
                       suite  = "TemplateData" }
+
                       suite  = "TemplateData",
 +
                      item  = 46997995 }
 
--[=[
 
--[=[
 
improve template:TemplateData
 
improve template:TemplateData
Zeile 8: Zeile 9:     
local Config = {
 
local Config = {
     -- multiple #invoke option names mapped into unique internal fields
+
     -- multiple option names mapped into unique internal fields
     cat            = "strange",
+
     basicCnf = { catProblem    = "strange",
     classNoNumTOC = "suppressTOCnum",
+
                classNoNumTOC = "suppressTOCnum",
 +
                cssParams     = "cssTable",
 +
                cssParWrap    = "cssTabWrap",
 +
                docpageCreate = "suffix",
 +
                docpageDetect = "subpage",
 +
                helpBoolean  = "support4boolean",
 +
                helpContent  = "support4content",
 +
                helpDate      = "support4date",
 +
                helpFile      = "support4wiki-file-name",
 +
                helpFormat    = "supportFormat",
 +
                helpLine      = "support4line",
 +
                helpNumber    = "support4number",
 +
                helpPage      = "support4wiki-page-name",
 +
                helpString    = "support4string",
 +
                helpTemplate = "support4wiki-template-name",
 +
                helpURL      = "support4url",
 +
                helpUser      = "support4wiki-user-name",
 +
                msgDescMiss  = "solo" },
 
--  classParams    = "classTable",
 
--  classParams    = "classTable",
    cssParams      = "stylesTable",
  −
    cssParWrap    = "stylesTabWrap",
  −
    debug          = false,
  −
    docpageCreate  = "suffix",
  −
    docpageDetect  = "subpage",
  −
    msgDescMiss    = "solo",
   
--  classTable    = false,    -- class for params table
 
--  classTable    = false,    -- class for params table
 
     loudly        = false,    -- show exported element, etc.
 
     loudly        = false,    -- show exported element, etc.
 
     solo          = false,    -- complaint on missing description
 
     solo          = false,    -- complaint on missing description
 
     strange        = false,    -- title of maintenance category
 
     strange        = false,    -- title of maintenance category
     stylesTable    = false,    -- styles for params table
+
     cssTable      = false,    -- styles for params table
     stylesTabWrap  = false,    -- styles for params table wrapper
+
     cssTabWrap    = false,    -- styles for params table wrapper
 +
    debug        = false,
 
     subpage        = false,    -- pattern to identify subpage
 
     subpage        = false,    -- pattern to identify subpage
     suffix        = false,     -- subpage creation scheme
+
     suffix        = false,   -- subpage creation scheme
     suppressTOCnum = false   -- class for TOC number suppression
+
     suppressTOCnum = false     -- class for TOC number suppression
 
}
 
}
 
local Data = {
 
local Data = {
Zeile 390: Zeile 403:  
     end
 
     end
 
end -- fathers()
 
end -- fathers()
 +
 +
 +
 +
local function favorize()
 +
    -- Local customization issues
 +
    local boole  = { ["font-size"] = "125%" }
 +
    local l, cx = pcall( mw.loadData,
 +
                        TemplateData.frame:getTitle() .. "/config" )
 +
    local scripting
 +
    TemplateData.ltr = not mw.language.getContentLanguage():isRTL()
 +
    if TemplateData.ltr then
 +
        scripting = "left"
 +
    else
 +
        scripting = "right"
 +
    end
 +
    boole[ "margin-" .. scripting ] = "3em"
 +
    Permit.boole = { [false] = { css  = boole,
 +
                                lead = true,
 +
                                show = "☐" },
 +
                    [true]  = { css  = boole,
 +
                                lead = true,
 +
                                show = "☑" } }
 +
    Permit.css  = { }
 +
    for k, v in pairs( Permit.colors ) do
 +
        if k == "tableheadbg" then
 +
            k = "tablehead"
 +
        end
 +
        Permit.css[ k ] = { ["background-color"]  =  "#" .. v }
 +
    end -- for k, v
 +
    if type( cx ) == "table" then
 +
        local c, s
 +
        if type( cx.permit ) == "table" then
 +
            if type( cx.permit.boole ) == "table" then
 +
                if type( cx.permit.boole[ true ] ) == "table" then
 +
                    Permit.boole[ false ]  = cx.permit.boole[ false ]
 +
                end
 +
                if type( cx.permit.boole[ true ] ) == "table" then
 +
                    Permit.boole[ true ]  = cx.permit.boole[ true ]
 +
                end
 +
            end
 +
            if type( cx.permit.css ) == "table" then
 +
                for k, v in pairs( cx.permit.css ) do
 +
                    if type( v ) == "table" then
 +
                        Permit.css[ k ] = v
 +
                    end
 +
                end -- for k, v
 +
            end
 +
        end
 +
        for k, v in pairs( Config.basicCnf ) do
 +
            s = type( cx[ k ] )
 +
            if s == "string"  or  s == "table" then
 +
                Config[ v ] = cx[ k ]
 +
            end
 +
        end -- for k, v
 +
    end
 +
end -- favorize()
      Zeile 579: Zeile 648:  
             if show then
 
             if show then
 
                 dd      = mw.html.create( "dd" )
 
                 dd      = mw.html.create( "dd" )
                                :wikitext( show )
   
                 section = factory( "doc-param-" .. s )
 
                 section = factory( "doc-param-" .. s )
 
                 if param.type == "boolean"  and
 
                 if param.type == "boolean"  and
 
                   ( show == "0" or show == "1" ) then
 
                   ( show == "0" or show == "1" ) then
                     local ticbox = mw.html.create( "span" )
+
                     local boole = Permit.boole[ ( show == "1" ) ]
                                          :css( "font-size", "125%" )
+
                    if boole.lead == true then
                                          :css( "margin-left", "3em" )
+
                        dd:node( mw.html.create( "code" )
                                          -- LTR
+
                                        :wikitext( show ) )
                     if show == "0" then
+
                          :wikitext( " " )
                         ticbox:wikitext( "☐" )
+
                    end
                    else
+
                    dd:node( mw.html.create( "span" )
                        ticbox:wikitext( "☑" )
+
                                    :css( boole.css )
 +
                                    :wikitext( boole.show ) )
 +
                     if type( boole.suffix ) == "string" then
 +
                         dd:wikitext( boole.suffix )
 
                     end
 
                     end
                     dd:node( ticbox )
+
                else
 +
                     dd:wikitext( show )
 
                 end
 
                 end
 
                 dl:node( mw.html.create( "dt" )
 
                 dl:node( mw.html.create( "dt" )
Zeile 616: Zeile 688:  
                 Data.lasting = true
 
                 Data.lasting = true
 
             else
 
             else
 +
                local support = Config[ "support4" .. param.type ]
 
                 s = factory( "doc-param-type-" .. param.type )
 
                 s = factory( "doc-param-type-" .. param.type )
 +
                if support then
 +
                    s = string.format( "[[%s|%s]]", support, s )
 +
                end
 
                 typed:wikitext( s )
 
                 typed:wikitext( s )
 
             end
 
             end
Zeile 661: Zeile 737:  
     -- <tr>
 
     -- <tr>
 
     r:attr( "id",  "templatedata:" .. mw.uri.anchorEncode( access ) )
 
     r:attr( "id",  "templatedata:" .. mw.uri.anchorEncode( access ) )
     :css( "background-color",  "#" .. Permit.colors[ status ] )
+
     :css( Permit.css[ status ] )
 
     :node( begin )
 
     :node( begin )
 
     :node( code )
 
     :node( code )
Zeile 683: Zeile 759:  
     local r
 
     local r
 
     if Data.tree and Data.tree.params then
 
     if Data.tree and Data.tree.params then
        local style = "#" .. Permit.colors.tableheadbg
   
         local tbl  = mw.html.create( "table" )
 
         local tbl  = mw.html.create( "table" )
 
                             :addClass( "wikitable" )
 
                             :addClass( "wikitable" )
Zeile 694: Zeile 769:  
--          tbl:addClass( Config.classTable )
 
--          tbl:addClass( Config.classTable )
 
--      end
 
--      end
         if Config.stylesTable then
+
         if Config.cssTable then
             tbl:cssText( Config.stylesTable )
+
             if type( Config.cssTable ) == "table" then
 +
                tbl:css( Config.cssTable )
 +
            elseif type( Config.cssTable ) == "string" then
 +
                -- deprecated
 +
                tbl:cssText( Config.cssTable )
 +
            end
 
         end
 
         end
 
         tr:node( mw.html.create( "th" )
 
         tr:node( mw.html.create( "th" )
 
                         :attr( "colspan", "2" )
 
                         :attr( "colspan", "2" )
                         :css( "background-color", style )
+
                         :css( Permit.css.tablehead )
 
                         :wikitext( factory( "doc-param-name" ) ) )
 
                         :wikitext( factory( "doc-param-name" ) ) )
 
           :node( mw.html.create( "th" )
 
           :node( mw.html.create( "th" )
                         :css( "background-color", style )
+
                         :css( Permit.css.tablehead )
 
                         :wikitext( factory( "doc-param-desc" ) ) )
 
                         :wikitext( factory( "doc-param-desc" ) ) )
 
           :node( mw.html.create( "th" )
 
           :node( mw.html.create( "th" )
                         :css( "background-color", style )
+
                         :css( Permit.css.tablehead )
 
                         :wikitext( factory( "doc-param-type" ) ) )
 
                         :wikitext( factory( "doc-param-type" ) ) )
 
           :node( mw.html.create( "th" )
 
           :node( mw.html.create( "th" )
                         :css( "background-color", style )
+
                         :css( Permit.css.tablehead )
 
                         :wikitext( factory( "doc-param-status" ) ) )
 
                         :wikitext( factory( "doc-param-status" ) ) )
 
         tbl:newline()
 
         tbl:newline()
 
--        :node( mw.html.create( "thead" )
 
--        :node( mw.html.create( "thead" )
 
                         :node( tr )
 
                         :node( tr )
--             )
+
--             )
 
           :newline()
 
           :newline()
 
         if Data.order then
 
         if Data.order then
Zeile 720: Zeile 800:  
             end -- for i = 1, #Data.order
 
             end -- for i = 1, #Data.order
 
         end
 
         end
         if Config.stylesTabWrap then
+
         if Config.cssTabWrap then
 
             r = mw.html.create( "div" )
 
             r = mw.html.create( "div" )
                  :cssText( Config.stylesTabWrap )
+
            if type( Config.cssTabWrap ) == "table" then
                  :node( tbl )
+
                tbl:css( Config.cssTabWrap )
 +
            elseif type( Config.cssTabWrap ) == "string" then
 +
                -- deprecated
 +
                tbl:cssText( Config.cssTabWrap )
 +
            end
 +
            r:node( tbl )
 
         else
 
         else
 
             r = tbl
 
             r = tbl
Zeile 993: Zeile 1.078:  
     end
 
     end
 
     if Data.tree and Data.tree.format then
 
     if Data.tree and Data.tree.format then
         local e, style
+
         local e, show, style
 
         s = Data.tree.format:lower( Data.tree.format )
 
         s = Data.tree.format:lower( Data.tree.format )
 
         if s == "inline"  or  s == "block" then
 
         if s == "inline"  or  s == "block" then
Zeile 999: Zeile 1.084:  
         else
 
         else
 
             style = "code"
 
             style = "code"
 +
        end
 +
        show = "Format"
 +
        if Config.supportFormat then
 +
            show = string.format( "[[%s|%s]]",
 +
                                  Config.supportFormat, show )
 
         end
 
         end
 
         r:node( mw.html.create( "p" )
 
         r:node( mw.html.create( "p" )
                       :wikitext( "Format: " )
+
                       :wikitext( show .. ": " )
 
                       :node( mw.html.create( style )
 
                       :node( mw.html.create( style )
 
                                     :wikitext( s ) ) )
 
                                     :wikitext( s ) ) )
Zeile 1.063: Zeile 1.153:  
--local spy=""
 
--local spy=""
 
     local source
 
     local source
     for k, v in pairs( Config ) do
+
    favorize()
 +
    -- deprecated:
 +
     for k, v in pairs( Config.basicCnf ) do
 
         if adapt[ k ]  and  adapt[ k ] ~= "" then
 
         if adapt[ k ]  and  adapt[ k ] ~= "" then
 
             Config[ v ] = adapt[ k ]
 
             Config[ v ] = adapt[ k ]
Zeile 1.122: Zeile 1.214:     
TemplateData.failsafe = function ( assert )
 
TemplateData.failsafe = function ( assert )
 +
    local since = assert
 
     local r
 
     local r
     if not assert or  assert <= TemplateData.serial then
+
    if since == "wikidata" then
 +
        local item = TemplateData.item
 +
        since = false
 +
        if type( item ) == "number"  and  item > 0 then
 +
            local entity = mw.wikibase.getEntity( string.format( "Q%d",
 +
                                                                item ) )
 +
            if type( entity ) == "table" then
 +
                local vsn = entity:formatPropertyValues( "P348" )
 +
                if type( vsn ) == "table"  and
 +
                  type( vsn.value) == "string" and
 +
                  vsn.value ~= "" then
 +
                    since = vsn.value
 +
                end
 +
            end
 +
        end
 +
    end
 +
     if not since or  since <= TemplateData.serial then
 
         r = TemplateData.serial
 
         r = TemplateData.serial
 
     else
 
     else
Cookies helfen uns bei der Bereitstellung von imedwiki. Durch die Nutzung von imedwiki erklärst du dich damit einverstanden, dass wir Cookies speichern.

Navigationsmenü