Source: site.view [edit]
Function name: newBlogCmd
Arguments: title,blogName,desc
Description: Creates a new blog.
Page type: webl
Render function:  
Module: siteutil

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 errors, continue
if res == nil then

     var fspec = Wub_ParseFunctionIdentifier(blogName);
     if fspec.module == nil then 
        fspec.module = wubinfo.user
     end;

     var blogData = [. title=title, description=desc, 
            editname=fspec.module+"."+fspec.name, entries = [] .];

     var flags;
     if (blogName == "activityLog") then
        flags = "activitylog, blog"
     else
        flags = "blog"
     end;
     var finfo = [. module=fspec.module, name=fspec.name, ctype="webl", 
           description=desc,
           render="blogRender", test="", version="0", tags="", flags=flags, 
           exec= ToSource(blogData), cacheexpire="", cacherefreshrate="", 
           usecache="", createdby=wubinfo.user, modified="", created="", 
           modifiedby=wubinfo.user,arglist="" .];
 
    res = Wub_SaveFunctionInfo(finfo);
end;
res;