Volatile:ListField: Difference between revisions

(New page: <!----List fields of name "<nowiki>{{{1|}}}</nowiki>" in namespace "<nowiki>{{{2}}}</nowiki>".---->{{#lua: function trim(s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end list = {} ...)
 
No edit summary
Line 1: Line 1:
<!----List fields of name "<nowiki>{{{1|}}}</nowiki>" in namespace "<nowiki>{{{2}}}</nowiki>".---->{{#lua:
<!----List fields of name "<nowiki>{{{1}}}</nowiki>" in namespace "<nowiki>{{{2}}}</nowiki>"---->
{{#def:ARG1|{{{1}}}}}{{#def:ARG2|{{{2}}}}}{{#def:ARG3|{{{3|0}}}}}
==Search Results of '''{{{1}}}'''==
{{#lua:
   function trim(s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end
   function trim(s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end
   list = {}
   list = {}
   id = {}
   id = {}
   for page,data in stdin:gmatch("&&([%S]+)&&{{{1}}}= *([^\n]+)") do
   for page,data in stdin:gmatch("&&([%S]+)&&{{{1}}} *= *([^\n]+)") do
     if ((data ~= "-") and (data ~= " ")) then
     if ((data ~= "-") and (data ~= " ")) then
       data = trim(data)
       data = trim(data)
Line 16: Line 19:
   end
   end
   table.sort(id)
   table.sort(id)
  print("Total " .. table.getn(id) .. " groups.")
  local coff = tonumber("{{#var:ARG3}}")
  if (coff == nil) then coff =0 else print("Showing groups more than size=" .. coff .. "only") end
   for _,v in ipairs(id) do
   for _,v in ipairs(id) do
     print("* {{{1}}} '''" .. v .. "'''")
     if (table.getn(list[v]) > coff) then
    table.sort(list[v])
      print("* '''" .. v .. "'''")
    local f = true
      table.sort(list[v])
    for i = 1,table.getn(list[v]) do
      for i = 1,table.getn(list[v]) do
      if list[v][i] ~= list[v][i + 1] then
        if (list[v][i] ~= list[v][i + 1]) then
        print("[[{{{2}}}:" .. list[v][i] .."|".. list[v][i] .."]]") end
          print("[[{{#var:ARG2}}:" .. list[v][i] .."|".. list[v][i] .."]]") end
      end
     end
     end
   end
   end
|
|
{{#replace:{{#SearchLine:{{{1}}}|{{{2}}}}}|&#124;|&&}}
{{#replace:{{#SearchLine:{{#var:ARG1}}|{{#var:ARG2}}}}|&#124;|&&}}
}}
}}

Revision as of 21:17, 5 June 2012


Search Results of {{{1}}}

{{#lua:

 function trim(s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end
 list = {}
 id = {}
 for page,data in stdin:gmatch("&&([%S]+)&&{{{1}}} *= *([^\n]+)") do
   if ((data ~= "-") and (data ~= " ")) then
     data = trim(data)
     tmp = list[data]
     if (tmp == nil) then
       list[data] = { page }
       table.insert(id, data)
     else
       table.insert(tmp, page)
     end
   end
 end
 table.sort(id)
 print("Total " .. table.getn(id) .. " groups.")
 local coff = tonumber("0")
 if (coff == nil) then coff =0 else print("Showing groups more than size=" .. coff .. "only") end
 for _,v in ipairs(id) do
   if (table.getn(list[v]) > coff) then
     print("* " .. v .. "")
     table.sort(list[v])
     for i = 1,table.getn(list[v]) do
       if (list[v][i] ~= list[v][i + 1]) then
         print("[[{{{2}}}:" .. list[v][i] .."|".. list[v][i] .."]]") end
     end
   end
 end

|

}}