parlement 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +9 -0
- data/README +9 -3
- data/app/helpers/elt_helper.rb +2 -2
- data/app/helpers/mailman.rb +4 -5
- data/app/models/choice.rb +4 -0
- data/app/models/elt.rb +31 -43
- data/app/models/mail.rb +68 -50
- data/app/models/mail_notify.rb +4 -4
- data/app/models/person.rb +2 -0
- data/app/views/account/_show.rhtml +7 -7
- data/app/views/elt/_elt.rhtml +65 -59
- data/app/views/elt/_list.rhtml +25 -7
- data/app/views/elt/new.rhtml +9 -9
- data/app/views/elt/show.rhtml +18 -6
- data/app/views/layouts/top.rhtml +9 -2
- data/app/views/mail_notify/publish.text.html.rhtml +4 -1
- data/app/views/person/_listElts.rhtml +2 -1
- data/app/views/person/show.rhtml +1 -3
- data/config/environment.rb +1 -1
- data/db/ROOT/parlement/ddRing.txt +1 -1
- data/db/ROOT/parlement/news/release0.4.txt +15 -0
- data/db/ROOT/parlement/news/release0.5.txt +3 -0
- data/db/ROOT/parlement/our-constitution.txt +11 -0
- data/db/ROOT/parlement/top-politics.txt +8 -10
- data/db/development_structure.sql +33 -21
- data/db/migrate/001_create_choices.rb +27 -0
- data/db/schema.sql +4 -3
- data/test/fixtures/choices.yml +13 -0
- data/test/fixtures/mail/mail_ruby +7 -0
- data/test/fixtures/mail/mail_rubyChild +3 -1
- data/test/fixtures/mail/mail_rubyChild2 +30 -0
- data/test/fixtures/subscribers.yml +3 -0
- data/test/unit/choice_test.rb +10 -0
- data/test/unit/mail_notify_test.rb +2 -2
- data/test/unit/mail_test.rb +52 -28
- data/test/unit/subscriber_test.rb +8 -1
- metadata +12 -2
data/CHANGES
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
- parlement changelog
|
2
2
|
|
3
|
+
== Version 0.5
|
4
|
+
|
5
|
+
Voting. Mails containing -1, 0 or +1 trigger a vote
|
6
|
+
|
7
|
+
* correct charset decoding when receiving a mail
|
8
|
+
* better ul li previews and proposals
|
9
|
+
|
10
|
+
|
3
11
|
== Version 0.4
|
4
12
|
|
5
13
|
Evolutions and corrections
|
@@ -16,6 +24,7 @@ Evolutions and corrections
|
|
16
24
|
* simplifications for w3m display
|
17
25
|
* yahoo and google footers now hidden
|
18
26
|
|
27
|
+
|
19
28
|
== Version 0.3
|
20
29
|
|
21
30
|
Major version, adding the possibility to use not only the web forums, but mails
|
data/README
CHANGED
@@ -65,9 +65,15 @@ Parameters
|
|
65
65
|
- votes
|
66
66
|
|
67
67
|
|
68
|
-
Here is my console code to reset threads from their original mails:
|
69
|
-
|
68
|
+
# Here is my console code to reset threads from their original mails:
|
70
69
|
>> elts=Mail.find_all.select{|m|m.file and mail=TMail::Mail.parse(m.file) and reply=mail.in_reply_to and mailObject=Mail.find_by_message(reply) and mailObject.elt.id!=m.elt.parent_id}.collect{|m| {:elt=>m.elt.id, :parent=>Mail.find_by_message(TMail::Mail.parse(m.file).in_reply_to).elt.id}}; puts elts.size
|
71
|
-
|
72
70
|
>> elts.each{|e|print e[:elt], ' ', e[:parent], ' '; puts Elt.update_all("parent_id='#{e[:parent]}'", "id='#{e[:elt]}'")}; puts elts.size
|
73
71
|
|
72
|
+
# To get duplicate messages
|
73
|
+
>> messages=Mail.find_by_sql "select message from mails group by message having count(message) > 1"; puts messages.length
|
74
|
+
>> messages.each{ |m| mail=Mail.find_all_by_message m.message; mail.each{|m| print m.elt.id, ' ', m.elt.subject, ' ', m.elt.children.size; puts } }; puts messages.length
|
75
|
+
|
76
|
+
# To get all existing votes
|
77
|
+
elts=Elt.find(:all, :conditions => ["body LIKE '%%+1%%' OR body LIKE '%%0%%' OR body LIKE '%%-1%%'"]); puts elts.size
|
78
|
+
elts.each { |e| print '(', Regexp.last_match(1), ')' if e.body =~ /^\s*(-1|0|\+1)(\s*|$)/ }; puts; puts elts.size
|
79
|
+
elts.each { |e| e.vote(Regexp.last_match(1), e.person) if e.body =~ /^\s*(-1|0|\+1)(\s*|$)/ }; puts; puts elts.size
|
data/app/helpers/elt_helper.rb
CHANGED
@@ -11,13 +11,13 @@ module EltHelper
|
|
11
11
|
# 1. numbered list
|
12
12
|
# short lines to which are added a break
|
13
13
|
text = auto_link data \
|
14
|
-
.gsub(
|
14
|
+
.gsub(/^\b(.*:)$(\n)^>\s/, '\\1<br/>\\2\\2> ') \
|
15
15
|
.gsub(/^Yahoo! Groups Links$(\n{2}^<*.*$\s.*$)*/, '') \
|
16
16
|
.gsub(/^[-~]*$\n^You.*$\n^To.*$\n^To.*$\n^For more.*$\n^[-~]*$/, '') \
|
17
17
|
.gsub(/(\s+)\/([\w\s]*)\//, '\\1_\\2_') \
|
18
18
|
.gsub(/^-\s/, '* ') \
|
19
19
|
.gsub(/^\d+[\.-]\s+/, '# ') \
|
20
|
-
.gsub(/^\
|
20
|
+
.gsub(/^\b(.{2,50})$(\n)\b/, '\\1<br/>\\2') \
|
21
21
|
if data != nil
|
22
22
|
|
23
23
|
textiled = text.blank? ? "" : RedCloth.new(text)
|
data/app/helpers/mailman.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
#
|
2
|
-
# Receive an email from which
|
2
|
+
# Receive an email from which a model Mail is created.
|
3
3
|
#
|
4
|
-
# An associated
|
5
|
-
#
|
4
|
+
# An associated Elt is generated. Attachments are also created in an associated
|
5
|
+
# table
|
6
6
|
#
|
7
7
|
class Mailman < ActionMailer::Base
|
8
8
|
def receive(email)
|
9
|
-
|
10
|
-
elt.receive(email)
|
9
|
+
Mail.receive email
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
data/app/models/elt.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
#
|
2
2
|
# This is, in fact, the main parlement class!
|
3
3
|
#
|
4
|
+
# It holds all posts, that's mostly a subject and a body, plus their
|
5
|
+
# relationships in a tree of elements
|
6
|
+
#
|
4
7
|
class Elt < ActiveRecord::Base
|
5
8
|
usesguid
|
6
9
|
|
@@ -11,9 +14,10 @@ class Elt < ActiveRecord::Base
|
|
11
14
|
|
12
15
|
belongs_to :person
|
13
16
|
|
14
|
-
has_and_belongs_to_many :subscribers,
|
15
|
-
|
16
|
-
|
17
|
+
has_and_belongs_to_many :subscribers, :class_name => "Person", :join_table => "subscribers"
|
18
|
+
|
19
|
+
has_many :choices
|
20
|
+
has_many :voters, :through => :choices, :source => :person
|
17
21
|
|
18
22
|
# for live_tree
|
19
23
|
def name
|
@@ -22,59 +26,43 @@ class Elt < ActiveRecord::Base
|
|
22
26
|
|
23
27
|
# Just a quick method to get all subscribers as a simple list
|
24
28
|
def all_recipients
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
eltRecipient = eltRecipient.parent
|
29
|
+
if parent
|
30
|
+
(subscribers + parent.all_recipients).uniq
|
31
|
+
else
|
32
|
+
subscribers
|
30
33
|
end
|
31
|
-
logger.debug "all_recipients result: #{result.to_s}"
|
32
|
-
return result
|
33
34
|
end
|
34
35
|
|
35
|
-
|
36
|
-
# Receive this new elt as an email, sent through app/helpers/mailman.rb
|
37
|
-
#
|
38
|
-
def receive(mail)
|
39
|
-
logger.info "Receive \"#{mail.subject}\""
|
36
|
+
alias_method :simple_save, :save
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
# Save, publish and vote this elt
|
39
|
+
def save
|
40
|
+
publish
|
41
|
+
simple_save
|
42
|
+
vote
|
43
|
+
end
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
save
|
53
|
-
else
|
54
|
-
logger.info "Already received (id: #{mail.message_id})...\n"
|
55
|
-
end
|
45
|
+
def vote(value = 1, person = self.person)
|
46
|
+
logger.info "#{person.name if person} vote #{value} on #{subject} #{self.choices}"
|
47
|
+
choices.each{ |c| logger.info c if c.person == person; c.destroy if c.person == person }
|
48
|
+
choice = choices.build :value => value, :person => person
|
49
|
+
choice.save!
|
56
50
|
end
|
57
51
|
|
58
|
-
#
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
publish
|
64
|
-
logger.info "\n"
|
52
|
+
# Get the vote results
|
53
|
+
def result(electoralList = nil)
|
54
|
+
(Choice.count("elt_id = '#{self.id}' AND value = 1") \
|
55
|
+
- \
|
56
|
+
Choice.count("elt_id = '#{self.id}' AND value = -1"))
|
65
57
|
end
|
66
58
|
|
67
59
|
private
|
68
60
|
|
69
|
-
#
|
70
|
-
# Mail the elt to all subscribers
|
71
|
-
#
|
61
|
+
# Mail this elt to all subscribers
|
72
62
|
def publish
|
73
63
|
logger.info "Publish #{subject}"
|
74
|
-
self
|
75
|
-
|
76
|
-
self.mail.publish
|
77
|
-
self.mail.save
|
64
|
+
build_mail(:elt => self) unless mail
|
65
|
+
mail.publish
|
78
66
|
end
|
79
67
|
end
|
80
68
|
|
data/app/models/mail.rb
CHANGED
@@ -9,7 +9,26 @@ class Mail < ActiveRecord::Base
|
|
9
9
|
|
10
10
|
belongs_to :elt
|
11
11
|
|
12
|
+
#
|
13
|
+
# Receive this new elt as an email, sent through app/helpers/mailman.rb
|
14
|
+
#
|
15
|
+
# TODO
|
16
|
+
# Loop detection, will need more work
|
17
|
+
#
|
18
|
+
def Mail.receive(mail)
|
19
|
+
logger.info "Receive \"#{mail.subject}\""
|
12
20
|
|
21
|
+
if Mail.find_by_message(mail.message_id) \
|
22
|
+
or (mail['X-Message-Id'] \
|
23
|
+
and Mail.find_by_message(mail['X-Message-Id'].to_s))
|
24
|
+
logger.info "Already received (id: #{mail.message_id})...\n"
|
25
|
+
|
26
|
+
else
|
27
|
+
m = Mail.new
|
28
|
+
m.receive mail
|
29
|
+
m
|
30
|
+
end
|
31
|
+
end
|
13
32
|
|
14
33
|
""" _
|
15
34
|
_ __ ___ ___ ___(_)_ _____
|
@@ -27,27 +46,34 @@ class Mail < ActiveRecord::Base
|
|
27
46
|
#
|
28
47
|
def receive(mail)
|
29
48
|
logger.info "Receive mail #{mail.message_id}"
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
49
|
+
if mail['X-Leparlement-Elt-Id'] then
|
50
|
+
build_elt :id => mail['X-Leparlement-Elt-Id'].to_s,
|
51
|
+
:created_on => mail.date,
|
52
|
+
:subject => unquote(mail.subject),
|
53
|
+
:body => '',
|
54
|
+
:mail => self
|
55
|
+
else
|
56
|
+
build_elt :created_on => mail.date,
|
57
|
+
:subject => unquote(mail.subject),
|
58
|
+
:body => '',
|
59
|
+
:mail => self
|
60
|
+
end
|
34
61
|
|
35
|
-
elt.person = Person.find_by_email(mail.from)
|
36
|
-
|
37
|
-
|
38
|
-
elt.person.name = unquote
|
62
|
+
elt.person = Person.find_by_email(mail.from) \
|
63
|
+
|| Person.find_by_name(unquote(mail.friendly_from)) \
|
64
|
+
|| elt.build_person
|
65
|
+
elt.person.name = unquote mail.friendly_from
|
39
66
|
elt.person.email = mail.from.first
|
40
67
|
|
41
68
|
# Try to find its mail parent in the db
|
42
|
-
if mail.in_reply_to
|
43
|
-
|
44
|
-
elt.parent = m.elt if m
|
69
|
+
if mail.in_reply_to and Mail.find_by_message mail.in_reply_to
|
70
|
+
elt.parent_id = mail.in_reply_to
|
45
71
|
end
|
46
72
|
|
47
73
|
# Try to find its mail parent in the db
|
48
74
|
if not elt.parent and mail.references
|
49
75
|
for parent in mail.references
|
50
|
-
m = Mail.find_by_message
|
76
|
+
m = Mail.find_by_message parent.to_s
|
51
77
|
elt.parent = m.elt if m
|
52
78
|
end
|
53
79
|
end
|
@@ -58,40 +84,40 @@ class Mail < ActiveRecord::Base
|
|
58
84
|
if not elt.parent and elt.subject.match(/\[[\w-]*\]/)
|
59
85
|
parentId = elt.subject.match(/\[[\w-]*\]/)
|
60
86
|
parentId = parentId[0].gsub(/[\[\]]/, '') if parentId
|
61
|
-
|
62
|
-
elt.parent = Elt.find(parentId)
|
87
|
+
elt.parent = Elt.find parentId
|
63
88
|
end
|
64
89
|
|
65
90
|
# No reference matching an existing parent, let's try the "to" field
|
66
91
|
to = mail["Envelope-to"].to_s + ', ' + mail.to.to_s
|
67
|
-
if not elt.parent and to.match(
|
68
|
-
parentId = to.match(
|
92
|
+
if not elt.parent and to.match(/[\w-]*@#{ActionMailer::Base.server_settings[:domain]}/)
|
93
|
+
parentId = to.match(/[\w-]*@#{ActionMailer::Base.server_settings[:domain]}/)[0] \
|
69
94
|
.gsub(/@#{ActionMailer::Base.server_settings[:domain]}/, '')
|
70
|
-
|
71
|
-
elt.parent = Elt.find(parentId)
|
95
|
+
elt.parent = Elt.find parentId
|
72
96
|
end
|
73
97
|
|
74
98
|
if not elt.parent
|
75
99
|
parentId = "lost+found"
|
76
|
-
|
77
|
-
elt.parent = Elt.find(parentId)
|
100
|
+
elt.parent = Elt.find parentId
|
78
101
|
end
|
79
102
|
|
80
103
|
rescue ActiveRecord::RecordNotFound
|
81
|
-
elt.
|
104
|
+
elt.build_parent :parent_id => 'mail', :subject => parentId, :body => ''
|
82
105
|
elt.parent.id = parentId
|
83
|
-
elt.parent.
|
84
|
-
elt.parent.subject = parentId
|
85
|
-
elt.parent.body = ''
|
86
|
-
elt.parent.save
|
106
|
+
elt.parent.save!
|
87
107
|
end
|
88
108
|
|
89
|
-
#elt.parent = Elt.find('mail') if not elt.parent
|
90
109
|
mngAttachment(mail) if mail
|
91
110
|
|
92
111
|
self.message = mail.message_id
|
93
112
|
self.mail_parents = mail.references
|
94
113
|
self.file = mail.encoded
|
114
|
+
elt.save!
|
115
|
+
|
116
|
+
if elt.body =~ /^\s*(-1|0|\+1)(\s*|$)/ then
|
117
|
+
#print '(', $`, ': ', Regexp.last_match(1), ')'
|
118
|
+
#puts
|
119
|
+
elt.parent.vote Regexp.last_match(1)
|
120
|
+
end
|
95
121
|
end
|
96
122
|
|
97
123
|
|
@@ -102,17 +128,15 @@ class Mail < ActiveRecord::Base
|
|
102
128
|
| .__/ \__,_|_.__/|_|_|___/_| |_|
|
103
129
|
|_| """
|
104
130
|
#
|
105
|
-
# An elt
|
131
|
+
# An elt needs to be published as a mail
|
106
132
|
#
|
107
133
|
def publish
|
108
134
|
logger.info "Publish mail"
|
109
135
|
|
110
136
|
if message and not message.blank? and file
|
111
|
-
mail = TMail::Mail.parse
|
137
|
+
mail = TMail::Mail.parse file
|
112
138
|
else
|
113
|
-
|
114
|
-
mail = MailNotify.create_publish(elt)
|
115
|
-
logger.info "tehre"
|
139
|
+
mail = MailNotify.create_publish elt
|
116
140
|
self.mail_parents = mail.references
|
117
141
|
self.file = mail.encoded
|
118
142
|
end
|
@@ -152,10 +176,8 @@ class Mail < ActiveRecord::Base
|
|
152
176
|
|
153
177
|
# Added to make sure it is not lost, but not modified if already existant
|
154
178
|
mail['X-Message-Id'] = mail.message_id if not mail['X-Message-Id']
|
155
|
-
|
156
179
|
mail['X-leparlement-elt-Id'] = elt.id
|
157
180
|
|
158
|
-
|
159
181
|
MailNotify::deliver(mail) if mail.destinations and not mail.destinations.empty?
|
160
182
|
|
161
183
|
# Do it after sending, to get the actual message id as generated by the MTA
|
@@ -169,33 +191,29 @@ class Mail < ActiveRecord::Base
|
|
169
191
|
|
170
192
|
private
|
171
193
|
|
172
|
-
#
|
173
194
|
# This is to make sure we only have utf-8, no iso-8859
|
174
|
-
#
|
175
195
|
def unquote(text)
|
176
|
-
text.gsub(/\=\?.*?\?\=/)
|
177
|
-
TMail::Unquoter.unquote_and_convert_to(m, 'utf-8')
|
178
|
-
end
|
196
|
+
text.gsub(/\=\?.*?\?\=/) { |m| TMail::Unquoter.unquote_and_convert_to m, 'utf-8' }
|
179
197
|
end
|
180
198
|
|
181
|
-
#
|
182
199
|
# Get and store the attachments
|
183
|
-
#
|
184
200
|
def mngAttachment(attachment)
|
185
201
|
if attachment.content_type == 'text/plain'
|
186
|
-
|
187
|
-
|
202
|
+
charset = attachment.type_param 'charset'
|
203
|
+
if charset and !charset.empty?
|
204
|
+
elt.body += Iconv.new(charset, 'utf-8').iconv(attachment.body)
|
205
|
+
else
|
206
|
+
elt.body += attachment.body
|
207
|
+
end
|
188
208
|
|
189
209
|
elsif attachment.multipart?
|
190
|
-
attachment.parts.each { |part| mngAttachment
|
191
|
-
|
192
|
-
elsif attachment.type_param('name')
|
193
|
-
file = File.new('/tmp/'+attachment.type_param('name'), 'w')
|
194
|
-
file << attachment.body
|
195
|
-
file.flush
|
210
|
+
attachment.parts.each { |part| mngAttachment part }
|
196
211
|
|
197
|
-
|
198
|
-
|
212
|
+
elsif attachment.type_param 'name'
|
213
|
+
File.open('/tmp/'+attachment.type_param('name'), 'w') { |file|
|
214
|
+
file << attachment.body
|
215
|
+
elt.attachments.build :file => file
|
216
|
+
}
|
199
217
|
end
|
200
218
|
end
|
201
219
|
end
|
data/app/models/mail_notify.rb
CHANGED
@@ -70,11 +70,11 @@ class MailNotify < ActionMailer::Base
|
|
70
70
|
# generated ids
|
71
71
|
#
|
72
72
|
def mailing_list(elt)
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
if (elt.id.size > 21 and elt.parent_id != 'ROOT') then
|
74
|
+
mailing_list elt.parent
|
75
|
+
else
|
76
|
+
elt
|
76
77
|
end
|
77
|
-
e
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
data/app/models/person.rb
CHANGED
@@ -6,6 +6,13 @@
|
|
6
6
|
<%= error_messages_for 'user' if @user %>
|
7
7
|
|
8
8
|
<% if @session[:person] %>
|
9
|
+
<span class="logout">
|
10
|
+
<%= link_to_remote('[X]',
|
11
|
+
:update => divId,
|
12
|
+
:url => { :controller => 'account', :action => 'logout', :divId => divId },
|
13
|
+
:complete => visual_effect(:BlindDown, divId)) %>
|
14
|
+
</span>
|
15
|
+
|
9
16
|
<% if @session[:person].name and @session[:person].name != '' %>
|
10
17
|
<span class="author">
|
11
18
|
<%= link_to(@session[:person].name,
|
@@ -14,13 +21,6 @@
|
|
14
21
|
:id => @session[:person]) %>
|
15
22
|
</span>
|
16
23
|
<% end %>
|
17
|
-
|
18
|
-
<span class="logout">
|
19
|
-
<%= link_to_remote('[X]',
|
20
|
-
:update => divId,
|
21
|
-
:url => { :controller => 'account', :action => 'logout', :divId => divId },
|
22
|
-
:complete => visual_effect(:BlindDown, divId)) %>
|
23
|
-
</span>
|
24
24
|
<% else %>
|
25
25
|
|
26
26
|
<%= render :partial => '/account/login', :locals => { :divId => divId } %>
|
data/app/views/elt/_elt.rhtml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
<% eltSubsNb = elt.children.count if eltSubsNb == nil %>
|
2
2
|
|
3
|
-
<li id="elt_<%= elt.id %>"
|
4
|
-
|
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 %>
|
5
13
|
<span class="created_on">
|
6
14
|
<%= elt.created_on.strftime('%d/%m/%y %H:%M') %>
|
7
15
|
</span>
|
@@ -17,26 +25,19 @@
|
|
17
25
|
|
18
26
|
<% if eltTop or displayTitle? elt %>
|
19
27
|
<<%= eltTop ? 'h1' : 'h2' %>>
|
20
|
-
<% if elt.
|
28
|
+
<% if elt.new_record? %>
|
29
|
+
<%= textilize_without_paragraph(elt.subject) %>
|
30
|
+
<% else %>
|
21
31
|
<%= link_to(textilize_without_paragraph(elt.subject),
|
22
32
|
:controller => 'elt', :action => 'show', :id => elt) %>
|
23
|
-
<% else %>
|
24
|
-
<%= textilize_without_paragraph(elt.subject) %>
|
25
33
|
<% end %>
|
26
34
|
</<%= eltTop ? 'h1' : 'h2' %>>
|
27
35
|
<% end %>
|
28
36
|
|
29
37
|
<%= format elt.body %>
|
30
38
|
|
31
|
-
<% for att in elt.attachments %>
|
32
|
-
<%= link_to image_tag('/attachment/file/'+att.file_relative_path),
|
33
|
-
'/attachment/file/'+att.file_relative_path %>
|
34
|
-
<% end %>
|
35
|
-
|
36
|
-
<!-- For IE --> 
|
37
|
-
|
38
39
|
<span class="eltQuickAdd" id="eltQuickAdd_<%= elt.id %>" title="<%= elt.created_on %>">
|
39
|
-
<% if elt.
|
40
|
+
<% if !elt.new_record? and elt.children.count == 0 %>
|
40
41
|
<%= link_to_remote('<span class="icon">>></span>',
|
41
42
|
{ :update => 'eltNew_'+elt.id.to_s,
|
42
43
|
:url => { :controller => 'elt', :action => 'new', :id => elt },
|
@@ -47,60 +48,65 @@
|
|
47
48
|
<% end %>
|
48
49
|
</span>
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
<%= link_to_remote(eltSubsNb.to_s+' more',
|
55
|
-
{ :update => 'eltSubs_'+elt.id.to_s,
|
56
|
-
:url => { :controller => 'elt', :action => 'list', :id => elt },
|
57
|
-
:loading => visual_effect(:SwitchOff, 'eltMore_'+elt.id.to_s),
|
58
|
-
:loaded => visual_effect(:BlindDown, 'eltSubs_'+elt.id.to_s)+
|
59
|
-
visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s)},
|
60
|
-
{ :href => url_for(:controller => 'elt', :action => 'show', :id => elt) }) %>
|
61
|
-
|
62
|
-
<%= link_to_remote('Add <span class="icon">>></span>',
|
63
|
-
{ :update => 'eltNew_'+elt.id.to_s,
|
64
|
-
:url => { :controller => 'elt', :action => 'new', :id => elt },
|
65
|
-
:loaded => visual_effect(:BlindDown, 'eltNew_'+elt.id.to_s)+
|
66
|
-
visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s)},
|
67
|
-
{ :href => url_for(:controller => 'elt', :action => 'new', :id => elt)}) %>
|
68
|
-
</span>
|
69
|
-
|
70
|
-
<span <%= (eltTop or eltSubsNb == 1) ? '' : 'style="display: none"' %>
|
71
|
-
id="eltSubs_<%= elt.id %>">
|
72
|
-
<% if eltTop or eltSubsNb == 1 %>
|
73
|
-
<%= render :partial => '/elt/list', :locals => { :elt => elt } %>
|
74
|
-
<% end %>
|
75
|
-
</span>
|
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 %>
|
76
55
|
|
77
|
-
|
78
|
-
|
79
|
-
</span>
|
80
|
-
</span>
|
56
|
+
<!-- For IE --> 
|
81
57
|
|
82
|
-
<span <%= (
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
visual_effect(:
|
88
|
-
visual_effect(:
|
89
|
-
|
90
|
-
|
91
|
-
<% if elt.person %>
|
92
|
-
<%= link_to(elt.person.name,
|
93
|
-
:controller => 'person', :action => 'show', :id => elt.person) %>
|
94
|
-
<% elsif not displayTitle? elt %>
|
95
|
-
<%= ANONYMOUS_POSTER %>
|
96
|
-
<% end %>
|
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) }) %>
|
97
67
|
|
98
68
|
<%= link_to_remote('Add <span class="icon">>></span>',
|
99
69
|
{ :update => 'eltNew_'+elt.id.to_s,
|
100
70
|
:url => { :controller => 'elt', :action => 'new', :id => elt },
|
101
71
|
:loaded => visual_effect(:BlindDown, 'eltNew_'+elt.id.to_s)+
|
102
|
-
|
72
|
+
visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s)},
|
103
73
|
{ :href => url_for(:controller => 'elt', :action => 'new', :id => elt)}) %>
|
104
74
|
</span>
|
75
|
+
|
76
|
+
<ul class="eltSubs">
|
77
|
+
<!-- Display automatically one element threads -->
|
78
|
+
<div <%= (eltTop or eltSubsNb == 1) ? '' : 'style="display: none"' %>
|
79
|
+
id="eltSubs_<%= elt.id %>" class="eltSub">
|
80
|
+
<% if eltTop or eltSubsNb == 1 %>
|
81
|
+
<%= render :partial => '/elt/list', :locals => { :elt => elt } %>
|
82
|
+
<% end %>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<span style="display:none" class="eltNew" id="eltNew_<%= elt.id %>"></span>
|
86
|
+
|
87
|
+
<span <%= ((eltTop and eltSubsNb > 0) or eltSubsNb == 1) ? '' : 'style="display: none"' %>
|
88
|
+
id="eltSubsClose_<%= elt.id %>" title="<%= elt.created_on %>"
|
89
|
+
class="eltSubsClose">
|
90
|
+
<%= link_to_function('<span class="icon"><<</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)) %>
|
95
|
+
|
96
|
+
<% if elt.person %>
|
97
|
+
<%= link_to(elt.person.name,
|
98
|
+
:controller => 'person', :action => 'show', :id => elt.person) %>
|
99
|
+
<% elsif not displayTitle? elt %>
|
100
|
+
<%= ANONYMOUS_POSTER %>
|
101
|
+
<% end %>
|
102
|
+
|
103
|
+
<%= link_to_remote('Add <span class="icon">>></span>',
|
104
|
+
{ :update => 'eltNew_'+elt.id.to_s,
|
105
|
+
:url => { :controller => 'elt', :action => 'new', :id => elt },
|
106
|
+
:loaded => visual_effect(:BlindDown, 'eltNew_'+elt.id.to_s)+
|
107
|
+
visual_effect(:BlindDown, 'eltSubsClose_'+elt.id.to_s)},
|
108
|
+
{ :href => url_for(:controller => 'elt', :action => 'new', :id => elt)}) %>
|
109
|
+
</span>
|
110
|
+
</ul>
|
105
111
|
</li>
|
106
112
|
|
data/app/views/elt/_list.rhtml
CHANGED
@@ -6,10 +6,6 @@ e = Elt.find_all("parent_id = '#{elt.id}'",
|
|
6
6
|
'created_on DESC', e_pages.current.to_sql)
|
7
7
|
%>
|
8
8
|
|
9
|
-
<%
|
10
|
-
# TODO There seems to be a problem with firefox when trying to use a visual_effect
|
11
|
-
%>
|
12
|
-
|
13
9
|
<%= link_to_remote('< Previous page',
|
14
10
|
{ :update => 'eltSubs_'+elt.id.to_s,
|
15
11
|
:url => { :action => 'list', :id => elt, :page => e_pages.current.next },
|
@@ -34,7 +30,29 @@ e = Elt.find_all("parent_id = '#{elt.id}'",
|
|
34
30
|
{ :href => url_for(:controller => 'elt', :action => 'show', :id => @elt,
|
35
31
|
:page => (@params['page'] ? @params['page'].to_i-1 : e_pages.length-1))}) if e_pages.current.previous %>
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
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 %>
|
43
|
+
|
44
|
+
<% 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 %>
|
49
|
+
|
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 %>
|
40
58
|
|