afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-08-05 07:07 am

[dw-free] Add comment-count image to crossposted entries

[commit: http://hg.dwscoalition.org/dw-free/rev/1e10c8cffe6c]

http://bugs.dwscoalition.org/show_bug.cgi?id=1035

Add comment-count image to crossposted entries (missed the file)

Patch by [personal profile] allen.

Files modified:
  • htdocs/tools/commentcount.bml
--------------------------------------------------------------------------------
diff -r b3557872aaba -r 1e10c8cffe6c htdocs/tools/commentcount.bml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/tools/commentcount.bml	Wed Aug 05 07:06:56 2009 +0000
@@ -0,0 +1,29 @@
+<?_code # -*-bml-*-
+{
+    use strict;
+    use vars qw(%GET);
+    use Image::Magick;
+
+    # creates an image that shows the current number of comments on 
+    # the given post.
+
+    my $ditemid = $GET{ditemid};
+    my $uid = $GET{uid};
+
+    # get the value to display
+    my $count = $GET{samplecount} || LJ::Entry->new( $uid, ditemid => $ditemid )->reply_count;
+
+    # create an image
+    my $image = Image::Magick->new;
+    $image->Set(pen => 'black');
+    $image->Set(font => 'Generic.ttf');
+    $image->Set(pointsize => 12);
+    $image->Read("label:$count");
+
+    # return the image
+    BML::set_content_type("image/png");
+    BML::noparse();
+
+    return $image->ImageToBlob( magick => "png" );
+}
+_code?>
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org