Source: site.view [edit]
Function name: newBlog
Arguments: blogName
Description: Creates a new blog named blogName
Page type: webl
Render function:  
Module: site

Page source:

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

if (wubinfo.user == nil) then
   res = WubCall("sitemessageref", ["mustlogin", blogName])
elsif (blogName == "") then
   res = WubCall("sitemessageref", ["unknowncmdtoedit", blogName])
elsif finfo != nil then
   res = `Error: a command named "` + blogName + `" 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(blogName);
   if fspec.module == nil then
      fspec.module = wubinfo.user
   end;

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


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

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

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

      <table>
        <tbody>

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

       <tr>

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

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

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

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

res;