Skip to content

Commit

Permalink
[#976 state:resolved] Updating Config Assistant to v2.1.34 (from v2.1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jayallen committed Jul 11, 2011
1 parent fa102c0 commit 6457836
Show file tree
Hide file tree
Showing 11 changed files with 749 additions and 216 deletions.
10 changes: 8 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.23
static_version: 10
version: 2.1.34
static_version: 13
schema_version: 3

applications:
Expand All @@ -15,6 +15,8 @@ applications:
theme_options: $ConfigAssistant::ConfigAssistant::Plugin::theme_options
ca_config_entry: $ConfigAssistant::ConfigAssistant::Plugin::list_entry_mini
ca_select_entry: $ConfigAssistant::ConfigAssistant::Plugin::select_entry
ca_config_entry_or_page: $ConfigAssistant::ConfigAssistant::Plugin::list_entry_or_page
ca_select_entry_or_page: $ConfigAssistant::ConfigAssistant::Plugin::select_entry_or_page
ca_save_config: $ConfigAssistant::ConfigAssistant::Plugin::save_config
run_static_copy: $ConfigAssistant::ConfigAssistant::Static::manual_run
ca_prefs_apply: $ConfigAssistant::ConfigAssistant::Prefs::apply
Expand Down Expand Up @@ -57,10 +59,14 @@ config_types:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_entry
page:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_page
entry_or_page:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_entry_or_page
tagged-entry:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_tagged_entry
link-group:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_link_group
text-group:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_text_group
category:
handler: $ConfigAssistant::ConfigAssistant::Plugin::type_category
category_list:
Expand Down
40 changes: 29 additions & 11 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 @@ -301,6 +299,26 @@ sub load_tags {
'ConfigAssistant::Plugin', @_ );
};
} ## end elsif ( $option->{'type'}...)
elsif ( $option->{'type'} eq 'text-group' ) {
$tags->{block}->{ $tag . 'Items' } = 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(
'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 'category_list'
or $option->{'type'} eq 'folder_list' )
{
Expand Down
Loading

0 comments on commit 6457836

Please sign in to comment.