[Bps-public-commit] jifty-plugin-wikitext branch, master, updated. 38e2243ba3a0af1383a11736a77823fe032b3f49

sartak at bestpractical.com sartak at bestpractical.com
Wed Nov 4 16:21:09 EST 2009


The branch, master has been updated
       via  38e2243ba3a0af1383a11736a77823fe032b3f49 (commit)
      from  c0bde4d7b4756b03b362523e027460d1977b8ef7 (commit)

Summary of changes:
 lib/Jifty/Web/Form/Field/Wikitext.pm |   43 ++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100644 lib/Jifty/Web/Form/Field/Wikitext.pm

- Log -----------------------------------------------------------------
commit 38e2243ba3a0af1383a11736a77823fe032b3f49
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Nov 4 16:20:49 2009 -0500

    Steal the form field class from Jifty

diff --git a/lib/Jifty/Web/Form/Field/Wikitext.pm b/lib/Jifty/Web/Form/Field/Wikitext.pm
new file mode 100644
index 0000000..fb1fc4e
--- /dev/null
+++ b/lib/Jifty/Web/Form/Field/Wikitext.pm
@@ -0,0 +1,43 @@
+package Jifty::Web::Form::Field::Wikitext;
+use warnings;
+use strict;
+use base qw/Jifty::Web::Form::Field::Textarea/;
+
+use Text::WikiFormat;
+use HTML::Scrubber;
+
+__PACKAGE__->mk_accessors(qw(rows cols));
+
+=head1 NAME
+
+Jifty::Web::Form::Field::Wikitext - A textarea that renders wiki syntax
+
+=head2 render_value
+
+Renders the value using L<Text::WikiFormat>.
+
+=cut
+
+sub render_value {
+    my $self  = shift;
+    my $field = '<span';
+    $field .= qq! class="@{[ $self->classes ]} value"> !;
+    if (defined $self->current_value) {
+        my $text = "@{[$self->current_value]}";
+        my $scrubber = HTML::Scrubber->new;
+        my $scrubbed = $scrubber->scrub($text);
+
+        $field .= Text::WikiFormat::format($scrubbed, {}, {
+            extended       => 1,
+            absolute_links => 1,
+            implicit_links => 0, # XXX: make this configurable
+            prefix         => Jifty->web->url,
+        });
+    }
+    $field .= qq!</span>\n!;
+    Jifty->web->out($field);
+    return '';
+}
+
+1;
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list