loading templates faster

This commit is contained in:
JT Smith 2004-09-01 19:14:00 +00:00
parent fb6fab4226
commit 4b17c88300
11 changed files with 198 additions and 44 deletions

View file

@ -87,7 +87,10 @@
- RFE [ 718739 ]. USS Submission Start/End Dates (Thanks to Roy Johnson).
- bugfix [ 1008039 ] When adding javascript to description, the script is
doubled
- bugfix [ 1007970 ] Fixed: DataForm duplicate doesn't copy tabs (Harry Waye)
- Added JavaScript RawHeadTags, and StyleSheet macros.
- Changed navigation, page, macro, and rich editor templates to load more
quickly.
6.1.1
- bugfix [ 991313 ] Manage Translations doesn't work

File diff suppressed because one or more lines are too long

View file

@ -52,6 +52,7 @@ macros = a => a_account, \
H => H_homeLink, \
i => i_imageNoTags, \
I => I_imageWithTags, \
JavaScript => JavaScript, \
L => L_loginBox, \
LastModified => LastModified, \
LoginToggle => LoginToggle, \
@ -59,12 +60,14 @@ macros = a => a_account, \
PageTitle => PageTitle, \
RandomImage => RandomImage, \
RandomSnippet => RandomSnippet, \
RawHeadTags => RawHeadTags, \
RootTitle => RootTitle, \
r => r_printable, \
/ => Slash_gatewayUrl, \
Snippet => Snippet, \
Spacer => Spacer, \
SI => SI_scaledImage, \
StyleSheet => StyleSheet, \
ThumbnailLinker => ThumbnailLinker, \
Thumbnail => Thumbnail, \
u => u_companyUrl

View file

@ -19,7 +19,6 @@ use WebGUI::ErrorHandler;
use WebGUI::Grouping;
use WebGUI::HTTP;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Operation;
use WebGUI::Privilege;
use WebGUI::Session;
@ -40,7 +39,7 @@ sub _generatePage {
".quote($session{env}{HTTP_REFERER}).", ".$session{page}{pageId}.",
".quote($session{page}{title}).", ".quote($session{form}{wid}).", ".quote($session{form}{func}).")");
}
my $output = WebGUI::Macro::process(WebGUI::Style::process($content));
my $output = WebGUI::Style::process($content);
if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Grouping::isInGroup(3))) {
$output .= WebGUI::ErrorHandler::showDebug();
}

View file

@ -0,0 +1,27 @@
package WebGUI::Macro::JavaScript;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::Style;
#-------------------------------------------------------------------
sub process {
my ($script) = WebGUI::Macro::getParams(shift);
WebGUI::Style::setScript($script,{type=>'text/javascript'});
return "";
}
1;

View file

@ -0,0 +1,27 @@
package WebGUI::Macro::RawHeadTags;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::Style;
#-------------------------------------------------------------------
sub process {
my ($html) = WebGUI::Macro::getParams(shift);
WebGUI::Style::setRawHeadTags($html);
return "";
}
1;

View file

@ -0,0 +1,30 @@
package WebGUI::Macro::StyleSheet;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::Style;
#-------------------------------------------------------------------
sub process {
my ($file) = WebGUI::Macro::getParams(shift);
WebGUI::Style::setLink($file,{
type=>'text/css',
rel=>'stylesheet'
});
return "";
}
1;

View file

