parlement 0.5 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/CHANGES +26 -0
  2. data/README +2 -1
  3. data/app/controllers/account_controller.rb +27 -18
  4. data/app/controllers/application.rb +1 -3
  5. data/app/controllers/elt_controller.rb +92 -42
  6. data/app/helpers/elt_helper.rb +7 -18
  7. data/app/models/elt.rb +76 -22
  8. data/app/models/mail.rb +13 -10
  9. data/app/models/mail_notify.rb +11 -27
  10. data/app/models/person.rb +1 -1
  11. data/app/views/account/_login.rhtml +14 -9
  12. data/app/views/account/_show.rhtml +23 -9
  13. data/app/views/elt/_choice.rhtml +32 -0
  14. data/app/views/elt/_elt.rhtml +90 -78
  15. data/app/views/elt/_list.rhtml +83 -50
  16. data/app/views/elt/_listByDate.rhtml +60 -0
  17. data/app/views/elt/_listByVote.rhtml +71 -0
  18. data/app/views/elt/choices.rhtml +29 -0
  19. data/app/views/elt/new.rhtml +11 -26
  20. data/app/views/elt/rss.rxml +14 -12
  21. data/app/views/elt/show.rhtml +23 -29
  22. data/app/views/elt/vote_rss.rxml +40 -0
  23. data/app/views/layouts/top.rhtml +5 -13
  24. data/config/environment.rb +3 -1
  25. data/config/routes.rb +4 -0
  26. data/db/development_structure.sql +5 -2
  27. data/db/migrate/002_nested_set.rb +22 -0
  28. data/db/migrate/003_elt_children_count.rb +12 -0
  29. data/public/images/ParlementLogo.png +0 -0
  30. data/public/images/indicator.gif +0 -0
  31. data/public/javascripts/behaviour.js +254 -0
  32. data/public/javascripts/mybehaviour.js +96 -0
  33. data/public/javascripts/slider.js +188 -163
  34. data/test/fixtures/elts.yml +19 -0
  35. data/test/fixtures/mail/mail_ruby +4 -0
  36. data/test/fixtures/mail/mail_rubyChild +1 -1
  37. data/test/fixtures/mail/mail_rubyChild2 +1 -1
  38. data/test/functional/account_controller_test.rb +24 -0
  39. data/test/functional/elt_controller_test.rb +64 -4
  40. data/test/unit/elt_test.rb +28 -4
  41. data/test/unit/mail_notify_test.rb +7 -5
  42. data/test/unit/mail_test.rb +1 -1
  43. data/vendor/plugins/google_analytics/README +19 -0
  44. data/vendor/plugins/google_analytics/Rakefile +22 -0
  45. data/vendor/plugins/google_analytics/init.rb +3 -0
  46. data/vendor/plugins/google_analytics/lib/rubaidh/google_analytics.rb +70 -0
  47. data/vendor/plugins/google_analytics/test/google_analytics_test.rb +8 -0
  48. data/vendor/plugins/output_compression/README +4 -0
  49. data/vendor/plugins/output_compression/Rakefile +22 -0
  50. data/vendor/plugins/output_compression/init.rb +2 -0
  51. data/vendor/plugins/output_compression/lib/output_compression.rb +66 -0
  52. data/vendor/plugins/output_compression/tasks/output_compression_tasks.rake +4 -0
  53. data/vendor/plugins/output_compression/test/output_compression_test.rb +8 -0
  54. metadata +32 -4
  55. data/public/images/smile.svg +0 -257
  56. data/public/javascripts/borders.js +0 -687
@@ -1,28 +1,33 @@
1
1
  <%= form_remote_tag(
2
2
  :update => divId,
3
- :url => { :controller => 'account', :action => 'login' },
3
+ :url => { :controller => 'account', :action => 'login', :divId => divId },
4
+ :before => visual_effect(:SwitchOff, divId)+";resetChoices();",
4
5
  :complete => visual_effect(:BlindDown, divId)) %>
5
6
 
7
+ <%= hidden_field 'elt', 'id' if @elt %>
8
+
6
9
  <div class="login">
7
10
  <span>
8
11
  <input type="hidden" id="divId" name="divId" value="<%= divId %>"/>
9
12
 
10
- <label for="person_name">Pseudo:</label>
11
- <%= text_field "person", "name", :size => 10 %>
13
+ <label for="person_name">Pseudo:
14
+ <%= text_field "person", "name", :size => 10 %>
15
+ </label>
12
16
 
13
17
  <%= link_to_function('+',
14
- "Element.toggle(this);"+visual_effect(:Grow, 'user_password_'+divId.to_s),
15
- :class => "subscribeLink") %>
18
+ "Element.toggle(this);"+visual_effect(:Grow, 'user_password_'+divId.to_s),
19
+ :class => "subscribeLink") %>
16
20
  </span>
