Skip to content

Commit

Permalink
[#343 state:resolved] Added support for autodirifcation of assets and…
Browse files Browse the repository at this point in the history
… two config directives to control the behavior.
  • Loading branch information
MikeThomsen committed Nov 25, 2010
1 parent c133564 commit a56c737
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/MT/CMS/Asset.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,12 @@ sub _upload_file {
my $basename = $q->param('file') || $q->param('fname');
$basename =~ s!\\!/!g; ## Change backslashes to forward slashes
$basename =~ s!^.*/!!; ## Get rid of full directory paths
if (MT->config->EnableAssetAutoDirify) {
my $delimiter = MT->config->AssetAutoDirifyDelimiter;
my (@parts) = ($basename =~ m/([\w\W]+)(\.[\w]+)/g);
use MT::Util;
$basename = scalar(@parts) == 2 ? MT::Util::dirify($parts[0], $delimiter) . $parts[1] : MT::Util::dirify($basename, $delimiter);
}
if ( $basename =~ m!\.\.|\0|\|! ) {
return
start_upload( $app, %param,
Expand Down
2 changes: 2 additions & 0 deletions lib/MT/Core.pm
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ BEGIN {
'PluginPath' =>
{ default => 'plugins', path => 1, type => 'ARRAY', },
'EnableArchivePaths' => { default => 0, },
'EnableAssetAutoDirify' => { default => 1 },
'AssetAutoDirifyDelimiter' => { default => '-' },
'SearchTemplatePath' =>
{ default => 'search_templates', path => 1, },
'ObjectDriver' => undef,
Expand Down

0 comments on commit a56c737

Please sign in to comment.