Skip to content

Commit

Permalink
migrate from secret to secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
jberger committed Apr 6, 2014
1 parent 9d8fecc commit 87fe40f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Build.PL
Expand Up @@ -11,7 +11,7 @@ my $builder = Module::Build->new(

requires => {
'perl' => '5.10.1',
'Mojolicious' => '4.0', # Websocket JSON handlers
'Mojolicious' => '4.63', # secrets
'Mojolicious::Plugin::Memorize' => 0,
'Mojolicious::Plugin::Humane' => '0.04',
'DBD::SQLite' => 0,
Expand Down
5 changes: 5 additions & 0 deletions Changes
@@ -1,5 +1,10 @@
Revision history for Perl module Galileo

0.032 2014-04-06
- Added 'secrets' configuration key
- Bump required Mojolicious version to 4.63
- Deprecated 'secret' configuration key

0.031 2013-11-28
- Fixed a few long-standing bugs (hrupprecht++)

Expand Down
8 changes: 4 additions & 4 deletions META.json
Expand Up @@ -4,7 +4,7 @@
"Joel Berger"
],
"dynamic_config" : 1,
"generated_by" : "Module::Build version 0.42",
"generated_by" : "Module::Build version 0.4203",
"license" : [
"perl_5"
],
Expand Down Expand Up @@ -35,7 +35,7 @@
"File::Copy::Recursive" : "0",
"File::Next" : "0",
"File::ShareDir" : "1.00",
"Mojolicious" : "4.0",
"Mojolicious" : "4.63",
"Mojolicious::Plugin::Humane" : "0.04",
"Mojolicious::Plugin::Memorize" : "0",
"SQL::Translator" : "0",
Expand All @@ -47,7 +47,7 @@
"provides" : {
"Galileo" : {
"file" : "lib/Galileo.pm",
"version" : "0.031"
"version" : "0.032"
},
"Galileo::Admin" : {
"file" : "lib/Galileo/Admin.pm"
Expand Down Expand Up @@ -102,5 +102,5 @@
"url" : "http://github.com/jberger/Galileo"
}
},
"version" : "0.031"
"version" : "0.032"
}
8 changes: 4 additions & 4 deletions META.yml
Expand Up @@ -6,7 +6,7 @@ build_requires: {}
configure_requires:
Module::Build: 0.38
dynamic_config: 1
generated_by: 'Module::Build version 0.42, CPAN::Meta::Converter version 2.132830'
generated_by: 'Module::Build version 0.4203, CPAN::Meta::Converter version 2.132830'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
Expand All @@ -18,7 +18,7 @@ no_index:
provides:
Galileo:
file: lib/Galileo.pm
version: 0.031
version: 0.032
Galileo::Admin:
file: lib/Galileo/Admin.pm
Galileo::Command::dump:
Expand Down Expand Up @@ -56,7 +56,7 @@ requires:
File::Copy::Recursive: 0
File::Next: 0
File::ShareDir: 1.00
Mojolicious: 4.0
Mojolicious: 4.63
Mojolicious::Plugin::Humane: 0.04
Mojolicious::Plugin::Memorize: 0
SQL::Translator: 0
Expand All @@ -66,4 +66,4 @@ resources:
bugtracker: http://github.com/jberger/Galileo/issues
license: http://dev.perl.org/licenses/
repository: http://github.com/jberger/Galileo
version: 0.031
version: 0.032
12 changes: 8 additions & 4 deletions lib/Galileo.pm
@@ -1,7 +1,7 @@
package Galileo;
use Mojo::Base 'Mojolicious';

our $VERSION = '0.031';
our $VERSION = '0.032';
$VERSION = eval $VERSION;

use File::Basename 'dirname';
Expand Down Expand Up @@ -48,7 +48,7 @@ sub load_config {
extra_js => [],
extra_static_paths => ['static'],
sanitize => 1,
secret => '', # default to null (unset) in case I implement an iterative config helper
secrets => [],
upload_path => 'uploads',
},
});
Expand Down Expand Up @@ -90,8 +90,12 @@ sub load_config {
$app->helper( upload_path => sub { 0 } );
}

if ( my $secret = $app->config->{secret} ) {
$app->secret( $secret );

if ( my $secrets = $app->config->{secrets} ) {
$app->secrets($secrets) if @$secrets;
} elsif ( my $secret = $app->config->{secret} ) {
warn "### 'secret' config key is deprecated, use 'secrets' instead ###\n";
$app->secrets([$secret]) if $secret;
}
}

Expand Down
19 changes: 3 additions & 16 deletions lib/Galileo/Command/setup.pm
Expand Up @@ -47,22 +47,9 @@ sub run {
my $self = shift;
my @params = sort $self->param;

{
my @config = sort keys %{ $self->app->config };

# check that all keys are represented
die "Incorrect number of configuration keys"
unless @params == @config;

for my $i (0 .. $#params) {
die "Config key mismatch $config[$i] vs $params[$i]"
unless $config[$i] eq $params[$i];
}
}

# map JSON keys to Perl data
my %params = map { $_ => scalar $self->param($_) } @params;
foreach my $key ( qw/extra_css extra_js extra_static_paths db_options/ ) {
foreach my $key ( qw/extra_css extra_js extra_static_paths secrets db_options/ ) {
$params{$key} = j($params{$key});
}

Expand Down Expand Up @@ -235,8 +222,8 @@ __DATA__
% }
%= hidden_field 'sanitize' => 0
% end
%= control_group for => 'secret', label => 'Application Secret' => begin
%= text_field 'secret', value => $config->{secret}, class => 'input-block-level'
%= control_group for => 'secrets', label => 'Application Secrets (JSON array)' => begin
%= text_field 'secrets', value => j($config->{secrets}), class => 'input-block-level'
% end
%= control_group for => 'submit-button', begin
<button class="btn" id="submit-button" type="submit">Save</button>
Expand Down

0 comments on commit 87fe40f

Please sign in to comment.