Only in VirtualKB/Backend: CVS
Only in VirtualKB/Backend/DiskCache: CVS
Only in VirtualKB/Backend/RestClient: CVS
diff -ur vkbdev/Backend/RestClient/KbDoc.pm VirtualKB/Backend/RestClient/KbDoc.pm
vkbdev/​Backend/​RestClient/​KbDoc.​pmVirtualKB/​Backend/​RestClient/​KbDoc.​pm
11 sub·​create_url·​{11 sub·​create_url·​{
12 ····​my·​$self·​=·​shift;​12 ····​my·​$self·​=·​shift;​
13 ····​my·​$base_url·​=·​$self-​>create_base_url;​13 ····​my·​$base_url·​=·​$self-​>create_base_url;​
14 ····​my·​$url·​=·​$base_url.​·​'v0/​document/​'·​.​·​$self-​>get_docid·.​·'.​xhtml?ldapaudiences=o​ncoursecl';​14 ····​my·​$url·​=·​$base_url.​·​'document/​'·​.​·​$self-​>get_audience·.​·
15 »       ​'/​'·​.​·​$self-​>get_docid·​.​·​'.​xml?domain='·​.​·​$self-​>get_domain;​
15 ····​$self-​>set_url($url)​;​16 ····​$self-​>set_url($url)​;​
16 }17 }
17 18
diff -ur vkbdev/Backend/RestClient/Search.pm VirtualKB/Backend/RestClient/Search.pm
vkbdev/​Backend/​RestClient/​Search.​pmVirtualKB/​Backend/​RestClient/​Search.​pm
12 sub·​create_url·​{12 sub·​create_url·​{
13 ····​my·​$self·​=·​shift;​13 ····​my·​$self·​=·​shift;​
14 ····​my·​$encoded_query·​=·​URI:​:​URL-​>new($self-​>get_query)​;​14 ····​my·​$encoded_query·​=·​URI:​:​URL-​>new($self-​>get_query)​;​
15 ····​my·​$url·​=·​$self-​>create_base_url·​.​·​'v0/​search.​json?q='·​.​·​$encoded_query-​>as_string;​15 ····​my·​$url·​=·​$self-​>create_base_url·​.​·​'search/​'·​.​·​$self-​>get_audience·.​·
16 »       ​'?domain='·​.​·​$self-​>get_domain·​.​·​'&query='·​.​·​$encoded_query-​>as_string;​
16 ····​$self-​>set_url($url)​;​17 ····​$self-​>set_url($url)​;​
17 }18 }
18 19
diff -ur vkbdev/Backend/RestClient.pm VirtualKB/Backend/RestClient.pm
vkbdev/​Backend/​RestClient.​pmVirtualKB/​Backend/​RestClient.​pm
22 ····​my·​$useragent·​=·​$self-​>create_useragent;​22 ····​my·​$useragent·​=·​$self-​>create_useragent;​
23 ····​my·​$result·​=·​$useragent-​>request($request)​;​23 ····​my·​$result·​=·​$useragent-​>request($request)​;​
24 ····​unless·​($result-​>is_success)​·​{24 ····​unless·​($result-​>is_success)​·​{
25 ········​http_error·​"Could·​not·​retrieve·​\"".​·​ref·​($self)​·​.​"\":​·"·.​·$result-​>status_line.​"\n";​25 ········​http_error·​"Could·​not·​retrieve·​\"".​·​ref·​($self)​·​.​"\"·from·".​·
26 »       ​····​$self-​>get_url.​":​·​"·​.​·​$result-​>status_line.​"\n";​
26 ····​}27 ····​}
27 ····$self-​>set_input_string($re​sult-​>content)​;​28 ····my·$content·=·$result-​>content;​
29 ····​$content·​=~·​s/​encoding="ascii"\?>/​encoding="US-​ASCII"?>/​;​
30 ····​$self-​>set_input_string($co​ntent)​;​
28 }31 }
29 32
30 sub·​create_useragent·​{33 sub·​create_useragent·​{
31 ····​my·​$self·​=·​shift;​34 ····​my·​$self·​=·​shift;​
32 ····​my·​$ua·​=·​LWP:​:​UserAgent-​>new()​;​35 ····​my·​$ua·​=·​LWP:​:​UserAgent-​>new()​;​····
33 ····​$ua-​>timeout(100)​;​36 ····​$ua-​>timeout(100)​;​
34 ····​return·​$ua;​37 ····​return·​$ua;​
35 }38 }
36 39
37 sub·​create_base_url·​{40 sub·​create_base_url·​{
38 ····​my·​$self·​=·​shift;​41 ····​my·​$self·​=·​shift;​
39 ····​my·​$base_url·​=·​'https:​/​/​'·​.​·​$self-​>get_username·​.​·​':​'42 ····​my·​$base_url·​=·​'http:​/​/​'·​.​·​$self-​>get_username·​.​·​':​'·
40 »       ​.​·​$self-​>get_password·​.​·​'@'·​.​43 »       ​.​·​$self-​>get_password·​.​·​'@'·​.​·
41 »       ​$self-​>get_server·​.​·​'/​';​44 »       ​$self-​>get_server·.​·'/​'·.​·$self-​>get_domain_class·​.​·​'/​';​·
42 ····​return·​$base_url;​45 ····​return·​$base_url;​
43 }46 }
44 47
Only in VirtualKB/: CVS
Only in VirtualKB/: .cvsignore
diff -ur vkbdev/default.conf VirtualKB/default.conf
vkbdev/​default.​confVirtualKB/​default.​conf
1 audience»       ​oncoursehelp1 audience»       ​oncoursecl
2 backend·········​Backend:​:​RestClient2 backend·········​Backend:​:​RestClient
3 cache_dir·······​/​ip/​sakaikb/​wwws/​oncoursecl3 cache_dir·······​/​ip/​sakaikb/​wwws/​oncoursecl
4 debug···········14 nodebug
5 domain_class····​oncoursehelp5 domain_class····​oncoursecl
6 domain··········​oncoursehelp6 domain··········​oncoursecl
7 file_type»      ​html7 file_type»      ​html
8 #·reg·password8 password········C5R8P585US
9 password·········wFxs271scjXxhG4h9 server··········remote.​kb.​iu.​edu/​REST/​v0.​2
10 #·stg·password10 username········oncourse
11 #password········Ncbl564gCvk2vnJL11 xslt_file·······/​ip/​sakaikb/​VirtualKB/​XSLT/​kbxml_to_html.​xslt
12 #legacy·​password12 xslt_head_file··/​ip/​sakaikb/​VirtualKB/​XSLT/​head.​xslt
13 #password········C5R8P585US13 xslt_pre_file···/​ip/​sakaikb/​VirtualKB/​XSLT/​kbxml_preprocess.​xslt
14 server··········rest-​test.​kb.​iu.​edu/​kmsrest-​reg14 config_file·····/​ip/​sakaikb/​OncourseHelpTool/​oht_default.​conf
15 #server··········remote.​kb.​iu.​edu/​REST/​v0.​2
16 username········oncoursehelp
17 #username········oncourse
18 #current_dir·is·an·Appconfig·variable·we·set·to·be·the·directory·of·the·currently·read·file·in·the·config·sub.​
19 #xslt_file·······$(current_dir)​XSLT/​xhtml.​xslt
20 xslt_file·······/​ip/​sakaikb/​vkbdev/​XSLT/​xhtml.​xslt
21 ##·Below·are·old·values
22 #xslt_file·······/​ip/​sakaikb/​VirtualKB/​XSLT/​kbxml_to_html.​xslt
23 xslt_head_file··/​ip/​sakaikb/​vkbdev/​XSLT/​head.​xslt
24 xslt_pre_file···/​ip/​sakaikb/​vkbdev/​XSLT/​kbxml_preprocess.​xslt
25 config_file·····/​ip/​sakaikb/​ohtdev/​oht_default.​conf
Only in VirtualKB/: ._.DS_Store
Only in VirtualKB/: .DS_Store
diff -ur vkbdev/Exceptions.pm VirtualKB/Exceptions.pm
vkbdev/​Exceptions.​pmVirtualKB/​Exceptions.​pm
9 »       ​»       ​·​rest_error9 »       ​»       ​·​rest_error
10 »       ​»       ​·​bad_docid_error10 »       ​»       ​·​bad_docid_error
11 »       ​»       ​·​xslt_error11 »       ​»       ​·​xslt_error
12 ·········​json_error
13 »       ​»       ​·​)​;​12 »       ​»       ​·​)​;​
14 13
15 use·​Exception:​:​Class14 use·​Exception:​:​Class·
16 ····​(·​'VirtualKB:​:​Exception',​15 ····​(·​'VirtualKB:​:​Exception',​
17 16
18 ······​'VirtualKB:​:​Exception:​:​BadConfig'·​=>17 ······​'VirtualKB:​:​Exception:​:​BadConfig'·​=>
59 ······​{·​description·​=>·​'problem·​while·​transforming·​xml',​58 ······​{·​description·​=>·​'problem·​while·​transforming·​xml',​
60 »       ​isa·​=>·​'VirtualKB:​:​Exception',​59 »       ​isa·​=>·​'VirtualKB:​:​Exception',​
61 »       ​alias·​=>·​'xslt_error'},​60 »       ​alias·​=>·​'xslt_error'},​
62
63 ······​'VirtualKB:​:​Exception:​:​JsonError'·​=>
64 ······​{·​description·​=>·​'problem·​while·​transforming·​json·​search·​results',​
65 »       ​isa·​=>·​'VirtualKB:​:​Exception',​
66 »       ​alias·​=>·​'json_error'},​
67 ······​)​;​61 ······​)​;​
68 62
69 #·​Uncomment·​to·​turn·​on·​stack·​trace·​reporting63 #·​Uncomment·​to·​turn·​on·​stack·​trace·​reporting
70 #·​OK·​this·​is·​weird.​·​When·​trace·​is·​not·​on,​·​CGI:​:​Application·​catches·​any·​die·​signals·​even·​if·​you've·​wrapped·​them·​in·​evals.​64 #·​OK·​this·​is·​weird.​·​When·​trace·​is·​not·​on,​·​CGI:​:​Application·​catches·​any·​die·​signals·​even·​if·​you've·​wrapped·​thm·​in·​evals.​
71 VirtualKB:​:​Exception-​>Trace(·​1·​)​;​65 VirtualKB:​:​Exception-​>Trace(·​1·​)​;​
72 66
73 1;​67 1;​
diff -ur vkbdev/KbDocBase.pm VirtualKB/KbDocBase.pm
vkbdev/​KbDocBase.​pmVirtualKB/​KbDocBase.​pm
9 sub·​new·​{9 sub·​new·​{
10 ····​my·​($class,​·​$config)​·​=·​@_;​10 ····​my·​($class,​·​$config)​·​=·​@_;​
11 ····​my·​$self·​=·​$class-​>SUPER:​:​new($config)​;​11 ····​my·​$self·​=·​$class-​>SUPER:​:​new($config)​;​
12 ····​missing_arg_error·​'Failure·​creating·​"'.​$class·​.​12 ····​missing_arg_error·​'Failure·​creating·​"'.​$class·​.​·
13 »       ​'"·​instance:​·​missing·​docid'·​unless·​$self-​>get_docid;​13 »       ​'"·​instance:​·​missing·​docid'·​unless·​$self-​>get_docid;​
14 ····​return·​$self;​14 ····​return·​$self;​
15 }15 }
22 ····​#·​stored·​in·​outputString·​so·​we·​don't·​need·​to·​do·​anything·​else22 ····​#·​stored·​in·​outputString·​so·​we·​don't·​need·​to·​do·​anything·​else
23 ····​return·​$self·​if·​$self-​>get_output_string;​23 ····​return·​$self·​if·​$self-​>get_output_string;​
24 ····​$self-​>basic_processing;​24 ····​$self-​>basic_processing;​
25 ····​$self-​>transform_pre_proces​s;​
25 ····​$self-​>transform_to_html;​26 ····​$self-​>transform_to_html;​
26 ····​return·​$self;​27 ····​return·​$self;​
27 }28 }
Only in VirtualKB/: PathConfig.pm
diff -ur vkbdev/SearchBase.pm VirtualKB/SearchBase.pm
vkbdev/​SearchBase.​pmVirtualKB/​SearchBase.​pm
18 18
19 sub·​process·​{19 sub·​process·​{
20 ····​my·​$self·​=·​shift;​20 ····​my·​$self·​=·​shift;​
21 ····​$self-​>json_to_hash;​21 ····​$self-​>basic_processing;​
22 ····​$self-​>transform_to_hash;​
22 ····​return·​$self;​23 ····​return·​$self;​
23 }24 }
24 25
Only in vkbdev/: .svn
diff -ur vkbdev/VirtualKB.pm VirtualKB/VirtualKB.pm
vkbdev/​VirtualKB.​pmVirtualKB/​VirtualKB.​pm
1 package·​VirtualKB;​1 package·​VirtualKB;​
2 use·​strict;​2 use·​strict;​
3 use·​warnings;​3 use·​warnings;​
4 #·use·just·the·cpanm·default·perl5·library·path·and·consolidate·everything·that4 use·lib·qw(·/​ip/​sakaikb/​local/​lib/​perl5/​site_perl/​5.​8.​8·)​;​
5 #·was·installed·in·all·the·various·cpan·lib·paths
6 use·lib·qw(/​ip/​sakaikb/​perl5/​lib/​perl5)​;​
7
8 #·import·the·expand·and·argcount·constant·tagsets
9 use·​AppConfig·​qw(:​expand·​:​argcount)​;​5 use·​AppConfig·​qw(:​expand·​:​argcount)​;​
10 use·​Data:​:​Dumper;​6 use·​Data:​:​Dumper;​
11 use·​vars·​'$AUTOLOAD';​7 use·​vars·​'$AUTOLOAD';​
12 use·​XML:​:​LibXML;​8 use·​XML:​:​LibXML;​
13 use·​XML:​:​LibXSLT;​9 use·​XML:​:​LibXSLT;​
14 use·​XML:​:​Simple;​10 use·​XML:​:​Simple;​
11 use·​PathConfig;​
15 use·​Exceptions;​12 use·​Exceptions;​
16 use·​JSON:​:​Parse·​'parse_json';​
17 13
18 #FIXME:​·​use·​the·​VirtualKB·​namespace·​for·​all·​packages14 #FIXME:​·​use·​the·​VirtualKB·​namespace·​for·​all·​packages
19 15
20 #·​set·​up·​the·​configuration·​object·​using·​AppConfig16 #·​set·​up·​the·​configuration·​object·​using·​AppConfig
21 our·​$config·​=·​AppConfig-​>new(17 our·​$config·​=·​AppConfig-​>new({
22 ····​{18 ····GLOBAL·=>·​{
23 ········GLOBAL·=>·{19 »       ​ARGCOUNT·=>·ARGCOUNT_ONE,​
24 ············ARGCOUNT·=>·ARGCOUNT_ONE,​20 ····},​
25 ············EXPAND···=>·EXPAND_VAR21 })​;​
26 ········},​
27 ····}
28 )​;​
29
30 #·don't·try·to·load·the·xhtml·1.​1·DTD·from·W3C;​·it·is·unnecessary·and
31 #·they·deliberately·respond·very·slowly·(~15s)​·to·conserve·resources
32 22
33 my·​$xml_parser··​=·​XML:​:​LibXML-​>new(load_ext_dtd·=>·0)​;​23 my·​$xml_parser·​=·​XML:​:​LibXML-​>new()​;​
34 my·​$xslt_parser·​=·​XML:​:​LibXSLT-​>new()​;​24 my·​$xslt_parser·​=·​XML:​:​LibXSLT-​>new()​;​
35 25
36 set_up_config()​;​26 set_up_config()​;​
40 sub·​new·​{30 sub·​new·​{
41 ····​my·​(·​$class,​·​$config·​)​·​=·​@_;​31 ····​my·​(·​$class,​·​$config·​)​·​=·​@_;​
42 32
43 ····​return·​bless(33 ····​return·​bless(·{·$config-​>varlist(".​*")​,​
44 ········{34 »       ​»       ​····#·for·an·explanation·of·why·xml_simple_params·is
45 ············$config-​>varlist(".​*")​,​35 »       ​»       ​····#·handled·differently,​·see·the·comments·at·the
46 36 »       ​»       ​····#·bottom·of·sub·config
47 ············#·for·an·explanation·of·why·xml_simple_params·is37 »       ​»       ​····xml_simple_params=>·$config-​>{xml_simple_params},​
48 ············#·handled·​differently,​·see·the·comments·at·the38 »       ​»       ​····​data_source=>·undef,​
49 ············#·bottom·of·sub·config39 »       ​»       ​····input_string=>·'',​
50 ············xml_simple_params·=>·$config-​>{xml_simple_params},​40 »       ​»       ​····output_string=>·'',​
51 ············data_source·······=>·undef,​41 »       ​»       ​····​output_hash=>·{},​
52 ············input_string······=>·'',​42 »       ​»       ​····xml_obj=>·undef,​
53 ············output_string·····=>·'',​43 »       ​»       ​},​·$class·)​;​
54 ············output_hash·······=>·{},​
55 ············xml_obj···········=>·undef,​
56 ········},​
57 ········$class
58 ····)​;​
59 }44 }
60 45
61 sub·​config·​{46 sub·​config·​{
62 ····​my·​(·$class,​·​%args·)​·​=·​@_;​47 ····​my·​($class,​·​%args)​·​=·​@_;​
63 48
64 ····​#·​read·​in·​values·​from·​the·​default·​config·​file·​first·​to·​let49 ····​#·​read·​in·​values·​from·​the·​default·​config·​file·​first·​to·​let
65 ····​#·​values·​in·​user·​files·​overwrite·​them.​50 ····​#·​values·​in·​user·​files·​overwrite·​them.​
66 ····my·(·$volume,​·​$directory,​·$file·)​·=·File:​:​Spec-​>splitpath(__FILE__)​;​51 ····​$config-​>file(PathConfig:​:​CONFIGFILE)​;​
67 ····$config-​>file(·$directory·.​·"default.​conf"·)​;​
68 52
69 ····​#·​initialize·​the·​config_file·​variable·​from·​the·​config_file·​arg·​so53 ····​#·​initialize·​the·​config_file·​variable·​from·​the·​config_file·​arg·​so
70 ····​#·​if·​there·​is·​one·​submitted,​·​we·​can·​load·​and·​read·​in·​values·​from54 ····​#·​if·​there·​is·​one·​submitted,​·​we·​can·​load·​and·​read·​in·​values·​from
72 ····​#·​params·​will·​override·​values·​from·​the·​file.​·​Also,​·​fall·​back·​to56 ····​#·​params·​will·​override·​values·​from·​the·​file.​·​Also,​·​fall·​back·​to
73 ····​#·​the·​config_file·​specified·​in·​default.​conf·​in·​the·​case·​where·​one57 ····​#·​the·​config_file·​specified·​in·​default.​conf·​in·​the·​case·​where·​one
74 ····​#·​wasn't·​supplied.​58 ····​#·​wasn't·​supplied.​
75 ····​$config-​>config_file(·$args{config_file}·)​·​if·​$args{config_file};​59 ····​$config-​>config_file($args{co​nfig_file})​·​if·​$args{config_file};​
76 60
77 ····​#·​if·​no·​configfile·​was·​submitted·​AppConfig·​won't·​complain,​·​so·​it's61 ····​#·​if·​no·​configfile·​was·​submitted·​AppConfig·​won't·​complain,​·​so·​it's
78 ····​#·​ok·​if·​$config-​>config_file·​is·​undef62 ····​#·​ok·​if·​$config-​>config_file·​is·​undef
79 ····​$config-​>file(·$config-​>config_file·)​;​63 ····​$config-​>file($config-​>config_file)​;​
80
81 #·Create·a·full·path·to·file·locations·by·building·it·from·the
82 #·location·of·the·this·(i.​e.​,​·VirtualKB.​pm)​·file·rather·than·using·absolute·paths.​
83 ····$config-​>current_dir($directo​ry)​;​
84 64
85 ····​#·​finally,​·​set·​the·​variables·​with·​the·​arguments65 ····​#·​finally,​·​set·​the·​variables·​with·​the·​arguments
86 ····​for·​my·​$key·​(·keys·​%args·)​·​{66 ····​for·​my·​$key·​(keys·​%args)​·​{
87 67 »       ​#·check·if·arg·is·a·ref·
88 ········#·check·if·​arg·is·a·ref68 »       ​if·(my·$type·=·ref·$args{$key})​·{
89 ········​if·(·my·$type·=·ref·$args{$key}·)​·{69 »       ​····#·​if·it's·a·hashref,​·deref·it
90 70 »       ​····if·($type·eq·'HASH')​·{
91 ············#·if·it's·a·hashref,​·deref·it71 »       ​»       ​for·my·$inner_key·(keys·%{$args{$key}})​·{
92 ············​if·(·$type·​eq·'HASH'·)​·{72 »       ​»       ​····#·This·​is·how·AppConfig·requires·hashes·to·be
93 ················for·my·$inner_key·(·keys·%{·$args{$key}·}·)​·{73 »       ​»       ​····$config-​>$key($inner_key.​"=".​$args{$key}-​>{$inner_key})​;​
94 74 »       ​»       ​}
95 ····················#·This·is·how·AppConfig·requires·hashes·to·be75 »       ​····}
96 ····················$config-​>$key(76 »       ​····else·{
97 ························$inner_key·.​·"="·.​·$args{$key}-​>{$inner_key}·)​;​77 »       ​»       ​bad_config_error·"Illegal·config·arg·of·type·'$type',​·arg·'$key'.​";​
98 ················​}78 »       ​····​}
99 ············}79 »       ​}
100 ············else·​{80 »       ​else·​{
101 ················bad_config_error81 »       ​····$config-​>set($key=>·$args{$key})​;​
102 ··················"Illegal·config·arg·of·type·'$type',​·arg·'$key'.​";​82 »       ​}
103 ············}
104 ········}
105 ········else·{
106 ············$config-​>set(·$key·=>·$args{$key}·)​;​
107 ········}
108 ····​}83 ····​}
109 84
110 ····​#·​Because·​AppConfig·​can't·​handle·​nested·​hashes,​·​we·​need·​to·​handle85 ····​#·​Because·​AppConfig·​can't·​handle·​nested·​hashes,​·​we·​need·​to·​handle
114 ····​#·​and·​can't·​be·​specified·​on·​the·​command·​line·​either.​·​It's·​a89 ····​#·​and·​can't·​be·​specified·​on·​the·​command·​line·​either.​·​It's·​a
115 ····​#·​hack.​·​Config:​:​YAML·​FIXME?90 ····​#·​hack.​·​Config:​:​YAML·​FIXME?
116 ····​$config-​>{xml_simple_params}·​=·​$args{xml_simple_para​ms}·​||·​{};​91 ····​$config-​>{xml_simple_params}·​=·​$args{xml_simple_para​ms}·​||·​{};​
117
118 ····​return·​$config;​92 ····​return·​$config;​
119 }93 }
120 94
129 #·​rather·​than·​us,​·​to·​handle·​it,​·​so·​we·​run·​config·​before·​instantiating.​103 #·​rather·​than·​us,​·​to·​handle·​it,​·​so·​we·​run·​config·​before·​instantiating.​
130 104
131 sub·​do_search·​{105 sub·​do_search·​{
132 ····​my·​(·$class,​·​%args·)​·​=·​@_;​106 ····​my·​($class,​·​%args)​·​=·​@_;​
133 ····​my·​$config·​=·​$class-​>config(%args)​;​107 ····​my·​$config·​=·​$class-​>config(%args)​;​
134 ····​return·​$class-​>_get_item(·$config,​·'Search'·)​;​108 ····​return·​$class-​>_get_item($config,​'Search')​
135 }109 }
136 110
137 sub·​get_doc·​{111 sub·​get_doc·​{
138 ····​my·​(·$class,​·​%args·)​·​=·​@_;​112 ····​my·​($class,​·​%args)​·​=·​@_;​
139 ····​my·​$config·​=·​$class-​>config(%args)​;​113 ····​my·​$config·​=·​$class-​>config(%args)​;​
140 ····​return·​$class-​>_get_item(·$config,​·'KbDoc'·)​;​114 ····​return·​$class-​>_get_item($config,​'KbDoc')​
141 }115 }
142 116
143 sub·​get_doc_list·​{117 sub·​get_doc_list·​{
144 ····​my·​(·$class,​·​%args·)​·​=·​@_;​118 ····​my·​($class,​·​%args)​·​=·​@_;​
145 ····​my·​$config·​=·​$class-​>config(%args)​;​119 ····​my·​$config·​=·​$class-​>config(%args)​;​
146 ····​return·​$class-​>_get_item(·$config,​·'DocList'·)​;​120 ····​return·​$class-​>_get_item($config,​'DocList')​
147 }121 }
148 122
149 ###·​PACKAGE·​FUNCTIONS·​###123 ###·​PACKAGE·​FUNCTIONS·​###
150 124
151 sub·​DESTROY·{·}125 sub·​DESTROY{};​
152 126
153 sub·​AUTOLOAD·​{127 sub·​AUTOLOAD·​{
154
155 ····​#·​From·​Conway·​OOP·​p.​·​93128 ····​#·​From·​Conway·​OOP·​p.​·​93
156 ····​no·​strict·​"refs";​129 ····​no·​strict·​"refs";​
157 ····​my·​(·​$self,​·​$newval·​)​·​=·​@_;​130 ····​my·​(·​$self,​·​$newval·​)​·​=·​@_;​
158
159 ····​#·​Was·​it·​a·​get_.​.​.​·​method?131 ····​#·​Was·​it·​a·​get_.​.​.​·​method?
160 ····​if·​(·$AUTOLOAD·​=~·​/​.​*:​:​get_(\w+)​/​·)​·​{132 ····​if·​($AUTOLOAD·​=~·​/​.​*:​:​get_(\w+)​/​)​·​{
161 ········​my·​$attr_name·​=·​$1;​133 ········​my·​$attr_name·​=·​$1;​
162 ········​*{$AUTOLOAD}·​=·​sub·​{·return·​$_[0]-​>{$attr_name}·​};​134 ········​*{$AUTOLOAD}·​=·​sub·​{return·​$_[0]-​>{$attr_name}·​};​
163 ········​return·​$self-​>{$attr_name};​135 ········​return·​$self-​>{$attr_name};​
164 ····​}136 ····​}
165
166 ····​#·​Was·​it·​a·​set_.​.​.​·​method?137 ····​#·​Was·​it·​a·​set_.​.​.​·​method?
167 ····​elsif·​(·$AUTOLOAD·​=~·​/​.​*:​:​set_(\w+)​/​·)​·​{138 ····​elsif·​($AUTOLOAD·​=~·​/​.​*:​:​set_(\w+)​/​)​·​{
168 ········​my·​$attr_name·​=·​$1;​139 ········​my·​$attr_name·​=·​$1;​
169 ········​*{$AUTOLOAD}·​=·​sub·​{·​$_[0]-​>{$attr_name}·​=·​$_[1];​·​return·};​140 ········​*{$AUTOLOAD}·​=·​sub·​{·​$_[0]-​>{$attr_name}·​=·​$_[1];​·​return};​
170 ········​$self-​>{$1}·​=·​$newval;​141 ········​$self-​>{$1}·​=·​$newval;​
171 ········​return;​142 ········​return;​
172 ····​}143 ····​}
173 ····die·​"No·​such·​method:​·​$AUTOLOAD";​144 ····warn·​"No·​such·​method:​·​$AUTOLOAD";​
174 }145 }
175 146
176 sub·​set_up_config·​{147 sub·​set_up_config·​{
177
178 ····​#·​define·​the·​config·​variables148 ····​#·​define·​the·​config·​variables
179 ····​$config-​>define(149 ····​$config-​>define(·qw(audience·
180 ········qw(audience150 »       ​»       ​»       ​backend·
181 ··········backend151 »       ​»       ​»       ​cache_dir·
182 ··········cache_dir152 »       ​»       ​»       ​config_file
183 ··········config_file153 »       ​»       ​»       ​debug!
184 ··········current_dir154 »       ​»       ​»       ​docid
185 ··········debug!155 »       ​»       ​»       ​domain_class·
186 ··········docid156 »       ​»       ​»       ​domain·
187 ··········domain_class157 »       ​»       ​»       ​file_type
188 ··········domain158 »       ​»       ​»       ​password·
189 ··········file_type159 »       ​»       ​»       ​query
190 ··········password160 »       ​»       ​»       ​server·
191 ··········query161 »       ​»       ​»       ​username·
192 ··········server162 »       ​»       ​»       ​xslt_file·
193 ··········username163 »       ​»       ​»       ​xslt_head_file
194 ··········xslt_file164 »       ​»       ​»       ​xslt_pre_file
195 ··········xslt_head_file165 »       ​»       ​»       ​xslt_params=s%
196 ··········xslt_pre_file166 »       ​»       ​»       ​)​
197 ··········xslt_params=s%167 »       ​»       ​·····)​;​
198 ··········)​
199 ····)​;​
200 }168 }
201 169
202 ###·​PRIVATE·​CLASS·​METHODS·​###170 ###·​PRIVATE·​CLASS·​METHODS·​###
203 171
204 sub·​_get_item·​{172 sub·​_get_item·​{
205 ····​my·​(·$class,​·$config,​·$item_type·)​·​=·​@_;​173 ····​my·​($class,​$config,​$item_type)​·​=·​@_;​
206 ····​my·​$class_to_instantiate​·​=174 ····​my·​$class_to_instantiate​·​=·VirtualKB-​>_make_package_name($​config-​>backend,​$item_type)​;​
207 ······VirtualKB-​>_make_package_name(·$config-​>backend,​·$item_type·)​;​
208 ····​my·​$item;​175 ····​my·​$item;​
209 ····​eval·​{·$item·=·$class_to_instantiate​-​>new($config)​;​·};​176 ····​eval·​{
210 ····if·(·my·$e·=·$@·)​·{177 »       ​$item·=·$class_to_instantiate​-​>new($config)​;​
211 ········bad_backend_error178 ····};​
212 ··········"Can't·instantiate·an·object·to·retrieve·a·\"$item_type\":​·$e";​179 ····​if·(my·$e·=·​$@)​·{
180 »       ​bad_backend_error·​"Can't·​instantiate·​an·​object·​to·​retrieve·​a·​\"$item_type\":​·​$e";​
213 ····​}181 ····​}
214 ····​$item-​>retrieve;​182 ····​$item-​>retrieve;​
215 ····​$item-​>process;​183 ····​$item-​>process;​
217 }185 }
218 186
219 sub·​_make_package_name·​{187 sub·​_make_package_name·​{
220 ····​my·​(·$class,​·$backend,​·$type·)​·​=·​@_;​188 ····​my·​($class,​$backend,​$type)​·​=·​@_;​
221 ····​my·​$backend_package_name​·​=·​$backend·​.​·​":​:​$type";​189 ····​my·​$backend_package_name​·​=·​$backend·​.​·​":​:​$type";​
222
223 ····​#·​must·​eval·​the·​requiring·​of·​a·​non-​bareword·​package·​name190 ····​#·​must·​eval·​the·​requiring·​of·​a·​non-​bareword·​package·​name
224 ····​eval·​"require·​$backend_package_name​";​191 ····​eval·​"require·​$backend_package_name​";​
225 ····​return·​$backend_package_name​;​192 ····​return·​$backend_package_name​;​
234 }201 }
235 202
236 sub·​transform_pre_process​·​{203 sub·​transform_pre_process​·​{
237 ····​my·​$self····​=·​shift;​204 ····​my·​$self·​=·​shift;​
238 ····​my·​$xml_obj·​=·​$self-​>_transform_base(·$self-​>get_xslt_pre_file·)​;​205 ····​my·​$xml_obj·​=·​$self-​>_transform_base($sel​f-​>get_xslt_pre_file)​;​
239 ····​$self-​>set_xml_obj($xml_obj​)​;​206 ····​$self-​>set_xml_obj($xml_obj​)​;​
240 }207 }
241 208
242 sub·​transform_to_hash·​{209 sub·​transform_to_hash·​{
243 ····​my·​$self···​=·​shift;​210 ····​my·​$self·​=·​shift;​
244 ····​my·​$simple·​=·​XML:​:​Simple-​>new(·%{·$self-​>get_xml_simple_param​s·}·)​;​211 ····​my·​$simple·​=·​XML:​:​Simple-​>new(%{$self-​>get_xml_simple_param​s})​;​
245 ····​my·​$hash;​212 ····​my·​$hash;​
246 ····​eval·​{·$hash·=·$simple-​>XMLin(·$self-​>get_input_string·)​;​·};​213 ····​eval·​{·
247 ····if·​(·my·$e·=·$@·​)​·{214 »       ​$hash·=·$simple-​>XMLin·​(·$self-​>get_input_string·​)​;​
248 ········xslt_error·"Couldn't·transform·"215 ····};​
249 ··········.​·ref($self)​216 ····if·(my·$e·=·$@)​·{
250 ··········.​·"·​to·​hash·​with·​XML:​:​Simple:​·​"217 »       ​xslt_error·"Couldn't·transform·".​ref($self)​.​"·​to·​hash·​with·​XML:​:​Simple:​·​"·.​·$e;​
251 ··········.​·$e;​218 ····}·
252 ····}219 ····$self-​>set_output_hash(·$hash·)​;​
253 ····$self-​>set_output_hash($has​h)​;​
254 }220 }
255 221
256 sub·​transform_to_html·​{222 sub·​transform_to_html·​{
257 ····​my·​$self·​=·​shift;​223 ····​my·​$self·​=·​shift;​
258 ····​$self-​>_transform_base(·$self-​>get_xslt_file·)​;​224 ····​$self-​>_transform_base($sel​f-​>get_xslt_head_file)​;​
225 ····​my·​$style·​=·​$self-​>get_output_string;​
226 ····​$self-​>_transform_base($sel​f-​>get_xslt_file)​;​
227 ····​my·​$body·​=·​$self-​>get_output_string;​
228 ····​$self-​>set_output_style($st​yle)​;​
229 ····​$self-​>set_output_string($b​ody)​;​
259 }230 }
260 231
261 sub·​json_to_hash·​{
262 ····​my·​$self·​=·​shift;​
263 ····​my·​$hash;​
264 ····​eval·​{·​$hash·​=·​parse_json(·​$self-​>get_input_string·​)​;​·​};​
265 ····​if·​(·​my·​$e·​=·​$@·​)​·​{
266 ········​json_error·​"Couldn't·​transform·​"
267 ··········​.​·​ref($self)​
268 ··········​.​·​"·​to·​hash·​with·​JSON:​:​Parse:​·​"
269 ··········​.​·​$e;​
270 ····​}
271 ····​$self-​>set_output_hash($has​h)​;​
272 }
273 ###·​PRIVATE·​XML·​METHODS·​###232 ###·​PRIVATE·​XML·​METHODS·​###
274 233
275 sub·​_check_xml_for_proble​ms·​{234 sub·​_check_xml_for_proble​ms·​{
276 ····​my·​$self·​=·​shift;​235 ····​my·​$self·​=·​shift;​
277 ····​my·​$root_node;​236 ····​my·​$root_node;​
278 ····​eval·​{·$root_node·=·$self-​>get_xml_obj-​>documentElement()​;​·};​237 ····​eval·​{
279 ····if·($@)​·{238 »       ​$root_node·=·$self-​>get_xml_obj-​>documentElement()​;​
280 ········bad_xml_error·"Could·not·find·root·node·in·'"239 ····};​
281 ··········.​·ref($self)​240 ····if·(·​$@·)​·{
282 ··········.​·"'·​retrieved·​from·"241 ····bad_xml_error·"Could·not·find·​root·node·in·'".​ref($self)​.​
283 ··········.​·$self-​>get_url;​242 »       ​····"'·retrieved·from·".​$self-​>get_url;​
284 ····​}243 ····​}
285 244 ····
286 ····​if·​(·$root_node-​>nodeName()​·​eq·​"kberror"·)​·​{245 ····​if·​($root_node-​>nodeName()​·​eq·​"kberror")​·​{
287 ········​my·​$error_class···​=·​$root_node-​>findvalue("/​kberror/​exception")​;​246 ········​my·​$error_class·​=·​$root_node-​>findvalue("/​kberror/​exception")​;​
288 ········​my·​$error_message·​=·​$root_node-​>findvalue("/​kberror/​message")​;​247 ········​my·​$error_message·​=·​$root_node-​>findvalue("/​kberror/​message")​;​
289 ········if·​(·$error_message·​=~·​/​Invalid·​document·​identifier/​·)​·​{248 »       ​if·​($error_message·​=~·​/​Invalid·​document·​identifier/​)​·​{
290 ············​bad_docid_error·​"Document·​"·.​·​$self-​>get_docid·​.​·​"·​doesn't·​exist";​249 »       ​····​bad_docid_error·​"Document·​".​·​$self-​>get_docid·​.​·​"·​doesn't·​exist";​
291 ········}250 »       ​}
292 ········else·​{251 »       ​else·​{
293 ············​rest_error·​"Retrieving·​"252 »       ​····​rest_error·​"Retrieving·​"·.​·$self-​>get_url.​·
294 ··············.​·​$self-​>get_url253 »       ​»       ​"·resulted·in·REST·​$error_message";​
295 ··············.​·"·resulted·in·REST·$error_message";​254 »       ​}
296 ········}
297 ····​}255 ····​}
298 }256 }
299 257
300 sub·​_parse_xml·​{258 sub·​_parse_xml·​{
301 ····​my·​$self·​=·​shift;​259 ····​my·​$self·​=·​shift;​
302 ····​my·​$xml_obj;​260 ····​my·​$xml_obj;​
303 ····​eval·​{·$xml_obj·=·$xml_parser-​>parse_string(·$self-​>get_input_string·)​;​·};​261 ····​eval·​{
262 »       ​$xml_obj·​=·​$xml_parser-​>parse_string(·​$self-​>get_input_string·​)​;​
263 ····​};​
304 ····​if·​(·​my·​$e·​=·​$@·​)​·​{264 ····​if·​(·​my·​$e·​=·​$@·​)​·​{
305 ········​bad_xml_error·​"Could·​not·​parse·​xml·​for·​\""·.​·ref($self)​·.​·"\":​·$e";​265 ········​bad_xml_error·​"Could·​not·​parse·​xml·​for·​\"".​ref($self)​.​
266 »       ​····​"\"·​retrieved·​from·​".​·​$self-​>get_url.​·​":​·​$e";​
306 ····​}267 ····​}
307 268
308 ····​$self-​>set_xml_obj($xml_obj​)​;​269 ····​$self-​>set_xml_obj($xml_obj​)​;​
309 }270 }
310 271
311 sub·​_parse_xslt·​{272 sub·​_parse_xslt·​{
312 ····​my·​(·$self,​·$stylesheet_file·)​·​=·​@_;​273 ····​my·​($self,​$stylesheet_file)​·​=·​@_;​
313 ····​my·​$xml_obj;​274 ····​my·​$xml_obj;​
314 ····​eval·​{·$xml_obj·=·$xml_parser-​>parse_file($styleshe​et_file)​;​·};​275 ····​eval·​{
276 »       ​$xml_obj·​=·​$xml_parser-​>parse_file(·​$stylesheet_file·​)​;​
277 ····​};​
315 ····​if·​(·​my·​$e·​=·​$@·​)​·​{278 ····​if·​(·​my·​$e·​=·​$@·​)​·​{
316 ········​xslt_error·​"Could·​not·​parse·​xslt·​file·​\""·.​·$stylesheet_file·.​·"\":​·$e";​279 ········​xslt_error·​"Could·​not·​parse·​xslt·​file·​\"".​·
280 »       ​····​$stylesheet_file.​"\":​·​$e";​
317 ····​}281 ····​}
318 ····​my·​$stylesheet·​=·​$xslt_parser-​>parse_stylesheet($xm​l_obj)​;​282 ····​my·​$stylesheet·​=·​$xslt_parser-​>parse_stylesheet(·$xml_obj·)​;​
319 ····​return·​$stylesheet;​283 ····​return·​$stylesheet;​
320 }284 }
321 285
322 sub·​_transform_base·​{286 sub·​_transform_base·​{
323 ····​my·​(·$self,​·$stylesheet_file·)​·​=·​@_;​287 ····​my·​($self,​$stylesheet_file)​·​=·​@_;​
324 ····​my·​$stylesheet·​=·​$self-​>_parse_xslt($stylesh​eet_file)​;​288 ····​my·​$stylesheet·​=·​$self-​>_parse_xslt($stylesh​eet_file)​;​
325 ····​my·​$transformed;​289 ····​my·​$transformed;​
326 ····​eval·​{290 ····​eval·​{·
327 ········$transformed·​=·​$stylesheet-​>transform(·$self-​>get_xml_obj,​291 »       ​$transformed·​=·​$stylesheet-​>transform($self-​>get_xml_obj,​·
328 ············​%{·$self-​>get_xslt_params·}·)​;​292 »       ​»       ​»       ​»       ​»       ​······​%{$self-​>get_xslt_params})​;​
329 ····​};​293 ····​};​
330 ····​if·​(·​my·​$e·​=·​$@·​)​·​{294 ····​if·​(·​my·​$e·​=·​$@·​)​·​{
331 ········xslt_error·​"Error·​while·​transforming·​xml·​for·​\""295 »       ​xslt_error·​"Error·​while·​transforming·​xml·​for·​\"".​·
332 ··········​.​·ref($self)​296 »       ​····ref($self)​·​.​·"\":​·$e";​
333 ··········.​·"\":​·$e";​
334 ····​}297 ····​}
335 ····​my·​$output_string·​=·​$stylesheet-​>output_string($trans​formed)​;​298 ····​my·​$output_string·​=·​$stylesheet-​>output_string($trans​formed)​;​
336 ····​$self-​>set_output_string($o​utput_string)​;​299 ····​$self-​>set_output_string($o​utput_string)​;​
Only in VirtualKB/: VirtualKB.pm.~1.3.2.1.~
diff -ur vkbdev/WebInterface.pm VirtualKB/WebInterface.pm
vkbdev/​WebInterface.​pmVirtualKB/​WebInterface.​pm
9 sub·​setup·​{9 sub·​setup·​{
10 ····​my·​$self·​=·​shift;​10 ····​my·​$self·​=·​shift;​
11 ····​$self-​>mode_param(·​\&_set_run_mode·​)​;​11 ····​$self-​>mode_param(·​\&_set_run_mode·​)​;​
12 ····$self-​>header_add(-​type·=>·'text/​html;​·charset=US-​ASCII')​;​12 }
13
14 sub·​search_form·​{
15 ····​my·​$self·​=·​shift;​
16 ····​my·​$template=$self-​>_load_and_config_tmp​l('search_form.​html')​;​
17 ····​my·​$query·​=·​$self-​>query-​>param('query')​;​
18 ····​$template-​>param(·​query·​=>·​$query,​
19 »       ​»       ​······​)​;​
20 ····​return·​$template-​>output;​
13 }21 }
14 22
15 sub·​doc·​{23 sub·​doc·​{
17 ····​my·​$template=$self-​>_load_and_config_tmp​l('html_wrapper.​html')​;​25 ····​my·​$template=$self-​>_load_and_config_tmp​l('html_wrapper.​html')​;​
18 ····​$args{docid}·​||=·​$self-​>param('docid')​;​26 ····​$args{docid}·​||=·​$self-​>param('docid')​;​
19 ····​my·​$doc·​=·​VirtualKB-​>get_doc(%args)​;​27 ····​my·​$doc·​=·​VirtualKB-​>get_doc(%args)​;​
20 ····return·​$doc-​>get_output_string;​28 ····$template-​>param(·body·=>·​$doc-​>get_output_string,​
29 »       ​»       ​······​kb_style·​=>·​$doc-​>get_output_style,​
30 »       ​»       ​··​)​;​
31 ····​return·​$template-​>output;​
21 }32 }
22 33
23 sub·​title·​{34 sub·​title·​{
Only in VirtualKB/XSLT: CVS
Only in vkbdev/XSLT: date.format-date.function.xsl
Only in vkbdev/XSLT: str.padding.function.xsl
Only in vkbdev/XSLT: xhtml.xslt