/[Frey]/trunk/lib/Frey/View/Exhibit.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Frey/View/Exhibit.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 467 - (show annotations)
Wed Nov 19 19:28:09 2008 UTC (15 years, 4 months ago) by dpavlin
File size: 1572 byte(s)
rename class with experimental script
1 package Frey::View::Exhibit;
2 use Moose;
3
4 extends 'Frey';
5 with 'Frey::Web';
6
7 use MooseX::Types::Moose qw(Str Int ArrayRef);
8 use MooseX::Types::Structured qw/Dict/;
9
10 use Data::Dump qw/dump/;
11
12 =head1 DESCRIPTION
13
14 present C<sponge> as Exhibit from L<http://simile.mit.edu/exhibit/>
15
16 =cut
17
18 has sponge => (
19 is => 'rw',
20 isa => Dict[
21 rows => ArrayRef[ArrayRef],
22 NAME => ArrayRef[Str],
23 ],
24 # required => 1,
25 );
26
27 sub as_data {
28 my ($self) = @_;
29
30 confess "need sponge" unless $self->as_sponge;
31
32 my $items;
33 my $names = $self->as_sponge->{NAME};
34
35 my $id = 0;
36 my $have_id = grep { m{^id$} } @$names;
37 my $have_label = grep { m{^label$} } @$names;
38
39 foreach my $row ( @{ $self->as_sponge->{rows} } ) {
40 my $item;
41 map { $item->{ $names->[$_] } = $row->[$_] } ( 0 .. $#{ $row } );
42 $item->{id} = $id unless $have_id;
43 $item->{label} = $id unless $have_label;
44 $id++;
45 push @{ $items->{items} }, $item;
46 }
47
48 return $items;
49 }
50
51 sub depends {
52 my ($self) = @_;
53 $self->add_head(qq{
54 <link href="/Frey::Pipe/as_markup?pipe=Frey::DelIcioUs/as_sponge|Frey::View::Exhibit/as_data|Frey::View::JSON/as_markup"
55 type="application/json" rel="exhibit/data" />
56 });
57 $self->add_head(qq|
58 <script src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"
59 type="text/javascript"></script>
60 |);
61 warn "# depends";
62 }
63
64 sub as_markup {
65 my ($self) = @_;
66
67 return qq|
68 <table width="100%">
69 <tr valign="top">
70 <td ex:role="viewPanel">
71 <div ex:role="view"></div>
72 </td>
73 <td width="25%">
74 browsing controls here...
75 </td>
76 </tr>
77 </table>
78 |;
79 }
80
81 1;

  ViewVC Help
Powered by ViewVC 1.1.26