OSDN Git Service

Plugin::DefaultConfig: remove unused config value
[newslash/newslash.git] / src / newslash_web / lib / Newslash / Plugin / DefaultConfig.pm
1 package Newslash::Plugin::DefaultConfig;
2 use Mojo::Base 'Mojolicious::Plugin';
3
4 my $defaults = {
5                 hypnotoad => { listen => [ 'http://*:80',
6                                            'https://*:443?cert=/etc/letsencrypt/live/example.com/cert.pem&key=/etc/letsencrypt/live/example.com/privkey.pem'
7                                          ],
8                                pid_file =>  '/var/run/newslash/newslash.pid',
9                              },
10
11                 Site => { admin_email => 'admin@example.com',
12                           name => "newslash",
13                           root => "/",
14                           base_url => "https://example.com",
15                           description => "this is newslash",
16                           img_path => "/img",
17                           js_path => "/js",
18                           css_path => "/css",
19                           topic_icon_base_url => "/img/topic_icon",
20                         },
21
22                 Log => { system_log => { mode => "console",
23                                          local_file => "/var/log/newslash/newslash.log",
24                                          level => "debug",
25                                        },
26                          backtrace => 0,
27                        },
28
29                 Search => { item_per_page => 10,
30                             searchd_host => "127.0.0.1",
31                             searchd_port => 6000,
32                             connect_timeout => 2,
33                             request_timeout => 5,
34                           },
35
36                 Polls => { TTL => 120,
37                            TTL_unit => "days",
38                            vote_cooling_seconds => 300,
39                          },
40
41                 Profiler => { profiler => "nytprof",
42                               enable => 0 },
43
44                 FeedFetcher => { fetch_timeout => 5,
45                                  http_proxy => "",
46                                  https_proxy => "",
47                                },
48
49                 System => { secret_key => "<SECRET_KEY>",
50                             session_store => "kvs",
51                             salt => '',
52                             readonly => 0,
53                             static_dir => [],
54                           },
55
56                 Repository => {path => "/var/newslash/repository" },
57
58                 Analytics => { tag => "" },
59
60                 Story => { title_max_byte => 100,
61                            submission_karma_bonus => 3,
62                          },
63
64                 IndexPage => { story_per_page => 10, },
65
66                 Timeline => { popular_period => { hours => 6 },
67                               item_per_page => 20,
68                             },
69
70                 Database => { host => "db",
71                               name => "newslash",
72                               user => "newslash",
73                               password => "PASSWORD"
74                             },
75
76                 KeyValueStore => { type => "redis",
77                                    host => "localhost:6379"
78                                  },
79
80                 Legacy => { memcached => "sd-master:11211" },
81
82                 Editor => { allowed_tags => { b =>  [],
83                                               i =>  [],
84                                               p =>  [],
85                                               br => [],
86                                               a =>  ["href"],
87                                               ol => ["start"],
88                                               ul => [],
89                                               li => [],
90                                               dl => [],
91                                               dt => [],
92                                               dd => [],
93                                               em => [],
94                                               strong => [],
95                                               tt => [],
96                                               blockquote => ["title", "cite"],
97                                               div => [],
98                                               ecode => [],
99                                               del => [],
100                                               ins => [],
101                                               sub => [],
102                                               sup => [],
103                                               quote => [],
104                                               strike => [],
105                                             },
106                           },
107                 Comments => { allowed_tags => { a => ["href"],
108                                                 blockquote => [],
109                                                 i => [],
110                                                 strong => [] },
111                             },
112                };
113
114 sub register {
115     my ($self, $app, $conf) = @_;
116
117     for my $sect_name (keys %$defaults) {
118         my $section = $defaults->{$sect_name};
119         next if !$section;
120         $app->config($sect_name, {}) if !$app->config->{$sect_name};
121         my $cfg = $app->config->{$sect_name};
122         for my $k (keys %$section) {
123             if (!defined $cfg->{$k}) {
124                 $cfg->{$k} = $section->{$k};
125             }
126         }
127     }
128 }
129
130
131 1;
132
133 =encoding utf8
134
135 =head1 NAME
136
137 Newslash::Plugin::DefaultConfig - Assign default value to configuration values
138
139 =head1 SYNOPSIS
140
141   # Mojolicious
142   $app->plugin('Newslash::Plugin::DefaultConfig');
143
144 =head1 DESCRIPTION
145
146 L<Newslash::Plugin::DefaultConfig> assing configuration values to $app->config.
147
148 =head1 METHODS
149
150 =head2 register
151
152   $plugin->register(Mojolicious->new);
153
154 Register DefaultConfig in L<Mojolicious> application.
155
156 =head1 SEE ALSO
157
158 L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.
159
160 =cut