Table of contents
No headers
/** Author: Blake Harms version: 1.0.3 HOW TO USE: Create a dekiscript block and add: blog(); Change the page permissions to whatever you would like. But if you only want you to be able to add a post, set it to semi-public and give ONLY you permission to create. */ /******************* Configurable options *********************/ var postsPerPage = $0 ?? $postsPerPage ?? 5; // # of posts to show per page var recentNum = $1 ?? $recentNum ?? 10; // # of recent posts to show in sidebar var commentsNum = $2 ?? $commentsNum ?? 10; // # of recent comments to show in sidebar var categoriesNum= $3 ?? $categoriesNum ?? 10; // # of top categories to show in sidebar /****************** /Configurable options ********************/ var startAt = __request.args.start ?? 0; <html><head> <style type="text/css">" /* main */ #posts { width:70%; float:left;margin-left:3%; } .post { padding-right:10px; } .post .post-head a { color:black !important; } .post .post-subhead { padding-left:50px;font-size:12px; } .post .post-subhead .post-date { padding:0px; margin:0px; } .post .post-subhead .post-author { padding:0px; margin:0px; font-weight:bold; font-size:14px; } .post .post-subhead .post-author a { color:black; } .post .post-body { padding:15px; } .post .post-footer .post-edited { font-style:italic; color: #AAA; padding:10px; } .post .post-footer .post-links a { padding-right:20px; } .post .post-footer .post-tags a { padding-right: 5px; color:black !important; } /* sidebar */ #blog-sidebar { float:right; width:24%; } #blog-sidebar { border-left: 2px solid black; padding-left:2%; padding-bottom:21px; } #blog-sidebar ul { margin-top:5px; list-style-type:none; padding-left:20px; } /* paginate */ #paginator { padding:15px; clear:both; } #paginator a.paginate-previous { float:left; text-align:left; } #paginator a.paginate-next { float:right; text-align:right; } "</style> </head></html> wiki.create("New Blog Post",_,_,true,"Blog #" .. #page.subpages); var blog= wiki.getSearch("path:" .. string.searchescape(page.path) .."/*", #page.subpages+1,"-date"); if(startAt > 0){ if(startAt < #blog){ let blog = List.splice(blog, 0, startAt); } } <div id="blog-body"> <div id="posts"> if(#blog> 0){ var shown = 0; foreach(var p in blog){ if(! p.path){ continue; } if(shown >=postsPerPage){ break; } <div class="post"> <div class="post-head"> <h2><a href=(p.path)>p.title</a></h2> </div> <div class="post-subhead"> "by "; <span class="post-author"> var author= p.revisions[0].author; <a href=(author.homepage.uri)>author.name</a> </span> " on "; <span class="post-date"> p.revisions[0].date; </span> </div> <div class="post-body"> wiki.page(p.path); </div> <div class="post-footer"> if(#p.revisions >1){ <div class="post-edited"> "Last Edited: "..p.date .. " "; "by "; <a href=(p.author.homepage.uri)>p.author.name</a> </div> } <div class="post-links"> <a href=(p.path.."#comment")>"Comments ("..#p.comments..")"</a><a href=(p.path)> "Views: "..p.viewcount</a> </div> if(#p.tags >0) { <div class="post-tags"> "Tags: "; var tags = Map.keys(p.tags); foreach(var tag in tags){ <a href=(uri.build(site.uri,"/Special:Tags",{'tag':tag}))>tag</a> } </div> } </div> </div> let shown+=1; } } else { "No posts"; } <div id="paginator"> if(startAt > 0){ var previous = 0; if(startAt - postsPerPage > 0){ let previous = startAt - postsPerPage; } <a href=(uri.build(page.uri,_,{start:previous})) class="paginate-previous"> "<Previous"</a> } if(startAt + postsPerPage <= #page.subpages -1){ var next = startAt + postsPerPage; <a href=(uri.build(page.uri,_,{start:next})) class="paginate-next"> "Next>"</a> } </div> </div> <div id="blog-sidebar"> <div id="recentPosts"> <h3>"Recent Posts"</h3> <ul> var recent = wiki.getSearch("path:" .. string.searchescape(page.path) .."/*", recentNum,"-date"); if(#recent > 1) { foreach(var post in recent){ <li><a href=(post.path)> post.title</a></li> } } else { <li>"No recent posts."</li> } </ul> </div> <div id="recentComments"> <h3>"Recent Comments"</h3> var comments= []; foreach(var p in page.subpages){ let comments ..= p.comments; } if(#comments != 0){ var comment= wiki.api(uri.build(page.api,"comments",{limit:5,sortby:"-date.posted",depth:"infinity"})); var com_page = xml.list(comment,"//comment/page.parent/title"); var com_path = xml.list(comment,"//comment/page.parent/path"); var com_num = xml.list(comment,"//comment/number"); var i=0; <ul> foreach(var n in com_num){ <li><a href=(com_path[i])>com_page[i]</a>; " ("; <a href=(com_path[i].."#comment"..n)>n</a>; ")"; </li> let i +=1; } </ul> } </div> <div id="cagtegories"> <h3>"Top Categories"</h3> // Get subpages tags. Credit: SteveB (TagDirectory) var tagmap = { }; var tag_count = [ ]; foreach(var p in page.subpages) { var tags = p.tags; // check if page has no tags; if so make up a default list if(!#tags) { let tags = [ { name: '(unclassified)', type: 'text' } ]; } // foreach tag on the page, append the page to that tag's list foreach(var t in tags where t.type == 'text') { let tagmap ..= { (t.name) : tagmap[t.name] .. [ p ] }; } } if(#tagmap) { // count how many pages each tag has foreach(var tag in map.keys(tagmap)) { let tag_count ..= [ { 'tag': tag, 'count': #tagmap[tag] } ]; } } let tag_count = List.splice(List.Sort(tag_count, 'count',true),categoriesNum); <ul> foreach(var category in tag_count){ <li> <a href=("/Special:Tags?tag=" .. category.tag)>category.tag</a>" ("..category.count..")" </li> } </ul> </div> </div> </div>
Comments