Roxen.git / server / modules / graphics / graphic_text.pike

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1: - constant cvs_version="$Id: graphic_text.pike,v 1.162 1999/05/19 02:57:18 peter Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.163 1999/05/19 09:11:46 peter Exp $";   constant thread_safe=1;      #include <config.h>   #include <module.h>   #include <stat.h>   inherit "module";   inherit "roxenlib";      #ifndef VAR_MORE   #define VAR_MORE 0   #endif /* VAR_MORE */      array register_module()   { -  return ({ MODULE_PARSER|MODULE_LOCATION, +  return ({ MODULE_PARSER,    "Graphics text",    "Generates graphical texts.<p>"    "See <tt>&lt;gtext help&gt;&lt;/gtext&gt;</tt> for "    "more information.",    0, 1    });   }         void create()
Roxen.git/server/modules/graphics/graphic_text.pike:45:    " dramatically. You can try this out with the &lt;gauge&gt; tag.",    0, lambda(){return !query("colorparse");});       defvar("deflen", 300, "Default maximum text-length", TYPE_INT|VAR_MORE,    "The module will, per default, not try to render texts "    "longer than this. This is a safeguard for things like "    "&lt;gh1&gt;&lt;/gh&gt;, which would otherwise parse the"    " whole document. This can be overrided with maxlen=... in the "    "tag.");    -  defvar("location", "/gtext/", "Mountpoint", TYPE_LOCATION|VAR_MORE, -  "The URL-prefix for the graphic characters."); -  -  defvar("gif", 0, "Append .fmt (gif, jpeg etc) to all images", -  TYPE_FLAG|VAR_MORE, +  defvar("gif", 0, "Append .fmt (gif, jpeg etc) to all images", TYPE_FLAG|VAR_MORE,    "Append .gif, .png, .gif etc to all images made by gtext. "    "Normally this will only waste bandwidth");   }      static private mapping cached_args = ([ ]);      #define MAX(a,b) ((a)<(b)?(b):(a))      static private mapping (int:array(array(int))) matrixes = ([]);   array (array(int)) make_matrix(int size)
Roxen.git/server/modules/graphics/graphic_text.pike:632:       // Now we have the image in 'img', or nothing.       if( !args->scroll && !args->fadein )    {    if(!args->notrans)    {    array (int) bgcolor = parse_color(args->bg);    object alpha;    alpha = img->distancesq( @bgcolor ); -  alpha->gamma( 20 ); +  alpha->gamma( 8 );    return ([ "img":img, "alpha":alpha ]);    }    return img;    }       if(args->fadein)    {    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);
Roxen.git/server/modules/graphics/graphic_text.pike:688:    "metadata":    ([    "xsize":data[1][0],    "ysize":data[1][1],    "type":"image/gif",    ])    ]);   }       - array stat_file() { return 0; } - array find_dir() { return 0; } -  - mapping find_file(string f, object rid) + mapping find_internal(string f, object rid)   { -  if( query("gif") && f[-4]=='.') // Remove .ext +  if( strlen(f)>4 && query("gif") && f[-4]=='.') // Remove .ext    f = f[..strlen(f)-5];    return image_cache->http_file_answer( f, rid );   }      string magic_javascript_header(object id)   {    if(!id->supports->netscape_javascript || !id->supports->images) return "";    return    ("\n<script>\n"    "function i(ri,hi,txt)\n"
Roxen.git/server/modules/graphics/graphic_text.pike:789:    if(arg->magic_background)    arg->magic_background=fix_relative(arg->magic_background,id);    if(arg->magicbg)    arg->magicbg = fix_relative(arg->magicbg,id);    if(arg->alpha)    arg->alpha = fix_relative(arg->alpha,id);       arg->text = ctn;       if(!short) -  return QUERY(location)+image_cache->store( arg, id ); +  return query_internal_location()+image_cache->store( arg, id )+ +  (query("gif")?".foo":"");    else -  return image_cache->store( arg, id ); +  return image_cache->store( arg, id )+(query("gif")?".foo":"");   }      string tag_graphicstext(string t, mapping arg, string contents,    object id, object foo, mapping defines)   {    if((contents-" ")=="")    return "";   //Allow <accessed> and others inside <gtext>.    if(arg->nowhitespace)    {
Roxen.git/server/modules/graphics/graphic_text.pike:823:    arg->magic_texture=fix_relative(arg->magic_texture,id);    if(arg->magic_background)    arg->magic_background=fix_relative(arg->magic_background,id);    if(arg->magicbg)    arg->magicbg = fix_relative(arg->magicbg,id);    if(arg->alpha)    arg->alpha = fix_relative(arg->alpha,id);          string gif=""; -  if(query("gif")) gif=".gif"; +  if(query("gif")) gif="."+(arg->format?arg->format[..2]:"gif");      #if efun(_static_modules)    contents = parse_rxml(contents, id, foo, defines);   #else    contents = parse_rxml(contents, id, foo);   #endif       string lp, url, ea;    string pre, post, defalign, gt, rest, magic;    int i;
Roxen.git/server/modules/graphics/graphic_text.pike:885:    {    if (sizeof(split=arg->split) != 1)    split = " ";    m_delete(arg,"split");    }       // Support for <gh 2> like things.    for(i=2; i<10; i++)    if(arg[(string)i])    { -  arg->scale = 1.0 / ((float)i*0.6); +  arg->scale = (string)(1.0 / ((float)i*0.6));    m_delete(arg, (string)i);    break;    }       // Support for <gh1> like things.    if(sscanf(t, "%s%d", t, i)==2) -  if(i > 1) arg->scale = 1.0 / ((float)i*0.6); +  if(i > 1) arg->scale = (string)(1.0 / ((float)i*0.6));       string na = arg->name, al=arg->align;    m_delete(arg, "name"); m_delete(arg, "align");       // Now the 'arg' mapping is modified enough..    gt=contents;    rest="";       switch(t)    {
Roxen.git/server/modules/graphics/graphic_text.pike:932:       foreach(gt/split-({""}), word)    {    arg->text = word;    string fn = image_cache->store( arg );    mapping size = image_cache->metadata( fn, id, 1 );       mapping tag =    ([    "alt":(arg->alt||word), -  "src":QUERY(location)+fn+gif, +  "src":query_internal_location()+fn+gif,    ]);    if( size )    {    tag->width = size->xsize;    tag->height = size->ysize;    }    res += ({ make_tag( "img", tag )+" " });    }    if(lp) res += ({ "</a>"+post });    return res*"";
Roxen.git/server/modules/graphics/graphic_text.pike:975:    arg[q[6..]]=arg[q];    m_delete(arg, q);    }       string num2 = image_cache->store( arg );    size = image_cache->metadata( arg, id );       if(!defines->magic_java)    res = magic_javascript_header(id);    defines->magic_java="yes"; -  +  if(!size) size = ([ ]);    return replace(res +    magic_image(url||"", size->xsize, size->ysize, "i"+(defines->mi++), -  QUERY(location)+num+"/"+gif, -  QUERY(location)+num2+"/"+gif, +  query_internal_location()+num+gif, +  query_internal_location()+num2+gif,    (arg->alt?arg->alt:replace(gt, "\"","'")),    (magic=="magic"?0:magic),    id,input?na||"submit":0,ea,lp),    "</script>\n<script>","");    }    if(input)    return (pre+"<input type=image name=\""+na+"\" border=0 alt=\""+    (arg->alt?arg->alt:replace(gt,"\"","'"))+ -  "\" src="+QUERY(location)+num+gif +  "\" src="+query_internal_location()+num+gif    +" align="+(al || defalign)+ea+    (size?(" width="+size->xsize+" height="+size->ysize):"")+">"+    rest+post);       return (pre+(lp?lp:"")    + "<img border=0 alt=\""    + (arg->alt?arg->alt:replace(gt,"\"","'"))    + "\" src=\"" -  + QUERY(location)+num+gif+"\" "+ea +  + query_internal_location()+num+gif+"\" "+ea    + " align="+(al || defalign)    + (size?(" width="+size->xsize+" height="+size->ysize):"")+">"+    rest+(lp?"</a>":"")+post);   }      inline string ns_color(array (int) col)   {    if(!arrayp(col)||sizeof(col)!=3)    return "#000000";    return sprintf("#%02x%02x%02x", col[0],col[1],col[2]);