view release on metacpan or search on metacpan
# SYNOPSIS
This module is just the main documentation for ZofCMS framework. See
["USING THE FRAMEWORK"](#using-the-framework) section below for explanation of how to use this
framework.
# WARNING
<div>
<div style="display: table; height: 91px; background: url(http://zoffix.com/CPAN/Dist-Zilla-Plugin-Pod-Spiffy/icons/section-warning.png) no-repeat left; padding-left: 120px;" ><div style="display: table-cell; vertical-align: middle;">
</div>
I have no desire to continue development or maintenance of this framework.
As far as I know, I am the only developer. My only ties to this
framework is its use at $work and I am actively trying to switch
to [Mojolicious](https://metacpan.org/pod/Mojolicious). For that reason,
I strongly recommend you do NOT use this framework. Please see
[Mojolicious](https://metacpan.org/pod/Mojolicious), [Catalyst](https://metacpan.org/pod/Catalyst), [Dancer](https://metacpan.org/pod/Dancer), or [Dancer2](https://metacpan.org/pod/Dancer2) as alternatives.
<div>
<p>Current time is: <tmpl_var name="cur_time">
Providing you did not edit anything else in your config file and did not
touch `base.tmpl` file in your "data directory" you can now access
your web application and see a page which will display current time.
How wonderful \\o/
# REPOSITORY
<div>
<div style="display: table; height: 91px; background: url(http://zoffix.com/CPAN/Dist-Zilla-Plugin-Pod-Spiffy/icons/section-github.png) no-repeat left; padding-left: 120px;" ><div style="display: table-cell; vertical-align: middle;">
</div>
Fork this module on GitHub:
[https://github.com/zoffixznet/App-ZofCMS](https://github.com/zoffixznet/App-ZofCMS)
<div>
</div></div>
</div>
# BUGS
<div>
<div style="display: table; height: 91px; background: url(http://zoffix.com/CPAN/Dist-Zilla-Plugin-Pod-Spiffy/icons/section-bugs.png) no-repeat left; padding-left: 120px;" ><div style="display: table-cell; vertical-align: middle;">
</div>
To report bugs or request features, please use
[https://github.com/zoffixznet/App-ZofCMS/issues](https://github.com/zoffixznet/App-ZofCMS/issues)
If you can't access GitHub, you can email your request
to `bug-App-ZofCMS at rt.cpan.org`
<div>
</div></div>
</div>
# AUTHOR
<div>
<div style="display: table; height: 91px; background: url(http://zoffix.com/CPAN/Dist-Zilla-Plugin-Pod-Spiffy/icons/section-author.png) no-repeat left; padding-left: 120px;" ><div style="display: table-cell; vertical-align: middle;">
</div>
<div>
<span style="display: inline-block; text-align: center;"> <a href="http://metacpan.org/author/ZOFFIX"> <img src="http://www.gravatar.com/avatar/328e658ab6b08dfb5c106266a4a5d065?d=http%3A%2F%2Fwww.gravatar.com%2Favatar%2F627d83ef9879f31bdabf448e66...
</div>
<div>
</div></div>
</div>
lib/App/ZofCMS.pm view on Meta::CPAN
App::ZofCMS - web framework and templating system for small-medium sites.
=head1 SYNOPSIS
This module is just the main documentation for ZofCMS framework. See
L<USING THE FRAMEWORK> section below for explanation of how to use this
framework.
=head1 WARNING
=for html <div style="display: table; height: 91px; background: url(http://zoffix.com/CPAN/Dist-Zilla-Plugin-Pod-Spiffy/icons/section-warning.png) no-repeat left; padding-left: 120px;" ><div style="display: table-cell; vertical-align: middle;">
I have no desire to continue development or maintenance of this framework.
As far as I know, I am the only developer. My only ties to this
framework is its use at $work and I am actively trying to switch
to L<Mojolicious>. For that reason,
I strongly recommend you do NOT use this framework. Please see
L<Mojolicious>, L<Catalyst>, L<Dancer>, or L<Dancer2> as alternatives.
=for html </div></div>
lib/App/ZofCMS.pm view on Meta::CPAN
<p>Current time is: <tmpl_var name="cur_time">
Providing you did not edit anything else in your config file and did not
touch C<base.tmpl> file in your "data directory" you can now access
your web application and see a page which will display current time.
How wonderful \o/
=head1 REPOSITORY
=for html <div style="display: table; height: 91px; background: url(http://zoffix.com/CPAN/Dist-Zilla-Plugin-Pod-Spiffy/icons/section-github.png) no-repeat left; padding-left: 120px;" ><div style="display: table-cell; vertical-align: middle;">
Fork this module on GitHub:
L<https://github.com/zoffixznet/App-ZofCMS>
=for html </div></div>
=head1 BUGS
=for html <div style="display: table; height: 91px; background: url(http://zoffix.com/CPAN/Dist-Zilla-Plugin-Pod-Spiffy/icons/section-bugs.png) no-repeat left; padding-left: 120px;" ><div style="display: table-cell; vertical-align: middle;">
To report bugs or request features, please use
L<https://github.com/zoffixznet/App-ZofCMS/issues>
If you can't access GitHub, you can email your request
to C<bug-App-ZofCMS at rt.cpan.org>
=for html </div></div>
=head1 AUTHOR
=for html <div style="display: table; height: 91px; background: url(http://zoffix.com/CPAN/Dist-Zilla-Plugin-Pod-Spiffy/icons/section-author.png) no-repeat left; padding-left: 120px;" ><div style="display: table-cell; vertical-align: middle;">
=for html <span style="display: inline-block; text-align: center;"> <a href="http://metacpan.org/author/ZOFFIX"> <img src="http://www.gravatar.com/avatar/328e658ab6b08dfb5c106266a4a5d065?d=http%3A%2F%2Fwww.gravatar.com%2Favatar%2F627d83ef9879f31bda...
=for html </div></div>
=head1 LICENSE
You can use and distribute this module under the same terms as Perl itself.
See the C<LICENSE> file included in this distribution for complete
details.
lib/App/ZofCMS/Plugin/AutoIMGSize.pm view on Meta::CPAN
App::ZofCMS::Plugin::AutoIMGSize - automatically get image sizes and generate appropriate <img> tags
=head1 SYNOPSIS
In your Main Config or ZofCMS Template file:
plugins => [ qw/AutoIMGSize/ ],
plug_auto_img_size => {
imgs => {
logo => 'pics/top_logo.png'
kitteh => 'pics/kitteh.jpg',
blah => { 'somewhere/there.jpg' => ' class="foo"' },
},
},
In your L<HTML::Template> template:
Logo: <tmpl_var name="img_logo">
Kitteh: <tmpl_var name="img_kitteh">
blah: <tmpl_var name="img_blah">
lib/App/ZofCMS/Plugin/AutoIMGSize.pm view on Meta::CPAN
You would obvisouly want to add the plugin to the list of plugins to run. Play with priorities
if you are loading image paths dynamically.
=head2 C<plug_auto_img_size>
plug_auto_img_size => {
xhtml => 1,
t_prefix => 'img_',
imgs => {
logo => 'pics/logo.png',
kitteh => { 'pics/kitteh.jpg' => ' class="kitteh' },
},
},
The C<plug_auto_img_size> first-level Main Config file or ZofCMS Template file is what
makes the plugin run. If you specify this key in both ZofCMS Template and Main Config file
then keys set in ZofCMS Template will override the ones set in Main Config file. B<Note:>
the C<imgs> key will be completely overridden.
The key takes a hashref as a value. Possible keys/values of that hashref are as follows:
lib/App/ZofCMS/Plugin/Barcode.pm view on Meta::CPAN
use strict;
our $VERSION = '1.001008'; # VERSION
use GD::Barcode;
use base 'App::ZofCMS::Plugin::Base';
sub _key { 'plug_barcode' }
sub _defaults {
code => undef,
format => 'png', # gif or png
type => 'UPCA',
no_text => 0,
height => 50,
file => undef,
}
sub _do {
my ( $self, $conf, $t, $q, $config ) = @_;
$conf->{code} = $conf->{code}->( $t, $q, $config )
if ref $conf->{code} eq 'CODE';
lib/App/ZofCMS/Plugin/Barcode.pm view on Meta::CPAN
my $bar = GD::Barcode->new( @$conf{ qw/type code/ } );
unless ( $bar ) {
$t->{t}{plug_barcode_error} = $GD::Barcode::errStr;
return;
}
if ( defined $conf->{file} and length $conf->{file} ) {
if ( open my $fh, '>', $conf->{file} ) {
binmode $fh;
print $fh $conf->{format} eq 'png'
? $bar->plot( Height => $conf->{height}, NoText => $conf->{no_text} )->png
: $bar->plot( Height => $conf->{height}, NoText => $conf->{no_text} )->gif;
}
else {
$t->{t}{plug_barcode_error} = $!;
return;
}
}
else {
binmode STDOUT;
if ( $conf->{format} eq 'png' ) {
print "Content-Type: image/png\n\n";
print $bar->plot( Height => $conf->{height}, NoText => $conf->{no_text} )->png;
}
else {
print "Content-Type: image/gif\n\n";
print $bar->plot( Height => $conf->{height}, NoText => $conf->{no_text} )->gif;
}
exit;
}
}
1;
lib/App/ZofCMS/Plugin/Barcode.pm view on Meta::CPAN
# direct output to browser with default values for optional arguments
plug_barcode => {
code => '12345678901',
},
# or
# save to file with all options set
plug_barcode => {
code => '12345678901',
file => 'bar.png',
type => 'UPCA', # default
format => 'png', # default
no_text => 0, # default
height => 50, # default
},
In your HTML::Template template (in case errors occur):
<tmpl_if name='plug_barcode_error'>
<p>Error: <tmpl_var escape='html' name='plug_barcode_error'></p>
</tmpl_if>
lib/App/ZofCMS/Plugin/Barcode.pm view on Meta::CPAN
=head2 C<plug_barcode>
# direct output to browser with default values for optional arguments
plug_barcode => {
code => '12345678901',
},
# save to file with all options set
plug_barcode => {
code => '12345678901',
file => 'bar.png',
type => 'UPCA', # default
format => 'png', # default
no_text => 0, # default
height => 50, # default
},
# set config with a sub
plug_barcode => sub {
my ( $t, $q, $config ) = @_;
}
B<Mandatory>. Specifies plugin's options. Takes a hashref or a subref as a value. If subref is
lib/App/ZofCMS/Plugin/Barcode.pm view on Meta::CPAN
Specifies the code for the barcode to generate. Valid values depend
on the C<type> of the barcode you're generating. If value is an invalid barcode, plugin
will error out (see C<ERROR HANDLING> section below). If value is either C<undef>
or an empty string, plugin will stop further processing (no exit()s)
=head3 C<file>
plug_barcode => {
code => '12345678901',
file => 'bar.png',
},
B<Optional>. Takes a string that represents the name of the file (relative to C<index.pl>)
into which to save the image. When is not defined (or set to an empty string) the plugin
will print out the right C<Content-type> header and output the image right into the browser
B<and then will call exit() UNLESS an error occurred> . Plugin will B<NOT> call C<exit()> if
saving to the file. B<By default> is not specified (output barcode image directly to the
browser).
=head3 C<type>
lib/App/ZofCMS/Plugin/Barcode.pm view on Meta::CPAN
UPCA
UPCE
If value is either C<undef> or an empty string, plugin will stop further processing (no exit()s)
B<Defaults to:> C<UPCA>
=head3 C<format>
plug_barcode => {
code => '12345678901',
format => 'png',
},
B<Optional>. Can be set to either string C<png> or C<gif> (case sensitive).
Specifies the format of the image to generate (C<png> is for PNG images and C<gif> is for GIF
images). B<Defaults to:> C<png>
=head3 C<no_text>
plug_barcode => {
code => '12345678901',
no_text => 0,
},
B<Optional>. Takes either true or false values. When set to a true value, the plugin
will not generate text (i.e. it will only make the barcode lines) in the output image.
lib/App/ZofCMS/Plugin/CRUD.pm view on Meta::CPAN
value="<tmpl_var escape='html' name='page'>"
><input type="hidden"
name="crud_delete"
value="1"
><input type="hidden"
name="crud_id"
value="[<<ITEM:ID>>]"
><input type="image"
alt="Delete"
class="delete_button_no_style"
src="/pics/delete-button.png"
></div></form>
END_HTML
}
sub _get_U_form_template {
return <<'END_HTML';
<form class="update_button_form update_form" method="POST" action=""
><div
><input type="hidden"
name="page"
value="<tmpl_var escape='html' name='page'>"
><input type="hidden"
name="crud_update"
value="1"
><input type="hidden"
name="crud_id"
value="[<<ITEM:ID>>]"
><input type="image"
alt="Update"
class="update_button"
src="/pics/update-button.png"
></div></form>
END_HTML
}
sub _get_CU_form_template {
return <<'END_HTML';
<tmpl_if name='create_success'>
<p class="success-message">Item has been successfully added. <a href="<tmpl_var escape='html' name='page'>">Add another one</a></p>
</tmpl_if>
<tmpl_if name='update_success'>
lib/App/ZofCMS/Plugin/Comments.pm view on Meta::CPAN
"moderation table". There is a feature that allows all comments that
are older than $x seconds (see C<mod_out_time> argument) to be deleted
from the "moderation table" automatically.
=head1 WHAT? NO CAPTCHA?
You will notice that there is no "captcha"
(L<http://en.wikipedia.org/wiki/Captcha>) thing done with comments form
generated by the plugin. The reason for that is that I hate them... pure
hate. I think the worst captcha I ever came across was this:
L<http://www.zoffix.com/new/captcha-wtf.png>. But most of all, I think
they are plain annoying.
In this plugin I implemented a non-annoying "captcha" mechanizm suggested
by one of the people I know who claimed it works very well. At the time
of this writing I am not yet aware of how "well" it really is. Basically,
the plugin sticks C<< <input type="hidden" name="zofcms_comments_username" value="your user name"> >> in the form. When checking the parameters,
the plugin checks that this hidden input's value matches. If it doesn't,
boot the request. Apparently the technique works much better when the
C<< <input> >> is not of C<type="hidden"> but I am very against "hiding"
something with CSS.
lib/App/ZofCMS/Plugin/FileTypeIcon.pm view on Meta::CPAN
$conf->{code_after}->( $t, $q, $config );
}
}
sub make_icon_name {
my ( $resource, $file ) = @_;
my ( $ext ) = $file =~ /[.]([^.]+)$/;
$ext = 'unknown'
unless defined $ext;
my $icon_file = File::Spec->catfile( $resource, $ext . '.png' );
if ( -e $icon_file ) {
return ( $icon_file, uc($ext) . ' file' );
}
else {
$ext = 'unknown';
$icon_file = File::Spec->catfile( $resource, $ext . '.png' );
return ( $icon_file, 'Unknown file format' );
}
}
1;
__END__
=encoding utf8
=head1 NAME
lib/App/ZofCMS/Plugin/FileTypeIcon.pm view on Meta::CPAN
=head1 SYNOPSIS
# first of all, get icon images (they are also in the examples/ dir of this distro)
wget http://zoffix.com/new/fileicons.tar.gz;tar -xvvf fileicons.tar.gz;rm fileicons.tar.gz;
In your ZofCMS Template or Main Config File:
plug_file_type_icon => {
files => [ # mandatory
qw/ foo.png bar.doc beer.pdf /,
sub {
my ( $t, $q, $conf ) = @_;
return 'meow.wmv';
},
],
# all the defaults for reference:
resource => 'pics/fileicons/',
prefix => 'fileicon_',
as_arrayref => 0, # put all files into an arrayref at $t->{t}{ $prefix }
only_path => 0, # i.e. do not generate the <img> element
lib/App/ZofCMS/Plugin/FileTypeIcon.pm view on Meta::CPAN
of this distribution. You can also get it from my website:
wget http://zoffix.com/new/fileicons.tar.gz;
tar -xvvf fileicons.tar.gz;
rm fileicons.tar.gz;
As well as the original website from where I got them:
L<http://www.splitbrain.org/projects/file_icons>
Alternatively, you may want to draw your own icons; in that case, the filenames for the icons
are made out as C<$lowercase_filetype_extension.png>.
If you draw some icons yourself and would like to share, feel free to email them to me
at C<zoffix@cpan.org>.
These images would obviously need to be placed in web-accessible directory on your website.
=head1 FIRST-LEVEL ZofCMS TEMPLATE AND MAIN CONFIG FILE KEYS
=head2 C<plugins>
plugins => [ qw/FileTypeIcon/ ],
You obviously need to include the plugin in the list of plugins to execute. You're likely
to use this plugin with some other plugins, so make sure to get priority right.
=head2 C<plug_file_type_icon>
plug_file_type_icon => {
files => [ # mandatory
qw/ foo.png bar.doc beer.pdf /,
sub {
my ( $t, $q, $conf ) = @_;
return 'meow.wmv';
},
],
# all the defaults for reference:
resource => 'pics/fileicons/',
prefix => 'fileicon_',
as_arrayref => 0, # put all files into an arrayref at $t->{t}{ $prefix }
only_path => 0, # i.e. do not generate the <img> element
lib/App/ZofCMS/Plugin/FileTypeIcon.pm view on Meta::CPAN
die "Weeee";
},
xhtml => 0,
},
# or set config via a subref
plug_file_type_icon => sub {
my ( $t, $q, $config ) = @_;
return {
files => [
qw/ foo.png bar.doc beer.pdf /,
],
};
},
Plugin won't run if C<plug_file_type_icon> is not set or its C<files> key does not contain
any files. The C<plug_file_type_icon> first-level key takes a hashref or a subref as a value. If subref is specified,
its return value will be assigned to C<plug_file_type_icon> as if it was already there. If sub returns
an C<undef>, then plugin will stop further processing. The C<@_> of the subref will
contain (in that order): ZofCMS Tempalate hashref, query parameters hashref and
L<App::ZofCMS::Config> object. The
keys of this hashref can be set in either ZofCMS Template or Main Config Files; keys that are
set in both files will take their values from ZofCMS Template file. The following keys/values
are valid in C<plug_file_type_icon>:
=head3 C<files>
files => [
qw/ foo.png bar.doc beer.pdf /,
{ 'beer.doc' => 'doc_file' },
sub {
my ( $t, $q, $conf ) = @_;
return 'meow.wmv';
},
],
B<Mandatory>. The C<files> key takes either an arrayref, a subref or a hashref as a value.
If its value is B<NOT> an arrayref, then it will be converted to an arrayref with just one
element - the original value.
lib/App/ZofCMS/Plugin/FileTypeIcon.pm view on Meta::CPAN
xhtml => 0,
B<Optional>. If you wish to close C<< <img> >> elements as to when you're writing XHTML, then
set C<xhtml> argument to a true value. B<Defaults to:> C<0>
=head1 GENERATED HTML CODE
The plugin generates the following HTML code:
<img class="file_type_icon" src="pics/fileicons/png.png" width="16" height="16" alt="PNG file" title="PNG file">
=head1 REPOSITORY
Fork this module on GitHub:
L<https://github.com/zoffixznet/App-ZofCMS>
=head1 BUGS
To report bugs or request features, please use
L<https://github.com/zoffixznet/App-ZofCMS/issues>
lib/App/ZofCMS/Plugin/FileUpload.pm view on Meta::CPAN
{ name => 'foos', }
{ name => '[rand]', }
{ name => \1 } # any scalar ref
{
name => sub {
my ( $t, $q, $config ) = @_;
return 'file_name.png';
},
}
B<Optional>. Specifies the name (without the extension)
of the local file into which save the uploaded file. Special value of
C<[rand]> specifies that the name should be random, in which case it
will be created by calling C<rand()> and C<time()> and removing any dots
from the concatenation of those two. If a I<scalarref> is specified
(irrelevant of its value), the plugin will use the filename that the
browser gave it (relying on L<File::Spec::Functions>'s