Junkfood

Food and Junk.

All | Food | Junk | Work

20050118 Tuesday January 18, 2005

Roller: Customizing Comment Details

Through experimentation, I've found that you can write macros that override the default implementation by Roller. On comments pages, email addresses (or IP addresses, if no email is provided) and websites are displayed by default. I don't like this behavior, so I wrote a macro that overrides it. The macro gets added to the top of the Weblog file, just after the DOCTYPE line.

#macro( showCommentDetails $comment $showPermalink )
    $dateFormatter.applyPattern($text.get( "macro.weblog.datepattern" ))
    #set($email = $utilities.hexEncode($comment.email))
    <p class="comment-details">
    $text.get("macro.weblog.postedby")
    #if (!$stringUtils.isEmpty($comment.name))
        <b>$comment.name</b>
    #else
        <b>Anonymous</b>
    #end
    $text.get("macro.weblog.on") $dateFormatter.format($comment.postTime)
    #if( $showPermalink )
    <a href=
"${ctxPath}/comments/${userName}/${page.link}/${entry.anchor}#comment${velocityCount}"
       class="entrypermalink"
       title="$text.get( "macro.weblog.commentpermalink.title" )">#</a>
    #end
    </p>
#end

The macro is intended for use with Roller 1.0. I'm not sure whether it works with other versions.

(2005-01-18 08:00:00.0) Permalink | Comments [2]

Comments:

Cool! Good to know.

Posted by Kevin on January 18, 2005 at 06:19 PM EST #

I didn't realize that the comment URL field was used by Trackback. The hack I originally posted resulted in Trackback comments that were mysterious and short (because the web link was missing). The following lines, added to the macro in the right spot, allow URLs to be displayed for Trackback comments only (and also comments that spoof Trackbacks).
    #if( ($comment.content.indexOf("[Trackback]") == 0) && $stringUtils.isNotEmpty($comment.url) )
        $text.get( "macro.weblog.postedbywebsite", [$comment.url, $comment.url] )
    #end

Posted by junkfood on January 20, 2005 at 06:51 PM EST #

Post a Comment:

Comments are closed for this entry.

Calendar

« November 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
Today

Recent Entries

Search

Navigation



XML