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

version» Context lines:

Roxen.git/server/modules/graphics/cimg.pike:1:   // This is a roxen module. Copyright © 1999 - 2000, Roxen IS.   //      #include <module.h>   inherit "module";   constant thread_safe=1;      roxen.ImageCache the_cache;    - constant cvs_version = "$Id: cimg.pike,v 1.40 2001/03/30 11:35:46 jhs Exp $"; + constant cvs_version = "$Id: cimg.pike,v 1.41 2001/04/03 07:29:34 per Exp $";   constant module_type = MODULE_TAG;   constant module_name = "Graphics: Image converter";   constant module_doc = "Provides the tag <tt>&lt;cimg&gt;</tt> that can be used "   "to convert images between different image formats.";         mapping tagdocumentation()   {    Stdio.File file=Stdio.File();    if(!file->open(__FILE__,"r")) return 0;
Roxen.git/server/modules/graphics/cimg.pike:103: Inside #if defined(manual)
   Returns the imagedata given through other sources, like databases    through entities.</p>   </desc>"   ])      }),      ]);   #endif    + int do_ext; +    void create()   {    defvar("ext", Variable.Flag(0, VAR_MORE,    "Append format to generated images",    "Append the image format (.gif, .png, "    ".jpg, etc) to the generated images. "    "This is not necessary, but might seem "    "nicer, especially to people who try "    "to mirror your site."));   }      void start()   {    the_cache = roxen.ImageCache( "cimg", generate_image ); -  +  do_ext = query("ext");   }      mapping(string:function) query_action_buttons() {    return ([ "Clear cache":flush_cache ]);   }      void flush_cache() {    the_cache->flush();   }   
Roxen.git/server/modules/graphics/cimg.pike:178:    foreach( layers, Image.Layer l )    {    if( l->get_misc_value( "visible" ) )    res += ({ l });    }    return res;   }      mapping find_internal( string f, RequestID id )   { -  if(strlen(f)>4 && query("ext") && f[-4]=='.') // Remove .ext -  f = f[..strlen(f)-5]; -  return the_cache->http_file_answer( f, id ); +  // It's not enough to +  // 1. Only do this check when the ext flag is set, old URLs might +  // live in caches +  // +  // 2. Check str[-4] for '.', consider .jpeg .tiff etc. +  // +  // However, . is not a valid character in the ID, so just cutting at +  // the first one works. +  return the_cache->http_file_answer( (f/".")[0], id );   }      mapping get_my_args( mapping args, RequestID id )   {    mapping a=    ([    "quant":args->quant,    "crop":args->crop,    "format":args->format,    "maxwidth":args->maxwidth,
Roxen.git/server/modules/graphics/cimg.pike:246:    constant plugin_name = "cimg";       array get_dataset( mapping args, RequestID id )    {    mapping res = ([ ]);    mapping a = get_my_args( check_args( args ), id );    string data;    catch // This code will fail if the image does not exist.    {    res->src=(query_absolute_internal_location(id)+the_cache->store( a,id )); -  if(query("ext")) +  if(do_ext)    res->src += "." + (a->format || "gif");    data = the_cache->data( a, id , 0 );    res["file-size"] = strlen(data);    res["file-size-kb"] = strlen(data)/1024;    res["data"] = data;    res |= the_cache->metadata( a, id, 0 ); // enforce generation    return ({ res });    };    RXML.parse_error( "Illegal arguments or image" );    return ({});
Roxen.git/server/modules/graphics/cimg.pike:275:       class Frame    {    inherit RXML.Frame;       array do_return(RequestID id)    {    mapping a = get_my_args( check_args( args ), id );    args -= a;    string ext = ""; -  if(query("ext")) +  if(do_ext)    ext = "." + (a->format || "gif");    args->src = query_absolute_internal_location( id )    + the_cache->store( a, id ) + ext;    if( mapping size = the_cache->metadata( a, id, 1 ) )    {    // image in cache (1 above prevents generation on-the-fly)    args->width = size->xsize;    args->height = size->ysize;    }    int xml=!args->noxml;
Roxen.git/server/modules/graphics/cimg.pike:306:    constant flags = RXML.FLAG_EMPTY_ELEMENT;       class Frame    {    inherit RXML.Frame;       array do_return(RequestID id)    {    result = query_absolute_internal_location(id)    + the_cache->store(get_my_args(check_args( args ), id ), id) -  + (query("ext") ? "" : "." + (args->format || "gif")); +  + (do_ext ? "." + (args->format || "gif") : "");    return 0;    }    }   }