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 - 2004, Roxen IS.   //      #include <module.h>   inherit "module";   constant thread_safe=1;      roxen.ImageCache the_cache;    - constant cvs_version = "$Id: cimg.pike,v 1.75 2007/01/17 12:45:24 jonasw Exp $"; + constant cvs_version = "$Id: cimg.pike,v 1.76 2008/10/28 23:22:02 erikd 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:32: Inside #if defined(manual)
   possible to convert, resize, crop and in other ways transform    images.</p>   </desc>      <attr name='src' value='url' required='required'><p>    The path to the indata file.</p>      <ex><cimg src='/internal-roxen-testimage'/></ex>   </attr>    + <attr name='filename' value='string'><p> + Append the filename value to the path. Recommended is not to append file suffix + to the filename since there are settings for handling that automatically through + this module settings. + </p><p>This is usefull if you want to have images indexed, since many search engines + uses the filename as a description of the image.</p> + <ex><cimg-url src='/internal-roxen-testimage' filename='Roxen Test Image'/></ex> + </attr> +    <attr name='data' value='imagedata'><p>    Insert images from other sources, e.g. databases through entities or    variables.</p>   <ex-box><emit source='sql' query='select imagedata from images where id=37'>   <cimg data='&sql.imagedata:none;'/>   </emit></ex-box>   </attr>      <attr name='process-all-layers'><p>Set this flag to make all image layers   visible regardless of their original state.</p>
Roxen.git/server/modules/graphics/cimg.pike:279:   }      mapping find_internal( string f, RequestID 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.    // +  // 3. Also handle / if filename attribute is used in either tag +  //    // 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 ); +  // the first one works as well as also cutting at the first /. +  sscanf (f, "%[^./]", f); +  return the_cache->http_file_answer( f, 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:371:    mixed err = catch // This code will fail if the image does not exist.    {    // Store misc->cacheable since the image cache can raise it and    // disable protocol cache.    int cacheable = id->misc->cacheable;    int no_proto_cache = id->misc->no_proto_cache;   #ifdef DEBUG_CACHEABLE    report_debug("%s:%d saved cacheable flags\n", __FILE__, __LINE__);   #endif    res->src=(query_absolute_internal_location(id)+the_cache->store( a,id )); +  if(args->filename && sizeof(args->filename)) +  res->src += "/" + args->filename;    if(do_ext)    res->src += "." + (a->format || "gif"); -  +  res->src = Roxen.http_encode_invalids(res->src);    data = the_cache->data( a, id , 0 );    res["file-size"] = strlen(data);    res["file-size-kb"] = strlen(data)/1024;    if (lower_case(args->nodata || "no") == "no")    res["data"] = data;    res |= the_cache->metadata( a, id, 0 ); // enforce generation   #ifdef DEBUG_CACHEABLE    report_debug("%s:%d restored cacheable flags\n", __FILE__, __LINE__);   #endif    id->misc->cacheable = cacheable;
Roxen.git/server/modules/graphics/cimg.pike:410:       class Frame    {    inherit RXML.Frame;       array do_return(RequestID id)    {    mapping a = get_my_args( check_args( args ), id );    args -= a;    string ext = ""; +  string filename = ""; +  if(args->filename && sizeof(args->filename)) +  filename += "/" + m_delete(args, "filename");    if(do_ext)    ext = "." + (a->format || "gif"); -  args->src = query_absolute_internal_location( id ) -  + the_cache->store( a, id ) + ext; +  args->src = Roxen.http_encode_invalids( query_absolute_internal_location( id ) +  + the_cache->store( a, id ) + filename + ext +  );    int no_draw = !id->misc->generate_images;    if( mapping size = the_cache->metadata( a, id, no_draw ) )    {    // image in cache (no_draw above prevents generation on-the-fly)    args->width = size->xsize;    args->height = size->ysize;    }    int xml=!args->noxml;    m_delete(args, "noxml");    result = Roxen.make_tag( "img", args, xml );
Roxen.git/server/modules/graphics/cimg.pike:440:    inherit RXML.Tag;    constant name = "cimg-url";    constant flags = RXML.FLAG_EMPTY_ELEMENT;       class Frame    {    inherit RXML.Frame;       array do_return(RequestID id)    { -  result = query_absolute_internal_location(id) +  string filename = ""; +  if(args->filename && sizeof(args->filename)) +  filename = "/" + m_delete(args, "filename"); +  result = Roxen.http_encode_invalids( query_absolute_internal_location(id)    + the_cache->store(get_my_args(check_args( args ), id ), id) -  + (do_ext ? "." + (args->format || "gif") : ""); +  + filename +  + (do_ext ? "." + (args->format || "gif") : "") +  );    return 0;    }    }   }