Branch: Tag:

1998-02-10

1998-02-10 18:36:21 by Per Hedbor <ph@opera.com>

Fixes...

Rev: server/base_server/cache.pike:1.19
Rev: server/base_server/color.pike:1.13
Rev: server/base_server/configuration.pike:1.94
Rev: server/base_server/disk_cache.pike:1.34
Rev: server/base_server/dummy_hosts.pike:1.5
Rev: server/base_server/html.pike:1.4
Rev: server/base_server/language.pike:1.12
Rev: server/base_server/lock.pike:1.3(DEAD)
Rev: server/base_server/mainconfig.pike:1.94
Rev: server/base_server/module_support.pike:1.15
Rev: server/base_server/newdecode.pike:1.7
Rev: server/base_server/privs.pike:1.33
Rev: server/base_server/read_config.pike:1.20
Rev: server/base_server/roxen.pike:1.166
Rev: server/base_server/roxenlib.pike:1.47
Rev: server/base_server/roxenloader.pike:1.58
Rev: server/base_server/smartpipe.pike:1.1
Rev: server/base_server/socket.pike:1.11
Rev: server/modules/filesystems/filesystem.pike:1.27
Rev: server/modules/filesystems/restrictedfs.pike:1.8
Rev: server/modules/filesystems/userfs.pike:1.18
Rev: server/modules/filters/htaccess.pike:1.29
Rev: server/modules/filters/redirect.pike:1.12
Rev: server/modules/graphics/graphic_text.pike:1.101
Rev: server/modules/misc/contenttypes.pike:1.11
Rev: server/modules/misc/demo.pike:1.2
Rev: server/modules/misc/ismap.pike:1.11
Rev: server/modules/misc/userdb.pike:1.24
Rev: server/modules/misc/ypuserdb.pike:1.7
Rev: server/protocols/http.pike:1.54

