Source: site.view [edit]
Function name: newPortal
Arguments: portalName
Description: Creates a new portal that will contain multiple portlets, each displaying results of a WubHub function.
Page type: webl
Render function:  
Module: site

Page source:

var res = nil;
var finfo = (Wub_GetFunctionInfo(portalName) ? nil);

if (wubinfo.user == nil) then
   res = WubCall("sitemessageref", ["mustlogin", portalName])
elsif (portalName== "") then
   res = WubCall("sitemessageref", ["unknowncmdtoedit", portalName])
elsif finfo != nil then
   res = `Error: a command named "` + portalName+ `" already exists.`
end;

// No Error, keep going
if res == nil then

   var ParseFunctionIdentifier = fun(namestr)
      var s = Str_Split(namestr, ".");
      if Size(s) == 2 then
         return [. module=s[0], name=s[1] .]
      else
         return [. module=nil, name=s[0] .]
      end;
   end;

   var fspec = ParseFunctionIdentifier(portalName);
   if fspec.module == nil then
      fspec.module = wubinfo.user
   end;

var html = `
<H1>Create New Portal</H1>


<form action="/webl/WubHub_DoIt" method="post">

   <input name="cmdline" 
          value="siteutil.newPortalCmd(title,name,desc)"
          type="hidden"/> 

   <input name="name" value="` + portalName + `" type=hidden>

      <table>
        <tbody>

       <tr><td>Portal:<p> </td>
       <td>` + fspec.module + "." + fspec.name + `<p></td></tr>

       <tr>

          <td>Portal Title: </td>
          <td><input name="title" value="" size="85" title="Title of portal"/>
          </td>
        </tr>

        <tr valign=top>
          <td>Description: </td>
          <td><textarea name="desc" cols="85" rows="5" title="Description of portal."></textarea></td>
        </tr>
         
        <tr><td>&nbsp;</td><td>
           <input type="submit" value="Create Portal"> </td>
        </tr>

      </tbody>
    </table>
</form>

`;
   res = NewPiece(html, "text/html");
end;

res;