17
21
 
18
22
  <span style="display: none;" id="user_password_<%= divId %>">
19
23
  &nbsp;
20
- <label for="user_password">Password:</label>
21
- <%= password_field "user", "password", :size => 10 %>
24
+ <label for="user_password">Password:
25
+ <%= password_field "user", "password", :size => 10 %>
26
+ </label>
22
27
 
23
28
  <%= link_to_function('email? &gt;',
24
- "Element.toggle(this);"+visual_effect(:Grow, 'person_email_'+divId.to_s),
25
- :class => "subscribeLink") %>
29
+ "Element.toggle(this);"+visual_effect(:Grow, 'person_email_'+divId.to_s),
30
+ :class => "subscribeLink") %>
26
31
  </span>
27
32
 
28
33
  <span style="display: none;" id="person_email_<%= divId %>">
@@ -5,20 +5,34 @@
5
5
  <%= error_messages_for 'person' if @person %>
6
6
  <%= error_messages_for 'user' if @user %>
7
7
 
8
- <% if @session[:person] %>
8
+ <% if choices ||= false %>
9
+ <!-- Here are updated all choices, watch out, javascript! -->
10
+ <div class="choicesToUpdate" title="choicesToUpdate">
11
+ <%= choices.size %>
12
+ <script language="JavaScript">
13
+ var choices_to_update = {
14
+ <%= choices.collect { |c| "'elt_#{ c.elt_id }' : '#{ c.value }'" }.join(', ') %>
15
+ };
16
+ updateChoices(choices_to_update);
17
+ </script>
18
+ </div>
19
+ <% end %>
20
+
21
+ <% if session[:person] %>
9
22
  <span class="logout">
10
23
  <%= link_to_remote('[X]',
11
- :update => divId,
12
- :url => { :controller => 'account', :action => 'logout', :divId => divId },
13
- :complete => visual_effect(:BlindDown, divId)) %>
24
+ :update => divId,
25
+ :url => { :controller => 'account', :action => 'logout', :divId => divId },
26
+ :before => visual_effect(:SwitchOff, divId)+";resetChoices();",
27
+ :complete => visual_effect(:BlindDown, divId)) %>
14
28
  </span>
15
29
 
16
- <% if @session[:person].name and @session[:person].name != '' %>
30
+ <% if session[:person].name and session[:person].name != '' %>
17
31
  <span class="author">
18
- <%= link_to(@session[:person].name,
19
- :controller => 'person',
20
- :action => 'show',
21
- :id => @session[:person]) %>
32
+ &lt;<%= link_to session[:person].name,
33
+ :controller => 'person',
34
+ :action => 'show',
35
+ :id => session[:person] %>&gt;
22
36
  </span>
23
37
  <% end %>
24
38
  <% else %>
@@ -0,0 +1,32 @@
1
+ <%
2
+ choice = Choice.find_by_elt_id_and_person_id elt.id, (session[:person] ? session[:person].id : nil)
3
+ %>
4
+
5
+ <label class="con <%= choice and choice.value == -1 ? "selected" : "" %>"
6
+ title="-1" for="choice_<%= elt.id %>_con">
7
+ V
8
+ <%= radio_button_tag "choice[value]", "-1",
9
+ (choice and choice.value == -1),
10
+ :id => "choice_#{elt.id}_con",
11
+ :onclick => "this.form.commit.click()" %>
12
+ </label>
13
+
14
+ <span class="result" id="result_<%= elt.id %>">
15
+ <%= link_to_remote("%+d" % elt.result,
16
+ { :update => 'result_'+elt.id,
17
+ :position => :top,
18
+ :url => { :action => 'choices', :id => elt } },
19
+ { :href => url_for(:controller => 'elt', :action => 'choices', :id => elt )}) %>
20
+ </span>
21
+
22
+ <label class="pro <%= choice and choice.value == 1 ? "selected" : "" %>"
23
+ title="+1" for="choice_<%= elt.id %>_pro">
24
+ Λ
25
+ <%= radio_button_tag "choice[value]", "+1",
26
+ (choice and choice.value == +1),
27
+ :id => "choice_#{elt.id}_pro",
28
+ :onclick => "this.form.commit.click()" %>
29
+ </label>
30
+
31
+ <%= submit_tag 'Vote!' %>
32
+
@@ -1,101 +1,113 @@
1
- <% eltSubsNb = elt.children.count if eltSubsNb == nil %>
2
-
3
- <li id="elt_<%= elt.id %>" result="<%= elt.result %>"
4
- class="elt <%= displayTitle?(elt) ? 'titled' : '' %>">
5
- <span class="result"><%= sprintf("%+d", elt.result) %></span>
6
- <!--
7
- <form class="vote">
8
- <label>-1</span> <span class="vote">0</span> <span class="vote">+1</span>
9
- </form>
10
- -->
11
-
12
- <% if (eltTop or displayTitle? elt) and elt.created_on %>
13
- <span class="created_on">
14
- <%= elt.created_on.strftime('%d/%m/%y %H:%M') %>
15
- </span>
16
- <% end %>
1
+ <li id="elt_<%= elt.id %>" class="elt <%= 'titled' if displayTitle?(elt) %>">
2
+ <script>setKnobs($('elt_<%= elt.id %>'));</script>
3
+
4
+ <!-- Here to make sure a text browser could see it all on one line -->
5
+ <%= form_remote_tag(
6
+ :update => 'eltChoice_'+elt.id,
7
+ :url => { :action => 'vote', :id => elt },
8
+ :before => visual_effect(:DropOut, 'eltChoice_'+elt.id, { :queue => 'end' }),
9
+ :loaded => visual_effect(:Grow, 'eltChoice_'+elt.id, { :queue => 'end' })) %>
10
+
11
+ <% if !elt.new_record? %>
12
+ <span class="choice" id="eltChoice_<%= elt.id %>">
13
+ <%= render :partial => '/elt/choice', :locals => { :elt => elt } %>
14
+ </span>
15
+ <% end %>
17
16
 
