Changeset 873
- Timestamp:
- 12/10/06 13:00:44 (2 years ago)
- Files:
-
- branches/wheeljack/default_templates/dynamic_site_bootstrapper.tmpl (deleted)
- branches/wheeljack/lib/MT/App/CMS.pm (modified) (9 diffs)
- branches/wheeljack/lib/MT/DefaultTemplates.pm (modified) (1 diff)
- branches/wheeljack/lib/MT/L10N/ja.pm (modified) (1 diff)
- branches/wheeljack/lib/MT/Upgrade.pm (modified) (2 diffs)
- branches/wheeljack/tmpl/cms/cfg_archives.tmpl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/wheeljack/lib/MT/App/CMS.pm
r872 r873 72 72 'cfg_archives' => \&cfg_archives, 73 73 'cfg_archives_do_add' => \&cfg_archives_do_add, 74 'js_check_mtview' => \&js_check_mtview, 74 75 'cfg_prefs' => \&cfg_prefs, 75 76 'cfg_entries' => \&cfg_entries, … … 4388 4389 if ($screen eq 'cfg_archives') { 4389 4390 if (my $dcty = $app->param('dynamicity')) { 4390 $app->update_dynamicity($obj); 4391 $app->update_dynamicity($obj, 4392 $app->param('dynamic_cache') ? 1 : 0, 4393 $app->param('dynamic_conditional') ? 1 : 0); 4391 4394 } 4392 4395 $app->cfg_archives_save($obj); … … 8194 8197 $blog->custom_dynamic_templates eq 'archives'; 8195 8198 $param{dynamic_custom} = $blog->custom_dynamic_templates eq 'custom'; 8199 $param{dynamic_all} = $blog->custom_dynamic_templates eq 'all'; 8196 8200 $param{show_build_options} = $app->config('ObjectDriver') =~ m/^DBI::(postgres|sqlite|mysql)/; 8197 8201 $iter = MT::Template->load_iter({ blog_id => $blog->id }); … … 10210 10214 sub update_dynamicity { 10211 10215 my $app = shift; 10212 my ($blog ) = @_;10216 my ($blog, $cache, $conditional) = @_; 10213 10217 my $dcty = $blog->custom_dynamic_templates; 10214 10218 if ($dcty eq 'none') { … … 10227 10231 } 10228 10232 } elsif ($dcty eq 'custom') { 10233 } elsif ($dcty eq 'all') { 10234 require MT::Template; 10235 my @templates = MT::Template->load({ 10236 blog_id => $blog->id, 10237 type => [ 'index', 'archive', 'individual', 'category' ], 10238 }); 10239 for my $tmpl (@templates) { 10240 $tmpl->build_dynamic(1); 10241 $tmpl->save(); 10242 } 10229 10243 } 10230 10244 … … 10242 10256 my $contents = ""; 10243 10257 if (open(HT, $htaccess_path)) { 10244 $/ = undef;10258 local $/ = undef; 10245 10259 $contents = <HT>; 10246 10260 close HT; … … 10301 10315 }; if ($@) { print STDERR $@; } 10302 10316 10317 eval { 10318 my $mtview_path = File::Spec->catfile($blog->site_path(), "mtview.php"); 10319 my $mv_contents = ''; 10320 if (-f $mtview_path) { 10321 open(my $mv, "<$mtview_path"); 10322 while (my $line = <$mv>) { 10323 $mv_contents .= "//$line" if ($line !~ /<\?(?:php)?|\?>/); 10324 } 10325 close $mv; 10326 } 10327 my $cgi_path = MT->instance->server_path() || ""; 10328 $cgi_path =~ s!/*$!!; 10329 my $mtphp_path = File::Spec->canonpath("$cgi_path/php/mt.php"); 10330 my $blog_id = $blog->id; 10331 my $config = MT->instance->{cfg_file}; 10332 my $cache_code = $cache ? "\n \$mt->caching = true;" : ''; 10333 my $conditional_code = $conditional ? "\n \$mt->conditional = true;" : ''; 10334 my $mtview = <<MTVIEW; 10335 <?php 10336 $mv_contents 10337 include('$mtphp_path'); 10338 \$mt = new MT($blog_id, '$config');$cache_code$conditional_code 10339 \$mt->view(); 10340 ?> 10341 MTVIEW 10342 $blog->file_mgr->mkpath($blog->site_path); 10343 10344 open(my $mv, ">$mtview_path") 10345 || die "Couldn't open $mtview_path for appending"; 10346 print $mv $mtview || die "Couldn't write to $mtview_path"; 10347 close $mv; 10348 }; if ($@) { print STDERR $@; } 10349 10303 10350 my $compiled_template_path = File::Spec->catfile($blog->site_path(), 10304 10351 'templates_c'); … … 10316 10363 } 10317 10364 # FIXME: use FileMgr 10365 10366 if ($cache) { 10367 my $cache_path = File::Spec->catfile($blog->site_path(), 'cache'); 10368 $app->config('DirUmask', '0000'); 10369 $fmgr->mkpath($cache_path); 10370 $app->config('DirUmask', $saved_umask); 10371 if (-d $cache_path) { 10372 $app->add_return_arg('no_write_cachepath' => 1) 10373 unless (-w $cache_path); 10374 } else { 10375 $app->add_return_arg('no_cachepath' => 1) 10376 unless (-d $cache_path); 10377 } 10378 } 10318 10379 } 10319 10380 $app->add_return_arg(dynamic_set => 1); 10381 } 10382 10383 sub js_check_mtview { 10384 my $app = shift; 10385 $app->validate_magic or return; 10386 my $blog_id = $app->param('blog_id'); 10387 my $blog = MT::Blog->load($blog_id, { cached_ok => 1 }); 10388 return $app->errtrans('Blog (ID: [_1]) can\'t be found', $blog_id) if !defined($blog); 10389 10390 my $cache = 0; 10391 my $conditional = 0; 10392 my $mtview_path = File::Spec->catfile($blog->site_path(), "mtview.php"); 10393 if (-f $mtview_path) { 10394 open my($fh), $mtview_path; 10395 while (my $line = <$fh>) { 10396 $cache = 1 if $line =~ m/^\s*\$mt->caching\s*=\s*true;/i; 10397 $conditional = 1 if $line =~ /^\s*\$mt->conditional\s*=\s*true;/i; 10398 } 10399 close $fh; 10400 } 10401 $app->send_http_header('text/javascript'); 10402 $app->{no_print_body} = 1; 10403 $app->print("{cache: $cache, conditional: $conditional}"); 10320 10404 } 10321 10405 … … 10850 10934 $param{targz} = $@ ? 0 : 1; 10851 10935 eval "require Archive::Zip;"; 10936 eval "require IO::String;"; 10852 10937 $param{zip} = $@ ? 0 : 1; 10938 10853 10939 $app->build_page('backup_restore.tmpl', \%param); 10854 10940 } branches/wheeljack/lib/MT/DefaultTemplates.pm
r855 r873 16 16 'type' => 'index', 17 17 'rebuild_me' => '1' 18 },19 {20 'outfile' => 'mtview.php',21 'name' => 'Dynamic Site Bootstrapper',22 'type' => 'index',23 'rebuild_me' => 1,24 18 }, 25 19 { branches/wheeljack/lib/MT/L10N/ja.pm
r722 r873 2387 2387 ¥åããªãã§ãã ããã', 2388 2388 'Dynamic Publishing:' => 'åæ§ç¯ãªãã·ã§ã³: ', 2389 'Build all templates statically' => 'ãã¹ãŠãã¹ã¿ãã£ãã¯HTMLã§åºåããŸã', 2390 'Build only Archive Templates dynamically' => 'ã¢ãŒã«ã€ãã®ã¿ãã€ãããã¯ã»ãããªãã·ã³ã°ã§åºåããŸã', 2391 'Set each template\'s Build Options separately' => 'ãã³ãã¬ãŒãå¥ã«ãã¹ã¿ãã£ãã¯HTMLãããã¯ãã€ãããã¯ã»ãããªãã·ã³ã°ãéžæããŸã', 2389 'Build all templates statically' => 'ãã¹ãŠã¹ã¿ãã£ãã¯HTMLã§åºå', 2390 'Build only Archive Templates dynamically' => 'ã¢ãŒã«ã€ãã®ã¿ãã€ãããã¯ã»ãããªãã·ã³ã°', 2391 'Set each template\'s Build Options separately' => 'ãã³ãã¬ãŒãããšã«éžæ', 2392 'Build all templates dynamically' => 'ãã¹ãŠãã€ãããã¯ã»ãããªãã·ã³ã°', 2392 2393 'Archive Mapping' => 'ã¢ãŒã«ã€ãã»ãããã³ã°', 2393 2394 '_USAGE_ARCHIVE_MAPS' => 'ãã®ç»é¢ã§ã¯ãåã¢ãŒã«ã€ãã«è€æ°ã®ãã³ãã¬ãŒããèšå®ããããšãã§ããŸããäŸãã°ãæå¥ã®ã¢ãŒã«ã€ãã2ã€äœãã1ã€ã¯1ãæåã®ãšã³ããªãŒã®ãªã¹ãã«ããŠããã1ã€ã¯ãã«ã¬ã³ããŒã®ããã«ãšã³ããªãŒãèŠãããããã«ããããšãã£ãããšãã§ããŸãã', branches/wheeljack/lib/MT/Upgrade.pm
r863 r873 566 566 } 567 567 }, 568 'core_remove_dynamic_site_bootstrapper' => { 569 code => \&remove_mtviewphp, 570 version_limit => 3.303, 571 priority => 5.1, 572 }, 568 573 ); 569 574 } … … 1031 1036 } 1032 1037 1038 1; 1039 } 1040 1041 sub remove_mtviewphp { 1042 my $self = shift; 1043 my (%param) = @_; 1044 1045 require MT::Template; 1046 $self->progress(MT->translate('Removing Dynamic Site Bootstrapper index template...')); 1047 MT::Template->remove( { type => 'index', outfile => 'mtview.php' } ); 1033 1048 1; 1034 1049 } branches/wheeljack/tmpl/cms/cfg_archives.tmpl
r812 r873 2 2 3 3 <div id="cfg-archives"> 4 <script type="text/javascript" src="<TMPL_VAR NAME=STATIC_URI>js/tc/client.js"></script> 4 5 5 6 <script type="text/javascript"> … … 113 114 } 114 115 116 function toggleDynamicOptions(selection) { 117 var fld = getByID('dynamic_options_area'); 118 if (fld) { 119 if (selection.value == 'none') { 120 fld.style.display = 'none'; 121 } else { 122 fld.style.display = 'block'; 123 TC.Client.call({ 124 'load': function(c, response) { 125 var result; 126 try { 127 result = eval('('+response+')'); 128 var cache = getByID("dynamic_cache"); 129 if (cache) 130 cache.checked = result.cache; 131 var condition = getByID("dynamic_conditional"); 132 if (condition) 133 condition.checked = result.conditional; 134 var progress = getByID("progress-bar"); 135 if (progress) { 136 progress.style.display = "none"; 137 } else { 138 } 139 var area = getByID('dynamic_options'); 140 if (area) { 141 area.style.display = "block"; 142 } 143 } catch ( e ) { 144 alert(e.message); 145 } 146 }, 147 'method': 'POST', 148 'uri': '<TMPL_VAR NAME=MT_URL>', 149 'arguments': { '__mode': 'js_check_mtview', 150 'blog_id': '<TMPL_VAR NAME=BLOG_ID>', 151 'magic_token': '<TMPL_VAR NAME=MAGIC_TOKEN>'} 152 }); 153 } 154 } 155 return false; 156 } 115 157 //--> 116 158 </script> … … 158 200 <TMPL_ELSE> 159 201 202 <TMPL_IF NAME=NO_CACHE_PATH> 203 <div class="error-message"><MT_TRANS phrase="Error: Movable Type was not able to create a directory to cache your dynamic templates. You should create a directory called <code>[_1]</code> underneath your blog directory." params="cache"></div> 204 205 <TMPL_ELSE> 206 207 <TMPL_IF NAME=NO_WRITE_CACHE_PATH> 208 <div class="error-message"><MT_TRANS phrase="Error: Movable Type cannot write to the template cache directory. Please check the permissions for the directory called <code>[_1]</code> underneath your blog directory." params="cache"></div> 209 210 <TMPL_ELSE> 211 160 212 <TMPL_IF NAME=SAVED> 161 213 <div class="message"><MT_TRANS phrase="Your weblog's archive configuration has been saved."> … … 164 216 </TMPL_IF> 165 217 <br /><TMPL_INCLUDE NAME="rebuild-stub.tmpl"></div> 218 </TMPL_IF> 219 </TMPL_IF> 166 220 </TMPL_IF> 167 221 </TMPL_IF> … … 301 355 <TMPL_IF NAME=SHOW_BUILD_OPTIONS> 302 356 <div class="setting"> 303 <div class="label"><label for="dynamicity"><MT_TRANS phrase="Dynamic Publishing:"></label> <a href="#" onclick="return openManual('blog_settings_publishing', 'dynamic_publishing')" class="help">?</a></div> 304 <div class="field"> 305 <ul> 306 <li><input type="radio" id="dynamic_none" name="dynamicity" value="none"<TMPL_IF NAME=DYNAMIC_NONE> checked="on"</TMPL_IF> class="rb" /> <label for="dynamic_none"><MT_TRANS phrase="Build all templates statically"></label></li> 307 <li><input type="radio" id="dynamic_archives" name="dynamicity" value="archives"<TMPL_IF NAME=DYNAMIC_ARCHIVES> checked="checked"</TMPL_IF> class="rb" /> <label for="dynamic_archives"><MT_TRANS phrase="Build only Archive Templates dynamically"></label></li> 308 <li><input type="radio" id="dynamic_custom" name="dynamicity" value="custom"<TMPL_IF NAME=DYNAMIC_CUSTOM> checked="checked"</TMPL_IF> class="rb" /> <label for="dynamic_custom"><MT_TRANS phrase="Set each template's Build Options separately"></label></li> 309 </ul> 357 <div class="label"><label for="dynamicity"><MT_TRANS phrase="Dynamic Publishing:"></label></div> 358 <div class="field"> 359 <select name="dynamicity" id="dynamicity" onchange="return toggleDynamicOptions(this)"> 360 <option value="none"<TMPL_IF NAME=DYNAMIC_NONE> selected="selected"</TMPL_IF>><MT_TRANS phrase="Build all templates statically"></option> 361 <option value="archives"<TMPL_IF NAME=DYNAMIC_ARCHIVES> selected="selected"</TMPL_IF>><MT_TRANS phrase="Build only Archive Templates dynamically"></option> 362 <option value="custom"<TMPL_IF NAME=DYNAMIC_CUSTOM> selected="selected"</TMPL_IF>><MT_TRANS phrase="Set each template's Build Options separately"></option> 363 <option value="all"<TMPL_IF NAME=DYNAMIC_ALL> selected="selected"</TMPL_IF>><MT_TRANS phrase="Build all templates dynamically"></option> 364 </select> 365 <div id="dynamic_options_area" style="display:none;"> 366 <div id="progress-bar"><p><img src="<TMPL_VAR NAME=STATIC_URI>images/indeterminate-progress-bar.gif" alt="" height="24" width="124" /></p></div> 367 <div id="dynamic_options" style="display:none;"> 368 <p><MT_TRANS phrase="Optional Settings for Dynamic Publishing:"> <a href="#" onclick="return openManual('blog_settings_publishing', 'dynamic_publishing_options')" class="help">?</a></p> 369 <div class="field"> 370 <input type="checkbox" id="dynamic_cache" name="dynamic_cache" /><label for="dynamic_cache"><MT_TRANS phrase="Enable caching"></label> <input type="checkbox" id="dynamic_conditional" name="dynamic_conditional" /><label for="dynamic_conditional"><MT_TRANS phrase="Enable conditional retrieval"></label> 371 </div> 372 </div><a href="#" onclick="return openManual('blog_settings_publishing', 'dynamic_publishing')" class="help">?</a> 310 373 </div> 311 374 </div>
