Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 3039 Bytes
1 | require 'net/http' |
2 | |
3 | begin |
4 | Kernel.require 'sparklines' |
5 | |
6 | Sparklines # this will throw an exception if the require failed. |
7 | |
8 | class Typo |
9 | class Textfilter |
10 | class Sparkline < TextFilterPlugin::MacroPost |
11 | plugin_public_action :plot |
12 | plugin_display_name "Sparkline" |
13 | plugin_description "Produce Sparklines" |
14 | |
15 | def self.help_text |
16 | %{ |
17 | You can use `<typo:sparkline>` to generate [Sparklines][], which are essentially small inline charts. |
18 | Example: |
19 | |
20 | <typo:sparkline data="5 10 15 20"/> |
21 | |
22 | Options: |
23 | |
24 | * **data** This is the data to be plotted. You may also include the data between `<typo:sparkline>` |
25 | and `</typo:sparkline>` tags. |
26 | * **type** This is the type of sparkline to be generated. Options include `area`, `discrete`, `pie`, and `smooth`. |
27 | |
28 | For other options, see the [Ruby Sparkline][] website. |
29 | |
30 | [Sparklines]: http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR&topic_id=1&topic= |
31 | [Ruby Sparkline]: http://nubyonrails.topfunky.com/articles/2005/08/01/sparklines-now-gem-i-fied |
32 | } |
33 | end |
34 | |
35 | def self.opt(attrib,optname) |
36 | if(attrib[optname]) |
37 | " #{optname}=\"#{attrib.delete(optname)}\"" |
38 | else |
39 | '' |
40 | end |
41 | end |
42 | |
43 | def self.macrofilter(controller,content,attrib,params,text="") |
44 | img_opts = opt(attrib,'style') + opt(attrib,'alt') + opt(attrib,'title') |
45 | data = text.to_s.split(/\s+/).join(',') |
46 | |
47 | if(attrib['data']) |
48 | data = attrib.delete('data').to_s.split.join(',') |
49 | end |
50 | |
51 | url = controller.url_for( |
52 | {:controller => '/textfilter', :action => 'public_action', :filter => 'sparkline', |
53 | :public_action => 'plot', :data => data}.update(attrib)) |
54 | |
55 | "<img #{img_opts} src=\"#{url}\"/>" |
56 | end |
57 | |
58 | # From the sparkline_controller that comes with sparklines. |
59 | def plot |
60 | ary = params['data'].split(',').collect { |i| i.to_i } |
61 | params.delete('filename') |
62 | |
63 | if(params['type'] and not ['smooth', 'pie', 'discrete', 'area'].include?(params['type'])) |
64 | render :text => 'bad params', :status => 500 |
65 | return |
66 | end |
67 | |
68 | fragmentname = @request.path+'?'+@request.parameters.keys.sort.collect {|k| "#{k}=#{@request.parameters[k]}"}.join('&') |
69 | fragment_cache = read_fragment(fragmentname) |
70 | |
71 | if(not fragment_cache) |
72 | fragment_cache = Sparklines.plot(ary,params) |
73 | write_fragment(fragmentname,fragment_cache) |
74 | end |
75 | |
76 | send_data( fragment_cache, |
77 | :disposition => 'inline', |
78 | :type => 'image/png', |
79 | :filename => "spark_#{params[:type]}.png" ) |
80 | end |
81 | |
82 | # This is really just here for the unit test; we try to call it and |
83 | # verify that plugin_public_action won't let the call through. |
84 | def plot2 |
85 | render :text => '' |
86 | end |
87 | end |
88 | end |
89 | end |
90 | rescue LoadError |
91 | # ignore load errors by not loading any of the library |
92 | end |