parlement 0.12 → 0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +16 -0
- data/MEMORY +4 -0
- data/README +1 -0
- data/app/controllers/account_controller.rb +3 -0
- data/app/controllers/application.rb +15 -0
- data/app/controllers/elt_controller.rb +64 -2
- data/app/controllers/subscriber_controller.rb +0 -6
- data/app/helpers/elt_helper.rb +28 -18
- data/app/models/elt.rb +8 -3
- data/app/models/old_visit.rb +4 -0
- data/app/models/person.rb +4 -0
- data/app/models/visit.rb +4 -0
- data/app/views/account/_show.rhtml +11 -3
- data/app/views/elt/_listByDate.rhtml +74 -58
- data/app/views/elt/_listByVote.rhtml +70 -65
- data/app/views/elt/_listVisitors.rhtml +20 -0
- data/app/views/elt/new.rhtml +36 -23
- data/app/views/elt/show.rhtml +30 -15
- data/app/views/subscriber/_list.rhtml +24 -15
- data/config/database.yml +3 -3
- data/config/environment.rb +1 -1
- data/db/ROOT/Titemagli.txt +3 -0
- data/db/ROOT/titemagli.txt +9 -0
- data/db/development_structure.sql +343 -53
- data/db/migrate/007_create_visits.rb +19 -0
- data/db/migrate/008_create_old_visits.rb +18 -0
- data/db/migrate/009_add_person_last_login.rb +9 -0
- data/db/schema.rb +22 -1
- data/public/images/feed-icon-14x14.png +0 -0
- data/public/images/feed-icon-28x28.png +0 -0
- data/public/javascripts/mybehaviour.js +13 -4
- data/public/stylesheets/default.css +46 -42
- data/test/unit/visit_test.rb +10 -0
- metadata +226 -216
- data/public/images/webfeed.gif +0 -0
data/CHANGES
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
- parlement changelog
|
2
2
|
|
3
|
+
== Version 0.13 ==
|
4
|
+
|
5
|
+
Better filtering. Periodical updating of visitors, subscribers and elements
|
6
|
+
lists.
|
7
|
+
|
8
|
+
* do not filter out the top element
|
9
|
+
* filtered elements are now only displayed as simple clickable >
|
10
|
+
* correction, no more showing the subscriptionLink even when it is not already
|
11
|
+
present
|
12
|
+
* lists didn't refer to the proper div id, resulting in the creation of
|
13
|
+
infinitely nested div over time
|
14
|
+
* possibility to preview then modify, in two distinct steps
|
15
|
+
* visits, subscribers and elements lists updated every 10s
|
16
|
+
* lists only display elements whose rating is above the filter
|
17
|
+
* new feed icon, placed alongside the associated box title
|
18
|
+
|
3
19
|
== Version 0.12
|
4
20
|
|
5
21
|
Internationalization
|
data/MEMORY
CHANGED
data/README
CHANGED
@@ -14,6 +14,7 @@ On debian, here are the commands used to setup a parlement server:
|
|
14
14
|
# apt-get install libpgsql-ruby
|
15
15
|
# apt-get install irb
|
16
16
|
# apt-get install rdoc
|
17
|
+
# apt-get install rake
|
17
18
|
|
18
19
|
Basically this install postgresql, ruby and the ruby driver to psql. Ruby on
|
19
20
|
Rails is database agnostic, parlement will be sometimes in the future.
|
@@ -100,6 +100,9 @@ class AccountController < UserController
|
|
100
100
|
if session[:person]
|
101
101
|
cookies[:person_name] = { :value => session[:person].name, :expires => 3.years.from_now }
|
102
102
|
cookies[:salted_password] = { :value => @user.salted_password, :expires => 3.years.from_now } if @user
|
103
|
+
|
104
|
+
@person.last_login = Time.now
|
105
|
+
@person.save
|
103
106
|
end
|
104
107
|
|
105
108
|
# To make sure the logout knows which elt's choices to update
|
@@ -5,6 +5,8 @@ require 'login_engine'
|
|
5
5
|
require 'term/ansicolor'
|
6
6
|
|
7
7
|
class ApplicationController < ActionController::Base
|
8
|
+
helper_method :filter
|
9
|
+
|
8
10
|
include LoginEngine
|
9
11
|
include Term::ANSIColor
|
10
12
|
|
@@ -32,8 +34,21 @@ class ApplicationController < ActionController::Base
|
|
32
34
|
logger.info yellow { bold { "#{person.name} is back" } }
|
33
35
|
session[:person] = person
|
34
36
|
session[:user] = person.user
|
37
|
+
|
38
|
+
person.last_login = Time.now
|
39
|
+
person.save
|
35
40
|
end
|
36
41
|
end
|
37
42
|
end
|
43
|
+
|
44
|
+
def filter
|
45
|
+
if request.cookies['filter'] && request.cookies['filter'][0]
|
46
|
+
filter = request.cookies['filter'][0].to_i - 1
|
47
|
+
filter = nil unless filter >= 0
|
48
|
+
else
|
49
|
+
filter = 0
|
50
|
+
end
|
51
|
+
filter
|
52
|
+
end
|
38
53
|
end
|
39
54
|
|
@@ -14,6 +14,7 @@ class EltController < ApplicationController
|
|
14
14
|
@elt = Elt.find(params[:id])
|
15
15
|
@title = @elt.subject
|
16
16
|
@title += " (parlement)" if !@title.downcase.include? "parlement"
|
17
|
+
|
17
18
|
render :layout => 'top'
|
18
19
|
|
19
20
|
rescue ActiveRecord::RecordNotFound => e
|
@@ -37,6 +38,68 @@ class EltController < ApplicationController
|
|
37
38
|
render :partial => 'listByVote'
|
38
39
|
end
|
39
40
|
|
41
|
+
def listVisitors
|
42
|
+
@elt = Elt.find params[:id] unless @elt
|
43
|
+
render :partial => 'listVisitors'
|
44
|
+
end
|
45
|
+
|
46
|
+
def listSubscribers
|
47
|
+
@elt = Elt.find params[:id] unless @elt
|
48
|
+
render :partial => '/subscriber/list'
|
49
|
+
end
|
50
|
+
|
51
|
+
def updateView
|
52
|
+
session[:lastUpdatedView] ||= Time.now - 10
|
53
|
+
acts = ""
|
54
|
+
visits = Visit.count \
|
55
|
+
:joins => "JOIN elts e1 ON e1.id = '#{params[:id]}' \
|
56
|
+
JOIN elts e2 ON visits.elt_id = e2.id \
|
57
|
+
AND ((e1.lft <= e2.lft AND e2.rgt <= e1.rgt) \
|
58
|
+
OR (e1.lft > e2.lft AND e2.rgt > e1.rgt))",
|
59
|
+
:conditions => "visits.updated_on >= '#{session[:lastUpdatedView]}'"
|
60
|
+
acts += "new Ajax.Updater('listVisitors', '/elt/listVisitors/#{params[:id]}', \
|
61
|
+
{asynchronous:true, evalScripts:true}); \
|
62
|
+
" if visits > 0
|
63
|
+
|
64
|
+
subscribers = Subscription.count \
|
65
|
+
:joins => "JOIN elts e1 ON e1.id = '#{params[:id]}' \
|
66
|
+
JOIN elts e2 ON subscriptions.elt_id = e2.id \
|
67
|
+
AND ((e1.lft <= e2.lft AND e2.rgt <= e1.rgt) \
|
68
|
+
OR (e1.lft > e2.lft AND e2.rgt > e1.rgt))",
|
69
|
+
:conditions => "subscriptions.created_on >= '#{session[:lastUpdatedView]}'"
|
70
|
+
acts += "new Ajax.Updater('listSubscribers', '/elt/listSubscribers/#{params[:id]}', \
|
71
|
+
{asynchronous:true, evalScripts:true}); \
|
72
|
+
" if subscribers > 0
|
73
|
+
|
74
|
+
elts = Elt.count \
|
75
|
+
:joins => "LEFT JOIN choices ON choices.elt_id = elts.id \
|
76
|
+
JOIN elts e2 ON elts.lft <= e2.lft AND e2.rgt <= elts.rgt",
|
77
|
+
:conditions => "elts.id = '#{params[:id]}' \
|
78
|
+
AND e2.created_on >= '#{session[:lastUpdatedView]}'"
|
79
|
+
acts += "new Ajax.Updater('listByDate', '/elt/listByDate/#{params[:id]}', \
|
80
|
+
{asynchronous:true, evalScripts:true});" \
|
81
|
+
+ "new Ajax.Updater('listByVote', '/elt/listByVote/#{params[:id]}', \
|
82
|
+
{asynchronous:true, evalScripts:true}); \
|
83
|
+
" if subscribers > 0
|
84
|
+
|
85
|
+
if person = session[:person]
|
86
|
+
visit = Visit.find_by_person_id_and_elt_id(person, params[:id])
|
87
|
+
if visit and person.last_login and person.last_login > visit.created_on then
|
88
|
+
logger.info "New visit"
|
89
|
+
visit.destroy
|
90
|
+
visit = nil
|
91
|
+
end
|
92
|
+
visit = Visit.new(:person => person, :elt_id => params[:id]) unless visit
|
93
|
+
visit.filter = filter
|
94
|
+
visit.save!
|
95
|
+
end
|
96
|
+
|
97
|
+
logger.info "#{visits} visits, #{subscribers} subscribers, #{elts} elts"
|
98
|
+
session[:lastUpdatedView] = Time.now
|
99
|
+
render :inline => " \
|
100
|
+
<script type=\"text/javascript\">#{acts}</script>"
|
101
|
+
end
|
102
|
+
|
40
103
|
def rss
|
41
104
|
params[:id] = params[:id].gsub(/.rss/, '')
|
42
105
|
headers["Content-Type"] = "text/xml; charset=utf-8"
|
@@ -51,8 +114,7 @@ class EltController < ApplicationController
|
|
51
114
|
|
52
115
|
# Used to initialise the elt, its subject mainly
|
53
116
|
def new
|
54
|
-
@elt = Elt.new
|
55
|
-
@elt.parent = Elt.find(params[:id])
|
117
|
+
@elt = Elt.new(:parent_id => params[:id], :body => "")
|
56
118
|
|
57
119
|
if @elt.parent.subject.include? 'Re: '
|
58
120
|
@elt.subject = @elt.parent.subject
|
@@ -17,12 +17,6 @@ class SubscriberController < ApplicationController
|
|
17
17
|
Subscription.find_by_person_id_and_elt_id(session[:person].id, elt2.id).destroy
|
18
18
|
logger.info yellow { "User #{session[:person].name} unsubscribed from #{elt2.subject}..." }
|
19
19
|
else
|
20
|
-
if cookies[:filter]
|
21
|
-
filter = cookies[:filter].to_i - 1
|
22
|
-
filter = nil unless filter >= 0
|
23
|
-
else
|
24
|
-
filter = 0
|
25
|
-
end
|
26
20
|
@elt.subscriptions.create :person => session[:person], :filter => filter
|
27
21
|
logger.info yellow { "User #{session[:person].name} subscribed to #{@elt.id} with filter #{filter}..." }
|
28
22
|
end
|
data/app/helpers/elt_helper.rb
CHANGED
@@ -1,8 +1,33 @@
|
|
1
1
|
module EltHelper
|
2
|
+
def countEltsAboveFilter
|
3
|
+
Elt.count_by_sql "\
|
4
|
+
SELECT COUNT(*) \
|
5
|
+
FROM (SELECT elts.id FROM elts \
|
6
|
+
LEFT JOIN choices ON choices.elt_id = elts.id \
|
7
|
+
WHERE lft > #{@elt.lft} AND rgt < #{@elt.rgt} \
|
8
|
+
GROUP BY elts.id \
|
9
|
+
HAVING SUM(value) >= #{filter||-10**10}) AS notUsed"
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# Should we display an element's title
|
14
|
+
#
|
15
|
+
# The algo used is simple, display a title if it is not a simple reply to its
|
16
|
+
# parent
|
17
|
+
#
|
18
|
+
def displayTitle? elt
|
19
|
+
#elt.id and elt.subject.reverse.index(elt.parent.subject.reverse) != 0
|
20
|
+
elt.id and elt.parent and elt.subject and !elt.subject.empty? \
|
21
|
+
and elt.subject != elt.parent.subject \
|
22
|
+
and elt.parent.subject \
|
23
|
+
and elt.subject.downcase != elt.parent.subject.downcase \
|
24
|
+
and not elt.subject.sub(/(Re|RE|r�f|re|sv|aw):\s*/, '') == elt.parent.subject
|
25
|
+
end
|
26
|
+
|
2
27
|
def format(data)
|
3
28
|
# for italics /.../ to _..._ \
|
4
|
-
|
5
|
-
|
29
|
+
# .gsub(/(\s+)\/([\w\s�������]*)\//, '\\1_\\2_') \
|
30
|
+
#
|
6
31
|
# On Date Time someone wrote: blockquote
|
7
32
|
# Yahoo footer
|
8
33
|
# Google footer
|
@@ -24,7 +49,7 @@ module EltHelper
|
|
24
49
|
.gsub(/^\s\*(.*)\*/, '*\\1*') \
|
25
50
|
.gsub(/^\b(.{2,50})$(\n)\b/, '\\1<br/>\\2') \
|
26
51
|
.gsub(/\n*^\b(position\s*:\s*(\d*(\.\d+)?))\s*$\n*/, ' <span class="position">\1</span>') \
|
27
|
-
|
52
|
+
if data != nil
|
28
53
|
|
29
54
|
# Only show the n first paragraphs
|
30
55
|
text.gsub!(/((?:(\n)(?:^.+$\n)*){#{NB_PARAGRAPH_TO_DISPLAY}})((?:.|\n)*)/,
|
@@ -55,20 +80,5 @@ module EltHelper
|
|
55
80
|
|
56
81
|
textiled
|
57
82
|
end
|
58
|
-
|
59
|
-
#
|
60
|
-
# Should we display an element's title
|
61
|
-
#
|
62
|
-
# The algo used is simple, display a title if it is not a simple reply to its
|
63
|
-
# parent
|
64
|
-
#
|
65
|
-
def displayTitle? elt
|
66
|
-
#elt.id and elt.subject.reverse.index(elt.parent.subject.reverse) != 0
|
67
|
-
elt.id and elt.parent and elt.subject and !elt.subject.empty? \
|
68
|
-
and elt.subject != elt.parent.subject \
|
69
|
-
and elt.parent.subject \
|
70
|
-
and elt.subject.downcase != elt.parent.subject.downcase \
|
71
|
-
and not elt.subject.sub(/(Re|RE|r�f|re|sv|aw):\s*/, '') == elt.parent.subject
|
72
|
-
end
|
73
83
|
end
|
74
84
|
|
data/app/models/elt.rb
CHANGED
@@ -25,6 +25,11 @@ class Elt < ActiveRecord::Base
|
|
25
25
|
has_many :subscriptions, :dependent => :destroy
|
26
26
|
has_many :subscribers, :through => :subscriptions, :source => :person
|
27
27
|
|
28
|
+
has_many :visits, :dependent => :destroy
|
29
|
+
has_many :visitors, :through => :visits, :source => :person
|
30
|
+
has_many :old_visits, :dependent => :destroy
|
31
|
+
has_many :old_visitors, :through => :old_visits, :source => :person
|
32
|
+
|
28
33
|
acts_as_nested_set :order => "position is not null, position, last_activity DESC, created_on DESC"
|
29
34
|
acts_as_tree :order => "position is not null, position, last_activity DESC, created_on DESC", :counter_cache => true
|
30
35
|
|
@@ -39,9 +44,9 @@ class Elt < ActiveRecord::Base
|
|
39
44
|
|
40
45
|
def all_subscriptions
|
41
46
|
if parent
|
42
|
-
|
47
|
+
(subscriptions + parent.all_subscriptions).uniq
|
43
48
|
else
|
44
|
-
|
49
|
+
subscriptions
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
@@ -73,7 +78,7 @@ class Elt < ActiveRecord::Base
|
|
73
78
|
|
74
79
|
parent.vote Regexp.last_match(1), person if body =~ /^\s*(-1|0|\+1)(\s|$)/
|
75
80
|
if Regexp.last_match(1) and self.body.gsub(/(-1|0|\+1)/, '').strip.empty?
|
76
|
-
|
81
|
+
# Hide simple votes
|
77
82
|
vote -1
|
78
83
|
else
|
79
84
|
vote if person
|
data/app/models/person.rb
CHANGED
@@ -7,6 +7,10 @@ class Person < ActiveRecord::Base
|
|
7
7
|
has_many :subscribed_elts, :through => :subscriptions, :source => :elt
|
8
8
|
has_many :person_mails, :dependent => :destroy
|
9
9
|
has_many :mails, :through => :person_mails, :source => :mail
|
10
|
+
has_many :visits, :dependent => :destroy
|
11
|
+
has_many :visited, :through => :visits, :source => :elt
|
12
|
+
has_many :old_visits, :dependent => :destroy
|
13
|
+
has_many :old_visited, :through => :old_visits, :source => :elt
|
10
14
|
|
11
15
|
validates_presence_of :name, :on => :create
|
12
16
|
validates_length_of :name, :within => 3..80, :on => :create
|
data/app/models/visit.rb
ADDED
@@ -1,3 +1,5 @@
|
|
1
|
+
<h3 class="boxTitle"><%= _('Identity')%></h3>
|
2
|
+
|
1
3
|
<% flash.each do |key, value| %>
|
2
4
|
<div class="<%= key %>"><%= value %></div>
|
3
5
|
<% end %>
|
@@ -19,12 +21,18 @@
|
|
19
21
|
<% end %>
|
20
22
|
|
21
23
|
<% if @person = session[:person] %>
|
22
|
-
<script language="JavaScript">
|
24
|
+
<script language="JavaScript">
|
25
|
+
if ($('subscriptionLink')) {
|
26
|
+
Element.show($('subscriptionLink'));
|
27
|
+
}
|
28
|
+
</script>
|
23
29
|
<span class="logout">
|
24
30
|
<%= link_to_remote('[X]',
|
25
31
|
{ :update => 'identity',
|
26
32
|
:url => { :controller => 'account', :action => 'logout', :elt => @elt },
|
27
|
-
|
33
|
+
:before => visual_effect(:BlindUp, 'identity', { :queue => 'login' }) \
|
34
|
+
+visual_effect(:BlindUp, 'subscriptionLink', { :queue => 'login' }) \
|
35
|
+
+"resetChoices();",
|
28
36
|
:loaded => visual_effect(:BlindDown, 'identity', { :queue => 'login' }) },
|
29
37
|
{ :href => url_for(:controller => 'account', :action => 'logout') }) %>
|
30
38
|
</span>
|
@@ -41,7 +49,7 @@
|
|
41
49
|
</div>
|
42
50
|
|
43
51
|
<fieldset id="edit">
|
44
|
-
|
52
|
+
<legend><%= _('Edit') %></legend>
|
45
53
|
<% form_remote_tag(
|
46
54
|
:update => 'identity',
|
47
55
|
:url => { :controller => 'account', :action => 'setPassword' },
|
@@ -1,60 +1,76 @@
|
|
1
|
+
<%= link_to image_tag("/images/feed-icon-28x28.png"),
|
2
|
+
{ :action => 'rss', :id => @elt }, :class => 'feed' %>
|
3
|
+
<h3 class="boxTitle"><%= _('Latest posts') %></h3>
|
4
|
+
|
1
5
|
<%e_pages = ActionController::Pagination::Paginator.new(
|
2
|
-
self,
|
3
|
-
elts = Elt.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
6
|
+
self, countEltsAboveFilter, LIST_LENGTH, params['page'])
|
7
|
+
elts = Elt.find_by_sql " \
|
8
|
+
SELECT SUM(value) AS resultLocal, elts.id, parent_id, elts.created_on, parent_id, \
|
9
|
+
elts_count, position, elts.person_id, subject, body, lft, rgt \
|
10
|
+
FROM elts \
|
11
|
+
LEFT JOIN choices ON choices.elt_id = elts.id \
|
12
|
+
WHERE lft > #{@elt.lft} AND rgt < #{@elt.rgt} \
|
13
|
+
GROUP BY elts.id, parent_id, elts.created_on, parent_id, elts_count, \
|
14
|
+
position, elts.person_id, subject, body, lft, rgt \
|
15
|
+
HAVING SUM(value) >= #{filter||-10**10} \
|
16
|
+
ORDER BY created_on DESC \
|
17
|
+
LIMIT #{e_pages.items_per_page} \
|
18
|
+
OFFSET #{e_pages.current.offset}" %>
|
19
|
+
|
20
|
+
<% if e_pages.length > 1 %>
|
21
|
+
<%= link_to_remote('|<',
|
22
|
+
{ :update => 'listByDate',
|
23
|
+
:url => { :action => 'listByDate', :id => @elt, :page => e_pages.last },
|
24
|
+
:before => visual_effect(:BlindUp, 'listByDate', { :queue => 'end' }),
|
25
|
+
:loaded => visual_effect(:BlindDown, 'listByDate', { :queue => 'end' }) }) \
|
26
|
+
if e_pages.last != e_pages.current %>
|
27
|
+
<%= link_to_remote('<',
|
28
|
+
{ :update => 'listByDate',
|
29
|
+
:url => { :action => 'listByDate', :id => @elt, :page => e_pages.current.next },
|
30
|
+
:before => visual_effect(:BlindUp, 'listByDate', { :queue => 'end' }),
|
31
|
+
:loaded => visual_effect(:BlindDown, 'listByDate', { :queue => 'end' }) }) \
|
32
|
+
if e_pages.current.next and e_pages.current.next != e_pages.last %>
|
33
|
+
|
34
|
+
<span class="pageCount"><%= e_pages.length-e_pages.current.to_i+1 %></span>
|
35
|
+
|
36
|
+
<%= link_to_remote('>',
|
37
|
+
{ :update => 'listByDate',
|
38
|
+
:url => { :action => 'listByDate', :id => @elt, :page => e_pages.current.previous },
|
39
|
+
:before => visual_effect(:BlindUp, 'listByDate', { :queue => 'end' }),
|
40
|
+
:loaded => visual_effect(:BlindDown, 'listByDate', { :queue => 'end' }) }) \
|
41
|
+
if e_pages.current.previous and e_pages.current.previous != e_pages.first %>
|
42
|
+
<%= link_to_remote('>|',
|
43
|
+
{ :update => 'listByDate',
|
44
|
+
:url => { :action => 'listByDate', :id => @elt, :page => e_pages.first },
|
45
|
+
:before => visual_effect(:BlindUp, 'listByDate', { :queue => 'end' }),
|
46
|
+
:loaded => visual_effect(:BlindDown, 'listByDate', { :queue => 'end' }) }) \
|
47
|
+
if e_pages.first != e_pages.current %>
|
48
|
+
<% end %>
|
49
|
+
|
50
|
+
<ul>
|
51
|
+
<% elts.each do |elt| %>
|
52
|
+
<li class="boxLine elt" title="<%= elt.created_on.strftime '%d/%m %H:%M' %>">
|
53
|
+
<span class="created_on"><%= elt.created_on.strftime '%d/%m %H:%M' %></span>
|
54
|
+
<span>
|
55
|
+
<%= link_to_remote("%+d" % elt.resultlocal,
|
56
|
+
{ :update => 'resultList_'+elt.id,
|
57
|
+
:position => :top,
|
58
|
+
:url => { :action => 'choices', :id => elt } },
|
59
|
+
{ :class => 'result', :id => "resultList_#{ elt.id}",
|
60
|
+
:href => url_for(:controller => 'elt', :action => 'choices', :id => elt) }
|
61
|
+
) if elt.resultlocal %>
|
62
|
+
</span>
|
63
|
+
|
64
|
+
<% if elt.person %>
|
65
|
+
<span class="author">
|
66
|
+
<<%= link_to elt.person.name, :controller => 'person', :action => 'show', :id => elt.person %>>
|
67
|
+
</span>
|
68
|
+
<% elsif not displayTitle? elt %>
|
69
|
+
<span class="author"><<%= ANONYMOUS_POSTER %>></span>
|
70
|
+
<% end %>
|
71
|
+
|
72
|
+
<%= link_to elt.subject.gsub(/\[.*\]/, ''), :action => 'show', :id => elt %>
|
73
|
+
</li>
|
74
|
+
<% end %>
|
75
|
+
</ul>
|
60
76
|
|
@@ -1,73 +1,78 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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" %>
|
1
|
+
<%= link_to image_tag("/images/feed-icon-28x28.png"),
|
2
|
+
{ :action => 'vote_rss', :id => @elt }, :class => 'feed' %>
|
3
|
+
<h3 class="boxTitle">
|
4
|
+
<%= _('Highest posts') %>
|
5
|
+
</h3>
|
13
6
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
7
|
+
<%e_pages = ActionController::Pagination::Paginator.new(
|
8
|
+
self, countEltsAboveFilter, LIST_LENGTH, params['page'])
|
9
|
+
elts = Elt.find_by_sql " \
|
10
|
+
SELECT SUM(value) AS resultLocal, elts.id, parent_id, elts.created_on, parent_id, \
|
11
|
+
elts_count, position, elts.person_id, subject, body, lft, rgt \
|
12
|
+
FROM elts \
|
13
|
+
LEFT JOIN choices ON choices.elt_id = elts.id \
|
14
|
+
WHERE lft > #{@elt.lft} AND rgt < #{@elt.rgt} \
|
15
|
+
GROUP BY elts.id, parent_id, elts.created_on, parent_id, elts_count, \
|
16
|
+
position, elts.person_id, subject, body, lft, rgt \
|
17
|
+
HAVING SUM(value) >= #{filter||-10**10} \
|
18
|
+
ORDER BY SUM(value) IS NULL, SUM(value) DESC, created_on DESC \
|
19
|
+
LIMIT #{e_pages.items_per_page} \
|
20
|
+
OFFSET #{e_pages.current.offset}" %>
|
28
21
|
|
29
|
-
|
22
|
+
<% if e_pages.length > 1 %>
|
23
|
+
<%= link_to_remote('|<',
|
24
|
+
{ :update => 'listByVote',
|
25
|
+
:url => { :action => 'listByVote', :id => @elt, :page => e_pages.last },
|
26
|
+
:before => visual_effect(:BlindUp, 'listByVote', { :queue => 'end' }),
|
27
|
+
:loaded => visual_effect(:BlindDown, 'listByVote', { :queue => 'end' }) }) \
|
28
|
+
if e_pages.last != e_pages.current %>
|
29
|
+
<%= link_to_remote('<',
|
30
|
+
{ :update => 'listByVote',
|
31
|
+
:url => { :action => 'listByVote', :id => @elt, :page => e_pages.current.next },
|
32
|
+
:before => visual_effect(:BlindUp, 'listByVote', { :queue => 'end' }),
|
33
|
+
:loaded => visual_effect(:BlindDown, 'listByVote', { :queue => 'end' }) }) \
|
34
|
+
if e_pages.current.next and e_pages.current.next != e_pages.last %>
|
30
35
|
|
31
|
-
|
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('>|',
|
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 %>
|
36
|
+
<span class="pageCount"><%= e_pages.length-e_pages.current.to_i+1 %></span>
|
44
37
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
38
|
+
<%= link_to_remote('>',
|
39
|
+
{ :update => 'listByVote',
|
40
|
+
:url => { :action => 'listByVote', :id => @elt, :page => e_pages.current.previous },
|
41
|
+
:before => visual_effect(:BlindUp, 'listByVote', { :queue => 'end' }),
|
42
|
+
:loaded => visual_effect(:BlindDown, 'listByVote', { :queue => 'end' }) }) \
|
43
|
+
if e_pages.current.previous and e_pages.current.previous != e_pages.first %>
|
44
|
+
<%= link_to_remote('>|',
|
45
|
+
{ :update => 'listByVote',
|
46
|
+
:url => { :action => 'listByVote', :id => @elt, :page => e_pages.first },
|
47
|
+
:before => visual_effect(:BlindUp, 'listByVote', { :queue => 'end' }),
|
48
|
+
:loaded => visual_effect(:BlindDown, 'listByVote', { :queue => 'end' }) }) \
|
49
|
+
if e_pages.first != e_pages.current %>
|
50
|
+
<% end %>
|
57
51
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
52
|
+
<ul>
|
53
|
+
<% elts.each do |elt| %>
|
54
|
+
<li class="boxLine elt" title="<%= elt.created_on.strftime '%d/%m %H:%M' %>">
|
55
|
+
<span class="created_on"><%= elt.created_on.strftime '%d/%m %H:%M' %></span>
|
56
|
+
<span>
|
57
|
+
<%= link_to_remote("%+d" % elt.resultlocal,
|
58
|
+
{ :update => 'resultList_'+elt.id,
|
59
|
+
:position => :top,
|
60
|
+
:url => { :action => 'choices', :id => elt } },
|
61
|
+
{ :class => 'result', :id => "resultList_#{ elt.id}",
|
62
|
+
:href => url_for(:controller => 'elt', :action => 'choices', :id => elt) }
|
63
|
+
) if elt.resultlocal %>
|
64
|
+
</span>
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
<% if elt.person %>
|
67
|
+
<span class="author">
|
68
|
+
<<%= link_to elt.person.name, :controller => 'person', :action => 'show', :id => elt.person %>>
|
69
|
+
</span>
|
70
|
+
<% elsif not displayTitle? elt %>
|
71
|
+
<span class="author"><<%= ANONYMOUS_POSTER %>></span>
|
72
|
+
<% end %>
|
70
73
|
|
71
|
-
|
72
|
-
</
|
74
|
+
<%= link_to elt.subject.gsub(/\[.*\]/, ''), :action => 'show', :id => elt %>
|
75
|
+
</li>
|
76
|
+
<% end %>
|
77
|
+
</ul>
|
73
78
|
|