image vp, widget, template
groditi [Sat, 11 Oct 2008 20:34:25 +0000 (20:34 +0000)]
lib/Reaction/UI/ViewPort/Image.pm [new file with mode: 0644]
lib/Reaction/UI/Widget/Image.pm [new file with mode: 0644]
share/skin/base/layout/image.tt [new file with mode: 0644]

diff --git a/lib/Reaction/UI/ViewPort/Image.pm b/lib/Reaction/UI/ViewPort/Image.pm
new file mode 100644 (file)
index 0000000..a531e50
--- /dev/null
@@ -0,0 +1,15 @@
+package Reaction::UI::ViewPort::Image;
+
+use Reaction::Class;
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::ViewPort';
+
+has uri => ( is => 'rw', isa => 'URI', required => 1);
+has width => ( is => 'rw', isa => 'Int');
+has height => ( is => 'rw', isa => 'Int');
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
+__END__;
diff --git a/lib/Reaction/UI/Widget/Image.pm b/lib/Reaction/UI/Widget/Image.pm
new file mode 100644 (file)
index 0000000..418c4e1
--- /dev/null
@@ -0,0 +1,20 @@
+package Reaction::UI::Widget::Image;
+
+use Reaction::UI::WidgetClass;
+use namespace::clean -except => [ qw(meta) ];
+
+before fragment widget {
+  my $vp = $_{viewport};
+  my $attrs = {
+    uri => $vp->uri,
+    ($vp->has_width ? (width => $vp->width) : ()),
+    ($vp->has_height ? (height => $vp->height) : ()),
+  };
+  arg img_attrs => attrs( $attrs );
+};
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
+__END__;
diff --git a/share/skin/base/layout/image.tt b/share/skin/base/layout/image.tt
new file mode 100644 (file)
index 0000000..5030c8f
--- /dev/null
@@ -0,0 +1,5 @@
+=for layout widget
+
+<img [% img_attrs %] />
+
+=cut