/[pub]/suikawiki/script/misc/plugins/SuikaWikiGraph.wps
Suika

Contents of /suikawiki/script/misc/plugins/SuikaWikiGraph.wps

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sat Jul 19 04:45:55 2003 UTC (21 years, 9 months ago) by wakaba
Branch: MAIN
Branch point for: branch-suikawiki-1
Imported to CVS

1 wakaba 1.1 Name:
2     SuikaWikiGraph
3     FullName:
4     "SuikaWikiGraph" format support
5     URI:
6     IW:SuikaWiki:SuikaWiki
7     Description:
8     This module provides "SuikaWikiGraph/0.9" support.
9     Initialize:
10     my $HAS_XML = SuikaWiki::Plugin->feature ('SuikaWiki::Markup::XML');
11     my $NS_XHTML1 = 'http://www.w3.org/1999/xhtml';
12    
13     {
14     Name:
15     wikiview/graph-timeline-pseudo-html
16     FullName:
17     Embeding timeline graph (written in pseudo HTML)
18     Description:
19     WARNING: This rule outputs very ugly HTML (some people call it "DIV chuu-teki").
20     SVG output should be used for SVG-enabled UAs.
21     Format:
22     my @data = (
23     {year => 1992, month => 0, label => 'Very earlier HTML spec'},
24     {year => 1993, month => 3, label => 'HTML 1.0 I-D'},
25     {year => 1993, month => 11, label => 'HTML+ I-D'},
26     {year => 1995, month => 5, label => 'HTML 3.0 I-D'},
27     {year => 1997, month => 01, label => 'HTML 2.x RFC'},
28     {year => 1997, month => 01, label => 'HTML 3.2 REC'},
29     {year => 1997, month => 12, label => 'HTML 4.0 REC'},
30     {year => 1998, month => 02, label => 'CHTML NoteC'},
31     {year => 1999, month => 12, label => 'HTML 4.01 REC'},
32     {year => 2000, month => 01, label => 'XHTML 1.0 REC'},
33     {year => 2000, month => 12, label => 'XHTML Basic 1.0 REC'},
34     {year => 2001, month => 04, label => 'XHTML m12n REC'},
35     {year => 2001, month => 05, label => 'XHTML 1.1 REC'},
36     {year => 2002, month => 8, label => 'XHTML 1.0 SE REC'},
37     {year => 2002, month => 00, label => 'XHTML 2.0 WD'},
38     );
39    
40     $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'div');
41     my @sorted_data = sort {$a->{value} <=> $b->{value}} @{time_db_to_graph_db(\@data)};
42     my $s = 700 / ($sorted_data[-1]->{value} - $sorted_data[0]->{value} || 1);
43     my $offset = $sorted_data[0]->{value};
44     my $pp = 0;
45     for my $entry (@sorted_data) {
46     unless ($entry->{value} == $sorted_data[0]->{value}) {
47     for ($r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'div')) {
48     $_->set_attribute (class => 'pi-swg-hgt-graph');
49     $_->set_attribute (style => qq(top: @{[($pp - $offset)*$s]}px; height: @{[($entry->{value} - $pp)*$s]}px));
50     }
51     }
52     for ($r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'div')) {
53     $_->set_attribute (class => 'pi-swg-hgt-label');
54     $_->set_attribute (style => qq(top: @{[($entry->{value} - $offset)*$s-16]}px));
55     $_->set_attribute (title => $entry->{label_full} || $entry->{label});
56     $_->append_text ($entry->{label});
57     }
58     $pp = $entry->{value};
59     }
60    
61     }
62    
63     MODULE:
64     sub time_db_to_graph_db (\@) {
65     require Time::Local;
66     my $tdb = shift;
67     my $gdb = [];
68     for my $t (@$tdb) {
69     my $g = {};
70     ## TODO
71     $g->{value} = Time::Local::timegm_nocheck ($t->{second}, $t->{minute}, $t->{hour}, $t->{day}, $t->{month}-1, $t->{year});
72     $g->{label} = $t->{label};
73     $g->{label_full} = sprintf '%s (%04d-%02d-%02dT%02d:%02d:%02dZ)', $t->{label}, $t->{year}, $t->{month}, $t->{day}, $t->{hour}, $t->{minute}, $t->{second};
74     push @$gdb, $g;
75     }
76     $gdb;
77     }
78    
79     SuikaWiki::View->definition (pi_swg__hgt_ => {
80     media => {type => 'text/html', charset => 1, expires => 600},
81     xmedia => {type => 'application/xhtml+xml', charset => 1, expires => 600},
82     template => <<EOH});
83     %html-document(title=>{%res(name=>{Plugin:SuikaWikiGraph:Timeline:WebPageTitle});}p,link-meta=>{%predefined-template(name=>links);}p,content=>{
84     %graph-timeline-pseudo-html;
85     }p);
86     EOH
87    
88     POD:TO DO:
89    
90     POD:LICENSE:
91     Copyright 2003 Wakaba <w@suika.fam.cx>
92    
93     %%GNUGPL2%%

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24