parlement 0.1

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.
Files changed (162) hide show
  1. data/CHANGES +709 -0
  2. data/COPYING +223 -0
  3. data/README +20 -0
  4. data/Rakefile +136 -0
  5. data/app/controllers/account_controller.rb +181 -0
  6. data/app/controllers/application.rb +30 -0
  7. data/app/controllers/elt_controller.rb +83 -0
  8. data/app/helpers/account_helper.rb +2 -0
  9. data/app/helpers/application_helper.rb +4 -0
  10. data/app/helpers/elt_helper.rb +37 -0
  11. data/app/helpers/live_tree.rb +238 -0
  12. data/app/helpers/mailman.rb +96 -0
  13. data/app/models/attachment.rb +4 -0
  14. data/app/models/elt.rb +17 -0
  15. data/app/models/mail.rb +4 -0
  16. data/app/models/notifier.rb +13 -0
  17. data/app/models/person.rb +9 -0
  18. data/app/models/user.rb +7 -0
  19. data/app/models/user_notify.rb +75 -0
  20. data/app/views/account/_help.rhtml +23 -0
  21. data/app/views/account/_login.rhtml +57 -0
  22. data/app/views/account/_show.rhtml +31 -0
  23. data/app/views/account/logout.rhtml +10 -0
  24. data/app/views/account/signup.rhtml +17 -0
  25. data/app/views/account/welcome.rhtml +13 -0
  26. data/app/views/elt/_elt.rhtml +105 -0
  27. data/app/views/elt/_form.rhtml +31 -0
  28. data/app/views/elt/_list.rhtml +28 -0
  29. data/app/views/elt/new.rhtml +102 -0
  30. data/app/views/elt/rss.rxml +31 -0
  31. data/app/views/elt/show.rhtml +46 -0
  32. data/app/views/elt/show_tree.rhtml +8 -0
  33. data/app/views/layouts/scaffold.rhtml +13 -0
  34. data/app/views/layouts/top.rhtml +45 -0
  35. data/app/views/notifier/changeEmail.rhtml +10 -0
  36. data/config/boot.rb +17 -0
  37. data/config/database.yml +82 -0
  38. data/config/environment.rb +92 -0
  39. data/config/environments/development.rb +17 -0
  40. data/config/environments/production.rb +17 -0
  41. data/config/environments/test.rb +17 -0
  42. data/config/environments/user_environment.rb +1 -0
  43. data/config/routes.rb +28 -0
  44. data/db/ROOT/CV.txt +166 -0
  45. data/db/ROOT/IP.txt +3 -0
  46. data/db/ROOT/parleR.txt +3 -0
  47. data/db/ROOT/parlement/security.txt +34 -0
  48. data/db/ROOT/parlement/test.txt +4 -0
  49. data/db/ROOT/parlement.txt +51 -0
  50. data/db/ROOT/perso.txt +215 -0
  51. data/db/schema.sql +127 -0
  52. data/lib/data_import.rb +54 -0
  53. data/lib/file_column.rb +263 -0
  54. data/lib/file_column_helper.rb +45 -0
  55. data/lib/localization.rb +88 -0
  56. data/lib/localizer.rb +88 -0
  57. data/lib/login_system.rb +87 -0
  58. data/lib/rails_file_column.rb +19 -0
  59. data/lib/user_system.rb +101 -0
  60. data/public/404.html +8 -0
  61. data/public/500.html +8 -0
  62. data/public/dispatch.cgi +10 -0
  63. data/public/dispatch.fcgi +24 -0
  64. data/public/dispatch.rb +10 -0
  65. data/public/engine_files/README +5 -0
  66. data/public/engine_files/login_engine/stylesheets/login_engine.css +81 -0
  67. data/public/favicon.ico +0 -0
  68. data/public/favicon.png +0 -0
  69. data/public/images/live_tree_branch_collapsed_icon.gif +0 -0
  70. data/public/images/live_tree_branch_expanded_icon.gif +0 -0
  71. data/public/images/live_tree_leaf_icon.gif +0 -0
  72. data/public/images/live_tree_loading_spinner.gif +0 -0
  73. data/public/images/webfeed.gif +0 -0
  74. data/public/javascripts/controls.js +721 -0
  75. data/public/javascripts/dragdrop.js +519 -0
  76. data/public/javascripts/effects.js +992 -0
  77. data/public/javascripts/live_tree.js +749 -0
  78. data/public/javascripts/prototype.js +1726 -0
  79. data/public/javascripts/scriptaculous.js +47 -0
  80. data/public/javascripts/slider.js +258 -0
  81. data/public/oldREADME +190 -0
  82. data/public/oldindex.html +78 -0
  83. data/public/robots.txt +1 -0
  84. data/public/stylesheets/default.css +238 -0
  85. data/public/stylesheets/live_tree.css +62 -0
  86. data/public/stylesheets/scaffold.css +74 -0
  87. data/script/about +3 -0
  88. data/script/benchmarker +19 -0
  89. data/script/breakpointer +3 -0
  90. data/script/console +3 -0
  91. data/script/create_db +7 -0
  92. data/script/destroy +3 -0
  93. data/script/generate +3 -0
  94. data/script/performance/benchmarker +3 -0
  95. data/script/performance/profiler +3 -0
  96. data/script/plugin +3 -0
  97. data/script/process/reaper +3 -0
  98. data/script/process/spawner +3 -0
  99. data/script/process/spinner +3 -0
  100. data/script/profiler +34 -0
  101. data/script/runner +3 -0
  102. data/script/server +3 -0
  103. data/test/fixtures/attachments.yml +10 -0
  104. data/test/fixtures/elts.yml +15 -0
  105. data/test/fixtures/mails.yml +7 -0
  106. data/test/fixtures/people.yml +49 -0
  107. data/test/fixtures/users.yml +41 -0
  108. data/test/functional/account_controller_test.rb +239 -0
  109. data/test/functional/elt_controller_test.rb +18 -0
  110. data/test/mocks/test/time.rb +17 -0
  111. data/test/mocks/test/user_notify.rb +16 -0
  112. data/test/test_helper.rb +28 -0
  113. data/test/unit/attachment_test.rb +14 -0
  114. data/test/unit/elt_test.rb +14 -0
  115. data/test/unit/mail_test.rb +14 -0
  116. data/test/unit/notifier_test.rb +31 -0
  117. data/test/unit/person_test.rb +24 -0
  118. data/test/unit/user_test.rb +94 -0
  119. data/vendor/plugins/engines/CHANGELOG +7 -0
  120. data/vendor/plugins/engines/README +128 -0
  121. data/vendor/plugins/engines/init.rb +33 -0
  122. data/vendor/plugins/engines/lib/action_mailer_extensions.rb +160 -0
  123. data/vendor/plugins/engines/lib/action_view_extensions.rb +130 -0
  124. data/vendor/plugins/engines/lib/dependencies_extensions.rb +56 -0
  125. data/vendor/plugins/engines/lib/engines.rb +292 -0
  126. data/vendor/plugins/engines/lib/ruby_extensions.rb +127 -0
  127. data/vendor/plugins/engines/lib/testing_extensions.rb +33 -0
  128. data/vendor/plugins/engines/test/ruby_extensions_test.rb +94 -0
  129. data/vendor/plugins/login_engine/README +258 -0
  130. data/vendor/plugins/login_engine/app/controllers/user_controller.rb +248 -0
  131. data/vendor/plugins/login_engine/app/helpers/user_helper.rb +88 -0
  132. data/vendor/plugins/login_engine/app/models/user.rb +7 -0
  133. data/vendor/plugins/login_engine/app/models/user_notify.rb +75 -0
  134. data/vendor/plugins/login_engine/app/views/user/_edit.rhtml +11 -0
  135. data/vendor/plugins/login_engine/app/views/user/_password.rhtml +9 -0
  136. data/vendor/plugins/login_engine/app/views/user/change_password.rhtml +17 -0
  137. data/vendor/plugins/login_engine/app/views/user/edit.rhtml +23 -0
  138. data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +18 -0
  139. data/vendor/plugins/login_engine/app/views/user/home.rhtml +7 -0
  140. data/vendor/plugins/login_engine/app/views/user/login.rhtml +17 -0
  141. data/vendor/plugins/login_engine/app/views/user/logout.rhtml +8 -0
  142. data/vendor/plugins/login_engine/app/views/user/signup.rhtml +17 -0
  143. data/vendor/plugins/login_engine/app/views/user_notify/change_password.rhtml +10 -0
  144. data/vendor/plugins/login_engine/app/views/user_notify/delete.rhtml +5 -0
  145. data/vendor/plugins/login_engine/app/views/user_notify/forgot_password.rhtml +11 -0
  146. data/vendor/plugins/login_engine/app/views/user_notify/pending_delete.rhtml +9 -0
  147. data/vendor/plugins/login_engine/app/views/user_notify/signup.rhtml +12 -0
  148. data/vendor/plugins/login_engine/db/schema.rb +25 -0
  149. data/vendor/plugins/login_engine/init_engine.rb +10 -0
  150. data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +107 -0
  151. data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +149 -0
  152. data/vendor/plugins/login_engine/lib/login_engine.rb +58 -0
  153. data/vendor/plugins/login_engine/public/stylesheets/login_engine.css +81 -0
  154. data/vendor/plugins/login_engine/tasks/tasks.rake +4 -0
  155. data/vendor/plugins/login_engine/test/fixtures/templates/users.yml +41 -0
  156. data/vendor/plugins/login_engine/test/fixtures/users.yml +41 -0
  157. data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +533 -0
  158. data/vendor/plugins/login_engine/test/mocks/mail.rb +14 -0
  159. data/vendor/plugins/login_engine/test/mocks/time.rb +19 -0
  160. data/vendor/plugins/login_engine/test/test_helper.rb +15 -0
  161. data/vendor/plugins/login_engine/test/unit/user_test.rb +94 -0
  162. metadata +276 -0
