| 1 | package Jifty::Plugin::SkeletonApp::View; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Jifty::View::Declare -base; | ||
| 7 | |||
| 8 | use Scalar::Defer; | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | Jifty::Plugin::SkeletonApp::View - Default fragments for your pages | ||
| 13 | |||
| 14 | =head1 DESCRIPTION | ||
| 15 | |||
| 16 | This somewhat-finished (But not quite) template library implements | ||
| 17 | Jifty's "pony" Application. It could certainly use some | ||
| 18 | refactoring. (And some of the menu stuff should get factored out into | ||
| 19 | a dispatcher or the other plugins that implement it. | ||
| 20 | |||
| 21 | |||
| 22 | =cut | ||
| 23 | |||
| 24 | private template 'salutation' => sub { | ||
| 25 | my $cu = Jifty->web->current_user; | ||
| 26 | div { | ||
| 27 | attr {id => "salutation" }; | ||
| 28 | if ( $cu->id and $cu->user_object ) { | ||
| 29 | _( 'Hiya, %1.', $cu->username ); | ||
| 30 | } | ||
| 31 | else { | ||
| 32 | _("You're not currently signed in."); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | }; | ||
| 36 | |||
| 37 | private template 'menu' => sub { | ||
| 38 | div { attr { id => "navigation" }; | ||
| 39 | Jifty->web->navigation->render_as_menu; | ||
| 40 | }; | ||
| 41 | }; | ||
| 42 | |||
| 43 | template '__jifty/empty' => sub :Static { | ||
| 44 | ''; | ||
| 45 | }; | ||
| 46 | |||
| 47 | |||
| 48 | private template 'header' => sub { | ||
| 49 | my ($title) = get_current_attr(qw(title)); | ||
| 50 | Jifty->web->response->content_type('text/html; charset=utf-8'); | ||
| 51 | head { | ||
| 52 | with( | ||
| 53 | 'http-equiv' => "content-type", | ||
| 54 | content => "text/html; charset=utf-8" | ||
| 55 | ), | ||
| 56 | meta {}; | ||
| 57 | with( name => 'robots', content => 'all' ), meta {}; | ||
| 58 | title { _($title) }; | ||
| 59 | Jifty->web->include_css; | ||
| 60 | Jifty->web->include_javascript; | ||
| 61 | }; | ||
| 62 | }; | ||
| 63 | |||
| 64 | private template 'heading_in_wrapper' => sub { | ||
| 65 | h1 { attr { class => 'title' }; outs_raw(get('title')) }; | ||
| 66 | }; | ||
| 67 | |||
| 68 | private template 'keybindings' => sub { | ||
| 69 | div { id is "keybindings" }; | ||
| 70 | }; | ||
| 71 | |||
| 72 | #template 'index.html' => page { { title is _('Welcome to your new Jifty application') } img { src is "/static/images/pony.jpg", alt is _( 'You said you wanted a pony. (Source %1)', 'http://hdl.loc.gov/loc.pnp/cph.3c13461'); }; }; | ||
| 73 | |||
| 74 | 1; |