| 1 | package CGI::Application::HelpMan; | ||
| 2 | 1 | ▶ | use base 'CGI::Application'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 0 | ▶ | use CGI::Application::Plugin::TmplInnerOuter; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 4 | use CGI::Application::Plugin::AutoRunmode; | ||
| 5 | use CGI::Application::Plugin::Session; | ||
| 6 | use CGI::Application::Plugin::Feedback ':all'; | ||
| 7 | use CGI::Application::Plugin::Forward; | ||
| 8 | use CGI::Application::Plugin::HelpMan ':all'; | ||
| 9 | #$CGI::Application::Plugin::TmplInnerOuter::DEBUG = 1; | ||
| 10 | |||
| 11 | sub setup { | ||
| 12 | my $self = shift; | ||
| 13 | $self->start_mode('help_search'); | ||
| 14 | } | ||
| 15 | |||
| 16 | sub help : Runmode { | ||
| 17 | my $self = shift; | ||
| 18 | |||
| 19 | $self->_set_tmpl_default(q{ | ||
| 20 | <h1><TMPL_VAR HELP_TITLE></h1> | ||
| 21 | <div> | ||
| 22 | <TMPL_VAR HELP_BODY> | ||
| 23 | </div> | ||
| 24 | }); | ||
| 25 | |||
| 26 | $self->_set_vars( | ||
| 27 | HELP_TITLE => $self->hm_help_title, | ||
| 28 | HELP_BODY => $self->hm_help_body, | ||
| 29 | ); | ||
| 30 | |||
| 31 | return $self->tmpl_output; | ||
| 32 | } | ||
| 33 | |||
| 34 | sub help_view : Runmode { | ||
| 35 | my $self = shift; | ||
| 36 | |||
| 37 | unless( $self->hm_found_term_query ){ | ||
| 38 | $self->feedback("What do you want to search for?"); | ||
| 39 | return $self->forward('help_search'); | ||
| 40 | } | ||
| 41 | |||
| 42 | $self->feedback(sprintf "You searched for [%s]", $self->hm_term_get ); | ||
| 43 | |||
| 44 | my $abs; | ||
| 45 | |||
| 46 | unless( $self->hm_found_term_abs ){ | ||
| 47 | $self->feedback( sprintf "Sorry, I can't find [%s]", $self->hm_term_get ); | ||
| 48 | return $self->forward('help_search'); | ||
| 49 | } | ||
| 50 | |||
| 51 | unless( $self->hm_found_term_doc ) { | ||
| 52 | $self->feedback( sprintf "Sorry, no doccumentation in [%s]", $self->hm_term_get ); | ||
| 53 | return $self->forward('help_search'); | ||
| 54 | } | ||
| 55 | |||
| 56 | unless( $self->hm_doc_body ) { | ||
| 57 | $self->feedback( sprintf "Sorry, cant get out the doccumentation for [%s]", $self->hm_term_get ); | ||
| 58 | return $self->forward('help_search'); | ||
| 59 | } | ||
| 60 | |||
| 61 | |||
| 62 | $self->_set_tmpl_default(q{ | ||
| 63 | <h1><TMPL_VAR HELP_TITLE></h1> | ||
| 64 | <div> | ||
| 65 | <TMPL_VAR HELP_BODY> | ||
| 66 | </div> | ||
| 67 | }); | ||
| 68 | |||
| 69 | |||
| 70 | $self->_set_vars( | ||
| 71 | HELP_TITLE => $self->hm_doc_title, | ||
| 72 | HELP_BODY => $self->hm_doc_body, | ||
| 73 | ); | ||
| 74 | |||
| 75 | return $self->tmpl_output; | ||
| 76 | } | ||
| 77 | |||
| 78 | |||
| 79 | sub help_search : Runmode { | ||
| 80 | my $self = shift; | ||
| 81 | |||
| 82 | $self->_set_tmpl_default(q{ | ||
| 83 | <h1>Search Help</h1> | ||
| 84 | <form> | ||
| 85 | <input type="text" name="query"> | ||
| 86 | <input type="hidden" name="rm" value="help_view"> | ||
| 87 | <input type="submit" value="search"> | ||
| 88 | </form> | ||
| 89 | }); | ||
| 90 | |||
| 91 | return $self->tmpl_output; | ||
| 92 | } | ||
| 93 | |||
| 94 | |||
| 95 | sub tmpl_output { | ||
| 96 | my $self = shift; | ||
| 97 | |||
| 98 | $self->_set_tmpl_default(q{ | ||
| 99 | <html> | ||
| 100 | <head><title><TMPL_VAR PAGE_TITLE></title></html></head> | ||
| 101 | <body> | ||
| 102 | |||
| 103 | <div><a href="?rm=help_search">new search</a> : <a href="?rm=help">help</a></div> | ||
| 104 | |||
| 105 | <div> | ||
| 106 | <TMPL_LOOP FEEDBACK> | ||
| 107 | <p><TMPL_VAR FEEDBACK></p> | ||
| 108 | </TMPL_LOOP> | ||
| 109 | </div> | ||
| 110 | |||
| 111 | <div><TMPL_VAR BODY></div> | ||
| 112 | </body> | ||
| 113 | </html>},'main.html'); | ||
| 114 | |||
| 115 | $self->_set_vars( FEEDBACK => $self->get_feedback_prepped ); | ||
| 116 | |||
| 117 | $self->_feed_vars_all; | ||
| 118 | $self->_feed_merge; | ||
| 119 | return $self->_tmpl_outer->output; | ||
| 120 | } | ||
| 121 | |||
| 122 | |||
| 123 | |||
| 124 | 1; | ||
| 125 | |||
| 126 | |||
| 127 | |||
| 128 | =pod | ||
| 129 | |||
| 130 | =head1 NAME | ||
| 131 | |||
| 132 | CGI::Application::HelpMan - look up system perl pod docs | ||
| 133 | |||
| 134 | =head1 DESCRIPTION | ||
| 135 | |||
| 136 | The application lets you look up documentation on this system. | ||
| 137 | |||
| 138 | For developer API, please see L<CGI::Application::Plugin::HelpMan>. | ||
| 139 | |||
| 140 | =head1 SCREENS | ||
| 141 | |||
| 142 | =head2 NEW SEARCH | ||
| 143 | |||
| 144 | Here you can enter a query to look up. | ||
| 145 | Enter the text in the box and click on search. | ||
| 146 | At any moment you can click on 'new search' to search something else. | ||
| 147 | |||
| 148 | =head2 HELP | ||
| 149 | |||
| 150 | Shows this screen. | ||
| 151 | |||
| 152 | =head1 AUTHOR | ||
| 153 | |||
| 154 | Leo Charre leocharre at cpan dot org | ||
| 155 | |||
| 156 | =head1 SEE ALSO | ||
| 157 | |||
| 158 | L<CGI::Application::Plugin::HelpMan> | ||
| 159 | L<CGI::Application::Plugin::Feedback> | ||
| 160 | L<CGI::Application::Plugin::Session> | ||
| 161 | L<CGI::Application::Plugin::AutoRunmode> | ||
| 162 | L<CGI::Application::Plugin::Forward> | ||
| 163 | L<CGI::Application::Plugin::TmplInnerOuter> | ||
| 164 | L<CGI::Application> | ||
| 165 | |||
| 166 | =cut | ||
| 167 | |||
| 168 | |||