@@ -0,0 +1,37 @@
1
+ module EltHelper
2
+ def format(data)
3
+ # for italics /.../ to _..._ \
4
+ #.gsub(/(\s+)\/([\w\s�������]*)\//, '\\1_\\2_') \
5
+
6
+ # ^here: data
7
+ # /italic/
8
+ # - listElement
9
+ # in reply to:\n>
10
+ # 1. numbered list
11
+ text = auto_link data \
12
+ .gsub(/^(\w*):\s/, ' \\1: ') \
13
+ .gsub(/(\s+)\/([\w\s]*)\//, '\\1_\\2_') \
14
+ .gsub(/^-\s/, '* ') \
15
+ .gsub(/(:)(\n)(^>\s)/, '\\1\\2\\2\\3') \
16
+ .gsub(/^\d+[\.-]\s+/, '# ') \
17
+ if data != nil
18
+
19
+ textiled = text.blank? ? "" : RedCloth.new(text).to_html
20
+ if textiled[0..2] == "<p>" then textiled = textiled[3..-1] end
21
+ if textiled[-4..-1] == "</p>" then textiled = textiled[0..-5] end
22
+ return textiled
23
+
24
+ """
25
+ hard_breaks = false
26
+ auto_link textilize_without_paragraph(data \
27
+ .gsub(/\&\#8211\;/, '* ') \
28
+ .gsub(/^-\s/, '* ') \
29
+ .gsub(/(\s+)\/([\w\s�������]*)\//, '\\1_\\2_') \
30
+ .gsub(/[^\n]\n^>/, '') \
31
+ .gsub(/^\d+[ \.-]+/, '# ') \
32
+ # ).gsub(/(.{65,182})<br\s\/>/, \
33
+ # ).gsub(/([\r\n\<\>=\w\d\s.\:;,$*?!\-����������\"\&#;()\/]{65,182})<br\s\/>([^>])/,
34
+ ) if data != nil
35
+ """
36
+ end
37
+ end
@@ -0,0 +1,238 @@
1
+ # Version:: 0.1
2
+ # Author:: Emanuel Borsboom (http://www.epiphyte.ca/)
3
+ # Copyright:: Copyright (c) 2005 Emanuel Borsboom
4
+ # License:: MIT (see LICENSE[link:files/LICENSE.html])
5
+ #
6
+ # See README[link:files/README.html] for general information about LiveTree.
7
+
8
+ module LiveTree
9
+
10
+ def self.included(base) #:nodoc:
11
+ super
12
+ base.extend(ClassMethods)
13
+ end
14
+
15
+ module ClassMethods
16
+
17
+ # Sets up this controller to serve data for a LiveTree.
18
+ #
19
+ # Arguments:
20
+ # * +name+ - the tree's name.
21
+ # * <tt>options</tt> - may contain:
22
+ # * <tt>:model</tt> - name of the model to use for retrieving data (symbol).
23
+ # * <tt>:model_class</tt> - name of the model's class, incase it can't be inferred (string)
24
+ # * <tt>:get_item_name_proc</tt> - proc object which, when called with an item, returns the name of the item to display.
25
+ #
26
+ # Either one of <tt>:model</tt> or <tt>:model_class</tt> must be specified.
27
+ #
28
+ # If <tt>:get_item_name_proc</tt> is not specified, the item's <tt>name</tt> attribute is used.
29
+ #
30
+ # This example sets up this controller to serve data for a tree with name +family_tree+, that uses the +person+ model to get data:
31
+ #
32
+ # class FamilyController < ApplicationController
33
+ # live_tree :family_tree, :model => :person
34
+ # end
35
+ #
36
+ # A data retrieval method is created that is named <em><tt><name></tt></em><tt>_live_tree_data</tt> (e.g. +family_tree_live_tree_data+)
37
+ def live_tree(name, options = {})
38
+ raise ":model or :model_class_name option is required" if options[:model] == nil && options[:model_class_name] == nil
39
+ if options[:model_class_name] != nil
40
+ model = options[:model_class_name]
41
+ else
42
+ model = Inflector.camelize(options[:model])
43
+ end
44
+ self.const_set("LIVE_TREE_OPTIONS_" + name.to_s.upcase, options);
45
+ code = "" +
46
+ "def #{name}_live_tree_options\n" +
47
+ " LIVE_TREE_OPTIONS_" + name.to_s.upcase + "\n" +
48
+ "end\n" +
49
+ "def #{name}_live_tree_data\n" +
50
+ " get_live_tree_data(" + model + ".find(live_tree_item_id), #{name}_live_tree_options)\n" +
51
+ "end\n"
52
+ #STDERR.write("\n\n#{code}\n\n")
53
+ class_eval code
54
+ end
55
+
56
+ end
57
+
58
+ module LiveTreeHelper
59
+
60
+ def _recurse_live_tree_data(item, depth, get_item_name_proc, special_child_id = nil, special_child_data = nil) #:nodoc:
61
+ result = "{id:" + item.id.to_s + ",name:'" + escape_javascript(get_item_name_proc.call(item).to_s) + "'"
62
+ if item.children.size == 0
63
+ result += ",children:[]"
64
+ elsif depth == nil || depth > 1
65
+ result += ",children:[\n"
66
+ first = true
67
+ for child in item.children
68
+ result += ",\n" unless first
69
+ first = false
70
+ if child.id == special_child_id
71
+ result += special_child_data
72
+ else
73
+ result += _recurse_live_tree_data(child, depth == nil ? nil : depth - 1, get_item_name_proc, special_child_id, special_child_data)
74
+ end
75
+ end
76
+ result += "]"
77
+ end
78
+ result += "}"
79
+ result
80
+ end
81
+
82
+ def _get_live_tree_data(item, options, params) #:nodoc:
83
+ options ||= {}
84
+ get_item_name_proc = Proc.new { |x| x.name }
85
+ if options[:get_item_name_proc] != nil
86
+ get_item_name_proc = options[:get_item_name_proc]
87
+ end
88
+ depth = params[:depth] == nil ? nil : params[:depth].to_i
89
+ include_parents = params[:include_parents]
90
+ root_item_id = params[:root_item_id] == nil ? nil : params[:root_item_id].to_i
91
+
92
+ result = _recurse_live_tree_data(item, depth, get_item_name_proc)
93
+ if include_parents
94
+ while item.parent != nil && (root_item_id == nil || item.id != root_item_id)
95
+ result = _recurse_live_tree_data(item.parent, 2, get_item_name_proc, item.id, result)
96
+ item = item.parent
97
+ end
98
+ end
99
+ return result;
100
+ end
101
+
102
+ def LiveTreeHelper.live_tree_js_name(name) #:nodoc:
103
+ Inflector.camelize(name).sub(/^(.)/) { |s| $1.downcase }
104
+ end
105
+
106
+ # Embeds a LiveTree at the current location in the document.
107
+ #
108
+ # Arguments:
109
+ # * +name+ - name of the tree
110
+ # * +options+ - may contain any of the options documented in #construct_live_tree_function, as well as:
111
+ # * <tt>:js_variable_name</tt> - JavaScript variable name to assign the JavaScript LiveTree object to (optional).
112
+ #
113
+ # If <tt>:js_variable_name</tt> is not specified, the tree is assigned to a variable with the name of the tree converted to camelcase
114
+ # with a lowercase first letter (e.g. if the tree is named +family_tree+, it will be assigned to +familyTree+).
115
+ def live_tree(name, options = {})
116
+ options = options.dup;
117
+ if options[:js_variable_name] != nil
118
+ var_name = options[:js_variable_name]
119
+ else
120
+ var_name = LiveTreeHelper.live_tree_js_name(name)
121
+ end
122
+ options.delete :js_variable_name
123
+ js = "var " + var_name + "=" + construct_live_tree_function(name, options) + ";"
124
+ js += var_name + ".render();"
125
+ return javascript_tag(js);
126
+ end
127
+
128
+ # Returns JavaScript code that constructs a JavaScript LiveTree object.
129
+ #
130
+ # Arguments:
131
+ #
132
+ # * +name+ - name of the tree
133
+ #
134
+ # * +options+ - most of these options are passed to the JavaScript LiveTree object as-is, but their
135
+ # names are converted to camelcase-with-lowercase-first-letter (e.g. <tt>:on_click_item</tt> becomes <tt>onClickItem</tt>).
136
+ # See LiveTreeClient[link:files/LiveTreeClient.html] for details details about those options. In addition, the following may be
137
+ # specified:
138
+ #
139
+ # * <tt>:id</tt> - HTML ID to give the tree's top HTML element (default is the tree's name).
140
+ # * <tt>:data_action</tt> - Action used by the tree to read data (default is "#{name}_live_tree_data").
141
+ # * <tt>:data_controller</tt> - Controller used by the tree to read data (default is the current controller).
142
+ # * <tt>:initial_data_root</tt> - Root item to construct initial tree data (optional, but you almost certainly want to include this).
143
+ # * <tt>:initial_data_whole_tree</tt> - Specifies whether the entire tree should be sent in the initial data, in which case the client will never have to contact the server for more data (default +false+, only used if <tt>:initial_data_root</tt> is specified).
144
+ # * <tt>:initial_data_options</tt> - Specifies options for constructing the initial data. See #construct_live_tree_data for details. If you used LiveTree::ClassMethods.live_tree to setup your controller, you don't need to specify this (the same values passed to live_tree are used). (default <tt>{}</tt>, only used if <tt>:initial_data_root</tt>).
145
+ def construct_live_tree_function(name, options = {})
146
+ options = options.dup;
147
+ if options[:id] != nil
148
+ tree_id = options[:id]
149
+ else
150
+ tree_id = name
151
+ end
152
+ for k in [:on_click_item, :on_expand_item, :on_collapse_item, :on_load_item]
153
+ if options[k] != nil
154
+ options[k] = "function(item){" + options[k] + "}"
155
+ end
156
+ end
157
+ if options[:data_url] == nil
158
+ if options[:data_action] == nil
159
+ act = name.to_s + "_live_tree_data"
160
+ else
161
+ act = options[:data_action]
162
+ end
163
+ if options[:data_controller] == nil
164
+ options[:data_url] = { :action => act }
165
+ else
166
+ options[:data_url] = { :controller => options[:data_controller], :action => act }
167
+ end
168
+ end
169
+ options[:data_url] = '"' + escape_javascript(url_for(options[:data_url])) + '"'
170
+ for k in [:css_class, :css_style]
171
+ if options[k] != nil
172
+ options[k] = '"' + escape_javascript(options[k]) + '"'
173
+ end
174
+ end
175
+ if options[:initial_data_root] != nil
176
+ item = options[:initial_data_root]
177
+ if (options[:initial_data_whole_tree])
178
+ depth = nil
179
+ elsif (options[:expand_root_item] == nil || options[:expand_root_item] || options[:hide_root_item])
180
+ depth = 2
181
+ else
182
+ depth = 1
183
+ end
184
+
185
+ if options[:initial_data_options] == nil
186
+ data_options_method = controller.method("#{name}_live_tree_options")
187
+ if data_options_method
188
+ data_options = data_options_method.call
189
+ else
190
+ data_options = {}
191
+ end
192
+ else
193
+ data_options = options[:initial_data_options]
194
+ end
195
+ data_options = data_options.dup
196
+ data_options[:depth] = depth;
197
+ options[:initial_data] = construct_live_tree_data(item, data_options)
198
+ end
199
+ options.delete :id
200
+ options.delete :data_action
201
+ options.delete :data_controller
202
+ options.delete :initial_data_root
203
+ options.delete :initial_data_options
204
+ options.delete :initial_data_whole_tree
205
+ options_js = "{\n" + options.map {|k, v| LiveTreeHelper.live_tree_js_name(k) + ":#{v}"}.join(",\n") + "\n}"
206
+ "new LiveTree(\"" + tree_id.to_s + "\"," + options_js + ")"
207
+ end
208
+
209
+ # Returns data in format appropriate for use with the <tt>:initial_data</tt> parameter of #construct_live_tree_function .
210
+ #
211
+ # Arguments:
212
+ # * +item+ - Root item of the data.
213
+ # * +options+ - Same options as LiveTree.get_live_tree_data, as well as:
214
+ # * <tt>:depth</tt> - How many level deep to recurse (default is +nil+, which means to recurse to the ends of all branches).
215
+ def construct_live_tree_data(item, options = {})
216
+ return _get_live_tree_data(item, options, options)
217
+ end
218
+
219
+ end
220
+
221
+ # Renders data to return to a LiveTree data request.
222
+ #
223
+ # Arguments:
224
+ # * +item+ - Item to return.
225
+ # * +options+ - May contain the following:
226
+ # * <tt>:get_item_name_proc</tt> - Proc object which, when called with an item, returns the name of the item to display. (by default, the item's name is retrieved using the object's +name+ attribute).
227
+ def get_live_tree_data(item, options = {})
228
+ #data = LiveTreeHelper.get_live_tree_data(item, options, params)
229
+ #render :text => data
230
+ render :inline => '<%= _get_live_tree_data(item, options, params) %>', :locals => { :item => item, :options => options }
231
+ end
232
+
233
+ # Returns the value of the item ID from the request's params.
234
+ def live_tree_item_id
235
+ params[:item_id]
236
+ end
237
+
238
+ end
@@ -0,0 +1,96 @@
1
+ """
2
+ Receive an email from which an elt is created. An associated mail is kept to
3
+ make sure we don't lose any data. Attachments are also created in an associated
4
+ table
5
+ """
6
+ class Mailman < ActionMailer::Base
7
+ """ This is to make sure we only have utf-8, no iso-8859 """
8
+ def unquote(text)
9
+ text.gsub(/\=\?.*?\?\=/) do |m|
10
+ TMail::Unquoter.unquote_and_convert_to(m, 'utf-8')
11
+ end
12
+ end
13
+
14
+ def receive(email)
15
+ @elt = Elt.new
16
+ @elt.created_on = email.date
17
+ @elt.subject = unquote(email.subject)
18
+
19
+ @elt.body = ''
20
+
21
+ @elt.person = Person.find_by_name(unquote(email.friendly_from))
22
+ @elt.person = Person.new if @elt.person == nil
23
+ @elt.person.name = unquote(email.friendly_from)
24
+ @elt.person.email = email.from.first
25
+
26
+ if email.references != nil
27
+ # Try to fin its email parent in the db
28
+ for parent in email.references
29
+ m = Mail.find_by_message(parent.to_s)
30
+ @elt.parent = m.elt if m != nil
31
+ end
32
+ end
33
+
34
+ if @elt.parent == nil
35
+ parentId = @elt.subject.match(/\[\w*\]/)
36
+ logger.info parentId
37
+ if parentId != nil
38
+ parentId = parentId[0].gsub(/[\[\]]/, '')
39
+ parentElt = Elt.find(parentId)
40
+ logger.info parentElt
41
+ if parentElt != nil
42
+ @elt.subject = @elt.subject
43
+ @elt.parent_id = parentId
44
+ end
45
+ logger.info @elt.subject
46
+ end
47
+ end
48
+
49
+ @elt.parent_id = 'mails' if @elt.parent == nil
50
+
51
+
52
+ mngAttachment(email) if email != nil
53
+
54
+
55
+ logger.info email.from.first
56
+ @mail = Mail.new
57
+ logger.info email.friendly_from
58
+ @mail.message = email.message_id
59
+ logger.info email.references
60
+ @mail.mail_parents = email.references
61
+
62
+ @mail.file = email.encoded
63
+
64
+ @elt.save
65
+ @mail.elt = @elt
66
+ @mail.save
67
+ end
68
+
69
+ def mngAttachment(attachment)
70
+ if attachment.content_type == 'text/plain'
71
+ @elt.body += attachment.body
72
+ elsif attachment.multipart?
73
+ attachment.parts.each do |part|
74
+ mngAttachment(part)
75
+ end
76
+ elsif attachment.content_type != 'text/html'
77
+ @attach = @elt.attachments.build
78
+ body = attachment.body
79
+
80
+ @attach.content_type = attachment.content_type
81
+
82
+ def body.original_filename=(orig)
83
+ @original_filename = orig
84
+ end
85
+ body.original_filename = attachment.type_param('name')
86
+ def body.original_filename
87
+ @original_filename
88
+ end
89
+ def body.read
90
+ self.to_s
91
+ end
92
+
93
+ @attach.file = body
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,4 @@
1
+ class Attachment < ActiveRecord::Base
2
+ belongs_to :elt
3
+ file_column :file
4
+ end
data/app/models/elt.rb ADDED
@@ -0,0 +1,17 @@
1
+ class Elt < ActiveRecord::Base
2
+ acts_as_tree :order => "position is not null, position, created_on"
3
+ belongs_to :person
4
+ has_one :mail, :dependent => true
5
+ has_many :attachments, :dependent => true
6
+
7
+ # for live_tree
8
+ def name
9
+ subject
10
+ end
11
+
12
+ def save
13
+ super
14
+ logger.info 'hello world!!!'
15
+ end
16
+ end
17
+
@@ -0,0 +1,4 @@
1
+ class Mail < ActiveRecord::Base
2
+ belongs_to :elt
3
+ end
4
+
@@ -0,0 +1,13 @@
1
+ class Notifier < ActionMailer::Base
2
+ def changeEmail(person, link)
3
+ # Email header info MUST be added here
4
+ @recipients = person.email
5
+ @subject = "[parleR] check key: "+person.check_key
6
+ @from = MAIL_FROM
7
+
8
+ # Email body substitutions go here
9
+ @body["name"] = person.name
10
+ @body["link"] = link
11
+ @body["check_key"] = person.check_key
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class Person < ActiveRecord::Base
2
+ has_many :elts
3
+
4
+ validates_presence_of :name, :on => :create
5
+ validates_length_of :name, :within => 3..40, :on => :create
6
+ validates_uniqueness_of :name, :on => :create
7
+ validates_uniqueness_of :email, :on => :create
8
+ end
9
+
@@ -0,0 +1,7 @@
1
+ class User < ActiveRecord::Base
2
+ include LoginEngine::AuthenticatedUser
3
+
4
+ # all logic has been moved into login_engine/lib/login_engine/authenticated_user.rb
5
+
6
+ end
7
+
@@ -0,0 +1,75 @@
1
+ class UserNotify < ActionMailer::Base
2
+ def signup(user, password, url=nil)
3
+ setup_email(user)
4
+
5
+ # Email header info
6
+ @subject += "Welcome to #{LoginEngine.config(:app_name)}!"
7
+
8
+ # Email body substitutions
9
+ @body["name"] = "#{user.firstname} #{user.lastname}"
10
+ @body["login"] = user.login
11
+ @body["password"] = password
12
+ @body["url"] = url || LoginEngine.config(:app_url).to_s
13
+ @body["app_name"] = LoginEngine.config(:app_name).to_s
14
+ end
15
+
16
+ def forgot_password(user, url=nil)
17
+ setup_email(user)
18
+
19
+ # Email header info
20
+ @subject += "Forgotten password notification"
21
+
22
+ # Email body substitutions
23
+ @body["name"] = "#{user.firstname} #{user.lastname}"
24
+ @body["login"] = user.login
25
+ @body["url"] = url || LoginEngine.config(:app_url).to_s
26
+ @body["app_name"] = LoginEngine.config(:app_name).to_s
27
+ end
28
+
29
+ def change_password(user, password, url=nil)
30
+ setup_email(user)
31
+
32
+ # Email header info
33
+ @subject += "Changed password notification"
34
+
35
+ # Email body substitutions
36
+ @body["name"] = "#{user.firstname} #{user.lastname}"
37
+ @body["login"] = user.login
38
+ @body["password"] = password
39
+ @body["url"] = url || LoginEngine.config(:app_url).to_s
40
+ @body["app_name"] = LoginEngine.config(:app_name).to_s
41
+ end
42
+
43
+ def pending_delete(user, url=nil)
44
+ setup_email(user)
45
+
46
+ # Email header info
47
+ @subject += "Delete user notification"
48
+
49
+ # Email body substitutions
50
+ @body["name"] = "#{user.firstname} #{user.lastname}"
51
+ @body["url"] = url || LoginEngine.config(:app_url).to_s
52
+ @body["app_name"] = LoginEngine.config(:app_name).to_s
53
+ @body["days"] = LoginEngine.config(:delayed_delete_days).to_s
54
+ end
55
+
56
+ def delete(user, url=nil)
57
+ setup_email(user)
58
+
59
+ # Email header info
60
+ @subject += "Delete user notification"
61
+
62
+ # Email body substitutions
63
+ @body["name"] = "#{user.firstname} #{user.lastname}"
64
+ @body["url"] = url || LoginEngine.config(:app_url).to_s
65
+ @body["app_name"] = LoginEngine.config(:app_name).to_s
66
+ end
67
+
68
+ def setup_email(user)
69
+ @recipients = "#{user.email}"
70
+ @from = LoginEngine.config(:email_from).to_s
71
+ @subject = "[#{LoginEngine.config(:app_name)}] "
72
+ @sent_on = Time.now
73
+ @headers['Content-Type'] = "text/plain; charset=#{LoginEngine.config(:mail_charset)}; format=flowed"
74
+ end
75
+ end
@@ -0,0 +1,23 @@
1
+ <%= link_to_function("?",
2
+ visual_effect(:Shrink, "help_#{divId}_link")+
3
+ visual_effect(:Grow, "help_#{divId}")+
4
+ visual_effect(:Grow, "help_close_#{divId}_link"),
5
+ :class => "helpLink",
6
+ :id => "help_#{divId}_link") %>
7
+
8
+ <%= link_to_function("?",
9
+ visual_effect(:Shrink, "help_#{divId}")+
10
+ visual_effect(:Shrink, "help_close_#{divId}_link")+
11
+ visual_effect(:Grow, "help_#{divId}_link"),
12
+ :class => "helpLinkClose",
13
+ :id => "help_close_#{divId}_link",
14
+ :style => "display:none") %>
15
+
16
+ <div style="display:none" class="help" id="help_<%= divId %>">
17
+ <%= link_to_function("Help:",
18
+ visual_effect(:Shrink, "help_#{divId}")+
19
+ visual_effect(:Shrink, "help_close_#{divId}_link")+
20
+ visual_effect(:Grow, "help_#{divId}_link"),
21
+ :class => "helpTitle") %>
22
+ <%= content %>
23
+ </div>
@@ -0,0 +1,57 @@
1
+ <div class="login">
2
+ <%= form_remote_tag(
3
+ :update => divId,
4
+ :url => { :controller => 'account', :action => 'login' },
5
+ :interactive => visual_effect(:BlindDown, divId)) %>
6
+ <!--:position => 'after',-->
7
+
8
+ <input type="hidden" id="divId" name="divId" value="<%= divId %>"/>
9
+
10
+ <label for="person_name">Pseudo:</label>
11
+ <%= text_field "person", "name", :size => 10 %>
12
+
13
+ <%= link_to_function('+',
14
+ "Element.toggle(this);"+visual_effect(:Grow, 'user_password_'+divId.to_s)) %>
15
+
16
+ <span style="display:none" id="user_password_<%= divId %>">
17
+ &nbsp;
18
+ <label for="user_password">Password:</label>
19
+ <%= password_field "user", "password", :size => 10 %>
20
+
21
+ <%= link_to_function('email? >',
22
+ "Element.toggle(this);"+visual_effect(:Grow, 'person_email_'+divId.to_s)) %>
23
+ </span>
24
+
25
+ <span style="display:none" id="person_email_<%= divId %>">
26
+ <br/>
27
+ <!--
28
+ <label for="user_password_confirmation">Confirm password:</label>
29
+ <%= password_field "user", "password_confirmation", :size => 10 %>
30
+ &nbsp;
31
+ -->
32
+ <label for="person_email">Email (or check key):</label>
33
+ <%= text_field "person", "email", :size => 30 %>
34
+ </span>
35
+
36
+ <%= submit_tag 'Ok' %>
37
+
38
+ <%= render :partial => 'account/help',
39
+ :locals => { :divId => 'login'+divId.to_s, :content => '
40
+ <ul>You can propose an element
41
+ <li>with no pseudo</li>
42
+ <li>with an unprotected pseudo</li>
43
+ <li>with a password protected pseudo (click on the "+")</li>
44
+ <li>with a password protected and email verified pseudo (TODO)</li>
45
+ </ul>
46
+ The last method is the only secure way to protect a nickname on
47
+ <strong>this</strong> server.
48
+ <br/>
49
+ If a nick is not protected and verified, anybody else can protect it for
50
+ themselves if they at least supply a password <em>and</em> an email.
51
+ <br/>
52
+ A login must contain [3..40] characters, a password [5..40].
53
+ ' } %>
54
+ </div>
55
+ <%= end_form_tag %>
56
+ </div>
57
+
@@ -0,0 +1,31 @@
1
+ <% @flash.each do |key, value| %>
2
+ <div class="<%= key %>"><%= value %></div>
3
+ <% end %>
4
+
5
+ <%= error_messages_for 'person' if @person %>
6
+ <%= error_messages_for 'user' if @user %>
7
+
8
+ <% if @session[:person] != nil %>
9
+ <% if @session[:person] != nil and @session[:person].name != nil \
10
+ and @session[:person].name != '' %>
11
+ <div class="author">
12
+ <% if @session[:person] != nil and @session[:person].email != nil %>
13
+ &lt;<%= mail_to @session[:person].email, @session[:person].name %>&gt;
14
+ <% else %>
15
+ &lt;<%= @session[:person].name %>&gt;
16
+ <% end %>
17
+ </div>
18
+ <% end %>
19
+
20
+
21
+ <div class="logout">
22
+ <%= link_to_remote('(X)',
23
+ :update => divId,
24
+ :url => { :controller => 'account', :action => 'logout', :divId => divId },
25
+ :loaded => visual_effect(:BlindDown, divId)) %>
26
+ </div>
27
+ <% else %>
28
+
29
+ <%= render :partial => 'account/login', :locals => { :divId => divId } %>
30
+ <% end %>
31
+
@@ -0,0 +1,10 @@
1
+
2
+ <div class="memo">
3
+ <h3>Logoff</h3>
4
+
5
+ <p>You are now logged out of the system...</p>
6
+
7
+ <%= link_to "&#171; login", :action=>"login"%>
8
+
9
+ </div>
10
+
@@ -0,0 +1,17 @@
1
+ <%= start_form_tag :action=> "signup" %>
2
+
3
+ <div title="Account signup" id="signupform" class="form">
4
+ <h3>Signup</h3>
5
+ <%= error_messages_for 'user' %><br/>
6
+
7
+ <label for="user_login">Desired login:</label><br/>
8
+ <%= text_field "user", "login", :size => 30 %><br/>
9
+ <label for="user_password">Choose password:</label><br/>
10
+ <%= password_field "user", "password", :size => 30 %><br/>
11
+ <label for="user_password_confirmation">Confirm password:</label><br/>
12
+ <%= password_field "user", "password_confirmation", :size => 30 %><br/>
13
+
14
+ <input type="submit" value="Signup &#187;" class="primary" />
15
+
16
+ <%= end_form_tag %>
17
+
@@ -0,0 +1,13 @@
1
+
2
+ <div class="memo">
3
+ <h3>Welcome</h3>
4
+
5
+ <p>You are now logged into the system...</p>
6
+ <p>
7
+ Since you are here it's safe to assume the application never called store_location, otherwise
8
+ you would have been redirected somewhere else after a successful login.
9
+ </p>
10
+
11
+ <%= link_to "&#171; logout", :action=>"logout"%>
12
+
13
+ </div>