1: - constant cvs_version="$Id: graphic_text.pike,v 1.100 1998/02/05 00:59:25 js Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.101 1998/02/10 18:36:17 per Exp $";   constant thread_safe=1;      #include <module.h> -  + #include <stat.h>   inherit "module";   inherit "roxenlib";    - #if efun(_static_modules) - # define map_array Array.map - import Image; - # define Image image - # define Font font - #endif -  +    #ifndef VAR_MORE   #define VAR_MORE 0   #endif /* VAR_MORE */
131:    "The gtext tag saves images when they are calculated in this "    "directory. We currently do not clean this directory.");    +  defvar("cache_age", 48, "Cache max age", +  +  TYPE_INT, +  +  "If the images in the cache have not been accessed for this " +  "number of hours they are removed."); +     defvar("speedy", 0, "Avoid automatic detection of document colors",    TYPE_FLAG|VAR_MORE,    "If this flag is set, the tags 'body', 'tr', 'td', 'font' and 'th' "
176:      string query_location() { return query("location"); }    - object(Font) load_font(string name, string justification, int xs, int ys) + object load_font(string name, string justification, int xs, int ys)   { -  object fnt = Font(); +  object fnt = Image.font();       if ((!name)||(name == ""))    {
219: Inside #if !efun(make_matrix)
   array res;    int i;    int j; -  res = map_array(allocate(size), lambda(int s, int size){ +  res = Array.map(allocate(size), lambda(int s, int size){    return allocate(size); }, size);       for(i=0; i<size; i++)
243:    if(last_image_name == f && last_image) return last_image->copy();    string data;    object file; -  object img = Image(); +  object img = Image.image();       if(!(data=roxen->try_get_file(fix_relative(f, id),id)))    if(!(file=open(f,"r")) || (!(data=file->read())))
254:    return img->copy();   }    - object (Image) blur(object img, int amnt) + object blur(object img, int amnt)   {    img->setcolor(0,0,0);    img = img->autocrop(amnt, 0,0,0,0, 0,0,0);
264:    return img;   }    - object (Image) outline(object (Image) on, object (Image) with, + object outline(object on, object with,    array (int) color, int radie, int x, int y)   {    int steps=10;
281:   array black = ({ 0,0,0 });      array wwwb = ({ lgrey,lgrey,grey,black }); - object (Image) bevel(object (Image) in, int width, int|void invert) + object bevel(object in, int width, int|void invert)   {    int h=in->ysize();    int w=in->xsize();    -  object corner = Image(width+1,width+1); -  object corner2 = Image(width+1,width+1); -  object pix = Image(1,1); +  object corner = Image.image(width+1,width+1); +  object corner2 = Image.image(width+1,width+1); +  object pix = Image.image(1,1);       for(int i=-1; i<=width; i++) {    corner->line(i,width-i,i,-1, @white);
298:       if(!invert)    { -  in->paste_alpha(Image(width,h-width*2,@white), 160, 0, width); -  in->paste_alpha(Image(width,h-width*2,@black), 128, in->xsize()-width, width); -  in->paste_alpha(Image(w-width,width,@white), 160, 0, 0); -  in->paste_alpha(Image(w-width,width,@black), 128, width, in->ysize()-width); +  in->paste_alpha(Image.image(width,h-width*2,@white), 160, 0, width); +  in->paste_alpha(Image.image(width,h-width*2,@black), 128, in->xsize()-width, width); +  in->paste_alpha(Image.image(w-width,width,@white), 160, 0, 0); +  in->paste_alpha(Image.image(w-width,width,@black), 128, width, in->ysize()-width);    } else {    corner=corner->invert();    corner2=corner2->invert(); -  in->paste_alpha(Image(width,h-width*2,@black), 160, 0, width); -  in->paste_alpha(Image(width,h-width*2,@white), 128, in->xsize()-width, width); -  in->paste_alpha(Image(w-width,width,@black), 160, 0, 0); -  in->paste_alpha(Image(w-width,width,@white), 128, width, in->ysize()-width); +  in->paste_alpha(Image.image(width,h-width*2,@black), 160, 0, width); +  in->paste_alpha(Image.image(width,h-width*2,@white), 128, in->xsize()-width, width); +  in->paste_alpha(Image.image(w-width,width,@black), 160, 0, 0); +  in->paste_alpha(Image.image(w-width,width,@white), 128, width, in->ysize()-width);    }       in->paste_mask(corner, corner->color(95,95,95), in->xsize()-width,-1);
325:   }       - object (Image) make_text_image(mapping args, object font, string text,object id) + object make_text_image(mapping args, object font, string text,object id)   {    object text_alpha=font->write(@(text/"\n"));    int xoffset=0, yoffset=0;       if(!text_alpha->xsize() || !text_alpha->ysize()) -  text_alpha = Image(10,10, 0,0,0); +  text_alpha = Image.image(10,10, 0,0,0);      // perror("Making image of '%s', args=%O\n", text, args);   
446:    case "left":    }    } else -  background = Image(xsize, ysize, @bgcolor); +  background = Image.image(xsize, ysize, @bgcolor);       if(args->border)    {
502:    string bg;    sscanf(args->textbox, "%d,%s", alpha, bg);    sscanf(bg,"%s,%d", bg,border); -  background->paste_alpha(Image(txsize+border*2,tysize+border*2, +  background->paste_alpha(Image.image(txsize+border*2,tysize+border*2,    @parse_color(bg)),    255-(alpha*255/100),xoffset-border,yoffset-border);    }
542:    int xs,ys;    xs = text_alpha->xsize()+sdist*2+4;    ys = text_alpha->ysize()+sdist*2+4; -  object ta = Image(xs+sdist*2,ys+sdist*2); +  object ta = Image.image(xs+sdist*2,ys+sdist*2);    array sc = parse_color(args->scolor||"black");       ta->paste_alpha_color(text_alpha,255,255,255,sdist,sdist);
568:    ->color(@fgcolor);       -  if(!foreground) foreground=Image(txsize, tysize, @fgcolor); +  if(!foreground) foreground=Image.image(txsize, tysize, @fgcolor);    if(args->textscale)    {    string c1="black",c2="black",c3="black",c4="black";
609:   string base_key;   object mc;    +  + array to_clean = ({}); + void clean_cache_dir() + { +  if(!sizeof(to_clean)) +  to_clean = get_dir(query("cache_dir")); +  if(!sizeof(to_clean)) return; +  int md = file_stat(query("cache_dir")+to_clean[0])[ST_ATIME]; +  +  if((time() - md) > (query("cache_age")*3600)) +  rm(query("cache_dir")+to_clean[0]); +  +  to_clean = to_clean[1..]; +  if(sizeof(to_clean)) +  call_out(clean_cache_dir, 0.1); +  else +  call_out(clean_cache_dir, 3600); + } +    void start(int|void val, object|void conf)   {    if(conf)
619: Inside #if undefined(__NT__)
   chmod( query( "cache_dir" ), 0777 );   #endif   #endif +  remove_call_out(clean_cache_dir); +  call_out(clean_cache_dir, 10);    mc = conf;    base_key = "gtext:"+(conf?conf->name:roxen->current_configuration->name);    }
854:    sscanf(args->fadein, "%d,%d,%d,%d", amount, steps, delay, initialdelay);    if(initialdelay)    { -  object foo=image(img->xsize(),img->ysize(),@parse_color(args->bg)); +  object foo=Image.image(img->xsize(),img->ysize(),@parse_color(args->bg));    res += foo->gif_add(0,0,initialdelay);    }    for(int i = 0; i<(steps-1); i++)
1061:       return    ("<script>\n" -  " "+sn+"l = new Image("+xs+", "+ys+");"+sn+"l.src = \""+image_1+"\";\n" -  " "+sn+"h = new Image("+xs+", "+ys+");"+sn+"h.src = \""+image_2+"\";\n" +  " "+sn+"l = new Image.image("+xs+", "+ys+");"+sn+"l.src = \""+image_1+"\";\n" +  " "+sn+"h = new Image.image("+xs+", "+ys+");"+sn+"h.src = \""+image_2+"\";\n"    "</script>\n"+    ("<a "+extra_args+"href=\""+url+"\" "+    (input?"onClick='document.forms[0].submit();' ":"")