18
- <% if elt.person %>
19
- <span class="author">
20
- <%= link_to(elt.person.name, :controller => 'person', :action => 'show', :id => elt.person) %>
21
- </span>
22
- <% elsif not displayTitle? elt %>
23
- <span class="author" <%= ANONYMOUS_POSTER %>><%= ANONYMOUS_POSTER %></span>
24
- <% end %>
25
-
26
- <% if eltTop or displayTitle? elt %>
27
- <<%= eltTop ? 'h1' : 'h2' %>>
28
- <% if elt.new_record? %>
29
- <%= textilize_without_paragraph(elt.subject) %>
30
- <% else %>
31
- <%= link_to(textilize_without_paragraph(elt.subject),
32
- :controller => 'elt', :action => 'show', :id => elt) %>
17
+ <% cache :action => 'show', :id => elt.id do %>
18
+ <% if displayTitle? elt and elt.created_on %>
19
+ <span class="created_on">
20
+ <%= elt.created_on.strftime('%d/%m/%y %H:%M') %>
21
+ </span>
22
+ <% end %>
23
+
24
+ <% if elt.person %>
25
+ <span class="author">
26
+ &lt;<%= link_to elt.person.name, :controller => 'person', :action => 'show', :id => elt.person %>&gt;
27
+ </span>
28
+ <% elsif not displayTitle? elt %>
29
+ <span class="author">&lt;<%= ANONYMOUS_POSTER %>&gt;</span>
33
30
  <% end %>
34
- </<%= eltTop ? 'h1' : 'h2' %>>
35
- <% end %>
36
31
 
37
- <%= format elt.body %>
32
+ <% if displayTitle? elt %>
33
+ <h1>
34
+ <% if elt.new_record? %>
35
+ <%= textilize_without_paragraph elt.subject.gsub(/\[.*\]/, '') %>
36
+ <% else %>
37
+ <%= link_to(textilize_without_paragraph(elt.subject.gsub(/\[.*\]/, '')),
38
+ :controller => 'elt', :action => 'show', :id => elt) %>
39
+ <% end %>
40
+ </h1>
41
+ <% end %>
38
42
 
