/[pub]/suikawiki/script/lib/SuikaWiki/Plugin/WikiDB.wp2
Suika

Contents of /suikawiki/script/lib/SuikaWiki/Plugin/WikiDB.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Sun Feb 8 08:52:03 2004 UTC (22 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.3: +7 -4 lines
SuikaWiki 3 WikiName interface supported

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: WikiDB
5     @Description:
6     @@@: WikiDatabase support
7     @@lang:en
8     @License: %%GPL%%
9     @Author:
10     @@Name:
11     @@@@: Wakaba
12     @@@lang:ja
13     @@@script:Latn
14     @@Mail[list]: w@suika.fam.cx
15 wakaba 1.4 @Date.RCS: $Date: 2004/02/01 12:15:07 $
16 wakaba 1.1 @RequiredModule[list]:
17     @RequiredPlugin[list]:
18     Error
19     WikiView
20     WikiStruct
21     WikiLinking
22 wakaba 1.3 WikiResource
23 wakaba 1.1 HTML
24 wakaba 1.3 @Use:
25     my $WIKIRESOURCE;
26 wakaba 1.1
27     PluginConst:
28     @NS_XHTML1:
29     http://www.w3.org/1999/xhtml
30 wakaba 1.3 @WIKIRESOURCE:
31     {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
32 wakaba 1.1
33     ViewDefinition:
34     @Mode: -wdb--fatal-error
35     @Description:
36     @@@: Reporting fatal error with WikiDB system
37     @@lang: en
38     @method:
39     @@Name: main
40     @@@:
41     require SuikaWiki::Output::HTTP;
42     $opt2->{output} = SuikaWiki::Output::HTTP->new
43     (wiki => $self->{view}->{wiki},
44     view => $self->{view}, viewobj => $self);
45     for (@{$self->{view}->{wiki}->{var}->{client}->{used_for_negotiate}},
46     'Accept-Language') {
47     $opt2->{output}->add_negotiate_header_field ($_);
48     }
49    
50     $opt2->{template} = q#%html-document (
51     title => {%res(name=>{WikiDB:FatalError:WebPageTitle});}p,
52     link-meta => {%template (name => links);
53     %html-meta(name => ROBOTS, content => NOINDEX);}p,
54     content => {
55 wakaba 1.4 %block (id => tools1, class => tools,
56 wakaba 1.3 content => {%template (name => navbar);}p);
57 wakaba 1.1 %section (title => {%res (name => {WikiDB:FatalError:Title});}p,
58 wakaba 1.2 heading,
59 wakaba 1.1 content => {
60     %paragraph (content => {%res (name =>
61     {WikiDB:FatalError:Description});}p);
62     %error-list (
63     no-error => {%res (name => {Error:NoErrorReported});}p,
64     );
65 wakaba 1.2 }p,
66 wakaba 1.1 );
67 wakaba 1.4 %block (id => footer, content => {%template (name => ws--footer);}p);
68 wakaba 1.1 }p,
69     );#;
70     $opt2->{o} = bless {
71     wiki => $self->{view}->{wiki},
72     plugin => $self->{view}->{wiki}->{plugin},
73     var => {},
74     }, 'SuikaWiki::Plugin';
75 wakaba 1.3 for (@{$self->{view}->{wiki}->{var}->{error}||[]}) {
76 wakaba 1.1 $opt2->{output}->{status_code} = $_->{http_status}
77     if $opt2->{output}->{status_code} < $_->{http_status};
78     }
79     $opt2->{output}->{status_code} ||= 500;
80    
81     $opt2->{output}->{entity}->{media_type} = q#text/html#;
82 wakaba 1.4 $opt2->{output}->{entity}->{charset}
83     = $self->{view}->{wiki}->{config}->{charset}->{output};
84     $opt2->{output}->set_expires
85     (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#error#}});
86 wakaba 1.1
87     $self->{view}->{wiki}->close_db;
88     $self->main_pre ($opt, $opt2);
89    
90     my $fmt = SuikaWiki::Plugin->formatter ('view');
91     $opt2->{output}->{entity}->{body}
92     = $fmt->replace ($opt2->{template}, param => $opt2->{o});
93     $opt2->{output}->output (output => 'http-cgi');
94     $self->main_post ($opt, $opt2);
95    
96     Function:
97     @Name: reporting_error
98     @Description:
99     @@@:
100     Reporting database error (or warning) message
101     @@lang:en
102     @Main:
103     my (undef, $err, $wiki) = @_;
104     my $error = {http_status => $err->{-def}->{http_status}};
105     my $dl = $error->{description}
106     = new Message::Markup::XML::Node
107     (type => '#element',
108     namespace_uri => $NS_XHTML1,
109     local_name => 'dl');
110     ## TODO: Use resource
111     $dl->append_new_node (type => '#element',
112     namespace_uri => $NS_XHTML1,
113     local_name => 'dt')
114 wakaba 1.3 ->append_text ($WIKIRESOURCE->get (name => 'Error:Detail',
115     wiki => $wiki));
116 wakaba 1.1 $dl->append_new_node (type => '#element',
117     namespace_uri => $NS_XHTML1,
118     local_name => 'dd')
119     ->append_text ($err->text);
120     $dl->append_new_node (type => '#element',
121     namespace_uri => $NS_XHTML1,
122     local_name => 'dt')
123 wakaba 1.3 ->append_text ($WIKIRESOURCE->get (name => 'Error:Call Stack Trace',
124     wiki => $wiki));
125 wakaba 1.1 SuikaWiki::Plugin->module_package ('Error')->make_caller_trace_table
126     ($dl->append_new_node (type => '#element',
127     namespace_uri => $NS_XHTML1,
128     local_name => 'dd'),
129     {skip => 2});
130     push @{$wiki->{var}->{error}||=[]}, $error;
131    
132     Resource:
133     @WikiDB:FatalError:Description:
134     @@@:
135     Some fatal error occurs during processing your request.
136     Please contact the administrator of the wiki
137     with error messages below.
138     @@lang:en
139     @WikiDB:FatalError:Title:
140     @@@: Internal WikiDatabase Error
141     @@lang:en
142     @WikiDB:FatalError:WebPageTitle:
143     @@@: WikiDatabase Error (%page-name;)
144     @@lang:en
145    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24