~ubuntu-branches/ubuntu/utopic/tdiary/utopic

« back to all changes in this revision

Viewing changes to contrib2/plugin/monthly_autopagerize.rb

  • Committer: Bazaar Package Importer
  • Author(s): Daigo Moriwaki
  • Date: 2011-04-11 21:53:16 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110411215316-ih4gt4q8p29d2wf8
Tags: 3.0.1-1
* New upstream release (Closes: #542801, #594947)
* debian/control:
 - Bumped up Standards-Version to 3.9.1.
 - Updated version dependency.
* debian/tdiary-setup.rb: Followed the upstream changes, incorporating js and
  index.fcgi

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# monthly_autopagerize.rb - tDiary plugin
 
3
#
 
4
# add <link rel="prev"> and <link rel="next"> tags for AutoPagerize at monthly mode
 
5
#
 
6
# Copyright (C) 2009 MATSUI Shinsuke <poppen@karashi.org>
 
7
# You can redistribute it and/or modify it under GPL2.
 
8
#
 
9
 
 
10
if @mode == 'month' then
 
11
        add_header_proc do
 
12
                stream = @conf['monthly_autopagerize.stream'] || 0
 
13
                result = String.new
 
14
 
 
15
                ym = []
 
16
                @years.keys.each do |y|
 
17
                        ym += @years[y].collect {|m| y + m}
 
18
                end
 
19
                ym.sort!
 
20
                now = @date.strftime( '%Y%m' )
 
21
                return '' unless ym.index( now )
 
22
                prev_month = ym.index( now ) == 0 ? nil : ym[ym.index( now )-1]
 
23
                next_month = ym[ym.index( now )+1]
 
24
 
 
25
                case stream
 
26
                #when 0
 
27
                #       rel_prev_month = 'next'
 
28
                #       rel_next_month = 'prev'
 
29
                when 1
 
30
                        rel_prev_month = 'prev'
 
31
                        rel_next_month = 'next'
 
32
                else
 
33
                        rel_prev_month = 'next'
 
34
                        rel_next_month = 'prev'
 
35
                end
 
36
 
 
37
                if prev_month then
 
38
                        result << %Q[<link rel="#{rel_prev_month}" title="#{h navi_prev_month}" href="#{h @index}#{anchor( prev_month )}">\n\t]
 
39
                end
 
40
                if next_month then
 
41
                        result << %Q[<link rel="#{rel_next_month}" title="#{h navi_next_month}" href="#{h @index}#{anchor( next_month )}">\n\t]
 
42
                end
 
43
 
 
44
                result.chop.chop
 
45
        end
 
46
end
 
47
 
 
48
add_conf_proc( 'monthly_autopagerize', 'Monthly AutoPagerize' ) do
 
49
        if @mode == 'saveconf' then
 
50
                @conf['monthly_autopagerize.stream'] = @cgi.params['monthly_autopagerize.stream'][0].to_i
 
51
        end
 
52
        <<-HTML
 
53
                <h3>Stream of Monthly AutoPagerize</h3>
 
54
                <p><select name="monthly_autopagerize.stream">
 
55
                        <option value="0"#{' selected' if @conf['monthly_autopagerize.stream'] == 0}>To Past</option>
 
56
                        <option value="1"#{' selected' if @conf['monthly_autopagerize.stream'] == 1}>To Future</option>
 
57
                </select></p>
 
58
        HTML
 
59
end
 
60
 
 
61
# Local Variables:
 
62
# mode: ruby
 
63
# indent-tabs-mode: t
 
64
# tab-width: 3
 
65
# ruby-indent-level: 3
 
66
# End:
 
67
# vi: ts=3 sw=3