parlement 0.6 → 0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +13 -0
- data/README +51 -38
- data/app/controllers/account_controller.rb +65 -37
- data/app/controllers/application.rb +1 -1
- data/app/controllers/elt_controller.rb +1 -0
- data/app/models/elt.rb +25 -14
- data/app/models/mail.rb +36 -35
- data/app/models/mail_notify.rb +23 -0
- data/app/views/account/_login.rhtml +1 -1
- data/app/views/account/_show.rhtml +22 -5
- data/app/views/elt/_elt.rhtml +44 -47
- data/app/views/elt/_listByDate.rhtml +7 -7
- data/app/views/elt/show.rhtml +3 -3
- data/app/views/layouts/top.rhtml +1 -0
- data/app/views/person/show.rhtml +5 -0
- data/config/environment.rb +1 -1
- data/db/ROOT/parlement/Parlement_fr.txt +46 -0
- data/db/ROOT/parlement/news/Version_06.txt +25 -0
- data/db/ROOT/parlement/news/Version_07.txt +12 -0
- data/db/ROOT/parlement/test.txt +14 -5
- data/db/ROOT/parlement.txt +2 -0
- data/db/development_structure.sql +119 -44
- data/db/migrate/004_people_image.rb +9 -0
- data/lib/data_import.rb +9 -13
- data/public/javascripts/mybehaviour.js +41 -0
- data/test/fixtures/img.png +0 -0
- data/test/fixtures/mail/avatar +249 -0
- data/test/fixtures/people.yml +1 -1
- data/test/functional/account_controller_test.rb +108 -56
- data/test/functional/elt_controller_test.rb +6 -6
- data/test/unit/elt_test.rb +1 -1
- data/test/unit/mail_test.rb +17 -0
- data/vendor/plugins/engines/CHANGELOG +91 -53
- data/vendor/plugins/engines/README +1 -1
- data/vendor/plugins/engines/generators/engine/templates/init_engine.erb +6 -4
- data/vendor/plugins/engines/generators/engine/templates/test/test_helper.erb +5 -1
- data/vendor/plugins/engines/init.rb +8 -3
- data/vendor/plugins/engines/lib/engines/action_mailer_extensions.rb +6 -5
- data/vendor/plugins/engines/lib/engines/action_view_extensions.rb +10 -6
- data/vendor/plugins/engines/lib/engines/active_record_extensions.rb +3 -1
- data/vendor/plugins/engines/lib/engines/dependencies_extensions.rb +27 -16
- data/vendor/plugins/engines/lib/engines/routing_extensions.rb +28 -0
- data/vendor/plugins/engines/lib/engines/testing_extensions.rb +6 -2
- data/vendor/plugins/engines/lib/engines.rb +77 -12
- data/vendor/plugins/engines/tasks/deprecated_engines.rake +7 -0
- data/vendor/plugins/engines/tasks/engines.rake +25 -10
- data/vendor/plugins/login_engine/CHANGELOG +8 -0
- data/vendor/plugins/login_engine/README +2 -2
- data/vendor/plugins/login_engine/app/controllers/user_controller.rb +4 -1
- data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +1 -1
- data/vendor/plugins/login_engine/init_engine.rb +6 -5
- data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +1 -1
- data/vendor/plugins/output_compression/CHANGELOG +0 -0
- data/vendor/plugins/output_compression/MIT-LICENSE +20 -0
- data/vendor/plugins/output_compression/README +4 -4
- data/vendor/plugins/output_compression/init.rb +1 -2
- data/vendor/plugins/output_compression/lib/output_compression.rb +84 -66
- data/vendor/plugins/output_compression/{Rakefile → rakefile} +22 -22
- data/vendor/plugins/output_compression/test/output_test.rb +11 -0
- data/vendor/plugins/output_compression/test/test_controller.rb +3 -0
- data/vendor/plugins/output_compression/test/test_helper.rb +14 -0
- data/vendor/plugins/responds_to_parent/MIT-LICENSE +20 -0
- data/vendor/plugins/responds_to_parent/README +42 -0
- data/vendor/plugins/responds_to_parent/Rakefile +22 -0
- data/vendor/plugins/responds_to_parent/init.rb +1 -0
- data/vendor/plugins/responds_to_parent/lib/responds_to_parent.rb +45 -0
- data/vendor/plugins/responds_to_parent/test/responds_to_parent_test.rb +115 -0
- metadata +33 -16
- data/vendor/plugins/login_engine/tasks/tasks.rake +0 -4
- data/vendor/plugins/output_compression/tasks/output_compression_tasks.rake +0 -4
- data/vendor/plugins/output_compression/test/output_compression_test.rb +0 -8
- /data/db/ROOT/parlement/news/{release0.1.txt → Version_01.txt} +0 -0
- /data/db/ROOT/parlement/news/{release0.2.txt → Version_02.txt} +0 -0
- /data/db/ROOT/parlement/news/{release0.3.txt → Version_03.txt} +0 -0
- /data/db/ROOT/parlement/news/{release0.4.txt → Version_04.txt} +0 -0
- /data/db/ROOT/parlement/news/{release0.5.txt → Version_05.txt} +0 -0
data/CHANGES
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
- parlement changelog
|
2
2
|
|
3
|
+
== Version 0.7
|
4
|
+
|
5
|
+
Avatars
|
6
|
+
|
7
|
+
* avatar initial upload
|
8
|
+
* correcting an automatic elt id generation, now removing all non characters
|
9
|
+
* avatar upload, reception and emission by mail
|
10
|
+
* addition of a "people" page listing all current and past avatars
|
11
|
+
* logout now possible in text based browsers
|
12
|
+
* attachments now derive their id from their element's subject
|
13
|
+
* >> for one liners now better placed as floats
|
14
|
+
* going from pluging output_compress to output_compression
|
15
|
+
|
3
16
|
== Version 0.6
|
4
17
|
|
5
18
|
Voting using V and Λ buttons (picturing -1 and +1 values, down and up).
|
data/README
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
|
1
|
+
_ _
|
2
|
+
_ __ __ _ _ __| | ___ _ __ ___ ___ _ __ | |_
|
3
|
+
| '_ \ / _` | '__| |/ _ \ '_ ` _ \ / _ \ '_ \| __|
|
4
|
+
| |_) | (_| | | | | __/ | | | | | __/ | | | |_
|
5
|
+
| .__/ \__,_|_| |_|\___|_| |_| |_|\___|_| |_|\__|
|
6
|
+
|_|
|
7
|
+
|
8
|
+
I use debian, here are the commands I use to setup my machine for parlement:
|
2
9
|
# apt-get install postgresql
|
3
10
|
# sudo su - postgres
|
4
11
|
# createuser /your_login/
|
@@ -7,12 +14,16 @@ I am using debian, so here are a few commands I use:
|
|
7
14
|
# apt-get install irb
|
8
15
|
# apt-get install rdoc
|
9
16
|
|
10
|
-
|
11
|
-
|
17
|
+
Basically this install postgresql, ruby and the ruby driver to psql. Ruby on
|
18
|
+
Rails is database agnostic, parlement will be sometimes in the near future.
|
12
19
|
|
20
|
+
You need to install "ruby gems":http://docs.rubygems.org
|
21
|
+
|
22
|
+
And then:
|
13
23
|
# gem install rails
|
14
24
|
# gem install redcloth
|
15
|
-
|
25
|
+
|
26
|
+
Only if you expect to develop and do any release:
|
16
27
|
# gem install meta_project
|
17
28
|
|
18
29
|
|
@@ -20,49 +31,51 @@ The database is setup for user "manu", you may need to change the file
|
|
20
31
|
config/database.yml for your own settings.
|
21
32
|
|
22
33
|
Change config/environment.rb to set the domain, default is something like
|
23
|
-
'leparlement.org',
|
34
|
+
'leparlement.org', use your web site or email domain.
|
24
35
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
36
|
+
When you want to setup your server as a node in the graph of servers, redirect
|
37
|
+
your incoming mails to *your* parlement. In procmail (or any other mail
|
38
|
+
filtering tool), define this kind of rule:
|
39
|
+
:0 c
|
40
|
+
* ^TO parlement|leparlement.org
|
41
|
+
| /home/manu/parlement/trunk/script/runner 'Mailman.receive STDIN.read'
|
29
42
|
|
30
43
|
|
31
44
|
Once you have everything set up (ruby, postgresql, redcloth, irb), you can
|
32
|
-
launch parlement
|
33
|
-
|
45
|
+
initialise and launch parlement this way:
|
46
|
+
|
47
|
+
Go into the right folder
|
48
|
+
~ cd parlement/trunk
|
49
|
+
|
50
|
+
Create the db
|
34
51
|
~ psql -q template1 -f db/schema.sql
|
52
|
+
|
53
|
+
Populate the db
|
35
54
|
~ ruby lib/data_import.rb
|
55
|
+
|
56
|
+
Migrate the db to its last version
|
57
|
+
~ rake migrate
|
58
|
+
|
59
|
+
Launch the developement web server
|
36
60
|
~ ruby ./script/server
|
37
61
|
|
62
|
+
Now you can go to http://localhost:3000 with your browser.
|
63
|
+
|
64
|
+
You can check that everything works all right on your machine with the testing suite:
|
65
|
+
~ rake
|
66
|
+
|
67
|
+
|
68
|
+
__ __ _
|
69
|
+
\ \ / /__| | ___ ___ _ __ ___ ___
|
70
|
+
\ \ /\ / / _ \ |/ __/ _ \| '_ ` _ \ / _ \
|
71
|
+
\ V V / __/ | (_| (_) | | | | | | __/
|
72
|
+
\_/\_/ \___|_|\___\___/|_| |_| |_|\___|
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
38
77
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
The problem: "how to display conversations"
|
43
|
-
The entities involved:
|
44
|
-
- element
|
45
|
-
- ancestor
|
46
|
-
- children
|
47
|
-
- children number
|
48
|
-
- author
|
49
|
-
- element's size
|
50
|
-
- title
|
51
|
-
- body
|
52
|
-
The possibilities
|
53
|
-
- show one element and its children closed
|
54
|
-
- show one element opened and its children closed
|
55
|
-
- show one element and its children opened, its grand children closed
|
56
|
-
- show one element opened, its children and grand children opened
|
57
|
-
- when an element is closed, also show its children?
|
58
|
-
Limits
|
59
|
-
- can not display all elements at once
|
60
|
-
- can not display one element and all its direct children at once
|
61
|
-
Parameters
|
62
|
-
- ordering
|
63
|
-
- date
|
64
|
-
- number of children displayed
|
65
|
-
- votes
|
78
|
+
What is below is just for future personal reference...
|
66
79
|
|
67
80
|
|
68
81
|
# Here is my console code to reset threads from their original mails:
|
@@ -5,7 +5,7 @@ class AccountController < UserController
|
|
5
5
|
model :person
|
6
6
|
model :user
|
7
7
|
|
8
|
-
|
8
|
+
def login
|
9
9
|
# Cleaning up
|
10
10
|
session[:person] = session[:user] = nil
|
11
11
|
|
@@ -21,11 +21,9 @@ class AccountController < UserController
|
|
21
21
|
# Create the pseudo
|
22
22
|
begin
|
23
23
|
Person.transaction(@person) do
|
24
|
-
@person = Person.new
|
25
|
-
@person.name = login
|
24
|
+
@person = Person.new :id => login.gsub(/\s/, '_'), :name => login
|
26
25
|
if @person.save
|
27
|
-
logger.info "person:
|
28
|
-
logger.info "person.id: "+@person.id.to_s
|
26
|
+
logger.info "person.id: #{@person.id}, name: #{@person.name}"
|
29
27
|
flash.now[:notice] = "Pseudo created"
|
30
28
|
session[:person] = @person
|
31
29
|
else
|
@@ -105,7 +103,7 @@ class AccountController < UserController
|
|
105
103
|
|
106
104
|
elsif email == @person.email
|
107
105
|
# User protected by password and with the same email as entered
|
108
|
-
|
106
|
+
key = @user.generate_security_token
|
109
107
|
url = url_for(:action => 'check_key')
|
110
108
|
url += "?user[id]=#{@user.id}&key=#{key}"
|
111
109
|
UserNotify::deliver_forgot_password(@user, url)
|
@@ -116,17 +114,17 @@ class AccountController < UserController
|
|
116
114
|
|
117
115
|
render :partial => 'show', :locals => {
|
118
116
|
:divId => params[:divId], :choices => getAllVotes }
|
119
|
-
|
117
|
+
end
|
120
118
|
|
121
119
|
|
122
|
-
|
123
|
-
|
124
|
-
|
120
|
+
def logout
|
121
|
+
session[:person] = @person = nil
|
122
|
+
session[:user] = @user = nil
|
125
123
|
render :partial => 'show', :locals => {
|
126
124
|
:divId => params[:divId], :choices => getAllVotes }
|
127
|
-
|
125
|
+
end
|
128
126
|
|
129
|
-
|
127
|
+
def check_key
|
130
128
|
if @user = User.authenticate_by_token(@params[:user][:id], @params[:key])
|
131
129
|
#@user = User.find(:first, :conditions => "security_token = '#{params[:key]}'")
|
132
130
|
@person = Person.find_by_name(@user.login) if @user
|
@@ -139,7 +137,7 @@ class AccountController < UserController
|
|
139
137
|
<br/> \
|
140
138
|
<a href='#{url_for :controller => 'elt', :action => 'show', :id => nil }'>\
|
141
139
|
Back</a>",
|
142
|
-
|
140
|
+
:layout => 'top'
|
143
141
|
else
|
144
142
|
render :text => "<h3>Sorry, no corresponding check key :-(</h3> \
|
145
143
|
<br/> \
|
@@ -149,41 +147,71 @@ class AccountController < UserController
|
|
149
147
|
end
|
150
148
|
end
|
151
149
|
|
150
|
+
def setAvatar
|
151
|
+
logger.info "Setting up an avatar for person #{session[:person].name}"
|
152
|
+
|
153
|
+
@elt = Elt.find_by_id 'people'
|
154
|
+
if !@elt
|
155
|
+
@elt = Elt.new :parent_id => 'ROOT', :subject => 'people', :body => ''
|
156
|
+
@elt.save!
|
157
|
+
@elt.publish
|
158
|
+
@elt.parent.add_child @elt
|
159
|
+
end
|
160
|
+
avatar = @elt.children.build :person => session[:person], :body => ""
|
161
|
+
att = avatar.attachments.build :file => params[:person][:image],
|
162
|
+
:content_type => params[:person][:image].content_type
|
163
|
+
|
164
|
+
avatar.subject = att.file.gsub /^.*public.*\//, ''
|
165
|
+
avatar.publish
|
166
|
+
@elt.add_child avatar
|
167
|
+
|
168
|
+
@person = session[:person]
|
169
|
+
@person.image = "/attachment/file/#{att.file_relative_path}"
|
170
|
+
@person.save!
|
171
|
+
|
172
|
+
responds_to_parent do
|
173
|
+
render :update do |page|
|
174
|
+
page << "$('person_avatar').src = '#{@person.image}';"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
152
179
|
|
153
|
-
# Mostly copied from the login engine
|
154
180
|
protected
|
155
|
-
|
181
|
+
|
182
|
+
# Mostly copied from the login engine
|
183
|
+
def signup
|
156
184
|
if @person and not @user
|
157
185
|
@user = User.new
|
158
186
|
@user.login = @person.name
|
159
187
|
end
|
160
188
|
|
161
189
|
@user.email = @params[:person][:email]
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
190
|
+
begin
|
191
|
+
User.transaction(@user) do
|
192
|
+
unless LoginEngine.config(:use_email_notification)
|
193
|
+
@user.verified = 1
|
194
|
+
end
|
195
|
+
if @user.save
|
196
|
+
key = @user.generate_security_token
|
197
|
+
#url = url_for(:action => 'home', 'user[id]' => @user.id, :key => key)
|
170
198
|
url = url_for(:action => 'check_key')
|
171
199
|
url += "?user[id]=#{@user.id}&key=#{key}"
|
172
|
-
|
200
|
+
#flash[:notice] = 'Signup successful!'
|
173
201
|
flash.now['notice 3'] = 'Confirmation email sent to '+@user.email
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
202
|
+
if LoginEngine.config(:use_email_notification)
|
203
|
+
UserNotify.deliver_signup(@user, params[:user][:password], url)
|
204
|
+
flash['notice 4'] = ' Please check your registered email account to verify your account registration.'
|
205
|
+
end
|
206
|
+
#redirect_to :action => 'login'
|
207
|
+
end
|
208
|
+
end
|
209
|
+
rescue Exception => e
|
210
|
+
flash.now[:notice] = nil
|
211
|
+
flash.now[:warning] = 'Error creating account: confirmation email not sent'
|
212
|
+
logger.error e
|
213
|
+
end
|
214
|
+
end
|
187
215
|
|
188
216
|
def getAllVotes
|
189
217
|
return if !params[:divId]
|
@@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
|
|
9
9
|
|
10
10
|
before_filter :set_charset
|
11
11
|
after_filter :fix_unicode_for_safari
|
12
|
-
after_filter
|
12
|
+
after_filter OutputCompressionFilter
|
13
13
|
|
14
14
|
# automatically and transparently fixes utf-8 bug
|
15
15
|
# with Safari when using xmlhttp
|
data/app/models/elt.rb
CHANGED
@@ -4,21 +4,27 @@
|
|
4
4
|
# It holds all posts, that's mostly a subject and a body, plus their
|
5
5
|
# relationships in a tree of elements
|
6
6
|
#
|
7
|
+
# An element is linked to:
|
8
|
+
# - mail
|
9
|
+
# - person
|
10
|
+
# - voters
|
11
|
+
# - choices
|
12
|
+
# - attachments
|
13
|
+
# - subscribers
|
14
|
+
#
|
15
|
+
# The element id is generated from the subject for better readability (but only
|
16
|
+
# normal characters are used)
|
17
|
+
#
|
7
18
|
class Elt < ActiveRecord::Base
|
8
|
-
usesguid
|
9
|
-
|
10
|
-
acts_as_nested_set :order => "position is not null, position, created_on"
|
11
|
-
acts_as_tree :order => "position is not null, position, created_on", :counter_cache => true
|
12
|
-
|
13
19
|
has_one :mail, :dependent => true
|
14
|
-
has_many :attachments, :dependent => true
|
15
|
-
|
16
20
|
belongs_to :person
|
17
|
-
|
21
|
+
has_many :voters, :through => :choices, :source => :person
|
22
|
+
has_many :choices, :dependent => true, :order => "choices.created_on"
|
23
|
+
has_many :attachments, :dependent => true
|
18
24
|
has_and_belongs_to_many :subscribers, :class_name => "Person", :join_table => "subscribers"
|
19
25
|
|
20
|
-
|
21
|
-
|
26
|
+
acts_as_nested_set :order => "position is not null, position, created_on"
|
27
|
+
acts_as_tree :order => "position is not null, position, created_on", :counter_cache => true
|
22
28
|
|
23
29
|
# Just a quick method to get all subscribers as a simple list
|
24
30
|
def all_recipients
|
@@ -53,7 +59,7 @@ class Elt < ActiveRecord::Base
|
|
53
59
|
save!
|
54
60
|
|
55
61
|
parent.vote Regexp.last_match(1), person if body =~ /^\s*(-1|0|\+1)(\s|$)/
|
56
|
-
if self.body.gsub(/(-1|0|\+1)/, '').strip.empty?
|
62
|
+
if Regexp.last_match(1) and self.body.gsub(/(-1|0|\+1)/, '').strip.empty?
|
57
63
|
# Hide simple votes
|
58
64
|
vote -1
|
59
65
|
else
|
@@ -63,12 +69,17 @@ class Elt < ActiveRecord::Base
|
|
63
69
|
end
|
64
70
|
|
65
71
|
def save
|
66
|
-
if new_record?
|
72
|
+
if new_record?
|
67
73
|
# Let's generate a nice looking id
|
68
|
-
self.id = new_id = subject.gsub(/\[[\w-]*\]/, '').strip
|
74
|
+
self.id = new_id = subject.gsub(/\[[\w-]*\]/, '').strip \
|
75
|
+
.gsub(/\s/, '_').gsub(/[^\w]+/, '').gsub(/_+/, '_') \
|
76
|
+
.gsub(/(^_|_$)/, '') \
|
77
|
+
if subject
|
78
|
+
self.id ||= "elt"
|
69
79
|
|
70
80
|
discrim = 0
|
71
|
-
self.id = "#{new_id}_#{discrim}"
|
81
|
+
self.id = "#{new_id}_#{discrim}" \
|
82
|
+
while discrim += 1 and self.class.find_by_id self.id
|
72
83
|
end
|
73
84
|
|
74
85
|
super
|
data/app/models/mail.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Receive a mail from which an elt is created.
|
3
3
|
#
|
4
4
|
# An associated mail is kept to make sure we don't lose any data. Attachments
|
5
|
-
# are also
|
5
|
+
# are also managed in an associated table
|
6
6
|
#
|
7
7
|
class Mail < ActiveRecord::Base
|
8
8
|
usesguid
|
@@ -24,9 +24,7 @@ class Mail < ActiveRecord::Base
|
|
24
24
|
logger.info "Already received (id: #{mail.message_id})...\n"
|
25
25
|
|
26
26
|
else
|
27
|
-
|
28
|
-
m.receive mail
|
29
|
-
m
|
27
|
+
Mail.new.receive mail
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
@@ -46,24 +44,10 @@ class Mail < ActiveRecord::Base
|
|
46
44
|
#
|
47
45
|
def receive(mail)
|
48
46
|
logger.info "Receive mail #{mail.message_id}"
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
61
|
-
|
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
|
66
|
-
elt.person.email = mail.from.first
|
47
|
+
build_elt :created_on => mail.date,
|
48
|
+
:subject => unquote(mail.subject),
|
49
|
+
:body => '',
|
50
|
+
:mail => self
|
67
51
|
|
68
52
|
# Try to find its mail parent in the db
|
69
53
|
if mail.in_reply_to and Mail.find_by_message mail.in_reply_to
|
@@ -110,11 +94,24 @@ class Mail < ActiveRecord::Base
|
|
110
94
|
|
111
95
|
mngAttachment(mail) if mail
|
112
96
|
|
113
|
-
|
97
|
+
elt.person = Person.find_by_email(mail.from) \
|
98
|
+
|| Person.find_by_name(unquote(mail.friendly_from)) \
|
99
|
+
|| elt.build_person(:id => unquote(mail.friendly_from).gsub(/\s/, '_'),
|
100
|
+
:name => unquote(mail.friendly_from),
|
101
|
+
:email => mail.from.first)
|
102
|
+
|
114
103
|
self.mail_parents = mail.references
|
104
|
+
self.message = mail.message_id
|
115
105
|
self.file = mail.encoded
|
116
106
|
elt.publish
|
107
|
+
|
108
|
+
if mail.to.to_s.match(/people@#{ActionMailer::Base.server_settings[:domain]}/)
|
109
|
+
elt.person.image = "/attachment/file/#{elt.attachments.first.file_relative_path}"
|
110
|
+
elt.person.save
|
111
|
+
end
|
112
|
+
|
117
113
|
elt.parent.add_child elt
|
114
|
+
self
|
118
115
|
end
|
119
116
|
|
120
117
|
""" _ _ _ _
|
@@ -172,7 +169,6 @@ class Mail < ActiveRecord::Base
|
|
172
169
|
|
173
170
|
# Added to make sure it is not lost, but not modified if already existant
|
174
171
|
mail['X-Message-Id'] = mail.message_id if not mail['X-Message-Id']
|
175
|
-
mail['X-leparlement-elt-Id'] = elt.id
|
176
172
|
|
177
173
|
MailNotify::deliver(mail) if mail.destinations and not mail.destinations.empty?
|
178
174
|
|
@@ -194,7 +190,20 @@ class Mail < ActiveRecord::Base
|
|
194
190
|
|
195
191
|
# Get and store the attachments
|
196
192
|
def mngAttachment(attachment)
|
197
|
-
if attachment.
|
193
|
+
if attachment.multipart?
|
194
|
+
attachment.parts.each { |part| mngAttachment part }
|
195
|
+
elsif attachment.disposition_param 'filename'
|
196
|
+
File.open("/tmp/#{attachment.disposition_param('filename')}", 'w') { |file|
|
197
|
+
file << attachment.body
|
198
|
+
elt.attachments.build :file => file, :content_type => attachment.content_type
|
199
|
+
}
|
200
|
+
elsif attachment.type_param 'name'
|
201
|
+
File.open("/tmp/#{attachment.type_param('name')}", 'w') { |file|
|
202
|
+
file << attachment.body
|
203
|
+
elt.attachments.build :file => file, :content_type => attachment.content_type
|
204
|
+
}
|
205
|
+
elsif attachment.content_type.match(/text\/plain/) \
|
206
|
+
or (!attachment.content_type and attachment.parts.size == 0)
|
198
207
|
charset = attachment.type_param 'charset'
|
199
208
|
if charset and !charset.empty?
|
200
209
|
if attachment.transfer_encoding == 'quoted-printable'
|
@@ -206,17 +215,9 @@ class Mail < ActiveRecord::Base
|
|
206
215
|
elt.body += Iconv.new(charset, 'utf-8').iconv(attachment.body)
|
207
216
|
end
|
208
217
|
else
|
209
|
-
|
218
|
+
# Here too have to remove any eventual null character!
|
219
|
+
elt.body += attachment.body.gsub(/\0/, '')
|
210
220
|
end
|
211
|
-
|
212
|
-
elsif attachment.multipart?
|
213
|
-
attachment.parts.each { |part| mngAttachment part }
|
214
|
-
|
215
|
-
elsif attachment.type_param 'name'
|
216
|
-
File.open('/tmp/'+attachment.type_param('name'), 'w') { |file|
|
217
|
-
file << attachment.body
|
218
|
-
elt.attachments.build :file => file
|
219
|
-
}
|
220
221
|
end
|
221
222
|
end
|
222
223
|
end
|
data/app/models/mail_notify.rb
CHANGED
@@ -23,6 +23,29 @@ class MailNotify < ActionMailer::Base
|
|
23
23
|
# Try to render the element as html
|
24
24
|
body :elt => elt
|
25
25
|
|
26
|
+
templates = Dir.glob("#{template_path}/#{@template}.*")
|
27
|
+
templates.each do |path|
|
28
|
+
# TODO: don't hardcode rhtml|rxml
|
29
|
+
basename = File.basename(path)
|
30
|
+
next unless md = /^([^\.]+)\.([^\.]+\.[^\+]+)\.(rhtml|rxml)$/.match(basename)
|
31
|
+
template_name = basename
|
32
|
+
content_type = md.captures[1].gsub('.', '/')
|
33
|
+
@parts << ActionMailer::Part.new(:content_type => content_type,
|
34
|
+
:disposition => "inline", :charset => charset,
|
35
|
+
:body => render_message(template_name, @body))
|
36
|
+
end
|
37
|
+
unless @parts.empty?
|
38
|
+
@content_type = "multipart/alternative"
|
39
|
+
@parts = sort_parts(@parts, @implicit_parts_order)
|
40
|
+
end
|
41
|
+
|
42
|
+
elt.attachments.each { |att|
|
43
|
+
attachment(att.content_type ? att.content_type : "") { |a|
|
44
|
+
a.filename = att.file.gsub /^.*public.*\//, ''
|
45
|
+
a.body = File.read(att.file)
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
26
49
|
# This is the essential of a mailing list, you reply to the mailing list,
|
27
50
|
# where every body sends their mail.
|
28
51
|
# This very mail can be a mailing list all by itself...
|
@@ -2,7 +2,7 @@
|
|
2
2
|
:update => divId,
|
3
3
|
:url => { :controller => 'account', :action => 'login', :divId => divId },
|
4
4
|
:before => visual_effect(:SwitchOff, divId)+";resetChoices();",
|
5
|
-
:
|
5
|
+
:loaded => visual_effect(:BlindDown, divId)) %>
|
6
6
|
|
7
7
|
<%= hidden_field 'elt', 'id' if @elt %>
|
8
8
|
|
@@ -18,13 +18,14 @@
|
|
18
18
|
</div>
|
19
19
|
<% end %>
|
20
20
|
|
21
|
-
<% if session[:person] %>
|
21
|
+
<% if @person = session[:person] %>
|
22
22
|
<span class="logout">
|
23
23
|
<%= link_to_remote('[X]',
|
24
|
-
:update => divId,
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
{ :update => divId,
|
25
|
+
:url => { :controller => 'account', :action => 'logout', :divId => divId },
|
26
|
+
:before => visual_effect(:SwitchOff, divId)+";resetChoices();",
|
27
|
+
:complete => visual_effect(:BlindDown, divId) },
|
28
|
+
{ :href => url_for(:controller => 'account', :action => 'logout') }) %>
|
28
29
|
</span>
|
29
30
|
|
30
31
|
<% if session[:person].name and session[:person].name != '' %>
|
@@ -35,6 +36,22 @@
|
|
35
36
|
:id => session[:person] %>>
|
36
37
|
</span>
|
37
38
|
<% end %>
|
39
|
+
|
40
|
+
<div>
|
41
|
+
<%= image_tag (@person.image ? @person.image : "/javascripts/blank.gif"),
|
42
|
+
:id => "person_avatar", :class => "avatar" %>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<%= form_tag( { :controller => "account", :action => "setAvatar"},
|
46
|
+
:multipart => true, :target => "avatar", :class => "setAvatar") %>
|
47
|
+
<label>
|
48
|
+
Avatar:
|
49
|
+
<%= file_field "person", "image", :onchange => "submit()" %>
|
50
|
+
</label>
|
51
|
+
<%= submit_tag 'Ok' %>
|
52
|
+
<%= end_form_tag %>
|
53
|
+
|
54
|
+
<iframe id="avatar" name="avatar" style="display: none"></iframe>
|
38
55
|
<% else %>
|
39
56
|
|
40
57
|
<%= render :partial => '/account/login', :locals => { :divId => divId } %>
|