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.166 1999/06/10 14:59:39 jonasw Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.167 1999/07/10 21:40:01 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
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("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:553:    image_cache = roxen.ImageCache( "gtext", draw_callback );   }      constant nbsp = iso88591["&nbsp;"];   constant replace_from = indices( iso88591 )+ ({"&ss;","&lt;","&gt;","&amp;",});   constant replace_to = values( iso88591 ) + ({ nbsp, "<", ">", "&", });      #define simplify_text( from ) replace(from,replace_from,replace_to)       - mixed draw_callback(mapping args, object id) + mixed draw_callback(mapping args, string text, object id)   {    array err;    mixed data;    int elapsed; -  string text = args->text; +     string orig_text = text;    object img;    -  +  if( objectp( text ) ) +  { +  if( !args->text ) +  error("Failed miserably to find a text to draw. That's not" +  " good.\n"); +  id = (object)text; +  text = args->text; +  } +     if(!args->verbatim) // typographically correct...    {    text = replace(text, nbsp, " ");    text = simplify_text( text );    string res="",nspace="",cspace="";    foreach(text/"\n", string line)    {    cspace="";nspace="";    foreach(line/" ", string word)    {
Roxen.git/server/modules/graphics/graphic_text.pike:689:    "type":"image/gif",    ])    ]);   }         mapping find_internal(string f, object rid)   {    if( strlen(f)>4 && query("gif") && f[-4]=='.') // Remove .ext    f = f[..strlen(f)-5]; +  if( strlen(f) && f[0..0]=="$" ) +  { +  array id_text = f/"/"; +  if( sizeof(id_text)==2 ) +  { // It's a gtext-id +  string second_key = roxen.argcache.store( (["":id_text[1]]) ); +  return image_cache->http_file_answer( id_text[0][1..] +"$"+ second_key, rid ); +  } +  }    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"    "{\n"
Roxen.git/server/modules/graphics/graphic_text.pike:753:    case "class":    case "id":    s+=i+"='"+in[i]+"' ";    m_delete(in, i);    break;    }    }    return s;   }    - string tag_gtext_id(string t, mapping arg, string ctn, + string tag_gtext_url(string t, mapping arg, string ctn,    object id, object foo, mapping defines)   {    int short=!!arg->short;    if(arg->help) return "Arguments are identical to the argumets to &lt;gtext&gt;. This tag returns a url-prefix that can be used to generate gtexts.";    m_delete(arg, "short"); m_delete(arg, "maxlen");    m_delete(arg,"magic"); m_delete(arg,"submit");    extra_args(arg); m_delete(arg,"split");    if(defines->fg && !arg->fg) arg->fg=defines->fg;    if(defines->bg && !arg->bg) arg->bg=defines->bg;    if(defines->nfont && !arg->nfont) arg->nfont=defines->nfont;
Roxen.git/server/modules/graphics/graphic_text.pike:789:       arg->text = ctn;       if(!short)    return query_internal_location()+image_cache->store( arg, id )+    (query("gif")?".foo":"");    else    return image_cache->store( arg, id )+(query("gif")?".foo":"");   }    + string tag_gtext_id(string t, mapping arg, object id, object foo, +  mapping defines) + { +  int short=!!arg->short; +  if(arg->help) return "Arguments are identical to the argumets to &lt;gtext&gt;. This tag returns a url-prefix that can be used to generate gtexts."; +  m_delete(arg, "short"); m_delete(arg, "maxlen"); +  m_delete(arg,"magic"); m_delete(arg,"submit"); +  extra_args(arg); m_delete(arg,"split"); +  if(defines->fg && !arg->fg) arg->fg=defines->fg; +  if(defines->bg && !arg->bg) arg->bg=defines->bg; +  if(defines->nfont && !arg->nfont) arg->nfont=defines->nfont; +  if(defines->afont && !arg->afont) arg->afont=defines->afont; +  if(defines->font && !arg->font) arg->font=defines->font; +  +  if(arg->background) +  arg->background = fix_relative(arg->background,id); +  if(arg->texture) +  arg->texture = fix_relative(arg->texture,id); +  if(arg->magic_texture) +  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); +  +  // arg->text = ctn; +  +  if(!short) +  return query_internal_location()+"$"+image_cache->store( arg, id )+"/"; +  else +  return "+"+image_cache->store( arg, id )+"/"; + } +    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)    {    sscanf(contents,"%*[ \n\r\t]%s",contents);    sscanf(reverse(contents),"%*[ \n\r\t]%s",contents);
Roxen.git/server/modules/graphics/graphic_text.pike:820:    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="."+(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 +  if( !arg->noparse && !arg->preparse ) +  contents = parse_rxml(contents, id); +  else +  { +  m_delete( arg, "noparse" ); +  m_delete( arg, "preparse" ); +  }       string lp, url, ea;    string pre, post, defalign, gt, rest, magic;    int i;    string split;       contents = contents[..(((int)arg->maxlen||QUERY(deflen))-1)];    m_delete(arg, "maxlen");       if(arg->magic)
Roxen.git/server/modules/graphics/graphic_text.pike:920:    if(split)    {    string word;    array res = ({ pre });    if(lp) res+=({ lp });       gt=replace(gt, "\n", " ");       foreach(gt/split-({""}), word)    { -  arg->text = word; -  string fn = image_cache->store( arg ); +  string fn = image_cache->store( ({arg,word}),id );    mapping size = image_cache->metadata( fn, id, 1 );    mapping tag =    ([    "alt":(arg->alt||word),    "src":query_internal_location()+fn+gif,    ]);    if( size )    {    tag->width = (string)size->xsize;    tag->height = (string)size->ysize;    }    res += ({ make_tag( "img", tag )+" " });    }    if(lp) res += ({ "</a>"+post });    return res*"";    }    -  arg->text = gt; -  string num = image_cache->store( arg ); -  mapping size = image_cache->metadata( arg, id, 1 ); +  string num = image_cache->store( ({arg,gt}),id ); +  mapping size = image_cache->metadata( num, id, 1 );       if(magic)    {    string res = "";    if(!arg->fg) arg->fg=defines->link||"#0000ff";    arg = mkmapping(indices(arg), values(arg));    if(arg->fuzz)    if(arg->fuzz != "fuzz")    arg->glow = arg->fuzz;    else
Roxen.git/server/modules/graphics/graphic_text.pike:963:    arg->fg = defines->alink||"#ff0000";    if(arg->magicbg) arg->background = arg->magicbg;    if(arg->bevel) arg->pressed=1;       foreach(glob("magic_*", indices(arg)), string q)    {    arg[q[6..]]=arg[q];    m_delete(arg, q);    }    -  string num2 = image_cache->store( arg ); -  size = image_cache->metadata( arg, id ); +  string num2 = image_cache->store( ({ arg, gt }),id ); +  size = image_cache->metadata( num2, 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_internal_location()+num+gif,    query_internal_location()+num2+gif,    (arg->alt?arg->alt:replace(gt, "\"","'")),
Roxen.git/server/modules/graphics/graphic_text.pike:1082:    defines->fg = c[-i-1][0];    defines->bg = c[-i-1][1];    break;    }    c = c[..sizeof(c)-i-2];    id->misc->colors = c;   }      mapping query_tag_callers()   { -  mapping tags = ([ ]); +  mapping tags = ([ "gtext-id":tag_gtext_id ]);    if(query("colorparse"))    foreach(query("colorparsing"), string t)    {    switch(t)    {    case "body":    tags[t] = tag_body;    break;    default:    tags[t] = tag_fix_color;    tags["/"+t]=pop_color;    }    }    return tags;   }         mapping query_container_callers()   {    return ([ "anfang":tag_graphicstext, -  "gtext-id":tag_gtext_id, "gh":tag_graphicstext, +  "gtext-url":tag_gtext_url, "gh":tag_graphicstext,    "gh1":tag_graphicstext, "gh2":tag_graphicstext,    "gh3":tag_graphicstext, "gh4":tag_graphicstext,    "gh5":tag_graphicstext, "gh6":tag_graphicstext,    "gtext":tag_graphicstext, ]);   }