39
- <span class="eltQuickAdd" id="eltQuickAdd_<%= elt.id %>" title="<%= elt.created_on %>">
40
- <% if !elt.new_record? and elt.children.count == 0 %>
41
- <%= link_to_remote('<span class="icon">&gt;&gt;</span>',
43
+ <%= format elt.body %>
44
+ <% end %>
45
+ <% @controller.expire_fragment( :action => 'show', :id => elt.id) if elt.new_record? %>
46
+
47
+ <span class="eltQuickAdd" id="eltQuickAdd_<%= elt.id %>" title="<%= elt.created_on %>">
48
+ <% if !elt.new_record? and elt.elts_count == 0 %>
49
+ <%= link_to_remote('<span class="icon">&gt;&gt;</span>',
50
+ { :update => 'eltNew_'+elt.id.to_s,
51
+ :url => { :controller => 'elt', :action => 'new', :id => elt },
52
+ :loading => visual_effect(:SwitchOff, 'eltQuickAdd_'+elt.id.to_s),
53
+ :loaded => visual_effect(:BlindDown, 'eltNew_'+elt.id.to_s)+
54
+ visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s)},
55
+ { :href => url_for(:controller => 'elt', :action => 'new', :id => @elt)}) %>
56
+ <% end %>
57
+ </span>
58
+
59
+ <% for att in elt.attachments %>
60
+ <%= link_to image_tag('/attachment/file/'+att.file_relative_path),
61
+ '/attachment/file/'+att.file_relative_path %>
62
+ <% end %>
63
+
64
+ <!-- For IE -->&#160;
65
+
66
+ <span <%= 'style="display: none"' if (eltTop or elt.elts_count < 2) %>
67
+ class="eltMore" id="eltMore_<%= elt.id %>">
68
+ <%= link_to_remote(elt.elts_count.to_s+' more',
69
+ { :update => 'eltSubs_'+elt.id.to_s,
70
+ :url => { :controller => 'elt', :action => 'list', :id => elt },
71
+ :loading => visual_effect(:SwitchOff, 'eltMore_'+elt.id.to_s),
72
+ :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s)+
73
+ visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s),
74
+ :complete => "Behaviour.apply();" },
75
+ { :href => url_for(:controller => 'elt', :action => 'show', :id => elt) }) %>
76
+
77
+ <%= link_to_remote('Add <span class="icon">&gt;&gt;</span>',
42
78
  { :update => 'eltNew_'+elt.id.to_s,
43
79
  :url => { :controller => 'elt', :action => 'new', :id => elt },
44
- :loading => visual_effect(:SwitchOff, 'eltQuickAdd_'+elt.id.to_s),
45
80
  :loaded => visual_effect(:BlindDown, 'eltNew_'+elt.id.to_s)+
46
81
  visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s)},
47
- { :href => url_for(:controller => 'elt', :action => 'new', :id => @elt)}) %>
48
- <% end %>
49
- </span>
50
-
51
- <% for att in elt.attachments %>
52
- <%= link_to image_tag('/attachment/file/'+att.file_relative_path),
53
- '/attachment/file/'+att.file_relative_path %>
54
- <% end %>
55
-
56
- <!-- For IE -->&#160;
57
-
58
- <span <%= (eltTop or eltSubsNb < 2) ? 'style="display: none"' : '' %>
59
- class="eltMore" id="eltMore_<%= elt.id %>">
60
- <%= link_to_remote(eltSubsNb.to_s+' more',
61
- { :update => 'eltSubs_'+elt.id.to_s,
62
- :url => { :controller => 'elt', :action => 'list', :id => elt },
63
- :loading => visual_effect(:SwitchOff, 'eltMore_'+elt.id.to_s),
64
- :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s)+
65
- visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s)},
66
- { :href => url_for(:controller => 'elt', :action => 'show', :id => elt) }) %>
82
+ { :href => url_for(:controller => 'elt', :action => 'new', :id => elt)}) %>
83
+ </span>
67
84
 
68
- <%= link_to_remote('Add <span class="icon">&gt;&gt;</span>',
69
- { :update => 'eltNew_'+elt.id.to_s,
70
- :url => { :controller => 'elt', :action => 'new', :id => elt },
71
- :loaded => visual_effect(:BlindDown, 'eltNew_'+elt.id.to_s)+
72
- visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s)},
73
- { :href => url_for(:controller => 'elt', :action => 'new', :id => elt)}) %>
74
- </span>
85
+ <!-- The choice end form, here to make sure it looks nice in text browsers -->
86
+ <%= end_form_tag %>
75
87
 
76
- <ul class="eltSubs">
88
+ <div class="eltSubs">
77
89
  <!-- Display automatically one element threads -->
78
- <div <%= (eltTop or eltSubsNb == 1) ? '' : 'style="display: none"' %>
90
+ <ul <%= 'style="display: none"' unless (eltTop or elt.elts_count == 1) %>
79
91
  id="eltSubs_<%= elt.id %>" class="eltSub">
80
- <% if eltTop or eltSubsNb == 1 %>
92
+ <% if eltTop or elt.elts_count == 1 %>
81
93
  <%= render :partial => '/elt/list', :locals => { :elt => elt } %>
82
94
  <% end %>
83
- </div>
95
+ </ul>
84
96
 
85
- <span style="display:none" class="eltNew" id="eltNew_<%= elt.id %>"></span>
97
+ <ul class="eltNew" id="eltNew_<%= elt.id %>"></ul>
86
98
 
