Source: site.view [edit]
Function name: tagRender
Arguments: data
Description: Formatting component of "ls" command
Page type: webl
Render function:  
Module: siteutil

Page source:

var s = "";
var item, func;

var addComma = fun(s, newStr)
   if Str_IndexOf(`%`, newStr) > 0 then
      return s
   end;
   if s != "" then
      s = s + ", "
   end;
   s + newStr
end;

var displayTag= fun(s, num)
  var origs = s;
  var i = Str_IndexOf(`.`, s);
  if (i > 0) and (Str_StartsWith(s, "tag") or Str_StartsWith(s, "flag")) then
     s = Select(s, i+1, Size(s));
  end;
  s = Wub_ALinkCmd2("lsByTag("+origs+")", s);
  s + " <small>(" + ToString(num) + ")</small>"
end;

var sys = "";
var flags = "";
var tags = "";
every m in data do
   if Str_StartsWith(m, `createdby\.`) or Str_StartsWith(m, `type\.`) or Str_StartsWith(m, `system\.`)  then
      sys = addComma(sys, displayTag(m, Size(data[m])))
   elsif Str_StartsWith(m, `flag\.`) then
      flags = addComma(flags, displayTag(m, Size(data[m])))
   else
      tags = addComma(tags, displayTag(m, Size(data[m])))
   end
end;

NewPiece("<h1>List of Tags and Flags</h1>" +
   "<h2>User Tags</h2>" + tags +
   "<h2>System Tags</h2>" + sys +
   "<h2>Function Flags</h2>" + flags,"text/html")