.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Jifty::Plugin::ViewDeclarePage::Page 3pm" .TH Jifty::Plugin::ViewDeclarePage::Page 3pm "2012-03-06" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Jifty::View::Declare::Page::NewStyle \- new style page wrapper to simplify customization and reuse. .SH "DESCRIPTION" .IX Header "DESCRIPTION" This library is a replacement for Jifty::View::Declare::Page. That is in Jifty for a while and can not be replaced with something completely different because of backwards compatibility. .PP When you declare a Jifty::View::Declare template that is a page, for example: .PP .Vb 3 \& template \*(Aqnews\*(Aq => page { \& ... \& }; .Ve .PP Page classes come into game. First of all App::View::Page is loaded (it's not true and there is a way to define class for particular page, but lets leave it alone as interface is not settled enough to be discussed). If the app class doesn't exist then default Jifty::View::Declare::Page is used. Code block right after page token is used to render core of the page wrapped into some layout. Page classes implement such layouts. .PP It's very hard to extended Jifty::View::Declare::Page class as it's written in such a way that forces you to copy&paste some internals from the class to make overridden method work and don't break things. .PP I think this implementation is much better thing. To use this class as a base for all your pages you can just add this plugin to your app and simple YourApp::View::Page will be generated for you. However, if you're here then you want to change layout, your App::View::Page should be something like: .PP .Vb 3 \& package MyApp::View::Page; \& use base qw(Jifty::Plugin::ViewDeclarePage::Page); \& use Jifty::View::Declare::Helpers; \& \& ... \& \& 1; .Ve .SH "DIFFERENCES FROM DEFAULT PAGE CLASS" .IX Header "DIFFERENCES FROM DEFAULT PAGE CLASS" .IP "no calls into templates" 4 .IX Item "no calls into templates" Yes, that's it. No call to show('/menu'), instead it's a method \&\*(L"render_navigation\*(R" here. Why? If it's subclassable then there is no need to split functionality between different modules. You can always return old behavior by using: .Sp .Vb 1 \& sub render_navigation { show(/menu) } .Ve .IP "no render_pre_content_hook" 4 .IX Item "no render_pre_content_hook" override \*(L"render_content\*(R". .IP "title is always rendered in page" 4 .IX Item "title is always rendered in page" Even when there is no 'page_title is ...' in the content code, see \*(L"instrument_content\*(R" and \*(L"render_title_inpage\*(R". .IP "no html in title" 4 .IX Item "no html in title" All \s-1HTML\s0 is just escaped. 99% of apps don't want to put tags inside title. Sure, it's wrapped into

tag. See \*(L"render_title_inpage\*(R" .IP "new 'add rel ...' and 'add rev ...'" 4 .IX Item "new 'add rel ...' and 'add rev ...'" Can be used in the content code to define feeds, relative links and other cool stuff. See \*(L"instrument_content\*(R" and \*(L"render_link_inpage\*(R". .IP "at last" 4 .IX Item "at last" It's documented! .SH "ACCESSORS" .IX Header "ACCESSORS" .IP "content_code" 4 .IX Item "content_code" Code reference that renders the core of the page, this is code block right after page token in the following example: .Sp .Vb 3 \& template \*(Aqnews\*(Aq => page { \& ... \& }; .Ve .Sp Is set by jifty during construction of the page object. .IP "_meta" 4 .IX Item "_meta" A hash reference that is set by jifty during construction of the page object. It's empty unless you use the following syntax: .Sp .Vb 3 \& template my_page => page { some => \*(Aqvalue\*(Aq, ... } content { \& ... \& }; .Ve .Sp In this case _meta is a reference to the hash that goes right after page token and content_code is after content token. .IP "_title and _links" 4 .IX Item "_title and _links" These are internal temporary holders of corresponding data. .SH "METHODS" .IX Header "METHODS" .SS "Initialization and rendering driver" .IX Subsection "Initialization and rendering driver" \fInew\fR .IX Subsection "new" .PP Sets up a new page class. Called by Jifty with content_code and optional _meta. .PP Calls \*(L"init\*(R" right before returning new instance of the class. .PP \fIinit\fR .IX Subsection "init" .PP Sets _title accessor from 'title' in _meta if the latter is defined, so you can do the following if title of a page is static: .PP .Vb 3 \& template news => page { title => _(\*(AqNews\*(Aq) } content { \& ... \& }; .Ve .PP \fIrender\fR .IX Subsection "render" .PP Renders whole page from doctype till closing html tag. Takes no arguments. .PP This method drives rendering of the page. Page is split into three major parts: header, body and footer. Each is implemented as corresponding method with 'render_' prefix. .PP It worth to note that order of rendering is changed and header is rendered after the body to allow you define page title, \s-1RSS\s0 feeds and other things in content. Read more about this below in \*(L"render_header\*(R" and \*(L"instrument_content\*(R". .SS "Main blocks of the page" .IX Subsection "Main blocks of the page" \fIrender_header\fR .IX Subsection "render_header" .PP Renders an \s-1HTML\s0 \*(L"doctype\*(R" and complete tag. Usually you don't want to override this. This method is rendered after body and main content of the page, so all things you need in head tag you can define in content. .IP "doctype" 4 .IX Item "doctype" Calls \*(L"render_doctype\*(R". .ie n .IP """page_title is ...""" 4 .el .IP "\f(CWpage_title is ...\fR" 4 .IX Item "page_title is ..." You can define dynamic title using the following: .Sp .Vb 6 \& template some => page { \& my $page_title = ...; \& ... \& page_title is $page_title; \& ... \& }; .Ve .Sp Don't want to define dynamic title then as well you can use syntax described in \*(L"init\*(R" above. .Sp When 'page_title is' is used in the content code, \*(L"render_title_inpage\*(R" is called, read more in \*(L"instrument_content\*(R". .Sp \&\*(L"render_title_inhead\*(R" is called during rendering of the head tag, so you can change title there as well by subclassing that method. .ie n .IP "tag , ""add rel ..."" and ""add rev ...""" 4 .el .IP "tag , \f(CWadd rel ...\fR and \f(CWadd rev ...\fR" 4 .IX Item "tag , add rel ... and add rev ..." You can add tags right from the content using the following syntax: .Sp .Vb 5 \& add rel "alternate", \& type => "application/atom+xml", \& title => _(\*(AqUpdated this week\*(Aq), \& href => \*(Aq/feeds/atom/recent\*(Aq, \& ; .Ve .Sp When these constructions are used, \*(L"render_link_inpage\*(R" is called so you can add something right in the page content, for example \&\s-1RSS\s0 image with link to the feed. See also \*(L"instrument_content\*(R". .Sp \&\*(L"render_links_inhead\*(R" is called during rendering of the head tag. .IP "css and js" 4 .IX Item "css and js" Links to \s-1CSS\s0 and \s-1JS\s0 files are rendered for you using \&\*(L"include_css\*(R" in Jifty::Web and \*(L"include_js\*(R" in Jifty::Web functions. .Sp Read docs around those methods and Jifty::Manual on adding your own styles and scripts. .IP "meta" 4 .IX Item "meta" Not implemented, but will be as soon as syntax will be defined. .PP \fIrender_body\fR .IX Subsection "render_body" .PP Renders body tag, declares that we're in body and calls \*(L"render_page\*(R" that actually defines layout of the body. \*(L"render_page\*(R" method is better target for subclassing instead of this. .PP \fIrender_footer\fR .IX Subsection "render_footer" .PP Renders the page footer \- tag :) .SS "Body layout" .IX Subsection "Body layout" \fIrender_page\fR .IX Subsection "render_page" .PP Renders the skeleton of the page and then calls \*(L"instrument_content\*(R" to prepare and finally render \*(L"content_code\*(R" using \*(L"render_content\*(R". .PP Default layout of the page is the following: .PP .Vb 10 \&
\&
\& this\->render_salutation \& this\->render_navigation \&
\&
\& this\->instrument_content \& this\->render_jifty_page_detritus \&
\&
.Ve .PP \fIinstrument_content\fR .IX Subsection "instrument_content" .PP Something you don't want ever touch. However, does the following: .ie n .IP "setups local 'page_title is ...' handler which calls ""render_title_inpage"" if 'page_title is' is used." 4 .el .IP "setups local 'page_title is ...' handler which calls ``render_title_inpage'' if 'page_title is' is used." 4 .IX Item "setups local 'page_title is ...' handler which calls render_title_inpage if 'page_title is' is used." .PD 0 .ie n .IP "if 'page_title is' is not used then calls ""render_title_inpage"" after and put result into output stream before the content." 4 .el .IP "if 'page_title is' is not used then calls ``render_title_inpage'' after and put result into output stream before the content." 4 .IX Item "if 'page_title is' is not used then calls render_title_inpage after and put result into output stream before the content." .ie n .IP "setup handler for 'add rel ...' and 'add rev ...', that calls ""render_link_inpage"" and fills _links accessor." 4 .el .IP "setup handler for 'add rel ...' and 'add rev ...', that calls ``render_link_inpage'' and fills _links accessor." 4 .IX Item "setup handler for 'add rel ...' and 'add rev ...', that calls render_link_inpage and fills _links accessor." .ie n .IP "sure calls ""render_content""." 4 .el .IP "sure calls ``render_content''." 4 .IX Item "sure calls render_content." .PD .PP \fIrender_content\fR .IX Subsection "render_content" .PP Renders content of the page \- \*(L"content_code\*(R". .SS "Helpers" .IX Subsection "Helpers" \fIrender_doctype\fR .IX Subsection "render_doctype" .PP Renders default doctype (\s-1HTML5\s0) and opening \f(CW\*(C`\*(C'\fR tag .PP \fIrender_title_inhead\fR .IX Subsection "render_title_inhead" .PP Should output nothing but a title tag what will be placed into the head. Title is passed as only argument. Arguments are combined. .PP \fIrender_title_inpage\fR .IX Subsection "render_title_inpage" .PP Renders the in-page title, followed by page navigation and jifty messages. .PP See \*(L"render_title_inhead\*(R", \*(L"instrument_content\*(R" and \*(L"render_header\*(R". .PP \fIrender_links_inhead\fR .IX Subsection "render_links_inhead" .PP Renders link tags which are passed as list of hashes. .PP \fIrender_link_inpage\fR .IX Subsection "render_link_inpage" .PP Do nothing by default, but link as a hash is passed when content has 'add rel ...' or 'add rev ...'. .PP Read more in \*(L"render_header\*(R" and \*(L"instrument_content\*(R". .PP \fIrender_navigation\fR .IX Subsection "render_navigation" .PP Renders \*(L"navigation\*(R" in Jifty::Web as menu wrapped into a div with id 'navigation'. There is as well page_navigation in Jifty that is rendered in \*(L"render_title_inpage\*(R" by default. .PP Called from \*(L"render_page\*(R". .PP \fIrender_salutation\fR .IX Subsection "render_salutation" .PP Renders salutation for the current user wrapped into div with id equal to 'salutation'. Called from \*(L"render_page\*(R". .PP \fIrender_jifty_page_detritus\fR .IX Subsection "render_jifty_page_detritus" .PP Renders admin mode warning, the wait message, the keybindings and PubSub javascript. Called from \*(L"render_page\*(R".