« blib/lib/UR/Object/Type/View/AvailableViews/Json.pm
↑ Summary
blib/lib/UR/Role/MethodModifier.pm »
| 1 | package UR::Object::View::Static::Html; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | require UR; | ||
| 6 | our $VERSION = "0.46"; # UR $VERSION; | ||
| 7 | |||
| 8 | class UR::Object::View::Static::Html { | ||
| 9 | is => 'UR::Object::View', | ||
| 10 | has => { | ||
| 11 | output_format => { value => 'html' }, | ||
| 12 | html_root => { doc => 'path to plain-old html files' } | ||
| 13 | }, | ||
| 14 | has_constant => [ | ||
| 15 | perspective => { value => 'static' }, | ||
| 16 | toolkit => { value => 'html' }, | ||
| 17 | ], | ||
| 18 | }; | ||
| 19 | |||
| 20 | sub content { | ||
| 21 | |||
| 22 | my ($self) = @_; | ||
| 23 | |||
| 24 | my $filename = class_to_filename($self->subject->class); | ||
| 25 | my $perspective = $self->perspective() || die "Error: I have no perspective"; | ||
| 26 | |||
| 27 | my $pathname = join('/', $self->html_root(), $perspective, $filename); | ||
| 28 | |||
| 29 | open(my $fh, $pathname); if (!$fh) { die "Could not open the static html file: $pathname"; } | ||
| 30 | my $c = do | ||
| 31 | { undef $/; | ||
| 32 | <$fh>; | ||
| 33 | }; | ||
| 34 | close($pathname); | ||
| 35 | |||
| 36 | return $c; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub class_to_filename { | ||
| 40 | my ($class) = @_; | ||
| 41 | $class = lc($class); | ||
| 42 | $class =~ s/::/_/g; | ||
| 43 | $class .= '.html'; | ||
| 44 | return $class; | ||
| 45 | } | ||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | 1; | ||
| 50 | |||
| 51 | =pod | ||
| 52 | |||
| 53 | =head1 NAME | ||
| 54 | |||
| 55 | UR::Object::View::Static::Html - represent object state in HTML format | ||
| 56 | |||
| 57 | =head1 SYNOPSIS | ||
| 58 | |||
| 59 | package Genome::Sample::Set::View::Detail::Html; | ||
| 60 | |||
| 61 | class Genome::Sample::Set::View::Detail::Html { | ||
| 62 | is => 'UR::Object::View::Static::Html', | ||
| 63 | has_constant => [ | ||
| 64 | toolkit => { value => 'html' }, | ||
| 65 | perspective => { value => 'detail' } | ||
| 66 | ] | ||
| 67 | }; | ||
| 68 | |||
| 69 | |||
| 70 | =head1 DESCRIPTION | ||
| 71 | |||
| 72 | The current default HTML class creates HTML by getting XML and applying XSL. | ||
| 73 | This class, on the other hand, displays some static html | ||
| 74 | |||
| 75 | =head1 SEE ALSO | ||
| 76 | |||
| 77 | UR::Object::View::Default::Html, UR::Object::View::Default::Text, UR::Object::View, UR::Object::View::Toolkit::XML, UR::Object::View::Toolkit::Text, UR::Object | ||
| 78 | |||
| 79 | =cut | ||
| 80 |