87
- <span <%= ((eltTop and eltSubsNb > 0) or eltSubsNb == 1) ? '' : 'style="display: none"' %>
99
+ <span <%= 'style="display: none"' unless ((eltTop and elt.elts_count > 0) or elt.elts_count == 1) %>
88
100
  id="eltSubsClose_<%= elt.id %>" title="<%= elt.created_on %>"
89
101
  class="eltSubsClose">
90
102
  <%= link_to_function('<span class="icon">&lt;&lt;</span> Close',
91
- visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s)+
92
- visual_effect(:BlindUp, 'eltNew_'+elt.id.to_s)+
93
- visual_effect(:BlindUp, 'eltSubsClose_'+elt.id.to_s)+
94
- visual_effect(:BlindDown, 'eltMore_'+elt.id.to_s)) %>
103
+ visual_effect(:BlindUp, 'eltSubs_'+elt.id)+
104
+ visual_effect(:BlindUp, 'eltNew_'+elt.id)+
105
+ visual_effect(:BlindUp, 'eltSubsClose_'+elt.id)+
106
+ visual_effect(:BlindDown, 'eltMore_'+elt.id)) %>
95
107
 
96
108
  <% if elt.person %>
97
109
  <%= link_to(elt.person.name,
98
- :controller => 'person', :action => 'show', :id => elt.person) %>
110
+ :controller => 'person', :action => 'show', :id => elt.person) %>
99
111
  <% elsif not displayTitle? elt %>
100
112
  <%= ANONYMOUS_POSTER %>
101
113
  <% end %>
@@ -103,10 +115,10 @@
103
115
  <%= link_to_remote('Add <span class="icon">&gt;&gt;</span>',
104
116
  { :update => 'eltNew_'+elt.id.to_s,
105
117
  :url => { :controller => 'elt', :action => 'new', :id => elt },
106
- :loaded => visual_effect(:BlindDown, 'eltNew_'+elt.id.to_s)+
118
+ :loading => visual_effect(:BlindDown, 'eltNew_'+elt.id.to_s)+
107
119
  visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s)},
108
120
  { :href => url_for(:controller => 'elt', :action => 'new', :id => elt)}) %>
109
121
  </span>
110
- </ul>
122
+ </div>
111
123
  </li>
112
124
 
@@ -1,58 +1,91 @@
1
- <%
2
- # TODO get the count from the parent element call
3
- e_pages = ActionController::Pagination::Paginator.new(
4
- self, elt.children.count, PAGE_ELT_LENGTH, @params['page'])
5
- e = Elt.find_all("parent_id = '#{elt.id}'",
6
- 'created_on DESC', e_pages.current.to_sql)
7
- %>
8
-
9
- <%= link_to_remote('< Previous page',
10
- { :update => 'eltSubs_'+elt.id.to_s,
11
- :url => { :action => 'list', :id => elt, :page => e_pages.current.next },
12
- :loading => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s),
13
- :complete => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s)+
14
- visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s) },
15
- { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
16
- :page => (@params['page'] ? @params['page'].to_i+1 : 2))}) if e_pages.current.next %>
1
+ <%e_pages = ActionController::Pagination::Paginator.new(
2
+ self, elt.elts_count, PAGE_ELT_LENGTH, @params['page'])
3
+ elts = Elt.find(:all,
4
+ :conditions => "parent_id = '#{elt.id}'",
5
+ :order => 'position, elts.created_on DESC',
6
+ :include => :person,
7
+ :limit => e_pages.items_per_page,
8
+ :offset => e_pages.current.offset) %>
17
9
 
18
10
  <% if e_pages.length > 1 %>
19
- <span class="pageCount">
20
- (<%= e_pages.length-e_pages.current.to_i+1 %>/<%= e_pages.length %>)
21
- </span>
11
+ <li class="pager">
12
+ <%= link_to_remote('|&lt;',
13
+ { :update => 'eltSubs_'+elt.id.to_s,
14
+ :url => { :action => 'list', :id => elt, :page => e_pages.first },
15
+ :before => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }),
16
+ :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }) },
17
+ { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
18
+ :page => e_pages.first)}) if e_pages.first != e_pages.current %>
19
+
20
+ <%= link_to_remote('&lt;',
21
+ { :update => 'eltSubs_'+elt.id.to_s,
22
+ :url => { :action => 'list', :id => elt, :page => e_pages.current.previous },
23
+ :before => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }),
24
+ :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }) },
25
+ { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
26
+ :page => e_pages.current.previous )}) if e_pages.current.previous and e_pages.current.previous != e_pages.first %>
27
+
28
+ <span class="pageCount">
29
+ <%= e_pages.current.to_i %> / <%= e_pages.length %>
30
+ </span>
31
+
32
+ <%= link_to_remote('&gt;',
33
+ { :update => 'eltSubs_'+elt.id.to_s,
34
+ :url => { :action => 'list', :id => elt, :page => e_pages.current.next },
35
+ :before => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }),
36
+ :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }) },
37
+ { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
38
+ :page => e_pages.current.next )}) if e_pages.current.next and e_pages.current.next != e_pages.last %>
39
+
40
+ <%= link_to_remote('&gt;|',
41
+ { :update => 'eltSubs_'+elt.id.to_s,
42
+ :url => { :action => 'list', :id => elt, :page => e_pages.last },
43
+ :before => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }),
44
+ :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }) },
45
+ { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
46
+ :page => e_pages.last)}) if e_pages.last != e_pages.current %>
47
+ </li>
22
48
  <% end %>
