f66860 | 2000-03-02 | Martin Nilsson | |
|
e95416 | 2000-01-02 | Martin Nilsson | |
|
f66860 | 2000-03-02 | Martin Nilsson | | constant cvs_version="$Id: graphic_text.pike,v 1.209 2000/03/02 04:18:37 nilsson Exp $";
|
ebf60d | 1997-03-08 | Henrik Grubbström (Grubba) | |
|
d47cbf | 1996-12-02 | Per Hedbor | | #include <module.h>
inherit "module";
inherit "roxenlib";
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
|
654fca | 1999-10-04 | Martin Bähr | |
|
7e471e | 2000-01-05 | Martin Nilsson | | constant module_type = MODULE_PARSER;
constant module_name = "Graphics text";
constant module_doc = "Generates graphical texts.";
constant thread_safe = 1;
|
0a76aa | 1998-03-27 | David Hedbor | |
|
d47cbf | 1996-12-02 | Per Hedbor | | void create()
{
|
39af1a | 1998-08-26 | Per Hedbor | | defvar("colorparse", 1, "Parse tags for document colors", TYPE_FLAG,
"If set, parse the specified tags for document colors.");
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
|
9b9f70 | 1997-08-12 | Per Hedbor | | defvar("deflen", 300, "Default maximum text-length", TYPE_INT|VAR_MORE,
|
bfc707 | 1997-01-13 | Per Hedbor | | "The module will, per default, not try to render texts "
"longer than this. This is a safeguard for things like "
"<gh1></gh>, which would otherwise parse the"
" whole document. This can be overrided with maxlen=... in the "
"tag.");
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | defvar("ext", 0, "Append .fmt (gif, jpeg etc) to all images",
|
8b6ee5 | 1999-07-10 | Peter Bortas | | TYPE_FLAG|VAR_MORE,
|
9374e6 | 1999-05-18 | Per Hedbor | | "Append .gif, .png, .gif etc to all images made by gtext. "
"Normally this will only waste bandwidth");
|
d47cbf | 1996-12-02 | Per Hedbor | | }
|
f02c0c | 1999-12-11 | Martin Nilsson | | TAGDOCUMENTATION;
|
2e0a35 | 1999-12-09 | Martin Nilsson | | #ifdef manual
|
e59a5a | 2000-03-01 | Kenneth Johansson | | constant gtextargs=#"
<attr name=afont>
<ex>
<gtext afont>foo</gtext>
</ex>
</attr>
<attr name=alpha value=path>
Use the specified image as an alpha channel, together with the
background attribute.
<ex>
<gtext
</attr>
<attr name=background value=path>
Specifies the image to use as background.
</attr>
<attr name=bevel value=width>
Draws a bevel box.
</attr>
<attr name=bgcolor value=color>
Sets the background color. Normally taken from the normal HTML tags
in your document (Currently: body, table, tr or td).
<p>If you set the background color, it is probably best to add the
notrans attribute as well.</p>
<ex type=vert>
<gtext notrans bgcolor=pink>Pink</gtext>
<gtext notrans bgcolor=red>Red</gtext>
<gtext notrans bgcolor=%50,0,100,0>%50,0,100,0</gtext>
</ex>
</attr>
<attr name=bgturbulence value=frequency,color;frequency,color;frequency,color>
Apply a turbulence effect.
</attr>
<attr name=black>
Use a black, or heavy, version of the font, if available.
</attr>
<attr name=bold>
Use a bold version of the font, if available.
</attr>
<attr name=bshadow value=distance>
Draw a blured black drop-shadow behind the text. Using 0 as distance
does not currently place the shadow directly below the text. Using
negative values for distance is possible, but you might have to add
'spacing'.
<ex type=vert>
<gtext scale=0.8 fgcolor=darkblue quant=200 bshadow=1><gtext quant=100 bshadow=1></gtext><br>
<gtext scale=0.8 fgcolor=darkblue quant=200 bshadow=2><gtext quant=100 bshadow=2></gtext>
</ex>
</attr>
<attr name=chisel>
Make the text look like it has been cut into the background.
<ex type=vert>
<gtext bold quant=200 ypad=-40% xpad=-20% chisel talign=center
opaque=70 fgcolor=gold bevel=2 background=tiles.jpg> Chisel
opaque=70</gtext>
</ex>
</attr>
<attr name=crop>
Remove all white-space around the image
</attr>
<attr name=encoding>
</attr>
<attr name=fadein value=blur,steps,delay,initialdelay>
Generates an animated GIF file of a fade-in effect.
</attr>
<attr name=fgcolor value=color>
Sets the text color.
<ex type=vert>
<gtext fgcolor=#0080FF>#0080FF</gtext>
</ex>
</attr>
<attr name=font>
</attr>
<attr name=font_size>
</attr>
<attr name=format>
</attr>
<attr name=fs>
Apply floyd-steinberg dithering to the resulting image. Most of the
time it is much better to increase the number of colors, instead of
dithering the image, but sometimes when using very complex background
images dithering is O.K.
</attr>
<attr name=fuzz value=color>
Apply a glow effect.
<ex type=vert>
<gtext fuzz=pink>fuzz=pink</gtext>
</ex>
</attr>
<attr name=ghost value=dist,blur,color>
Apply a ghost effect. Cannot be used together with shadow or magic
coloring.
<ex type=vert>
<gtext spacing=2 crop quant=200 ghost=1,1,red>ghost=1,1,red</gtext>
<gtext spacing=2 crop quant=200 ghost=1,3,blue>ghost=1,3,blue</gtext>
<gtext spacing=2 crop bshadow=1 opaque=90 ghost=-1,1,yellow>ghost=-1,1,yellow opaque=90 bshadow=1</gtext>
</ex>
</attr>
<attr name=glow value=color>
Apply a 'glow' filter to the image. Quite a CPU eater. Looks much
better on a dark background, where a real 'glow' effect can be
achieved.
<ex type=vert>
<gtext quant=200 glow=red><gtext glow=red></gtext>
</ex>
</attr>
<attr name=italic>
Use an italic version of the font, if available.
</attr>
<attr name=light>
Use a light version of the font, if available.
</attr>
<attr name=maxlen value=number>
Sets the maximum length of the text that will be rendered into an
image, by default 300.
</attr>
<attr name=mirrortile>
Tiles the background and foreground images around x-axis and y-axis
for odd frames, creating seamless textures.
</attr>
<attr name=move value=x,y>
Moves the text relative to the upper left corner of the background
image. This will not change the size of the image.
</attr>
<attr name=narrow>
</attr>
<attr name=nfont value=fontname>
Select a font using somewhat more memonic font-names. You can get a
font-list by accessing the configuration interface.
<p>There are several modifiers available: bold, italic, black and light.
If the requested version of the font is available, it will be used to
render the text, otherwise the closest match will be used.</p>
<ex type=vert>
<gtext nfont=futura light >Light</gtext>
<gtext nfont=futura light italic>Italic</gtext>
<gtext nfont=futura >Normal</gtext>
<gtext nfont=futura italic >Italic</gtext>
<gtext nfont=futura bold >Bold</gtext>
<gtext nfont=futura bold italic >Italic</gtext>
<gtext nfont=futura black >Black</gtext>
<gtext nfont=futura black italic>Italic</gtext>
</ex>
</attr>
<attr name=notrans>
Do not make the background transparent. Useful when making 'boxes' of
color around the text.
<ex type=vert>
<gtext bgcolor=red><gtext bgcolor=red></gtext>
<gtext bgcolor=red notrans><gtext bgcolor=red notrans></gtext>
</ex>
</attr>
<attr name=nowhitespace>
</attr>
<attr name=opaque value=percentage>
Generate text with this amount of opaqueness. 100% is default.
<ex>
<gtext fgcolor=blue opaque=50>Opaque</gtext>
</ex>
</attr>
<attr name=outline>
</attr>
<attr name=pressed>
Inverts the direction of the bevel box, to make it look like a button
that is pressed down.
</attr>
<attr name=quant value=number>
Use this number of colors in the generated image. For GIF images,
fewer colors implies smaller images but also aliasing effects. It is
advisable to use powers of 2 to optimize the palette allocation.
</attr>
<attr name=rescale>
Rescale the background to fill the whole image.
</attr>
<attr name=rotate value=angle>
Rotates the image this number of degrees counter-clockwise.
</attr>
<attr name=scale value=number>
|
f66860 | 2000-03-02 | Martin Nilsson | | Sets the scale of the image. Larger than 1.0 is enlargement.
|
e59a5a | 2000-03-01 | Kenneth Johansson | | <ex type=vert>
<gtext scale=1.0><gtext scale=1.0></gtext>
<gtext scale=0.5><gtext scale=0.5></gtext>
</ex>
</attr>
<attr name=scolor value=color>
Use this color for the shadow. Used with the shadow attribute.
</attr>
<attr name=scroll value=width,steps,delay>
Generate an animated GIF image of the text scrolling.
</attr>
<attr name=shadow value=intensity,distance>
Draw a drop-shadow with the specified intensity and distance. The
intensity is specified as a percentage.
</attr>
<attr name=size value=width,height>
Set the size of the image.
</attr>
<attr name=spacing value=number>
Add space around the text.
</attr>
<attr name=talign value=left,right,center>
Adjust the alignment of the text.
</attr>
<attr name=textbelow value=color>
Place the text in a colored box.
</attr>
<attr name=textbox value=opaque,color>
Draw a box with an opaque value below the text of the specified color.
</attr>
<attr name=texture value=path>
Uses the specified images as a field texture.
</attr>
<attr name=tile>
Tiles the background and foreground images if they are smaller than
the actual image.
</attr>
<attr name=verbatim>
Allows the gtext parser to not be typographically correct.
</attr>
<attr name=xpad value=percentage>
Increases padding between characters.
</attr>
<attr name=xsize value=number>
Sets the width.
</attr>
<attr name=xspacing value=number>
Sets the horizontal spacing.
</attr>
<attr name=ypad>
</attr>
<attr name=ysize value=number>
Sets the height.
</attr>
<attr name=yspacing value=number>
Sets the vertical spacing.
</attr>";
constant tagdoc=([
"anfang":#"<desc cont></desc>"+gtextargs,
"gh":#"<desc cont></desc>"+gtextargs,
"gh1":#"<desc cont></desc>"+gtextargs,
"gh2":#"<desc cont></desc>"+gtextargs,
"gh3":#"<desc cont></desc>"+gtextargs,
"gh4":#"<desc cont></desc>"+gtextargs,
"gh5":#"<desc cont></desc>"+gtextargs,
"gh6":#"<desc cont></desc>"+gtextargs,
"gtext":#"<desc cont>
Renders a GIF image of the contents.
<p>Note: If the background and text colors are not set in the
<tag>body</tag>> tag of the page, the bg and fg attributes must be
set, otherwise the <tag>gtext</tag>> tag will only render a \"Please
reload this page\" message.</p>
</desc>
<attr name=alt value=string>
Sets the alt attribute of the generated <tag>img</tag> tag. By
default the alt attribute will be set to the contents of the
<tag>gtext</tag> tag.
<ex type=vert>
<gtext fgcolor=blue alt=\"Hello!\">Point your mouse here</gtext>
</ex>
</attr>
<attr name=border value=width,color>
Draws a border around the text of the specified width and color.
<ex type=vert>
<gtext fgcolor=blue border=1,pink>Pink border</gtext>
</ex>
</attr>
<attr name=href value=URL>
Link the image to the specified URL. The link color of the document
will be used as the default foreground rather than the foreground
color.
</attr>
<attr name=magic value=message>
Used together with the href attribute to generate a JavaScript that
will highlight the image when the mouse is moved over it. The message
is shown in the browser's status bar.
<ex type=vert>
<gtext href=http://www.roxen.com magic=HERE!>www.roxen.com</gtext>
</ex>
</attr>
<attr name=magic_attribute value=value> Same as for any
<tag>gtext</tag> attribute, except for the highlighted image.
<ex type=vert>
<gtext fgcolor=blue>Magic_attribute</gtext>
</ex>
</attr>
<attr name=magicbg value=color,path>
Same as the background attribute, except for the highlighted image.
</attr>
<attr name=noxml>
</attr>
<attr name=split>
<gtext scale=0.4 split>Make each word into a separate gif image.
Useful if you are writing a large text, and word wrap at the edges of
the display is desired. This text is an example (try resisizing your
browser window, the images should move just like normal text
would)</gtext>
<p>This will allow the browser to word-wrap the text, but will disable certain attributes like magic.</p>
<ex type=vert>
<gtext scale=0.4 split>Make each word..</gtext>
</ex>
</attr>
<attr name=submit>
Creates a submit-button for forms. Does not work together with split
or magic arguments.
</attr>",
"gtext-id":#"<desc tag></desc>
<attr name=href value=URL>
Link the image to the specified URL. The link color of the document
will be used as the default foreground rather than the foreground
color.
</attr>
<attr name=short>
</attr>",
"gtext-url":#"<desc cont></desc>
<attr name=href value=URL>
Link the image to the specified URL. The link color of the document
will be used as the default foreground rather than the foreground
color.
</attr>
<attr name=short>
</attr>",]);
|
2e0a35 | 1999-12-09 | Martin Nilsson | | #endif
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
|
9374e6 | 1999-05-18 | Per Hedbor | | roxen.ImageCache image_cache;
|
e5bad2 | 1998-02-10 | Per Hedbor | |
|
e95416 | 2000-01-02 | Martin Nilsson | | string status() {
array s=image_cache->status();
return sprintf("<b>Images in cache:</b> %d images<br>\n<b>Cache size:</b> %s",
s[0]/2, sizetostring(s[1]));
}
|
7e471e | 2000-01-05 | Martin Nilsson | | void start(int num, Configuration conf)
|
2468b2 | 1997-07-06 | Henrik Grubbström (Grubba) | | {
|
9374e6 | 1999-05-18 | Per Hedbor | | image_cache = roxen.ImageCache( "gtext", draw_callback );
|
23f8eb | 2000-02-16 | Per Hedbor | | roxen.dump( "etc/modules/GText.pmod" );
|
7e471e | 2000-01-05 | Martin Nilsson | | if(query("colorparse")) module_dependencies(conf, ({ "wiretap" }) );
|
2468b2 | 1997-07-06 | Henrik Grubbström (Grubba) | | }
|
c3655b | 1997-01-27 | Per Hedbor | |
|
b1ab8d | 1997-12-23 | Per Hedbor | | constant nbsp = iso88591[" "];
|
db46c8 | 1999-06-10 | Jonas Wallden | | constant replace_from = indices( iso88591 )+ ({"&ss;","<",">","&",});
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | constant replace_to = values( iso88591 ) + ({ nbsp, "<", ">", "&", });
|
b1ab8d | 1997-12-23 | Per Hedbor | |
#define simplify_text( from ) replace(from,replace_from,replace_to)
|
06583f | 1997-09-03 | Per Hedbor | |
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | mixed draw_callback(mapping args, string text, RequestID id)
|
20ca2b | 1998-01-26 | Per Hedbor | | {
|
f02c0c | 1999-12-11 | Martin Nilsson | | array data;
Image.Font font;
|
38569c | 1999-12-07 | Martin Nilsson | | Image.Image img;
|
9374e6 | 1999-05-18 | Per Hedbor | |
|
6a9b9d | 1999-06-25 | Per Hedbor | | if( objectp( text ) )
{
if( !args->text )
error("Failed miserably to find a text to draw. That's not"
|
8b6ee5 | 1999-07-10 | Peter Bortas | | " good.\n");
|
6a9b9d | 1999-06-25 | Per Hedbor | | id = (object)text;
text = args->text;
}
|
9374e6 | 1999-05-18 | Per Hedbor | | if(!args->verbatim)
|
ba73a2 | 1996-12-10 | Per Hedbor | | {
|
9374e6 | 1999-05-18 | Per Hedbor | | text = replace(text, nbsp, " ");
text = simplify_text( text );
string res="",nspace="",cspace="";
foreach(text/"\n", string line)
|
a5c21b | 1999-05-18 | Peter Bortas | | {
|
38569c | 1999-12-07 | Martin Nilsson | | cspace="";
nspace="";
|
9374e6 | 1999-05-18 | Per Hedbor | | foreach(line/" ", string word)
|
e8c29c | 1997-09-12 | Johan Schön | | {
|
9374e6 | 1999-05-18 | Per Hedbor | | string nonum;
if(strlen(word) &&
(nonum = replace(word,
({"1","2","3","4","5","6","7","8","9","0","."}),
({"","","","","","","","","","",""}))) == "") {
cspace=nbsp+nbsp;
if((strlen(word)-strlen(nonum)<strlen(word)/2) &&
|
38569c | 1999-12-07 | Martin Nilsson | | (upper_case(word) == word))
|
9374e6 | 1999-05-18 | Per Hedbor | | word=((word/"")*nbsp);
}
|
38569c | 1999-12-07 | Martin Nilsson | | else if(cspace!="")
cspace=" ";
|
9374e6 | 1999-05-18 | Per Hedbor | | res+=(nspace==cspace?nspace:" ")+word;
|
38569c | 1999-12-07 | Martin Nilsson | | if(cspace!="")
nspace=cspace;
else
nspace=" ";
|
1cd5eb | 1998-03-20 | Per Hedbor | | }
|
9374e6 | 1999-05-18 | Per Hedbor | | res+="\n";
|
1cd5eb | 1998-03-20 | Per Hedbor | | }
|
9374e6 | 1999-05-18 | Per Hedbor | | text=replace(res[..strlen(res)-2], ({"!","?",": "}),({ nbsp+"!",nbsp+"?",nbsp+": "}));
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | text=replace(replace(replace(text,({". ",". "+nbsp}),
|
9374e6 | 1999-05-18 | Per Hedbor | | ({"\000","\001"})),".","."+nbsp+nbsp),
({"\000","\001"}),({". ","."+nbsp}));
}
|
e8c29c | 1997-09-12 | Johan Schön | |
|
9374e6 | 1999-05-18 | Per Hedbor | | if( args->afont )
|
5fe8d8 | 2000-01-30 | Per Hedbor | | font = resolve_font((args->afont||args->font)+" "+(args->font_size||32));
|
9374e6 | 1999-05-18 | Per Hedbor | | else
|
a5c21b | 1999-05-18 | Peter Bortas | | {
|
38569c | 1999-12-07 | Martin Nilsson | | int bold=0, italic=0;
|
5fe8d8 | 2000-01-30 | Per Hedbor | | if(args->nfont) args->font = args->nfont;
|
9374e6 | 1999-05-18 | Per Hedbor | | if(args->bold) bold=1;
if(args->light) bold=-1;
if(args->black) bold=2;
if(args->italic) italic=1;
|
5fe8d8 | 2000-01-30 | Per Hedbor | | font = get_font(args->font||"default",
(int)(args->font_size||args["font-size"])||32,
bold,
italic,
|
9374e6 | 1999-05-18 | Per Hedbor | | lower_case(args->talign||"left"),
|
5fe8d8 | 2000-01-30 | Per Hedbor | | (float)args->xpad,
(float)args->ypad);
|
a5c21b | 1999-05-18 | Peter Bortas | | }
|
5fe8d8 | 2000-01-30 | Per Hedbor | | if(!font)
font = resolve_font(0);
|
974b2a | 1997-10-02 | Peter Bortas | |
|
f02c0c | 1999-12-11 | Martin Nilsson | | if (!font)
|
5fe8d8 | 2000-01-30 | Per Hedbor | | error("gtext: No font (tried "+
(args->afont||args->font||args->nfont)+ ")!\n");
|
1a6758 | 1997-09-26 | Henrik Grubbström (Grubba) | |
|
9374e6 | 1999-05-18 | Per Hedbor | |
|
742aab | 1999-12-14 | Martin Nilsson | | img = GText.make_text_image(args, font, text, id);
|
9558e3 | 1998-07-04 | Per Hedbor | |
|
e95416 | 2000-01-02 | Martin Nilsson | |
|
a5c21b | 1999-05-18 | Peter Bortas | |
|
9374e6 | 1999-05-18 | Per Hedbor | | if( !args->scroll && !args->fadein )
{
if(!args->notrans)
|
a5c21b | 1999-05-18 | Peter Bortas | | {
|
b89ccb | 1999-11-28 | Martin Nilsson | | array (int) bgcolor = parse_color(args->bgcolor);
|
f02c0c | 1999-12-11 | Martin Nilsson | | Image.Image alpha;
|
9374e6 | 1999-05-18 | Per Hedbor | | alpha = img->distancesq( @bgcolor );
alpha->gamma( 8 );
return ([ "img":img, "alpha":alpha ]);
|
a5c21b | 1999-05-18 | Peter Bortas | | }
|
9374e6 | 1999-05-18 | Per Hedbor | | return img;
}
|
a5c21b | 1999-05-18 | Peter Bortas | |
|
9374e6 | 1999-05-18 | Per Hedbor | | if(args->fadein)
|
a5c21b | 1999-05-18 | Peter Bortas | | {
|
9374e6 | 1999-05-18 | Per Hedbor | | int amount=2, steps=10, delay=10, initialdelay=0, ox;
string res = img->gif_begin();
sscanf(args->fadein,"%d,%d,%d,%d", amount, steps, delay, initialdelay);
if(initialdelay)
|
a5c21b | 1999-05-18 | Peter Bortas | | {
|
f02c0c | 1999-12-11 | Martin Nilsson | | Image.Image foo=Image.Image(img->xsize(),img->ysize(),@parse_color(args->bgcolor));
|
9374e6 | 1999-05-18 | Per Hedbor | | res += foo->gif_add(0,0,initialdelay);
|
a5c21b | 1999-05-18 | Peter Bortas | | }
|
9374e6 | 1999-05-18 | Per Hedbor | | for(int i = 0; i<(steps-1); i++)
{
|
f02c0c | 1999-12-11 | Martin Nilsson | | Image.Image foo=img->clone();
|
742aab | 1999-12-14 | Martin Nilsson | | foo = foo->apply_matrix(GText.make_matrix(( (int)((steps-i)*amount))));
|
9374e6 | 1999-05-18 | Per Hedbor | | res += foo->gif_add(0,0,delay);
|
a5c21b | 1999-05-18 | Peter Bortas | | }
|
f02c0c | 1999-12-11 | Martin Nilsson | | res += img->gif_add(0,0,delay);
|
9374e6 | 1999-05-18 | Per Hedbor | | res += img->gif_end();
data = ({ res, ({ img->xsize(), img->ysize() }) });
|
a5c21b | 1999-05-18 | Peter Bortas | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | else
|
a5c21b | 1999-05-18 | Peter Bortas | | {
|
9374e6 | 1999-05-18 | Per Hedbor | | int len=100, steps=30, delay=5, ox;
string res = img->gif_begin() + img->gif_netscape_loop();
sscanf(args->scroll, "%d,%d,%d", len, steps, delay);
img=img->copy(0,0,(ox=img->xsize())+len-1,img->ysize()-1);
img->paste(img, ox, 0);
for(int i = 0; i<steps; i++)
{
int xp = i*ox/steps;
res += img->copy(xp, 0, xp+len, img->ysize(),
|
b89ccb | 1999-11-28 | Martin Nilsson | | @parse_color(args->bgcolor))->gif_add(0,0,delay);
|
9374e6 | 1999-05-18 | Per Hedbor | | }
res += img->gif_end();
data = ({ res, ({ len, img->ysize() }) });
|
a5c21b | 1999-05-18 | Peter Bortas | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | return
([
"data":data[0],
|
df8c03 | 1999-05-25 | Per Hedbor | | "meta":
|
9374e6 | 1999-05-18 | Per Hedbor | | ([
"xsize":data[1][0],
"ysize":data[1][1],
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | "type":(args->format?id->conf->type_from_filename("x."+args->format):"image/gif"),
|
9374e6 | 1999-05-18 | Per Hedbor | | ])
]);
|
68e030 | 1997-08-19 | Per Hedbor | | }
|
f02c0c | 1999-12-11 | Martin Nilsson | | mapping find_internal(string f, RequestID id)
|
a5c21b | 1999-05-18 | Peter Bortas | | {
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | if( strlen(f)>4 && query("ext") && f[-4]=='.')
|
9374e6 | 1999-05-18 | Per Hedbor | | f = f[..strlen(f)-5];
|
0ee5ab | 1999-09-05 | Per Hedbor | | if( strlen(f) && f[0]=='$' )
|
8b6ee5 | 1999-07-10 | Peter Bortas | | {
array id_text = f/"/";
if( sizeof(id_text)==2 )
{
|
0ee5ab | 1999-09-05 | Per Hedbor | | string second_key = roxen->argcache->store( (["":id_text[1]]) );
|
f02c0c | 1999-12-11 | Martin Nilsson | | return image_cache->http_file_answer( id_text[0][1..] +"$"+ second_key, id );
|
8b6ee5 | 1999-07-10 | Peter Bortas | | }
}
|
f02c0c | 1999-12-11 | Martin Nilsson | | return image_cache->http_file_answer( f, id );
|
a5c21b | 1999-05-18 | Peter Bortas | | }
|
d47cbf | 1996-12-02 | Per Hedbor | |
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
|
b89ccb | 1999-11-28 | Martin Nilsson | | constant filearg=({"background","texture","alpha","magic-texture","magic-background","magic-alpha"});
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | constant textarg=({"afont",
"alpha",
"bevel",
|
b89ccb | 1999-11-28 | Martin Nilsson | | "bgcolor",
|
fc9c28 | 2000-01-12 | Martin Nilsson | | "bgturbulence",
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | "black",
"bold",
"bshadow",
"chisel",
"crop",
"encoding",
"fadein",
|
b89ccb | 1999-11-28 | Martin Nilsson | | "fgcolor",
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | "fs",
"font",
"font_size",
"format",
"ghost",
"glow",
"italic",
"light",
"mirrortile",
|
c3aacd | 1999-12-06 | Peter Bortas | | "move",
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | "narrow",
"nfont",
"notrans",
"opaque",
"outline",
"pressed",
"quant",
"rescale",
"rotate",
"scale",
"scolor",
"scroll",
"shadow",
"size",
"spacing",
"talign",
"tile",
"textbox",
"textbelow",
"textscale",
"verbatim",
"xpad",
"xsize",
"xspacing",
"ypad",
"ysize",
"yspacing"
});
|
7e471e | 2000-01-05 | Martin Nilsson | | constant theme=({"fgcolor","bgcolor","font"});
|
22cbbd | 2000-02-29 | Martin Nilsson | | constant hreffilter=(["split":1,"magic":1,"noxml":1,"alt":1]);
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | mapping mk_gtext_arg(mapping arg, RequestID id) {
mapping p=([]);
|
22cbbd | 2000-02-29 | Martin Nilsson | | m_delete(arg,"src");
m_delete(arg,"width");
m_delete(arg,"height");
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | foreach(filearg, string tmp)
if(arg[tmp]) {
p[tmp]=fix_relative(arg[tmp],id);
m_delete(arg,tmp);
}
|
d47cbf | 1996-12-02 | Per Hedbor | |
|
b89ccb | 1999-11-28 | Martin Nilsson | | if(arg->border && search(arg->border,",")) {
p->border=arg->border;
m_delete(arg,"border");
}
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | foreach(textarg, string tmp)
if(arg[tmp]) {
p[tmp]=arg[tmp],id;
m_delete(arg,tmp);
}
|
d47cbf | 1996-12-02 | Per Hedbor | |
|
7e471e | 2000-01-05 | Martin Nilsson | | foreach(theme, string tmp)
if( (id->misc->defines[tmp] || id->misc->defines["theme_"+tmp]) && !p[tmp])
p[tmp]=id->misc->defines["theme_"+tmp] || id->misc->defines[tmp];
if(id->misc->defines->nfont && !p->nfont) p->nfont=id->misc->gtext_nfont;
if(id->misc->defines->afont && !p->afont) p->afont=id->misc->gtext_afont;
if(id->misc->defines->bold && !p->bold) p->bold=id->misc->gtext_bold;
if(id->misc->defines->italic && !p->italic) p->italic=id->misc->gtext_italic;
if(id->misc->defines->black && !p->black) p->black=id->misc->gtext_black;
if(id->misc->defines->narrow && !p->narrow) p->narrow=id->misc->gtext_narrow;
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
return p;
|
d47cbf | 1996-12-02 | Per Hedbor | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | string fix_text(string c, mapping m, RequestID id) {
|
b91fd5 | 1996-12-10 | Per Hedbor | |
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | if(m->nowhitespace)
|
b91fd5 | 1996-12-10 | Per Hedbor | | {
|
04cd2a | 2000-02-19 | Martin Nilsson | | c=String.trim_all_whites(c);
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | m_delete(m, "nowhitespace");
}
if(!m->noparse && !m->preparse)
c = parse_rxml(c, id);
else {
m_delete(m, "noparse");
m_delete(m, "preparse");
|
b91fd5 | 1996-12-10 | Per Hedbor | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
|
dccfb5 | 2000-03-01 | Martin Nilsson | | c=replace(c, replace_entities+({" "," ", "\n\n\n", "\n\n", "\r"}),
replace_values+({" ", " ", "\n", "\n", ""}));
|
04cd2a | 2000-02-19 | Martin Nilsson | |
if(m->maxlen) {
c = c[..(((int)m->maxlen||QUERY(deflen))-1)];
m_delete(m, "maxlen");
}
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
return c;
|
b91fd5 | 1996-12-10 | Per Hedbor | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
|
f02c0c | 1999-12-11 | Martin Nilsson | | string container_gtext_url(string t, mapping arg, string c, RequestID id) {
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | c=fix_text(c,arg,id);
mapping p=mk_gtext_arg(arg,id);
|
e95416 | 2000-01-02 | Martin Nilsson | | if(arg->href && !p->fgcolor) p->fgcolor=id->misc->gtext_link||"#0000ff";
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | string ext="";
if(query("ext")) ext="."+(p->format || "gif");
if(!arg->short)
return query_internal_location()+image_cache->store( ({p,c}), id )+ext;
|
f02c0c | 1999-12-11 | Martin Nilsson | | return "+"+image_cache->store( ({p,c}), id )+ext;
|
8b6ee5 | 1999-07-10 | Peter Bortas | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | string tag_gtext_id(string t, mapping arg, RequestID id) {
mapping p=mk_gtext_arg(arg,id);
|
e95416 | 2000-01-02 | Martin Nilsson | | if(arg->href && !p->fgcolor) p->fgcolor=id->misc->gtext_link||"#0000ff";
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | if(!arg->short)
return query_internal_location()+"$"+image_cache->store(p, id)+"/";
|
f02c0c | 1999-12-11 | Martin Nilsson | | return "+"+image_cache->store(p, id )+"/foo";
|
07969c | 1997-02-25 | Per Hedbor | | }
|
f02c0c | 1999-12-11 | Martin Nilsson | | string container_gtext(string t, mapping arg, string c, RequestID id)
|
62d8c4 | 1997-10-16 | Per Hedbor | | {
|
e95416 | 2000-01-02 | Martin Nilsson | | if((c-" ")=="") return "";
|
033c7e | 1997-02-27 | Per Hedbor | |
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | c=fix_text(c,arg,id);
mapping p=mk_gtext_arg(arg,id);
|
d47cbf | 1996-12-02 | Per Hedbor | |
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | string ext="";
if(query("ext")) ext="."+(p->format || "gif");
|
bfc707 | 1997-01-13 | Per Hedbor | |
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | string lp="%s", url="", ea="";
|
38dca8 | 1996-12-10 | Per Hedbor | |
|
e95416 | 2000-01-02 | Martin Nilsson | | int input=0;
|
38dca8 | 1996-12-10 | Per Hedbor | | if(arg->submit)
{
input=1;
m_delete(arg,"submit");
}
|
bfc707 | 1997-01-13 | Per Hedbor | |
|
d47cbf | 1996-12-02 | Per Hedbor | | if(arg->href)
{
url = arg->href;
|
22cbbd | 2000-02-29 | Martin Nilsson | | lp = replace(make_tag("a",arg-hreffilter),"%","%%")+"%s</a>";
|
e95416 | 2000-01-02 | Martin Nilsson | | if(!p->fgcolor) p->fgcolor=id->misc->gtext_link||"#0000ff";
|
094371 | 1997-02-25 | Per Hedbor | | m_delete(arg, "href");
|
d47cbf | 1996-12-02 | Per Hedbor | | }
|
22cbbd | 2000-02-29 | Martin Nilsson | | if(!arg->noxml) { arg["/"]="/"; m_delete(arg, "noxml"); }
if(!arg->border) arg->border=arg->border||"0";
|
d47cbf | 1996-12-02 | Per Hedbor | | if(arg->split)
{
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | string res="",split=arg->split;
if(lower_case(split)=="split") split=" ";
|
d47cbf | 1996-12-02 | Per Hedbor | | m_delete(arg,"split");
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | c=replace(c, "\n", " ");
int setalt=!arg->alt;
foreach(c/split-({""}), string word)
|
d47cbf | 1996-12-02 | Per Hedbor | | {
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | string fn = image_cache->store( ({ p, word }),id );
|
9374e6 | 1999-05-18 | Per Hedbor | | mapping size = image_cache->metadata( fn, id, 1 );
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | if(setalt) arg->alt=word;
arg->src=query_internal_location()+fn+ext;
|
9374e6 | 1999-05-18 | Per Hedbor | | if( size )
{
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | arg->width = (string)size->xsize;
arg->height = (string)size->ysize;
|
1bd5c9 | 1997-09-26 | Henrik Grubbström (Grubba) | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | res+=make_tag( "img", arg )+" ";
|
d47cbf | 1996-12-02 | Per Hedbor | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | return sprintf(lp,res);
|
d47cbf | 1996-12-02 | Per Hedbor | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
string num = image_cache->store( ({ p, c }), id );
|
6a9b9d | 1999-06-25 | Per Hedbor | | mapping size = image_cache->metadata( num, id, 1 );
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | if(!arg->alt) arg->alt=replace(c,"\"","'");
|
f1be80 | 1998-02-22 | Per Hedbor | |
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | arg->src=query_internal_location()+num+ext;
if(size) {
|
7e471e | 2000-01-05 | Martin Nilsson | | arg->width=(string)size->xsize;
arg->height=(string)size->ysize;
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | }
if(arg->magic)
|
d47cbf | 1996-12-02 | Per Hedbor | | {
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | string magic=replace(arg->magic,"'","`");
m_delete(arg,"magic");
if(p->bevel) p->pressed=1;
foreach(glob("magic-*", indices(arg)), string q)
|
20ca2b | 1998-01-26 | Per Hedbor | | {
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | p[q[6..]]=arg[q];
|
20ca2b | 1998-01-26 | Per Hedbor | | m_delete(arg, q);
}
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
|
22cbbd | 2000-02-29 | Martin Nilsson | | if(!arg->fgcolor) p->fgcolor=id->misc->defines->theme_alink||
id->misc->defines->alink||"#ff0000";
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | string num2 = image_cache->store( ({ p, c }),id );
|
6a9b9d | 1999-06-25 | Per Hedbor | | size = image_cache->metadata( num2, id );
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | if(size) {
|
7e471e | 2000-01-05 | Martin Nilsson | | arg->width=(string)max(arg->xsize,size->xsize);
arg->height=(string)max(arg->ysize,size->ysize);
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | }
if(!id->supports->images) return sprintf(lp,arg->alt);
|
094371 | 1997-02-25 | Per Hedbor | |
|
e95416 | 2000-01-02 | Martin Nilsson | | string sn="i"+id->misc->gtext_mi++;
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | if(!id->supports->netscape_javascript) {
return (!input)?
("<a "+ea+"href=\""+url+"\">"+make_tag("img",arg+(["name":sn]))+"</a>"):
make_tag("input",arg+(["type":"image"]));
}
arg->name=sn;
|
e95416 | 2000-01-02 | Martin Nilsson | | string res="\n<script>\n";
if(!id->misc->gtext_magic_java) {
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | res += "function i(ri,hi,txt)\n"
"{\n"
" document.images[ri].src = hi.src;\n"
" setTimeout(\"top.window.status = '\"+txt+\"'\", 100);\n"
"}\n";
|
e95416 | 2000-01-02 | Martin Nilsson | | }
id->misc->gtext_magic_java="yes";
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
return
res+
" "+sn+"l = new Image("+arg->width+", "+arg->height+");"+sn+"l.src = \""+arg->src+"\";\n"
" "+sn+"h = new Image("+arg->width+", "+arg->height+");"+sn+"h.src = \""+query_internal_location()+num2+ext+"\";\n"
|
e95416 | 2000-01-02 | Martin Nilsson | | "</script>\n"+
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | "<a "+ea+"href=\""+url+"\" "+
(input?"onClick='document.forms[0].submit();' ":"")
|
e95416 | 2000-01-02 | Martin Nilsson | | +"onMouseover=\"i('"+sn+"',"+sn+"h,'"+(magic=="magic"?url:magic)+"'); return true;\" "
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | "onMouseout=\"top.window.status='';document.images['"+sn+"'].src = "+sn+"l.src;\">"
+make_tag("img",arg)+"</a>";
|
d47cbf | 1996-12-02 | Per Hedbor | | }
|
a3dfd4 | 1999-11-28 | Martin Nilsson | |
|
ca0f08 | 1997-02-22 | Per Hedbor | | if(input)
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | return make_tag("input",arg+(["type":"image"]));
return sprintf(lp,make_tag("img",arg));
|
d47cbf | 1996-12-02 | Per Hedbor | | }
|
f02c0c | 1999-12-11 | Martin Nilsson | | array(string) container_gh(string t, mapping m, string c, RequestID id) {
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | int i;
if(sscanf(t, "%s%d", t, i)==2 && i>1)
m->scale = (string)(1.0 / ((float)i*0.6));
if(!m->valign) m->valign="top";
|
f02c0c | 1999-12-11 | Martin Nilsson | | return ({ "<p>"+container_gtext("",m,c,id)+"<br>" });
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | }
|
f02c0c | 1999-12-11 | Martin Nilsson | | array(string) container_anfang(string t, mapping m, string c, RequestID id) {
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | if(!m->align) m->align="left";
|
f02c0c | 1999-12-11 | Martin Nilsson | | return ({ "<br clear=\"left\">"+container_gtext("",m,c[0..0],id)+c[1..] });
|
a3dfd4 | 1999-11-28 | Martin Nilsson | | }
|
bfc707 | 1997-01-13 | Per Hedbor | | mapping query_tag_callers()
|
d47cbf | 1996-12-02 | Per Hedbor | | {
|
7e471e | 2000-01-05 | Martin Nilsson | | return ([ "gtext-id":tag_gtext_id ]);
|
d47cbf | 1996-12-02 | Per Hedbor | | }
mapping query_container_callers()
{
|
f02c0c | 1999-12-11 | Martin Nilsson | | return ([ "anfang":container_anfang,
"gtext-url":container_gtext_url, "gh":container_gh,
"gh1":container_gh, "gh2":container_gh,
"gh3":container_gh, "gh4":container_gh,
"gh5":container_gh, "gh6":container_gh,
"gtext":container_gtext ]);
|
d47cbf | 1996-12-02 | Per Hedbor | | }
|