Skip to content

Commit

Permalink
abstracted out plugin_static_web/file_path into utility functions so …
Browse files Browse the repository at this point in the history
…that other plugins may make use of them
  • Loading branch information
byrnereese committed Nov 25, 2010
1 parent 96165f6 commit 80c065e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ExtUtils::MakeMaker;

use YAML::Any qw(LoadFile);
my $file = "addons/ConfigAssistant.plugin/config.yaml";
my $file = "addons/ConfigAssistant.pack/config.yaml";
my $version = LoadFile($file)->{version} ||
die "No version found in $file";

Expand Down
2 changes: 1 addition & 1 deletion addons/ConfigAssistant.pack/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.9
version: 2.1.10
static_version: 4
schema_version: 2

Expand Down
11 changes: 3 additions & 8 deletions addons/ConfigAssistant.pack/lib/ConfigAssistant/Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use MT::Util
ts2epoch format_ts encode_html decode_html dirify );
use ConfigAssistant::Util
qw( find_theme_plugin find_template_def find_option_def
find_option_plugin process_file_upload );
find_option_plugin process_file_upload plugin_static_web_path );
use JSON;
# use MT::Log::Log4perl qw( l4mtdump ); use Log::Log4perl qw( :resurrect );
our $logger;
Expand All @@ -29,10 +29,7 @@ sub tag_plugin_static_web_path {
);
}
elsif ( $obj->registry('static_version') ) {
my $url = MT->instance->static_path;
$url .= '/' unless $url =~ m!/$!;
$url .= 'support/plugins/' . $obj->id . '/';
return $url;
return plugin_static_web_path($obj);
}
else {

Expand Down Expand Up @@ -66,9 +63,7 @@ sub tag_plugin_static_file_path {
);
}
elsif ( $obj->registry('static_version') ) {
return
File::Spec->catdir( MT->instance->static_file_path,
'support', 'plugins', $obj->id );
return plugin_static_file_path($obj);
}
else {
return
Expand Down
16 changes: 16 additions & 0 deletions addons/ConfigAssistant.pack/lib/ConfigAssistant/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use base 'Exporter';
our @EXPORT_OK
= qw( find_theme_plugin find_template_def find_option_def
find_option_plugin process_file_upload
plugin_static_web_path plugin_static_file_path
ERROR SUCCESS OVERWRITE NO_UPLOAD );

use MT::Util qw( encode_url );
Expand All @@ -15,6 +16,21 @@ sub SUCCESS () {1}
sub OVERWRITE () {2}
sub NO_UPLOAD () {3}

sub plugin_static_web_path {
my ($plugin) = @_;
my $url = MT->instance->static_path;
$url .= '/' unless $url =~ m!/$!;
$url .= 'support/plugins/' . $plugin->id . '/';
return $url;
}

sub plugin_static_file_path {
my ($plugin) = @_;
return File::Spec->catdir( MT->instance->static_file_path,
'support', 'plugins', $plugin->id );

}

sub process_file_upload {
my $app = shift;
my ( $param_name, $scope, $extra_path, %upload_param ) = @_;
Expand Down

0 comments on commit 80c065e

Please sign in to comment.