File Coverage

blib/lib/Kwiki/PrinterFriendly.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package Kwiki::PrinterFriendly;
2 1     1   19276 use Kwiki::Plugin -Base;
  0            
  0            
3             use Kwiki::Installer '-base';
4             use strict;
5             use warnings;
6              
7             our $VERSION = '0.13';
8              
9             const class_id => 'printer_friendly';
10             const class_title => 'Printer Friendly';
11             const screen_template => 'printer_friendly_screen.html';
12             const cgi_class => 'Kwiki::PrinterFriendly::CGI';
13              
14             sub register {
15             my $registry = shift;
16             $registry->add(action => 'printer_friendly');
17             $registry->add(toolbar => 'printer_friendly_button',
18             template => 'printer_friendly_button.html',
19             show_for => ['display', 'revisions']
20             );
21             }
22              
23             sub printer_friendly {
24             my $page = $self->pages->current;
25             my $content = $self->cgi->revision_id
26             ? $self->hub->archive->fetch($page, $self->cgi->revision_id)
27             : $page->content;
28             my $html = $self->hub->formatter->text_to_html($content);
29             $self->render_screen(
30             page_html => $html,
31             screen_title => $page->title,
32             site_title => $page->title,
33             page_content => $content,
34             page_time => $page->modified_time,
35             );
36             }
37              
38             package Kwiki::PrinterFriendly::CGI;
39             use base 'Kwiki::CGI';
40             cgi 'revision_id';
41             package Kwiki::PrinterFriendly;
42              
43             =head1 NAME
44              
45             Kwiki::PrinterFriendly - A Kwiki plugin to format pages for printing
46              
47             =head1 SYNOPSIS
48              
49             Provides an printer friendly display of the current page.
50              
51             =head1 REQUIRES
52              
53             Kwiki
54              
55             =head1 INSTALLATION
56              
57             perl Makefile.PL
58             make
59             make test
60             make install
61              
62             cd ~/where/your/kwiki/is/located
63             echo "Kwiki::PrinterFriendly" >>plugins
64              
65             kwiki -update
66              
67             =head1 UPGRADING
68              
69             You should always run 'kwiki -update' after upgrading Kwiki::PrinterFriendly
70              
71             =head1 CONFIGURATION
72              
73             In config.yaml, following are necessary for proper functioning:
74              
75             =over
76              
77             =item toolbar_order
78              
79             Add the item printer_friendly_button in the position where you
80             want the printer icon to appear
81              
82             =item printer_icon
83              
84             Included in this distribution is a sample icon, printer.png. To use it, put
85              
86             printer_icon: printer.png
87              
88             in your config.yaml file. If you have a better one, just put it in
89             the top of your Kwiki directory.
90              
91             =back
92              
93             =head1 ACKNOWLEDGEMENTS
94              
95             This is a hacked together version of Kwiki::Edit,
96             Kwiki::RecentChangesRSS, and various bits and pieces from other
97             modules. Thanks to James Peregrino and Brian Ingerson for doing
98             the heavy lifting.
99              
100             =head1 AUTHOR
101              
102             Henry Laxen
103              
104             =head1 COPYRIGHT
105              
106             Copyright (c) 2004. Henry Laxen. All rights reserved.
107              
108             This program is free software; you can redistribute it and/or modify it
109             under the same terms as Perl itself.
110              
111             See http://www.perl.com/perl/misc/Artistic.html
112              
113             =cut
114              
115             __DATA__