23
49
 
24
- <%= link_to_remote('Next page >',
25
- { :update => 'eltSubs_'+elt.id.to_s,
26
- :url => { :action => 'list', :id => elt, :page => e_pages.current.previous },
27
- :loading => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s),
28
- :complete => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s)+
29
- visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s) },
30
- { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
31
- :page => (@params['page'] ? @params['page'].to_i-1 : e_pages.length-1))}) if e_pages.current.previous %>
32
-
33
- <%= render :partial => '/elt/elt', :collection => e.reverse, :locals => { :eltTop => false } %>
34
-
35
- <%= link_to_remote('< Previous page',
36
- { :update => 'eltSubs_'+elt.id.to_s,
37
- :url => { :action => 'list', :id => elt, :page => e_pages.current.next },
38
- :loading => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s),
39
- :complete => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s)+
40
- visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s) },
41
- { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
42
- :page => (@params['page'] ? @params['page'].to_i+1 : 2))}) if e_pages.current.next %>
50
+ <%= render :partial => '/elt/elt', :collection => elts, :locals => { :eltTop => false } %>
43
51
 
44
52
  <% if e_pages.length > 1 %>
45
- <span class="pageCount">
46
- (<%= e_pages.length-e_pages.current.to_i+1 %>/<%= e_pages.length %>)
47
- </span>
48
- <% end %>
53
+ <li class="pager">
54
+ <%= link_to_remote('|&lt;',
55
+ { :update => 'eltSubs_'+elt.id.to_s,
56
+ :url => { :action => 'list', :id => elt, :page => e_pages.first },
57
+ :before => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }),
58
+ :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }) },
59
+ { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
60
+ :page => e_pages.first)}) if e_pages.first != e_pages.current %>
49
61
 
50
- <%= link_to_remote('Next page >',
51
- { :update => 'eltSubs_'+elt.id.to_s,
52
- :url => { :action => 'list', :id => elt, :page => e_pages.current.previous },
53
- :loading => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s),
54
- :complete => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s)+
55
- visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s) },
56
- { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
57
- :page => (@params['page'] ? @params['page'].to_i-1 : e_pages.length-1))}) if e_pages.current.previous %>
62
+ <%= link_to_remote('&lt;',
63
+ { :update => 'eltSubs_'+elt.id.to_s,
64
+ :url => { :action => 'list', :id => elt, :page => e_pages.current.previous },
65
+ :before => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }),
66
+ :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }) },
67
+ { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
68
+ :page => e_pages.current.previous )}) if e_pages.current.previous and e_pages.current.previous != e_pages.first %>
69
+
70
+ <span class="pageCount">
71
+ <%= e_pages.current.to_i %> / <%= e_pages.length %>
72
+ </span>
73
+
74
+ <%= link_to_remote('&gt;',
75
+ { :update => 'eltSubs_'+elt.id.to_s,
76
+ :url => { :action => 'list', :id => elt, :page => e_pages.current.next },
77
+ :before => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }),
78
+ :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }) },
79
+ { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
80
+ :page => e_pages.current.next )}) if e_pages.current.next and e_pages.current.next != e_pages.last %>
81
+
82
+ <%= link_to_remote('&gt;|',
83
+ { :update => 'eltSubs_'+elt.id.to_s,
84
+ :url => { :action => 'list', :id => elt, :page => e_pages.last },
85
+ :before => visual_effect(:BlindUp, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }),
86
+ :loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s, { :queue => 'end' }) },
87
+ { :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
88
+ :page => e_pages.last)}) if e_pages.last != e_pages.current %>
89
+ </li>
90
+ <% end %>
58
91
 
