File Coverage: lib/Yukki/Web/Settings.pm

# File Coverage

File: | lib/Yukki/Web/Settings.pm
Coverage: | 100.0%

line | stmt | bran | cond | sub | pod | time | code
--- | --- | --- | --- | --- | --- | --- | ---
1 |  |  |  |  |  |  | package Yukki::Web::Settings;
2 |
3 | 1 1 |  |  | 1 |  | 7 2 | use v5.24;
4 | 1 1 1 |  |  | 1 |  | 3 1 5 | use utf8;
5 | 1 1 1 |  |  | 1 |  | 9 2 2 | use Moo;
6 |
7 |  |  |  |  |  |  | extends 'Yukki::Settings';
8 |
9 | 1 1 1 |  |  | 1 |  | 177 1 5 | use Types::Path::Tiny qw( Path );
10 | 1 1 1 |  |  | 1 |  | 225 2 2 | use Types::Standard qw( ArrayRef HashRef Str );
11 | 1 1 1 |  |  | 1 |  | 553 1 4 | use Yukki::Types qw( BaseURL PluginConfig );
12 |
13 | 1 1 1 |  |  | 1 |  | 340 2 3 | use namespace::clean;
14 |
15 |  |  |  |  |  |  | # ABSTRACT: provides structure and validation to web settings in yukki.conf
16 |
17 - 27 |  |
    =head1 DESCRIPTION

    L<Yukki::Web> needs a few additional settings.

    =head1 ATTRIBUTES

    =head2 template_path

    THis is the folder where Yukki will find templates under the C<root>. The default is F<root/template>.

    =cut
28 |
29 |  |  |  |  |  |  | has template_path => (
30 |  |  |  |  |  |  | is => 'ro',
31 |  |  |  |  |  |  | isa => Path,
32 |  |  |  |  |  |  | required => 1,
33 |  |  |  |  |  |  | coerce => 1,
34 |  |  |  |  |  |  | default => 'root/template',
35 |  |  |  |  |  |  | );
36 |
37 - 41 |  |
    =head2 static_path

    This is the folder where Yukki will find the static files to serve for your application.

    =cut
42 |
43 |  |  |  |  |  |  | has static_path => (
44 |  |  |  |  |  |  | is => 'ro',
45 |  |  |  |  |  |  | isa => Path,
46 |  |  |  |  |  |  | required => 1,
47 |  |  |  |  |  |  | coerce => 1,
48 |  |  |  |  |  |  | default => 'root',
49 |  |  |  |  |  |  | );
50 |
51 - 57 |  |
    =head2 base_url

    This configures the L<Yukki::Web::Context/base_url> attribute. It is either an absolute URL or the words C<SCRIPT_NAME> or C<REWRITE>. See L<Yukki::Web::Context/base_url> for more information.

    The default is C<SCRIPT_NAME>.

    =cut
58 |
59 |  |  |  |  |  |  | has base_url => (
60 |  |  |  |  |  |  | is => 'ro',
61 |  |  |  |  |  |  | isa => BaseURL,
62 |  |  |  |  |  |  | required => 1,
63 |  |  |  |  |  |  | coerce => 1,
64 |  |  |  |  |  |  | default => 'SCRIPT_NAME',
65 |  |  |  |  |  |  | );
66 |
67 - 92 |  |
    =head2 scripts

    =head2 styles

    This is a list of the JavaScript and CSS files, respectively, to load into the
    shell template. If not set, the defaults are:

      scripts:
          - script/lib/jquery/jquery.js
          - script/lib/jquery/jquery-ui.js
          - script/lib/jquery/jquery.caret.js
          - script/lib/jquery/jquery.tag-editor.js
          - script/lib/plupload/plupload.full.js
          - script/lib/sha1/sha1.js
          - script/yukki.js

      styles:
          - style/yukki.css
          - style/lib/jquery/jquery.css
          - style/lib/jquery/jquery.tag-editor.css

    As you can see, these are full paths and may be given as paths to foreign hosts.
    In order to keep Yukki working in good order, you will probaby want to include
    at least the scripts listed above.

    =cut
93 |
94 |  |  |  |  |  |  | has scripts => (
95 |  |  |  |  |  |  | is => 'ro',
96 |  |  |  |  |  |  | isa => ArrayRef[Str],
97 |  |  |  |  |  |  | required => 1,
98 |  |  |  |  |  |  | default => sub {
99 |  |  |  |  |  |  | [ qw(
100 |  |  |  |  |  |  | script/lib/jquery/jquery.js
101 |  |  |  |  |  |  | script/lib/jquery/jquery-ui.js
102 |  |  |  |  |  |  | script/lib/jquery/jquery.caret.js
103 |  |  |  |  |  |  | script/lib/jquery/jquery.tag-editor.js
104 |  |  |  |  |  |  | script/lib/plupload/plupload.full.js
105 |  |  |  |  |  |  | script/lib/sha1/sha1.js
106 |  |  |  |  |  |  | script/yukki.js
107 |  |  |  |  |  |  | ) ]
108 |  |  |  |  |  |  | },
109 |  |  |  |  |  |  | );
110 |
111 |  |  |  |  |  |  | sub all_scripts {
112 | 2 |  |  | 2 | 1 | 22 | my $self = shift;
113 | 2 |  |  |  |  | 30 | $self->scripts->@*;
114 |  |  |  |  |  |  | }
115 |
116 |  |  |  |  |  |  | has styles => (
117 |  |  |  |  |  |  | is => 'ro',
118 |  |  |  |  |  |  | isa => ArrayRef[Str],
119 |  |  |  |  |  |  | required => 1,
120 |  |  |  |  |  |  | default => sub {
121 |  |  |  |  |  |  | [ qw(
122 |  |  |  |  |  |  | style/yukki.css
123 |  |  |  |  |  |  | style/lib/jquery/jquery.css
124 |  |  |  |  |  |  | style/lib/jquery/jquery.tag-editor.css
125 |  |  |  |  |  |  | ) ]
126 |  |  |  |  |  |  | },
127 |  |  |  |  |  |  | );
128 |
129 |  |  |  |  |  |  | sub all_styles {
130 | 2 |  |  | 2 | 1 | 15 | my $self = shift;
131 | 2 |  |  |  |  | 15 | $self->styles->@*;
132 |  |  |  |  |  |  | }
133 |
134 - 146 |  |
    =head2 menu_names

    In case your templates have custom menus on them, you may need to set this. The default is:

      menu_names:
          - repository
          - user
          - page
          - page_bottom

    This will insure that those menus are empty when they should be empty.

    =cut
