Roxen.git / server / modules / tags / static_resource.pike

version» Context lines:

Roxen.git/server/modules/tags/static_resource.pike:35:      class TagServeStaticResources   {    inherit RXML.Tag;    constant name = "serve-static-resources";       string mangle_resource_urls(string s, RequestID id)    {    mapping process_tags = query("process_tags");    Parser.HTML parser = Parser.HTML(); +  parser->xml_tag_syntax(0);       function process_tag = lambda(Parser.HTML p, mapping args)    {    string tag_name = p->tag_name();    string attr_name = process_tags[tag_name];    string link = args[attr_name]; -  if(link && link[0] == '/') { +  if(link && has_prefix (link, "/") && !has_prefix (link, "//")) {    array(int)|Stdio.Stat st =    id->conf->try_stat_file(link, id);       if(st) {    if(arrayp(st))    st = Stdio.Stat(st);       string varystr = sprintf("mtime=%d", st->mtime);       args[attr_name] =    Roxen.add_pre_state(link, (< "cache-forever", varystr >)); -  return ({ Roxen.make_tag(tag_name, args, 1, 1) }); +  return ({ Roxen.make_tag(tag_name, args, has_suffix (tag_name, "/"), +  1) });    }    }    return 0;    };    -  foreach(process_tags; string tag_name; string attr_name) +  foreach(process_tags; string tag_name; string attr_name) {    parser->add_tag(tag_name, process_tag); -  +  parser->add_tag(tag_name + "/", process_tag); +  }    -  +  parser->ignore_unknown (1);    string res = parser->finish(s)->read();    parser = 0;    process_tag = 0;    return res;    };       class Frame    {    inherit RXML.Frame;    array do_return(RequestID id)
Roxen.git/server/modules/tags/static_resource.pike:91:       if(id->prestate["cache-forever"]) {    if (res->extra_heads) {    m_delete(res->extra_heads, "cache-control");    m_delete(res->extra_heads, "Cache-Control");    m_delete(res->extra_heads, "expires");    m_delete(res->extra_heads, "Expires");    }       RAISE_CACHE(expire_time); +  PROTO_CACHE();       id->misc->vary = (<>);    return res;    }   }      TAGDOCUMENTATION;   #ifdef manual   constant tagdoc = ([    "serve-static-resources":#"<desc type='tag'><p><short>Specifies a block of tags referring static resources.</short> Wrap this tag around your block of static resource referring tags.</p>   <ex-box>   <serve-static-resources>    <link rel=\"stylesheet\" href=\"/index.css\"/>    <script type=\"text/javascript\" src=\"/index.js\"/>   </serve-static-resources>   </ex-box>   <p>Note: Only local absolute paths will be processed, i.e. they have to begin with a '/'.</p>   </desc>"   ]);   #endif // manual   Newline at end of file added.