[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]
New WML features for gif generation (patch)
- From: Thomas Akin <nospam@thanx>
- Date: Wed, 20 Oct 1999 16:57:13 -0400
Name: wml174.imgdir.patch
WML Version: 1.7.4
Patch Author: Thomas Akin
Applying the Patch:
1) copy the patch to your wml-1.7.4 directory
2) delete everything up to and including the line
------- <cut here> -------------------
3) run 'patch -b -p1 < patchfilename'
where "patchfilename" is the name of the patch file.
Function:
This patch allows you to easily designate a new location where
images generated by des::gfont, des::imgbg, des::imgdot, and
std::logo to be created. This is done by
- adding a "dir" attribute to the above features
- adding feature specific wml variables:
GFONT_DIR
IMGBG_DIR
IMDOT_DIR
LOGO_DIR
- adding a "IMGDIR" variable which redirects all generated
gifs to the defined location.
Why:
Again, because I needed it :)
I tend to be a fairly organized person and having gifs
generated directly into my working directory grated on my
nerves... For I while I played around with the base options to
get my gifs generated neatly in their own directory, but doing
this broke the nice filename.feature.gif naming convention.
If I put the following line in home.wml
<imgdot base="images">
a gif was created called "images/.imgdot-1x1-trans.gif". We
have lost our per file uniqueness. I then started using
<imgdot base="images/home">
which created the gif with the right name, but now I have to
specify a base name for every gif that is created. I have lost
the automatic naming feature. Dealing with this gets
especially annoying when using templates...
So... My sense of order required an elegant way to redirect
newly created gifs into a separate location while retaining
the automatic naming features...
Enter the "dir" attribute. This patch adds a "dir" attribute
to the features provided by these include files:
des::gfont
des::imgbg
des::imgdot
std::logo
which allows you to specify a separate directory to place
generated gifs. For the home.wml example above you can simply
use
<imgdot dir="images">
and the gif will be generated as
"images/home.imgdot-1x1-trans.gif".
For consistency and to avoid having to specify the dir
attribute every time you render a gif this patch also adds the
wml variables
GFONT_DIR
BGIMG_DIR
IMGDOT_DIR
LOGO_DIR
which you use just like any other wml variable:
wml -DIMGDOT_DIR~images home.wml
this example causing any imgdot gifs generated to be created
in the "images" directory.
Lastly, generally when you redirect gifs generated by wml you
want them sent the same directory. To avoid having to set all
four variables to the same setting, the wml variable "IMGDIR"
was added to direct all generated gifs into the specified
directory.
To generate a site with all gifs generated in the "images"
directory you can now simply use
wmk -DIMGDIR~images
Precedence:
Here is the precedence of these additions
1) uses the "dir" attribute if specified
2) uses the feature specific wml variable if specified
ie. GFONT_DIR
BGIMG_DIR
IMGDOT_DIR
LOGO_DIR
3) uses the IMGDIR variable if specified
4) if none of the above are set it uses the default behavior
That's it.... Let me know if you find this useful or have any
questions... Denis, again, any chance of these features making it into
the next release? I've notice some past discussions on the mailing
list asking about this feature so I think It would be put to good
use...
Thanks,
Thomas
---------------------------------------------------------------
Thomas Akin Kennesaw State University
Networking Instructor Continuing Education
CNX, CSA, ICS 1000 Chastain Road
takin@kennesaw.edu Kennesaw, GA 30144-5591
---------------------------------------------------------------
------- <cut here> -------------------
Index: wml-1.7.4/wml_include/des/gfont.src
*** wml-1.7.4/wml_include/des/gfont.src Tue Sep 21 09:37:55 1999
--- wml-1.7.4.1/wml_include/des/gfont.src Wed Oct 20 14:56:03 1999
***************
*** 17,20 ****
--- 17,21 ----
<define-container gfont whitespace=delete>
<preserve base>
+ <preserve dir>
<preserve color>
<preserve bgcolor>
***************
*** 33,40 ****
--- 34,45 ----
<match <get-var WML_SRC_FILENAME>
"\\.[a-zA-Z0-9]+$" action=delete>>>
+ <defvar dir
+ <or <get-var GFONT_DIR>
+ <get-var IMGDIR>>>
<:
{
# import attributes to ePerl
my $base = "<get-var base>";
+ my $dir = "<get-var dir>";
my $color = "<get-var color>";
my $bgcolor = "<get-var bgcolor>";
***************
*** 51,54 ****
--- 56,69 ----
my $str = q|%body|;
+ # Deal with dir attribute
+ if ($dir ne '') {
+ $dir =~ s/\/$//;
+ if (! -d $dir) {
+ use File::Path;
+ mkpath("$dir", 0, 0755);
+ }
+ $base = $dir . "/" . $base;
+ }
+
# create the output filename
if ($base ne '') {
***************
*** 137,140 ****
--- 152,156 ----
<restore bgcolor>
<restore color>
+ <restore dir>
<restore base>
</define-container>
Index: wml-1.7.4/wml_include/des/imgbg.src
*** wml-1.7.4/wml_include/des/imgbg.src Mon Sep 20 09:12:33 1999
--- wml-1.7.4.1/wml_include/des/imgbg.src Wed Oct 20 14:56:22 1999
***************
*** 85,88 ****
--- 85,89 ----
<define-tag imgbg whitespace=delete>
<preserve base>
+ <preserve dir>
<preserve direction>
<preserve content>
***************
*** 92,95 ****
--- 93,100 ----
<match <get-var WML_SRC_FILENAME>
"\\.[a-zA-Z0-9]+$" action=delete>>>
+ <defvar dir
+ <or <get-var BGIMG_DIR>
+ <get-var IMGDIR>>>
+
<:
# import attributes to ePerl
***************
*** 97,102 ****
--- 102,116 ----
$direction = qq|<get-var direction>|;
$content = qq|<get-var content>|;
+ $dir = qq|<get-var dir>|;
# determine parameter values
+ if ($dir ne '') {
+ $dir =~ s/\/$//;
+ if (! -d $dir) {
+ use File::Path;
+ mkpath("$dir", 0, 0755);
+ }
+ $base = $dir . "/" . $base;
+ }
if ($base ne '') {
$base .= '/' if (-d $base);
***************
*** 113,116 ****
--- 127,131 ----
<restore content>
<restore direction>
+ <restore dir>
<restore base>
</define-tag>
Index: wml-1.7.4/wml_include/des/imgdot.src
*** wml-1.7.4/wml_include/des/imgdot.src Mon Sep 20 09:12:33 1999
--- wml-1.7.4.1/wml_include/des/imgdot.src Wed Oct 20 13:45:46 1999
***************
*** 37,40 ****
--- 37,41 ----
<define-tag imgdot whitespace=delete>
<preserve base>
+ <preserve dir>
<preserve width>
<preserve height>
***************
*** 48,54 ****
--- 49,59 ----
<match <get-var WML_SRC_FILENAME>
"\\.[a-zA-Z0-9]+$" action=delete>>>
+ <defvar dir
+ <or <get-var IMGDOT_DIR>
+ <get-var IMGDIR>>>
<:
# import attributes to ePerl
$base = qq|<get-var base>|;
+ $dir = qq|<get-var dir>|;
$width = qq|<get-var width>|;
$height = qq|<get-var height>|;
***************
*** 73,76 ****
--- 78,91 ----
$x = ($noscale ? $width : 1);
$y = ($noscale ? $height : 1);
+
+ # Deal with dir attribute
+ if ($dir ne '') {
+ $dir =~ s/\/$//;
+ if (! -d $dir) {
+ use File::Path;
+ mkpath("$dir", 0, 0775);
+ }
+ $base = $dir . "/" . $base;
+ }
# create the actual GIF image file
Index: wml-1.7.4/wml_include/std/logo.src
*** wml-1.7.4/wml_include/std/logo.src Tue Sep 28 05:27:43 1999
--- wml-1.7.4.1/wml_include/std/logo.src Wed Oct 20 14:56:39 1999
***************
*** 12,15 ****
--- 12,16 ----
<preserve name>
<preserve base>
+ <preserve dir>
<preserve file>
<preserve target>
***************
*** 20,26 ****
--- 21,31 ----
<match <get-var WML_SRC_FILENAME>
"\\.[a-zA-Z0-9]+$" action=delete>>>
+ <defvar dir
+ <or <get-var LOGO_DIR>
+ <get-var IMGDIR>>>
<:
my $name = "<get-var name>";
my $base = "<get-var base>";
+ my $dir = "<get-var dir>";
my $file = "<get-var file>";
my $target = "<get-var target>";
***************
*** 35,38 ****
--- 40,53 ----
}
+ # deal with dir attribute
+ if ($dir ne '') {
+ $dir =~ s/\/$//;
+ if (! -d $dir) {
+ use File::Path;
+ mkpath("$dir", 0, 0755);
+ }
+ $base = $dir . "/" . $base;
+ }
+
# create the output filename
if ($file eq '') {
***************
*** 73,76 ****
--- 88,92 ----
<restore file>
<restore base>
+ <restore dir>
<restore name>
</define-tag>
______________________________________________________________________
Website META Language (WML) www.engelschall.com/sw/wml/
Official Support Mailing List sw-wml@engelschall.com
Automated List Manager majordomo@engelschall.com