147 |
148 |  |  |  |  |  |  | has menu_names => (
149 |  |  |  |  |  |  | is => 'ro',
150 |  |  |  |  |  |  | isa => ArrayRef[Str],
151 |  |  |  |  |  |  | required => 1,
152 |  |  |  |  |  |  | default => sub { [ qw(
153 |  |  |  |  |  |  | repository
154 |  |  |  |  |  |  | user
155 |  |  |  |  |  |  | page
156 |  |  |  |  |  |  | page_bottom
157 |  |  |  |  |  |  | ) ] },
158 |  |  |  |  |  |  | );
159 |
160 - 180 |  |
    =head2 page_views

    This is the list of page views to provide. By default, this is

      page_views:
          default:
              label: View
              sort: 10
              template: shell.html
          slides:
              label: Slides
              sort: 11
              template: slides.html
              hide: 1
              vars:
                  "head link.local":
                      - style/slides.css
                  "head script.local":
                      - script/slides.js

    =cut
181 |
182 |  |  |  |  |  |  | has page_views => (
183 |  |  |  |  |  |  | is => 'ro',
184 |  |  |  |  |  |  | isa => HashRef[HashRef],
185 |  |  |  |  |  |  | required => 1,
186 |  |  |  |  |  |  | default => sub { +{
187 |  |  |  |  |  |  | default => {
188 |  |  |  |  |  |  | label => 'View',
189 |  |  |  |  |  |  | sort => 10,
190 |  |  |  |  |  |  | template => 'shell.html',
191 |  |  |  |  |  |  | },
192 |  |  |  |  |  |  | slides => {
193 |  |  |  |  |  |  | label => 'Slides',
194 |  |  |  |  |  |  | sort => 11,
195 |  |  |  |  |  |  | template => 'slides.html',
196 |  |  |  |  |  |  | hide => 1,
197 |  |  |  |  |  |  | vars => {
198 |  |  |  |  |  |  | "head link.local" => [ qw( style/slides.css ) ],
199 |  |  |  |  |  |  | "head script.local" => [ qw( script/slides.js ) ],
200 |  |  |  |  |  |  | },
201 |  |  |  |  |  |  | },
202 |  |  |  |  |  |  | } },
203 |  |  |  |  |  |  | );
204 |
205 - 209 |  |
    =head2 plugins

    This is the list of plugins to use. This is an array of hashes. The hashes must have a C<module> key naming the class defining the plugin. The rest of the keys will be passed to the plugin constructor.

    =cut
210 |
211 |  |  |  |  |  |  | has plugins => (
212 |  |  |  |  |  |  | is => 'ro',
213 |  |  |  |  |  |  | isa => PluginConfig,
214 |  |  |  |  |  |  | required => 1,
215 |  |  |  |  |  |  | default => sub { [
216 |  |  |  |  |  |  | { module => 'Attachment' },
217 |  |  |  |  |  |  | { module => 'YukkiText' },
218 |  |  |  |  |  |  | ] },
219 |  |  |  |  |  |  | );
220 |
221 - 227 |  |
    =head2 media_types

    This is a list of custom media types. Because media types are detected using L<LWP::MediaTypes>, you may also configured media types by putting a F<.media.types> file in the home directory of the user running Yukki.

    By default, "text/yukki" is mapped to the "yukki" file extension.

    =cut
228 |
229 |  |  |  |  |  |  | has media_types => (
230 |  |  |  |  |  |  | is => 'ro',
231 |  |  |  |  |  |  | isa => HashRef[Str|ArrayRef[Str]],
232 |  |  |  |  |  |  | required => 1,
233 |  |  |  |  |  |  | default => sub { +{
234 |  |  |  |  |  |  | 'text/yukki' => 'yukki',
235 |  |  |  |  |  |  | } },
236 |  |  |  |  |  |  | );
237 |
238 - 248 |  |
    =head1 METHODS

    =head2 all_scripts

    Convenience accessor that returns C<scripts> as a list.

    =head2 all_styles

    Convenience accessor that returns C<styles> as a list.

    =cut
249 |
250 |  |  |  |  |  |  | 1;