| 1 | package Miril; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use autodie; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Exception::Class; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Module::Load; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Ref::List qw(list); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Miril::Warning; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Miril::Exception; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use Miril::Config; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use Miril::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 1 | our $VERSION = '0.008'; | |||||||||
| 18 | |||||||||||
| 19 | ### ACCESSORS ### | ||||||||||
| 20 | |||||||||||
| 21 | 1 | ▶ | use Object::Tiny qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | store | ||||||||||
| 23 | tmpl | ||||||||||
| 24 | cfg | ||||||||||
| 25 | filter | ||||||||||
| 26 | util | ||||||||||
| 27 | 1 | ); | |||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | ### CONSTRUCTOR ### | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 33 | 0 | my $class = shift; | |||||||||
| 34 | 0 | my $self = bless {}, $class; | |||||||||
| 35 | 0 | my $miril_dir = shift; | |||||||||
| 36 | 0 | my $site = shift; | |||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | # load configuration | ||||||||||
| 40 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 41 | 0 | my $cfg = Miril::Config->new($miril_dir, $site); | |||||||||
| 42 | 0 | $self->{cfg} = $cfg; | |||||||||
| 43 | 0 | ▶ | } catch { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 44 | 0 | Miril::Exception->throw( | |||||||||
| 45 | errorvar => $_, | ||||||||||
| 46 | message => 'Could not open configuration file', | ||||||||||
| 47 | ); | ||||||||||
| 48 | 0 | }; | |||||||||
| 49 | 0 | ▶ | return unless $self->cfg; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | 0 | my $cfg = $self->cfg; | |||||||||
| 52 | |||||||||||
| 53 | # load store | ||||||||||
| 54 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 55 | 0 | my $store_name = "Miril::Store::" . $cfg->store; | |||||||||
| 56 | 0 | load $store_name; | |||||||||
| 57 | 0 | my $store = $store_name->new($self); | |||||||||
| 58 | 0 | $self->{store} = $store; | |||||||||
| 59 | 0 | ▶ | } catch { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 60 | 0 | Miril::Exception->throw( | |||||||||
| 61 | errorvar => $_, | ||||||||||
| 62 | message => 'Could not load store', | ||||||||||
| 63 | ); | ||||||||||
| 64 | 0 | }; | |||||||||
| 65 | 0 | ▶ | return unless $self->store; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | |||||||||||
| 67 | # load temlate | ||||||||||
| 68 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 69 | 0 | my $tmpl_name = "Miril::Template::" . $cfg->template; | |||||||||
| 70 | 0 | load $tmpl_name; | |||||||||
| 71 | 0 | $self->{tmpl} = $tmpl_name->new($self); | |||||||||
| 72 | 0 | ▶ | } catch { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 73 | 0 | Miril::Exception->throw( | |||||||||
| 74 | errorvar => $_, | ||||||||||
| 75 | message => 'Could not load template', | ||||||||||
| 76 | ); | ||||||||||
| 77 | 0 | }; | |||||||||
| 78 | |||||||||||
| 79 | # load filter | ||||||||||
| 80 | 0 | ▶ | try { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 81 | 0 | my $filter_name = "Miril::Filter::" . $cfg->filter; | |||||||||
| 82 | 0 | load $filter_name; | |||||||||
| 83 | 0 | $self->{filter} = $filter_name->new($cfg); | |||||||||
| 84 | 0 | ▶ | } catch { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 85 | 0 | Miril::Exception->throw( | |||||||||
| 86 | errorvar => $_, | ||||||||||
| 87 | message => 'Could not load filter', | ||||||||||
| 88 | ); | ||||||||||
| 89 | 0 | }; | |||||||||
| 90 | |||||||||||
| 91 | # load utils | ||||||||||
| 92 | 0 | $self->{util} = Miril::Util->new($cfg); | |||||||||
| 93 | |||||||||||
| 94 | 0 | return $self; | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | ### PUBLIC METHODS ### | ||||||||||
| 98 | |||||||||||
| 99 | sub warnings | ||||||||||
| 100 | 0 | ▶ | { | ||||||||
|
Subroutine
warnings: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 101 | 0 | my $self = shift; | |||||||||
| 102 | 0 | return list $self->{warnings}; | |||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | sub push_warning | ||||||||||
| 106 | 0 | ▶ | { | ||||||||
|
Subroutine
push_warning: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 107 | 0 | my $self = shift; | |||||||||
| 108 | 0 | my %params = @_; | |||||||||
| 109 | |||||||||||
| 110 | my $warning = Miril::Warning->new( | ||||||||||
| 111 | message => $params{'message'}, | ||||||||||
| 112 | 0 | errorvar => $params{'errorvar'}, | |||||||||
| 113 | ); | ||||||||||
| 114 | |||||||||||
| 115 | 0 | my @warnings_stack = $self->warnings; | |||||||||
| 116 | 0 | push @warnings_stack, $warning; | |||||||||
| 117 | 0 | $self->{warnings} = \@warnings_stack; | |||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | 1 | 1; | |||||||||
| 121 | |||||||||||
| 122 | =head1 NAME | ||||||||||
| 123 | |||||||||||
| 124 | Miril - A Static Content Management System | ||||||||||
| 125 | |||||||||||
| 126 | =head1 VERSION | ||||||||||
| 127 | |||||||||||
| 128 | Version 0.008 | ||||||||||
| 129 | |||||||||||
| 130 | =head1 WARNING | ||||||||||
| 131 | |||||||||||
| 132 | This is alfa-quality software, use with great care! | ||||||||||
| 133 | |||||||||||
| 134 | =head1 DESCRPTION | ||||||||||
| 135 | |||||||||||
| 136 | Miril is a lightweight static content management system written in perl and based on CGI::Application. It is designed to be easy to deploy and easy to use. Documentation is currently lacking, read L<Miril::Manual> to get started. | ||||||||||
| 137 | |||||||||||
| 138 | =head1 AUTHOR | ||||||||||
| 139 | |||||||||||
| 140 | Peter Shangov, C<< <pshangov at yahoo.com> >> | ||||||||||
| 141 | |||||||||||
| 142 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 143 | |||||||||||
| 144 | Copyright 2009 Peter Shangov. | ||||||||||
| 145 | |||||||||||
| 146 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 147 | under the terms of either: the GNU General Public License as published | ||||||||||
| 148 | by the Free Software Foundation; or the Artistic License. | ||||||||||
| 149 | |||||||||||
| 150 | See http://dev.perl.org/licenses/ for more information. | ||||||||||
| 151 | |||||||||||
| 152 | |||||||||||
| 153 | =cut | ||||||||||
| 154 | |||||||||||