1 # Blosxom Plugin: textile2 -*- perl -*-
2 # Author: Todd Larason (jtl@molehill.org)
4 # Blosxom Home/Docs/Licensing: http://www.raelity.org/blosxom
5 # Textile plugin Home/Docs/Licensing:
6 # http://molelog.molehill.org/blox/Computers/Internet/Web/Blosxom/Plugins/Textile/
10 # Configuration Variables
11 # ----------------------------------------------------------------------------
12 #$flavour = "xhtml" unless defined $flavour;
13 $flavor = "xhtml" unless defined $flavour;
14 $character_encoding = 1 unless defined $character_encoding;
15 $character_set = "utf-8" unless defined $character_set;
16 $head_offset = 3 unless defined $head_offset;
17 $image_root = $blosxom::datadir unless defined $image_root;
18 $handle_textile_1 = 0 unless defined $handle_textile_1;
19 # ----------------------------------------------------------------------------
24 use lib qq{$blosxom::plugin_dir/lib};
25 use vars qw/$flavor $character_encoding $character_set $head_offset
26 $image_root $handle_textile_1 $textile/;
28 eval {require Text::Textile;};
34 my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
35 if ($meta::markup eq 'textile2' ||
36 ($handle_textile_1 && $meta::markup eq 'textile')) {
38 image_root => $image_root,
39 image_rel_base => "$blosxom::datadir/$path"
42 $$body_ref = blostile($$body_ref, $c);
47 # Simplified interface to Blosxom::Textile
50 # image_root absolute image filenames relative to this
51 # image_rel_base relative image filenames relative to this
54 # modif : http://groups.yahoo.com/group/blosxom/message/4052
59 $textile = new Blosxom::Textile;
61 $textile->char_encoding($character_encoding);
62 $textile->charset($character_set);
64 $textile->flavor($flavor);
65 $textile->filter_param($ctx);
67 $str = $textile->process($str);
69 if (defined $head_offset && ($head_offset > 1)) {
70 for (my $h = 7 - $head_offset; $h > 0; $h--) {
71 my $h2 = $h + $head_offset - 1;
72 $str =~ s/(<\/?)h$h([ >])/$1h$h2$2/g;
83 package Blosxom::Textile;
85 @Blosxom::Textile::ISA = qw(Text::Textile);
88 my ($self, $src) = @_;
89 my $ctx = $self->filter_param;
90 if ($src !~ m{^http:}) {
91 eval {require Image::Size;};
95 $file = "$ctx->{image_root}$src";
97 $file = "$ctx->{image_rel_base}/$src";
99 my ($w, $h) = Image::Size::imgsize($file);
103 warn "Image sizing without Image::Size not implemented";