1 | | |
2 | | |
3 | | |
4 | | |
5 | | |
6 | | |
7 | | |
8 | | |
9 | | |
10 | | |
11 | | |
12 | | |
13 | | |
14 | | |
15 | | |
16 | | |
17 | | |
18 | | |
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | | |
25 | | |
26 | | |
27 | | |
28 | | |
29 | | |
30 | | |
31 | | |
32 | | |
33 | | |
34 | | |
35 | | |
36 | | |
37 | | |
38 | | |
39 | | |
40 | | |
41 | | |
42 | | |
43 | | |
44 | | |
45 | | |
46 | | |
47 | | |
48 | | |
49 | | |
50 | | |
51 | | |
52 | | |
53 | | |
54 | | |
55 | | |
56 | | |
57 | | |
58 | | |
59 | | |
60 | | |
61 | | |
62 | | |
63 | | |
| | | #include <module.h> | | inherit "module"; | inherit "roxenlib"; | | mapping hrefs; | string tagname; | | void create() | { | defvar( "hrefs", "", "Indirect hrefs", TYPE_TEXT_FIELD, | "Syntax:\n" | + "[name] = [URL]\n" ); | defvar( "tagname", "newa", "Tagname", TYPE_STRING, | "Name of the tag\n" | + "<tag name=[name]>foo</tag> will be replaced with\n" | + "<a href=[URL]>foo</a>" ); | } | | mixed *register_module() | { | return ({ | MODULE_PARSER, | "Indirect href", | ("Indirect href") | }); | } | | void start() | { | string *lines, line; | string variable, value, *foo; | string dir = ""; | mapping all = ([ ]); | | hrefs = ([ ]); | if (lines = query( "hrefs" ) /"\n") | foreach (lines, line) | if (sscanf( line, "%s=%s", variable, value ) >= 2) | hrefs[ variable - " " - "\t" ] = value - " " - "\t"; | tagname = query( "tagname" ); | } | | string tag_newa( string tag, mapping m, string q, mapping got ) | { | 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; | } | | mapping query_container_callers() | { | return ([ tagname : tag_newa ]); | } | | | |
|