1 package Newslash::Plugin::DefaultConfig;
2 use Mojo::Base 'Mojolicious::Plugin';
5 hypnotoad => { listen => [ 'http://*:80',
6 'https://*:443?cert=/etc/letsencrypt/live/example.com/cert.pem&key=/etc/letsencrypt/live/example.com/privkey.pem'
8 pid_file => '/var/run/newslash/newslash.pid',
11 Site => { admin_email => 'admin@example.com',
14 base_url => "https://example.com",
15 description => "this is newslash",
19 topic_icon_base_url => "/img/topic_icon",
22 Log => { system_log => { mode => "console",
23 local_file => "/var/log/newslash/newslash.log",
29 Search => { item_per_page => 10,
30 searchd_host => "127.0.0.1",
36 Polls => { TTL => 120,
38 vote_cooling_seconds => 300,
41 Profiler => { profiler => "nytprof",
44 FeedFetcher => { fetch_timeout => 5,
49 System => { secret_key => "<SECRET_KEY>",
50 session_store => "kvs",
56 Repository => {path => "/var/newslash/repository" },
58 Analytics => { tag => "" },
60 Story => { title_max_byte => 100,
61 submission_karma_bonus => 3,
64 IndexPage => { story_per_page => 10, },
66 Timeline => { popular_period => { hours => 6 },
70 Database => { host => "db",
73 password => "PASSWORD"
76 KeyValueStore => { type => "redis",
77 host => "localhost:6379"
80 Legacy => { memcached => "sd-master:11211" },
82 Editor => { allowed_tags => { b => [],
96 blockquote => ["title", "cite"],
107 Comments => { allowed_tags => { a => ["href"],
115 my ($self, $app, $conf) = @_;
117 for my $sect_name (keys %$defaults) {
118 my $section = $defaults->{$sect_name};
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};
137 Newslash::Plugin::DefaultConfig - Assign default value to configuration values
142 $app->plugin('Newslash::Plugin::DefaultConfig');
146 L<Newslash::Plugin::DefaultConfig> assing configuration values to $app->config.
152 $plugin->register(Mojolicious->new);
154 Register DefaultConfig in L<Mojolicious> application.
158 L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.