@@ -0,0 +1,60 @@
1
+ <%e_pages = ActionController::Pagination::Paginator.new(
2
+ self, (@elt.rgt-@elt.lft-1)/2, PAGE_ELT_LENGTH, @params['page'])
3
+ elts = Elt.find :all,
4
+ :conditions => "lft > #{@elt.lft} AND rgt < #{@elt.rgt}",
5
+ :order => 'elts.created_on DESC',
6
+ :include => :person,
7
+ :limit => e_pages.items_per_page,
8
+ :offset => e_pages.current.offset %>
9
+
10
+ <div id="listByDate">
11
+ <% if e_pages.length > 1 %>
12
+ <%= link_to_remote('|&lt;',
13
+ { :update => 'listByDate',
14
+ :url => { :action => 'listByDate', :id => @elt, :page => e_pages.last },
15
+ :before => visual_effect(:BlindUp, 'listByDate', { :queue => 'end' }),
16
+ :loading => visual_effect(:BlindDown, 'listByDate', { :queue => 'end' }) }) \
17
+ if e_pages.last != e_pages.current %>
18
+ <%= link_to_remote('&lt;',
19
+ { :update => 'listByDate',
20
+ :url => { :action => 'listByDate', :id => @elt, :page => e_pages.current.next },
21
+ :before => visual_effect(:BlindUp, 'listByDate', { :queue => 'end' }),
22
+ :loading => visual_effect(:BlindDown, 'listByDate', { :queue => 'end' }) }) \
23
+ if e_pages.current.next and e_pages.current.next != e_pages.last %>
24
+
25
+ <span class="pageCount"><%= e_pages.length-e_pages.current.to_i+1 %></span>
26
+
27
+ <%= link_to_remote('&gt;',
28
+ { :update => 'listByDate',
29
+ :url => { :action => 'listByDate', :id => @elt, :page => e_pages.current.previous },
30
+ :before => visual_effect(:BlindUp, 'listByDate', { :queue => 'end' }),
31
+ :loading => visual_effect(:BlindDown, 'listByDate', { :queue => 'end' }) }) \
32
+ if e_pages.current.previous and e_pages.current.previous != e_pages.first %>
33
+ <%= link_to_remote('&gt;|',
34
+ { :update => 'listByDate',
35
+ :url => { :action => 'listByDate', :id => @elt, :page => e_pages.first },
36
+ :before => visual_effect(:BlindUp, 'listByDate', { :queue => 'end' }),
37
+ :loading => visual_effect(:BlindDown, 'listByDate', { :queue => 'end' }) }) \
38
+ if e_pages.first != e_pages.current %>
39
+ <% end %>
40
+
41
+ <ul>
42
+ <% elts.each do |elt| %>
43
+ <li class="boxLine elt" title="<%= elt.created_on.strftime('%d/%m %H:%M') %>">
44
+ <span class="created_on"><%= elt.created_on.strftime('%d/%m %H:%M') %></span>
45
+ <% if elt.person %>
46
+ <span class="author">
47
+ &lt;<%= link_to(elt.person.name, :controller => 'person', :action => 'show', :id => elt.person) %>&gt;
48
+ </span>
49
+ <% elsif not displayTitle? elt %>
50
+ <span class="author">&lt;<%= ANONYMOUS_POSTER %>&gt;</span>
51
+ <% end %>
52
+
53
+ <%= link_to elt.subject.gsub(/\[.*\]/, ''), :action => 'show', :id => elt %>
54
+ </li>
55
+ <% end %>
56
+ </ul>
57
+
58
+ <%= link_to image_tag("/images/webfeed.gif"), :action => 'rss', :id => @elt %>
59
+ </div>
60
+
@@ -0,0 +1,71 @@
1
+ <%e_pages = ActionController::Pagination::Paginator.new(
2
+ self, (@elt.rgt-@elt.lft-1)/2, PAGE_ELT_LENGTH, @params['page'])
3
+ elts = Elt.find :all,
4
+ :select => 'SUM(value) AS resultLocal, elts.id, parent_id, elts.created_on, parent_id,' \
5
+ +'elts_count, position, elts.person_id, subject, body, lft, rgt',
6
+ :conditions => "lft > #{@elt.lft} AND rgt < #{@elt.rgt}",
7
+ :order => 'SUM(value) IS NULL, SUM(value) DESC, created_on DESC',
8
+ :group => 'elts.id, parent_id, elts.created_on, parent_id, elts_count,' \
9
+ +'position, elts.person_id, subject, body, lft, rgt',
10
+ :limit => e_pages.items_per_page,
11
+ :offset => e_pages.current.offset,
12
+ :joins => "LEFT JOIN choices ON choices.elt_id = elts.id" %>
13
+
14
+ <div id="listByVote">
15
+ <% if e_pages.length > 1 %>
16
+ <%= link_to_remote('|&lt;',
17
+ { :update => 'listByVote',
18
+ :url => { :action => 'listByVote', :id => @elt, :page => e_pages.last },
19
+ :before => visual_effect(:BlindUp, 'listByVote', { :queue => 'end' }),
20
+ :loaded => visual_effect(:BlindDown, 'listByVote', { :queue => 'end' }) }) \
21
+ if e_pages.last != e_pages.current %>
22
+ <%= link_to_remote('&lt;',
23
+ { :update => 'listByVote',
24
+ :url => { :action => 'listByVote', :id => @elt, :page => e_pages.current.next },
25
+ :before => visual_effect(:BlindUp, 'listByVote', { :queue => 'end' }),
26
+ :loaded => visual_effect(:BlindDown, 'listByVote', { :queue => 'end' }) }) \
27
+ if e_pages.current.next and e_pages.current.next != e_pages.last %>
28
+
29
+ <span class="pageCount"><%= e_pages.length-e_pages.current.to_i+1 %></span>
30
+
31
+ <%= link_to_remote('&gt;',
32
+ { :update => 'listByVote',
33
+ :url => { :action => 'listByVote', :id => @elt, :page => e_pages.current.previous },
34
+ :before => visual_effect(:BlindUp, 'listByVote', { :queue => 'end' }),
35
+ :loaded => visual_effect(:BlindDown, 'listByVote', { :queue => 'end' }) }) \
36
+ if e_pages.current.previous and e_pages.current.previous != e_pages.first %>
37
+ <%= link_to_remote('&gt;|',
38
+ { :update => 'listByVote',
39
+ :url => { :action => 'listByVote', :id => @elt, :page => e_pages.first },
40
+ :before => visual_effect(:BlindUp, 'listByVote', { :queue => 'end' }),
41
+ :loaded => visual_effect(:BlindDown, 'listByVote', { :queue => 'end' }) }) \
42
+ if e_pages.first != e_pages.current %>
43
+ <% end %>
44
+
45
+ <ul>
46
+ <% elts.each do |elt| %>
47
+ <li class="boxLine elt" title="<%= elt.created_on.strftime('%d/%m %H:%M') %>">
48
+ <span class="result" id="resultList_<%= elt.id %>">
49
+ <%= link_to_remote("%+d" % elt.resultlocal,
50
+ { :update => 'resultList_'+elt.id,
51
+ :position => :top,
52
+ :url => { :action => 'choices', :id => elt } },
53
+ { :href => url_for(:controller => 'elt', :action => 'choices', :id => elt )}) if elt.resultlocal %>
54
+ </span>
55
+
56
+ <% if elt.person %>
57
+ <span class="author">
58
+ &lt;<%= link_to(elt.person.name, :controller => 'person', :action => 'show', :id => elt.person) %>&gt;
59
+ </span>
60
+ <% elsif not displayTitle? elt %>
61
+ <span class="author">&lt;<%= ANONYMOUS_POSTER %>&gt;</span>
62
+ <% end %>
63
+
64
+ <%= link_to elt.subject.gsub(/\[.*\]/, ''), :action => 'show', :id => elt %>
65
+ </li>
66
+ <% end %>
67
+ </ul>
68
+
69
+ <%= link_to image_tag("/images/webfeed.gif"), :action => 'vote_rss', :id => @elt %>
70
+ </div>
71
+
@@ -0,0 +1,29 @@
1
+ <table border="1" id="choices_<%= @elt.id %>" class="choices">
2
+ <caption><h2><%= @elt.subject %></h2></caption>
3
+ <tr onclick="Element.remove(this.parentNode);return false;">
4
+ <th><label class="con" title="-1">V</label></th>
5
+ <th><label title="0">0</label></th>
6
+ <th><label class="pro" title="+1">Λ</label></th>
7
+ <th style="border: none"><a href="#" class="closeChoices">X</a></th>
8
+ </tr>
9
+ <tr>
10
+ <% (-1..1).each { |n| %>
11
+ <td>
12
+ <% @elt.choices.select{ |c| c.value == n }.reverse.each { |c| %>
13
+ <div class="personalChoice" title="<%= c.created_on.strftime('%d/%m %H:%M') %>">
14
+ <span class="created_on"><%= c.created_on.strftime('%d/%m %H:%M') %></span>
15
+ <% if c.person %>
16
+ <span class="author">
17
+ &lt;<%= link_to c.person.name, :controller => 'person',
18
+ :action => 'show', :id => c.person %>&gt;
19
+ </span>
20
+ <% else %>
21
+ <span class="author">&lt;<%= ANONYMOUS_POSTER %>&gt;</span>
22
+ <% end %>
23
+ </div>
24
+ <% } %>
25
+ </td>
26
+ <% } %>
27
+ </tr>
28
+ </table>
29
+