timed-build — save output of Interchange interpolation to named file (cache pages)
Attribute | Pos. | Req. | Default | Description |
---|---|---|---|---|
file | Yes | Cache filename. | ||
if | ||||
scan | ||||
login | ||||
auto | ||||
new | ||||
force | ||||
minutes | 60 |
Number of minutes the cache file is kept. A value of
0 means infinitely.
|
||
period | ||||
umask | ||||
interpolate | 0 | interpolate input? | ||
reparse | 1 | interpolate output? | ||
hide | 0 | Hide the tag return value? |
Interchange 5.9.0:
Source: code/SystemTag/timed_build.coretag
Lines: 16
# Copyright 2002-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: timed_build.coretag,v 1.4 2007-03-30 23:40:49 pajamian Exp $ UserTag timed-build Order file UserTag timed-build addAttr UserTag timed-build Gobble UserTag timed-build hasEndTag UserTag timed-build PosNumber 1 UserTag timed-build Version $Revision: 1.4 $ UserTag timed-build MapRoutine Vend::Interpolate::timed_build
Source: lib/Vend/Interpolate.pm
Lines: 5369
sub timed_build { my $file = shift; my $opt = shift; my $abort; if ($Vend::LockedOut) { $abort = 1; delete $opt->{new}; } elsif (defined $opt->{if}) { $abort = 1 if ! $opt->{if}; } my $saved_file; if($opt->{scan}) { $saved_file = $Vend::ScanPassed; $abort = 1 if ! $saved_file || $file =~ m:MM=:; } $opt->{login} = 1 if $opt->{auto}; my $save_scratch; if($opt->{new} and $Vend::new_session and !$Vend::Session->{logged_in}) { #::logDebug("we are new"); $save_scratch = $::Scratch; $Vend::Cookie = 1; $Vend::Session->{scratch} = { %{$Vend::Cfg->{ScratchDefault}}, mv_no_session_id \ => 1, mv_no_count => 1, mv_force_cache => 1 }; } else { return Vend::Interpolate::interpolate_html($_[0]) if $abort or ( ! $opt->{force} and ( ! $Vend::Cookie or ! $opt->{login} && $Vend::Session->{logged_in} ) ); } local ($Scratch->{mv_no_session_id}); $Scratch->{mv_no_session_id} = 1; if($opt->{auto}) { $opt->{minutes} = 60 unless defined $opt->{minutes}; my $dir = "$Vend::Cfg->{ScratchDir}/auto-timed"; unless (allowed_file($dir)) { log_file_violation($dir, 'timed_build'); return; } if(! -d $dir) { require File::Path; File::Path::mkpath($dir); } $file = "$dir/" . generate_key(@_); } my $secs; CHECKDIR: { last CHECKDIR if Vend::File::file_name_is_absolute($file); last CHECKDIR if $file and $file !~ m:/:; my $dir; if ($file) { $dir = '.'; } else { $dir = 'timed'; $file = $saved_file || $Vend::Flypart || $Global::Variable->{MV_PAGE}; #::logDebug("static=$file"); if($saved_file) { $file = $saved_file; $file =~ s:^scan/::; $file = generate_key($file); $file = "scan/$file"; } else { $saved_file = $file = ($Vend::Flypart || $Global::Variable->{MV_PAGE}); } $file .= $Vend::Cfg->{HTMLsuffix}; } $dir .= "/$1" if $file =~ s:(.*)/::; unless (allowed_file($dir)) { log_file_violation($dir, 'timed_build'); return; } if(! -d $dir) { require File::Path; File::Path::mkpath($dir); } $file = Vend::Util::catfile($dir, $file); } #::logDebug("saved=$saved_file"); #::logDebug("file=$file exists=" . -f $file); if($opt->{minutes}) { $secs = int($opt->{minutes} * 60); } elsif ($opt->{period}) { $secs = Vend::Config::time_to_seconds($opt->{period}); } $file = Vend::Util::escape_chars($file); if(! $opt->{auto} and ! allowed_file($file)) { log_file_violation($file, 'timed_build'); return undef; } if( ! -f $file or $secs && (stat(_))[9] < (time() - $secs) ) { my $out = Vend::Interpolate::interpolate_html(shift); $opt->{umask} = '22' unless defined $opt->{umask}; Vend::Util::writefile(">$file", $out, $opt ); $Vend::Session->{scratch} = $save_scratch if $save_scratch; return $out; } $Vend::Session->{scratch} = $save_scratch if $save_scratch; return Vend::Util::readfile($file); }