Title: Recent Entries Plugin: Starburst-Blog

Web Blog

You shouldn't see this page. # Load the blog config. $root->{blogcfg} = &readConfig('blog.conf') unless exists $root->{blogcfg}; my $id = $query->{id} || ''; if (length $id > 0) { if (&entryExists($id)) { # Read this entry. my $entry = &readEntry($id); my $stamp = &timeFormat($root->{blogcfg}->{blog}->{timestamp}, $entry->{time}); my $subject = $entry->{subject} || $stamp; # Hidden entry? my $hide = 0; if ($entry->{privacy} eq 'private') { if ($root->{auth}) { if (&isAdmin() || $root->{me} eq $entry->{author}) { # Okay. } else { $hide = 1; } } else { $hide = 1; } } elsif ($entry->{privacy} eq 'members') { if (not $root->{auth}) { $hide = 1; } } if ($hide) { $root->{content} = "

Can't Read Entry

\n\n" . "You are not allowed to view this entry."; return 1; } # Read the author's profile. $root->{meta}->{title} = $entry->{subject}; &readUser($entry->{author}); my $nick = &getNickname($entry->{author}); # Render emoticons? if (not $entry->{noemote}) { $entry->{body} = &renderEmoticons($entry->{body}); } # Splitting/showing only the summary? my $cutID = 1; while ($entry->{body} =~ /(.+?)<\/sb\-cut>/si) { my $cut = $1; my $code = "$1"; $cutID++; $entry->{body} =~ s/(.+?)<\/sb\-cut>/$code/si; } $root->{content} = "

$subject

\n\n" . "
\n" . "{author}\">" . "{conf}->{site}->{public}/avatars/$entry->{avatar}\" " . "alt=\"$nick\">
\n" . "{author}\">" . "$entry->{author}\n" . "
\n" . "
" . "Posted on $stamp by {author}\">" . "$nick

\n\n" . "$entry->{body}

\n\n" . "$root->{blogcfg}->{vocab}->{tags}: "; my @cats = (); foreach my $cat (split(/\,/, $entry->{categories})) { $cat =~ s/^\s+//g; $cat =~ s/\s+$//g; push (@cats,"$cat"); } if (scalar @cats > 0) { $root->{content} .= join (", ", @cats); } else { $root->{content} .= "{blogcfg}->{blog}->{defcategory}\">" . "$root->{blogcfg}->{blog}->{defcategory}"; } if ($root->{auth}) { my $perm = &getBlogPermissions(); if ($perm eq 'authors' || ($perm eq 'publishers' && $root->{me} eq $entry->{author})) { $root->{content} .= "

" . "[edit|" . "delete" . "]\n\n"; } } # Show blog comments? my $showComments = 1; if ($entry->{noreply} == 1) { # Comments are disabled. $showComments = 0; } else { # Comments are allowed. $showComments = 1; } if ($showComments) { $root->{content} .= "
\n" . ""; } } else { $root->{content} = "

Missing Entry

"; } } else { # Just showing the whole list of entries. my $offset = $query->{os} || 0; my $tag = $query->{tag} || ''; my $total = &countEntries(); my @entries = &getEntries($offset,$root->{blogcfg}->{blog}->{postsperpage},$tag); if (length $tag) { $root->{content} = "

Category: $tag

\n\n"; $root->{meta}->{title} = $tag; } else { $root->{content} = "

Recent Entries

\n\n"; } if (scalar(@entries)) { foreach my $item (@entries) { my $entry = &readEntry($item); my $stamp = &timeFormat($root->{blogcfg}->{blog}->{timestamp}, $entry->{time}); my $subject = $entry->{subject} || $stamp; # Read the author's profile. &readUser($entry->{author}); my $nick = &getNickname($entry->{author}); # Render emoticons? if (not $entry->{noemote}) { $entry->{body} = &renderEmoticons($entry->{body}); } # Splitting/showing only the summary? my $cutID = 1; while ($entry->{body} =~ /(.+?)<\/sb\-cut>/si) { my $cut = $1; my $code = "\n"; $cutID++; $entry->{body} =~ s/(.+?)<\/sb\-cut>/$code/si; } $root->{content} .= "
\n" . "\n" . "\n" . "
" . "Posted on $stamp by {author}\">" . "$nick

\n\n" . "$entry->{body}

\n\n" . "$root->{blogcfg}->{vocab}->{tags}: "; my @cats = (); foreach my $cat (split(/\,/, $entry->{categories})) { $cat =~ s/^\s+//g; $cat =~ s/\s+$//g; push (@cats,"$cat"); } if (scalar @cats > 0) { $root->{content} .= join (", ", @cats); } else { $root->{content} .= "{blogcfg}->{blog}->{defcategory}\">" . "$root->{blogcfg}->{blog}->{defcategory}"; } if ($root->{auth}) { my $perm = &getBlogPermissions(); if ($perm eq 'authors' || ($perm eq 'publishers' && $root->{me} eq $entry->{author})) { $root->{content} .= "

" . "[edit|" . "delete" . "]\n\n"; } } # Count the comments. my @com = &getComments($item); my $ccount = scalar(@com); my $plural = $ccount == 1 ? '' : 's'; # Show blog comments? my $showComments = 1; my $canComment = 1; if ($entry->{noreply} == 1) { # Comments are disabled. $showComments = 0; $canComment = 0; } else { # Comments are allowed; is guest commenting allowed? $showComments = 1; if ($root->{blogcfg}->{comments}->{allowguests} != 1) { # If we're not logged in... if (not $root->{auth}) { # Commenting denied. $canComment = 0; } } } $root->{content} .= "

\n" . "["; if ($showComments) { my $comlab = $root->{blogcfg}->{vocab}->{single}; if ($ccount != 1) { $comlab = $root->{blogcfg}->{vocab}->{multiple}; } $comlab =~ s/(\#)+/$ccount/ig; $root->{content} .= "$comlab|"; } if ($canComment) { my $lab = $root->{blogcfg}->{vocab}->{comment}; $root->{content} .= "$lab|"; } $root->{content} .= "" . "$root->{blogcfg}->{vocab}->{permalink}]\n\n"; } $root->{content} .= "
\n"; if ($offset > 0) { my $prev = $offset - $root->{blogcfg}->{blog}->{postsperpage}; $prev = 0 if $prev < 0; $root->{content} .= "< Newer " . "$root->{blogcfg}->{blog}->{postsperpage} | "; } if (($offset + $root->{blogcfg}->{blog}->{postsperpage}) < $total) { my $next = $offset + $root->{blogcfg}->{blog}->{postsperpage}; $root->{content} .= "Older " . "$root->{blogcfg}->{blog}->{postsperpage} >"; } $root->{content} .= "
\n"; } else { $root->{content} .= "No blog posts were found."; } }