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

diff --git a/lib/Reaction/UI/ViewPort/URI.pm b/lib/Reaction/UI/ViewPort/URI.pm
new file mode 100644 (file)
index 0000000..d07adf2
--- /dev/null
@@ -0,0 +1,12 @@
+package Reaction::UI::ViewPort::URI;
+
+use Reaction::Class;
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::ViewPort';
+
+has uri => ( is => 'rw', isa => 'URI', required => 1);
+has display => ( is => 'rw' );
+
+__PACKAGE__->meta->make_immutable;
+
+1;
diff --git a/lib/Reaction/UI/Widget/URI.pm b/lib/Reaction/UI/Widget/URI.pm
new file mode 100644 (file)
index 0000000..db35a08
--- /dev/null
@@ -0,0 +1,28 @@
+package Reaction::UI::Widget::URI;
+
+use Reaction::UI::WidgetClass;
+use namespace::clean -except => [ qw(meta) ];
+
+before fragment widget {
+  arg uri => $_{viewport}->uri;
+};
+
+implements fragment display_fragment {
+  my $vp = $_{viewport};
+  return unless $vp->has_display;
+  my $display = $vp->display;
+  if( blessed($display) && $display->isa('Reaction::UI::ViewPort')){
+    arg '_' => $display;
+    render 'viewport';
+  } else {
+    arg string_value => $display;
+    render 'display_string';
+  }
+};
+
+__PACKAGE__->meta->make_immutable;
+
+
+1;
+
+__END__;
diff --git a/share/skin/base/layout/uri.tt b/share/skin/base/layout/uri.tt
new file mode 100644 (file)
index 0000000..b1c9831
--- /dev/null
@@ -0,0 +1,12 @@
+
+=widget URI
+
+=for layout widget
+
+<a href="[% uri %]">[% display_fragment %]</a>
+
+=for layout display_string
+
+[% string_value %]
+
+=cut