Changeset 1971

Show
Ignore:
Timestamp:
04/18/08 02:34:26 (4 months ago)
Author:
takayama
Message:

Fixed BugId:75137
* Keep compatibility of attribute name
* added tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-35/lib/MT/Blog.pm

    r1949 r1971  
    385385    my $path = $param->{path} || ''; 
    386386    my @path; 
    387     if ($path =~ m!^/!) { 
     387    if ($path =~ s!^/!!) { 
    388388        # absolute 
    389         @path = split /\//, $path; 
     389        @path = split q{/}, $path; 
    390390    } else { 
    391391        # relative 
    392392        push @path, MT->config('IncludesDir'); 
    393         push @path, split /\//, $path; 
     393        push @path, split q{/}, $path; 
    394394    } 
    395395    return ($filename, @path); 
  • branches/release-35/lib/MT/Template/ContextHandlers.pm

    r1958 r1971  
    23702370            $use_ssi = 0; 
    23712371        } else { 
    2372             my $extra_path = $arg->{cache_key} ? $arg->{cache_key} 
     2372            my $extra_path = ($arg->{cache_key} || $arg->{key}) ? $arg->{cache_key} || $arg->{key} 
    23732373                : $tmpl->cache_path ? $tmpl->cache_path 
    23742374                    : ''; 
     
    23872387      && ( ( $arg->{cache} && $arg->{cache} > 0 ) 
    23882388        || $arg->{cache_key} 
     2389        || $arg->{key} 
    23892390        || ( exists $arg->{ttl} ) 
    23902391        || $tmpl->use_cache ) ? 1 : 0; 
    23912392    my $cache_key = 
    2392         $arg->{cache_key} 
    2393       ? $arg->{cache_key} 
     2393        ($arg->{cache_key} || $arg->{key}) 
     2394      ? $arg->{cache_key} || $arg->{key} 
    23942395      : 'blog::' . $blog_id . '::template_' . $type . '::' . $tmpl_name; 
    23952396    my $ttl = 
  • branches/release-35/t/65-ssi.t

    r1949 r1971  
    105105    'test template included template by ssi'); 
    106106 
     107$tmpl = MT->model('template')->new; 
     108$tmpl->blog_id($blog->id); 
     109$tmpl->text(q(hi <mt:include module="Included Template" key="w" ttl="1000" ssi="1"> bye)); 
     110 
     111$ctx = MT::Template::Context->new; 
     112$ctx->{__stash}{vars}{woot} = 'terrible'; 
     113$out = $tmpl->build($ctx, {}); 
     114 
     115ok(defined $out, 'test template built'); 
     116$site_url = $blog->site_url; 
     117$site_url =~ s{ \A \w+ :// [^/]+ }{}xms; 
     118$site_url =~ s{ / \z }{}xms; 
     119like($out, qr(\Ahi <!--#include virtual="${site_url}/includes_c/w/included_template.html" --> bye\z)ms, 
     120    'test template included template by ssi using \'key\' with relative path'); 
     121 
     122 
     123$tmpl = MT->model('template')->new; 
     124$tmpl->blog_id($blog->id); 
     125$tmpl->text(q(hi <mt:include module="Included Template" ttl="1000" ssi="1"> bye)); 
     126 
     127$ctx = MT::Template::Context->new; 
     128$ctx->{__stash}{vars}{woot} = 'terrible'; 
     129$out = $tmpl->build($ctx, {}); 
     130 
     131ok(defined $out, 'test template built'); 
     132$site_url = $blog->site_url; 
     133$site_url =~ s{ \A \w+ :// [^/]+ }{}xms; 
     134$site_url =~ s{ / \z }{}xms; 
     135like($out, qr(\Ahi <!--#include virtual="${site_url}/includes_c/included_template.html" --> bye\z)ms, 
     136    'test template included template by ssi without \'key\''); 
     137 
     138 
     139$tmpl = MT->model('template')->new; 
     140$tmpl->blog_id($blog->id); 
     141$tmpl->text(q(hi <mt:include module="Included Template" cache_key="/w" ttl="1000" ssi="1"> bye)); 
     142 
     143$ctx = MT::Template::Context->new; 
     144$ctx->{__stash}{vars}{woot} = 'terrible'; 
     145$out = $tmpl->build($ctx, {}); 
     146 
     147ok(defined $out, 'test template built'); 
     148$site_url = $blog->site_url; 
     149$site_url =~ s{ \A \w+ :// [^/]+ }{}xms; 
     150$site_url =~ s{ / \z }{}xms; 
     151like($out, qr(\Ahi <!--#include virtual="${site_url}/w/included_template.html" --> bye\z)ms, 
     152    'test template included template by ssi with \'key\' absolute path'); 
     153