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

version» Context lines:

Roxen.git/server/modules/tags/indirect_href.pike:1: - /* This is a Roxen module. Copyright © 1996, 1997, 1998, Idonex AB. + /* This is a Roxen module. Copyright © 1996-1999 Idonex AB.    *    * This module makes it possible to write symbolic names instead of    * absoulte hrefs.    *    * made by Mattias Wingstedt <peter@idonex.se> -96    */    - constant cvs_version = "$Id: indirect_href.pike,v 1.9 1999/05/20 03:26:19 neotron Exp $"; + constant cvs_version = "$Id: indirect_href.pike,v 1.10 1999/12/09 21:40:56 nilsson Exp $";   constant thread_safe=1;   #include <module.h>      inherit "module";   inherit "roxenlib";      mapping hrefs;   string tagname;      void create()
Roxen.git/server/modules/tags/indirect_href.pike:41:    "name=string. It then uses the name to index a database of "    "URLs, and inserts a &lt;a href=...&gt; tag instead. This can "    "be very useful, since you can move all links to a document at "    "once. It also allows the special case 'name=random'. If this "    "is used, a random link will be selected from the database. "    "Example:<pre>"    " roxen=http://www.roxen.com/\n"    " idonex=http://www.idonex.se/</pre>", });   }    + // Dynamic tagname, hence dynamic documentation. + mapping tagdocumentation() { +  return ([tagname:"<desc cont>ai</desc>"]); + } +    void start()   { -  array (string) lines, foo; -  string line; +  array (string) lines;    string variable, value; -  string dir = ""; +     mapping all = ([ ]);       hrefs = ([ ]); -  if (lines = query( "hrefs" ) /"\n") -  foreach (lines, line) +  if (lines = (query( "hrefs" )-" "-"\t") /"\n") +  foreach (lines, string line)    if (sscanf( line, "%s=%s", variable, value ) >= 2) -  hrefs[ variable - " " - "\t" ] = value - " " - "\t"; +  hrefs[ variable ] = value;    tagname = query( "tagname" );   }    - string tag_newa( string tag, mapping m, string q, mapping got ) + string tag_newa(string tag, mapping m, string q)   { -  if (m[ "name" ] && hrefs[ m[ "name" ] ]) -  return "<a href=" + hrefs[ m[ "name" ] ] + ">" + q + "</a>"; -  else if (m[ "random" ]) -  return "<a href=" + values( hrefs )[ random( sizeof( hrefs ) ) ] + ">" -  + q + "</a>"; -  else -  return q; +  if(!m->name && !m->random) return q; +  if(m->name) { +  m->href=hrefs[m->name]; +  m_delete(m, "name");    } -  +  if(m->random) { +  m->href=values(hrefs)[random(sizeof(hrefs))]; +  m_delete(m, "random"); +  } +  return make_container("a",m,q); + }    - mapping query_tag_callers() { return ([]); } -  +    mapping query_container_callers()   {    return ([ tagname : tag_newa ]);   }