Skip to content

Commit

Permalink
[#976 state:resolved] Updating Config Assistant to v2.1.35 (from v2.1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jayallen committed Jul 13, 2011
1 parent 5867b84 commit 1bab88f
Show file tree
Hide file tree
Showing 8 changed files with 1,274 additions and 223 deletions.
6 changes: 4 additions & 2 deletions addons/ConfigAssistant.pack/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ key: ConfigAssistant
author_link: http://openmelody.org/
author_name: "Byrne Reese, Open Melody Software Group"
description: This plugin provides a simple YAML based framework for creating plugin and theme configuration options.
version: 2.1.34
static_version: 13
version: 2.1.35
static_version: 14
schema_version: 3

applications:
Expand Down Expand Up @@ -75,6 +75,8 @@ config_types:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_folder
folder_list:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_folder_list
datetime:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_datetime

upgrade_functions:
static_copy:
Expand Down
62 changes: 43 additions & 19 deletions addons/ConfigAssistant.pack/lib/ConfigAssistant/Init.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sub init_app {
# been merged with Config Assistant, so is not needed anymore.)
my $switch = $cfg->PluginSwitch || {};
$switch->{'AutoPrefs/config.yaml'} = $switch->{'AutoPrefs'} = 0;
$cfg->PluginSwitch($switch);
$cfg->PluginSwitch( $switch );

# FIXME This needs some commentary...
init_options($app);
Expand All @@ -32,16 +32,14 @@ sub init_app {

# Static files only get copied during an upgrade.
if ( $app->id eq 'upgrade' ) {

# Because no schema version is set, the upgrade process does nothing
# during the plugin's initial install. So, in order to copy static
# files on first run, we set an initial schema version which triggers
# the framework.
my $schemas = $cfg->PluginSchemaVersion || {};
my $schemas = $cfg->PluginSchemaVersion || {};
$schemas->{ $plugin->id } ||= '0.1';

# $schemas->{$plugin->id} = '0.1'; ## UNCOMMENT TO TEST UPGRADE ##
$cfg->PluginSchemaVersion($schemas);
$cfg->PluginSchemaVersion( $schemas );
}

# TODO - This should not have to reinstall a subroutine. It should invoke
Expand Down Expand Up @@ -81,9 +79,9 @@ sub init_options {
my $option
= $r->{'template_sets'}->{$set}->{'options'}->{$opt};

# To avoid option names that may collide with other
# options in other template sets settings are derived
# by combining the name of the template set and the
# To avoid option names that may collide with other
# options in other template sets settings are derived
# by combining the name of the template set and the
# option's key.
my $optname = $set . '_' . $opt;
if ( _option_exists( $sig, $optname ) ) {
Expand All @@ -93,7 +91,7 @@ sub init_options {
else {

# if ( my $default = $option->{default} ) {
# if ( !ref($default)
# if ( !ref($default)
# && ( $default =~ /^\s*sub/
# || $default =~ /^\$/)) {
# $default
Expand All @@ -112,7 +110,7 @@ sub init_options {
$obj->{'registry'}->{'settings'}->{$optname}
= { scope => 'blog', %$option, };
}
} ## end else [ if ( _option_exists( $sig...))]
}
} ## end foreach my $opt ( keys %{ $r...})
} ## end if ( $r->{'template_sets'...})
} # end foreach (@sets)
Expand Down Expand Up @@ -186,7 +184,7 @@ sub load_tags {
class => 'system',
category => 'plugin',
level => MT::Log::ERROR(),
}
}
);
}
}
Expand Down Expand Up @@ -309,18 +307,23 @@ sub load_tags {
$_[0]->stash( 'plugin_ns',
find_theme_plugin($bset)->id );
$_[0]->stash( 'scope', 'blog' );
$_[0]->stash(
'show_children',
(
defined $option->{show_children}
? $option->{show_children}
: 1
)
);
runner( '_hdlr_field_text_group',
'ConfigAssistant::Plugin', @_ );
};
} ## end elsif ( $option->{'type'}...)
elsif ( $option->{'type'} eq 'datetime' ) {
$tags->{function}->{ $tag } = sub {
my $blog = $_[0]->stash('blog');
my $bset = $blog->template_set;
$_[0]->stash( 'field', $bset . '_' . $opt );
$_[0]->stash( 'plugin_ns',
find_theme_plugin($bset)->id );
$_[0]->stash( 'scope', 'blog' );
$_[0]->stash( 'format', $option->{format} );
runner( '_hdlr_field_datetime',
'ConfigAssistant::Plugin', @_ );
};
} ## end elsif ( $option->{'type'}...)
elsif ( $option->{'type'} eq 'category_list'
or $option->{'type'} eq 'folder_list' )
{
Expand All @@ -339,6 +342,13 @@ sub load_tags {
$_[0]->stash( 'plugin_ns',
find_theme_plugin($bset)->id );
$_[0]->stash( 'scope', 'blog' );
$_[0]->stash(
'show_children',
(
defined $option->{show_children}
? $option->{show_children}
: 1
));
runner( '_hdlr_field_category_list',
'ConfigAssistant::Plugin', @_ );
};
Expand Down Expand Up @@ -428,6 +438,20 @@ sub load_tags {
};

}
elsif ( $option->{'type'} eq 'datetime' ) {
$tags->{function}->{ $tag } = sub {
my $blog = $_[0]->stash('blog');
my $bset = $blog->template_set;
$_[0]->stash( 'field', $bset . '_' . $opt );
$_[0]->stash( 'plugin_ns',
find_theme_plugin($bset)->id );
$_[0]->stash( 'scope', 'blog' );
$_[0]->stash( 'format', $option->{format} );
runner( '_hdlr_field_datetime',
'ConfigAssistant::Plugin', @_ );
};
} ## end elsif ( $option->{'type'}...)

elsif ( $option->{'type'} eq 'category_list'
or $option->{'type'} eq 'folder_list' )
{
Expand Down
Loading

0 comments on commit 1bab88f

Please sign in to comment.