@ -18,6 +18,7 @@ package WebGUI::Style;
use strict;
use Tie::CPHash;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::Template;
use WebGUI::URL;
@ -36,6 +37,7 @@ This package contains utility methods for WebGUI's style system.
$template = WebGUI::Style::getTemplate();
$html = WebGUI::Style::process($content);
$html = generateAdditionalHeadTags();
setLink($url,\%params);
setMeta(\%params);
setRawHeadTags($html);
@ -47,6 +49,44 @@ These subroutines are available from this package:
=cut
#-------------------------------------------------------------------
=head2 generateAdditionalHeadTags ( )
Creates tags that were set using setLink, setMeta, setScript, and setRawHeadTags.
=cut
sub generateAdditionalHeadTags {
# generate additional raw tags
my $tags = $session{page}{head}{raw};
# generate additional link tags
foreach my $url (keys %{$session{page}{head}{link}}) {
$tags .= '<link href="'.$url.'"';
foreach my $name (keys %{$session{page}{head}{link}{$url}}) {
$tags .= ' '.$name.'="'.$session{page}{head}{link}{$url}{$name}.'"';
}
$tags .= ' />'."\n";
}
# generate additional javascript tags
foreach my $tag (@{$session{page}{head}{javascript}}) {
$tags .= '<script';
foreach my $name (keys %{$tag}) {
$tags .= ' '.$name.'="'.$tag->{$name}.'"';
}
$tags .= '></script>'."\n";
}
# generate additional meta tags
foreach my $tag (@{$session{page}{head}{meta}}) {
$tags .= '<meta';
foreach my $name (keys %{$tag}) {
$tags .= ' '.$name.'="'.$tag->{$name}.'"';
}
$tags .= ' />'."\n";
}
delete $session{page}{head};
return $tags;
}
#-------------------------------------------------------------------
@ -110,7 +150,6 @@ sub process {
<meta http-equiv="Content-Type" content="text/html; charset='.WebGUI::International::getLanguage($session{page}{languageId},"charset").'" />
<link rel="icon" href="'.$session{setting}{siteicon}.'" type="image/'.$type.'" />
<link rel="SHORTCUT ICON" href="'.$session{setting}{favicon}.'" />
'.$session{page}{head}{raw}.'
<script>
function getWebguiProperty (propName) {
var props = new Array();
@ -120,30 +159,6 @@ sub process {
}
</script>
';
# generate additional link tags
foreach my $url (keys %{$session{page}{head}{link}}) {
$var{'head.tags'} .= '<link href="'.$url.'"';
foreach my $name (keys %{$session{page}{head}{link}{$url}}) {
$var{'head.tags'} .= ' '.$name.'="'.$session{page}{head}{link}{$url}{$name}.'"';
}
$var{'head.tags'} .= ' />'."\n";
}
# generate additional javascript tags
foreach my $tag (@{$session{page}{head}{javascript}}) {
$var{'head.tags'} .= '<script';
foreach my $name (keys %{$tag}) {
$var{'head.tags'} .= ' '.$name.'="'.$tag->{$name}.'"';
}
$var{'head.tags'} .= '></script>'."\n";
}
# generate additional meta tags
foreach my $tag (@{$session{page}{head}{meta}}) {
$var{'head.tags'} .= '<meta';
foreach my $name (keys %{$tag}) {
$var{'head.tags'} .= ' '.$name.'="'.$tag->{$name}.'"';
}
$var{'head.tags'} .= ' />'."\n";
}
if ($session{var}{adminOn}) {
# This "triple incantation" panders to the delicate tastes of various browsers for reliable cache suppression.
$var{'head.tags'} .= '
@ -152,7 +167,14 @@ sub process {
<meta http-equiv="Expires" content="0" />
';
}
return WebGUI::Template::process($templateId,"style",\%var);
$var{'head.tags'} .= generateAdditionalHeadTags();
$var{'head.tags'} .= "\n<!-- macro head tags -->\n";
my $output = WebGUI::Template::process($templateId,"style",\%var);
$output = WebGUI::Macro::process($output);
my $macroHeadTags = generateAdditionalHeadTags();
$macroHeadTags = WebGUI::Macro::process($macroHeadTags);
$output =~ s/\<\!-- macro head tags --\>/$macroHeadTags/;
return $output;
}

View file

@ -116,16 +116,30 @@ sub _createTabInit {
#-------------------------------------------------------------------
sub duplicate {
my ($w, %data, $sth);
tie %data, 'Tie::CPHash';
$w = $_[0]->SUPER::duplicate($_[1]);
$w = WebGUI::Wobject::DataForm->new({wobjectId=>$w,namespace=>$_[0]->get("namespace")});
$sth = WebGUI::SQL->read("select * from DataForm_field where wobjectId=".quote($_[0]->get("wobjectId")));
while (%data = $sth->hash) {
$data{DataForm_fieldId} = "new";
$w->setCollateral("DataForm_field","DataForm_fieldId",\%data);
}
$sth->finish;
my ($w, %dataField, %dataTab, $sthField, $sthTab, $newTabId);
tie %dataTab, 'Tie::CPHash';
tie %dataField, 'Tie::CPHash';
$w = $_[0]->SUPER::duplicate($_[1]);
$w = WebGUI::Wobject::DataForm->new({wobjectId=>$w,namespace=>$_[0]->get("namespace")});
$sthTab = WebGUI::SQL->read("select * from DataForm_tab where wobjectId=".$_[0]->get("wobjectId"));
while (%dataTab = $sthTab->hash) {
$sthField = WebGUI::SQL->read("select * from DataForm_field where wobjectId=".$_[0]->get("wobjectId")." AND DataForm_tabId=".$dataTab{DataForm_tabId});
$dataTab{DataForm_tabId} = "new";
$newTabId = $w->setCollateral("DataForm_tab","DataForm_tabId",\%dataTab);
while (%dataField = $sthField->hash) {
$dataField{DataForm_fieldId} = "new";
$dataField{DataForm_tabId} = $newTabId;
$w->setCollateral("DataForm_field","DataForm_fieldId",\%dataField);
}
$sthField->finish;
}
$sthField = WebGUI::SQL->read("select * from DataForm_field where wobjectId=".$_[0]->get("wobjectId")." AND DataForm_tabId=0");
while (%dataField = $sthField->hash) {
$dataField{DataForm_fieldId} = "new";
$w->setCollateral("DataForm_field","DataForm_fieldId",\%dataField);
}
$sthField->finish;
$sthTab->finish;
}
#-------------------------------------------------------------------

View file

@ -169,6 +169,10 @@ The email address for your company specified in the settings by your Administrat
Returns the path to the WebGUI "extras" folder, which contains things like WebGUI icons.
<p>
<b>&#94;JavaScript();</b><br>
This macro allows you to set a javascript in the head section of the page. Just pass in the URL to the javascript file.
<p>
<b>&#94;LastModified; or &#94;LastModified();</b><br>
Displays the date that the current page was last modified based upon the wobjects on the page. The date is defaultly displayed based upon the user's date preferences. Optionally, it can take two parameters. The first is text to display before the date. The second is a date format string (see the D (date) macro for details.
<p>
@ -215,20 +219,27 @@ The translated label for the printable link, or the text that you supply to the
Returns the title of the root of the current page. For instance, the main root in WebGUI is the "Home" page. Many advanced sites have many roots and thus need a way to display to the user which root they are in.
<p>
<b>&#94;u; - Company URL</b><br>
The URL for your company specified in the settings by your Administrator.
<b>&#94;StyleSheet();</b><br>
This macro allows you to set a cascading style sheet in the head section of the page. Just pass in the URL to the CSS file.
<p>
<b>&#94;Spacer();</b><br>
Create a spacer in your layout. Great for creating blocks of color with divs and tables. It takes two parameters, width and height.
<p>
<i>Example:</i> &#94;Spacer("100","50");
<p>
<b>&#94;RawHeadTags();</b><br>
This macro allows you to set some arbitrary tags in the head section of the page. Just pass in the text.
<p>
<b>&#94;u; - Company URL</b><br>
The URL for your company specified in the settings by your Administrator.
<p>
|,
lastUpdated => 1078243435
lastUpdated => 1094053549
},
'634' => {

4
www/extras/textFix.js Normal file
View file

@ -0,0 +1,4 @@
function fixChars(element) {
element.value = element.value.replace(/-/mg,"-");
}