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
data/COPYING ADDED
@@ -0,0 +1,223 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
3
+
4
+ 0. This License applies to any program or other work which contains
5
+ a notice placed by the copyright holder saying it may be distributed
6
+ under the terms of this General Public License. The "Program", below,
7
+ refers to any such program or work, and a "work based on the Program"
8
+ means either the Program or any derivative work under copyright law:
9
+ that is to say, a work containing the Program or a portion of it,
10
+ either verbatim or with modifications and/or translated into another
11
+ language. (Hereinafter, translation is included without limitation in
12
+ the term "modification".) Each licensee is addressed as "you".
13
+
14
+ Activities other than copying, distribution and modification are not
15
+ covered by this License; they are outside its scope. The act of
16
+ running the Program is not restricted, and the output from the Program
17
+ is covered only if its contents constitute a work based on the
18
+ Program (independent of having been made by running the Program).
19
+ Whether that is true depends on what the Program does.
20
+
21
+ 1. You may copy and distribute verbatim copies of the Program's
22
+ source code as you receive it, in any medium, provided that you
23
+ conspicuously and appropriately publish on each copy an appropriate
24
+ copyright notice and disclaimer of warranty; keep intact all the
25
+ notices that refer to this License and to the absence of any warranty;
26
+ and give any other recipients of the Program a copy of this License
27
+ along with the Program.
28
+
29
+ You may charge a fee for the physical act of transferring a copy, and
30
+ you may at your option offer warranty protection in exchange for a fee.
31
+
32
+ 2. You may modify your copy or copies of the Program or any portion
33
+ of it, thus forming a work based on the Program, and copy and
34
+ distribute such modifications or work under the terms of Section 1
35
+ above, provided that you also meet all of these conditions:
36
+
37
+ a) You must cause the modified files to carry prominent notices
38
+ stating that you changed the files and the date of any change.
39
+
40
+ b) You must cause any work that you distribute or publish, that in
41
+ whole or in part contains or is derived from the Program or any
42
+ part thereof, to be licensed as a whole at no charge to all third
43
+ parties under the terms of this License.
44
+
45
+ c) If the modified program normally reads commands interactively
46
+ when run, you must cause it, when started running for such
47
+ interactive use in the most ordinary way, to print or display an
48
+ announcement including an appropriate copyright notice and a
49
+ notice that there is no warranty (or else, saying that you provide
50
+ a warranty) and that users may redistribute the program under
51
+ these conditions, and telling the user how to view a copy of this
52
+ License. (Exception: if the Program itself is interactive but
53
+ does not normally print such an announcement, your work based on
54
+ the Program is not required to print an announcement.)
55
+
56
+ These requirements apply to the modified work as a whole. If
57
+ identifiable sections of that work are not derived from the Program,
58
+ and can be reasonably considered independent and separate works in
59
+ themselves, then this License, and its terms, do not apply to those
60
+ sections when you distribute them as separate works. But when you
61
+ distribute the same sections as part of a whole which is a work based
62
+ on the Program, the distribution of the whole must be on the terms of
63
+ this License, whose permissions for other licensees extend to the
64
+ entire whole, and thus to each and every part regardless of who wrote it.
65
+
66
+ Thus, it is not the intent of this section to claim rights or contest
67
+ your rights to work written entirely by you; rather, the intent is to
68
+ exercise the right to control the distribution of derivative or
69
+ collective works based on the Program.
70
+
71
+ In addition, mere aggregation of another work not based on the Program
72
+ with the Program (or with a work based on the Program) on a volume of
73
+ a storage or distribution medium does not bring the other work under
74
+ the scope of this License.
75
+
76
+ 3. You may copy and distribute the Program (or a work based on it,
77
+ under Section 2) in object code or executable form under the terms of
78
+ Sections 1 and 2 above provided that you also do one of the following:
79
+
80
+ a) Accompany it with the complete corresponding machine-readable
81
+ source code, which must be distributed under the terms of Sections
82
+ 1 and 2 above on a medium customarily used for software interchange; or,
83
+
84
+ b) Accompany it with a written offer, valid for at least three
85
+ years, to give any third party, for a charge no more than your
86
+ cost of physically performing source distribution, a complete
87
+ machine-readable copy of the corresponding source code, to be
88
+ distributed under the terms of Sections 1 and 2 above on a medium
89
+ customarily used for software interchange; or,
90
+
91
+ c) Accompany it with the information you received as to the offer
92
+ to distribute corresponding source code. (This alternative is
93
+ allowed only for noncommercial distribution and only if you
94
+ received the program in object code or executable form with such
95
+ an offer, in accord with Subsection b above.)
96
+
97
+ The source code for a work means the preferred form of the work for
98
+ making modifications to it. For an executable work, complete source
99
+ code means all the source code for all modules it contains, plus any
100
+ associated interface definition files, plus the scripts used to
101
+ control compilation and installation of the executable. However, as a
102
+ special exception, the source code distributed need not include
103
+ anything that is normally distributed (in either source or binary
104
+ form) with the major components (compiler, kernel, and so on) of the
105
+ operating system on which the executable runs, unless that component
106
+ itself accompanies the executable.
107
+
108
+ If distribution of executable or object code is made by offering
109
+ access to copy from a designated place, then offering equivalent
110
+ access to copy the source code from the same place counts as
111
+ distribution of the source code, even though third parties are not
112
+ compelled to copy the source along with the object code.
113
+
114
+ 4. You may not copy, modify, sublicense, or distribute the Program
115
+ except as expressly provided under this License. Any attempt
116
+ otherwise to copy, modify, sublicense or distribute the Program is
117
+ void, and will automatically terminate your rights under this License.
118
+ However, parties who have received copies, or rights, from you under
119
+ this License will not have their licenses terminated so long as such
120
+ parties remain in full compliance.
121
+
122
+ 5. You are not required to accept this License, since you have not
123
+ signed it. However, nothing else grants you permission to modify or
124
+ distribute the Program or its derivative works. These actions are
125
+ prohibited by law if you do not accept this License. Therefore, by
126
+ modifying or distributing the Program (or any work based on the
127
+ Program), you indicate your acceptance of this License to do so, and
128
+ all its terms and conditions for copying, distributing or modifying
129
+ the Program or works based on it.
130
+
131
+ 6. Each time you redistribute the Program (or any work based on the
132
+ Program), the recipient automatically receives a license from the
133
+ original licensor to copy, distribute or modify the Program subject to
134
+ these terms and conditions. You may not impose any further
135
+ restrictions on the recipients' exercise of the rights granted herein.
136
+ You are not responsible for enforcing compliance by third parties to
137
+ this License.
138
+
139
+ 7. If, as a consequence of a court judgment or allegation of patent
140
+ infringement or for any other reason (not limited to patent issues),
141
+ conditions are imposed on you (whether by court order, agreement or
142
+ otherwise) that contradict the conditions of this License, they do not
143
+ excuse you from the conditions of this License. If you cannot
144
+ distribute so as to satisfy simultaneously your obligations under this
145
+ License and any other pertinent obligations, then as a consequence you
146
+ may not distribute the Program at all. For example, if a patent
147
+ license would not permit royalty-free redistribution of the Program by
148
+ all those who receive copies directly or indirectly through you, then
149
+ the only way you could satisfy both it and this License would be to
150
+ refrain entirely from distribution of the Program.
151
+
152
+ If any portion of this section is held invalid or unenforceable under
153
+ any particular circumstance, the balance of the section is intended to
154
+ apply and the section as a whole is intended to apply in other
155
+ circumstances.
156
+
157
+ It is not the purpose of this section to induce you to infringe any
158
+ patents or other property right claims or to contest validity of any
159
+ such claims; this section has the sole purpose of protecting the
160
+ integrity of the free software distribution system, which is
161
+ implemented by public license practices. Many people have made
162
+ generous contributions to the wide range of software distributed
163
+ through that system in reliance on consistent application of that
164
+ system; it is up to the author/donor to decide if he or she is willing
165
+ to distribute software through any other system and a licensee cannot
166
+ impose that choice.
167
+
168
+ This section is intended to make thoroughly clear what is believed to
169
+ be a consequence of the rest of this License.
170
+
171
+ 8. If the distribution and/or use of the Program is restricted in
172
+ certain countries either by patents or by copyrighted interfaces, the
173
+ original copyright holder who places the Program under this License
174
+ may add an explicit geographical distribution limitation excluding
175
+ those countries, so that distribution is permitted only in or among
176
+ countries not thus excluded. In such case, this License incorporates
177
+ the limitation as if written in the body of this License.
178
+
179
+ 9. The Free Software Foundation may publish revised and/or new versions
180
+ of the General Public License from time to time. Such new versions will
181
+ be similar in spirit to the present version, but may differ in detail to
182
+ address new problems or concerns.
183
+
184
+ Each version is given a distinguishing version number. If the Program
185
+ specifies a version number of this License which applies to it and "any
186
+ later version", you have the option of following the terms and conditions
187
+ either of that version or of any later version published by the Free
188
+ Software Foundation. If the Program does not specify a version number of
189
+ this License, you may choose any version ever published by the Free Software
190
+ Foundation.
191
+
192
+ 10. If you wish to incorporate parts of the Program into other free
193
+ programs whose distribution conditions are different, write to the author
194
+ to ask for permission. For software which is copyrighted by the Free
195
+ Software Foundation, write to the Free Software Foundation; we sometimes
196
+ make exceptions for this. Our decision will be guided by the two goals
197
+ of preserving the free status of all derivatives of our free software and
198
+ of promoting the sharing and reuse of software generally.
199
+
200
+ NO WARRANTY
201
+
202
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
203
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
204
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
205
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
206
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
207
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
208
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
209
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
210
+ REPAIR OR CORRECTION.
211
+
212
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
213
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
214
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
215
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
216
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
217
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
218
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
219
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
220
+ POSSIBILITY OF SUCH DAMAGES.
221
+
222
+ END OF TERMS AND CONDITIONS
223
+
data/README ADDED
@@ -0,0 +1,20 @@
1
+ I am using debian, so here are a few commands I use:
2
+ # apt-get install ruby
3
+ # apt-get install postgresql
4
+ # apt-get install libpgsql-ruby1.6
5
+ # apt-get install libredcloth-ruby
6
+ # apt-get install irb
7
+
8
+
9
+ Once you have everything set up (ruby, postgresql, redcloth, irb), you can
10
+ launch parlement thus:
11
+ ~ cd parlement
12
+ ~ psql -q template1 -f db/schema.sql
13
+ ~ ruby lib/data_import.rb
14
+ ~ ruby ./script/server
15
+
16
+ The database is setup for user "manu", you may need to change the file
17
+ config/database.yml for your own settings.
18
+
19
+ Now you can go to localhost:3000
20
+
data/Rakefile ADDED
@@ -0,0 +1,136 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
3
+
4
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
+
6
+ require 'rake'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+ require 'rake/gempackagetask'
10
+
11
+ require 'tasks/rails'
12
+
13
+ require 'meta_project'
14
+
15
+ require 'rake/contrib/rubyforgepublisher'
16
+
17
+
18
+ desc "Deploy basic application directories"
19
+ task :deploy => :environment do
20
+ # public is missing
21
+ dirs = %w{ app lib test config}
22
+ onserver = "manu@vvv:/home/manu/develop/parlement/"
23
+ dirs.each do | dir|
24
+ `rsync -a --delete "#{RAILS_ROOT}/#{dir}" "#{onserver}" --exclude ".svn"`
25
+ end
26
+ end
27
+
28
+
29
+ PKG_NAME = "parlement"
30
+ PKG_VERSION = "0.1"
31
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
32
+
33
+ PKG_FILES = FileList[
34
+ '[A-Z]*', 'app/**/*', 'components/**/*', 'config/**/*', 'db/**/*',
35
+ 'lib/**/*', 'public/**/*', 'script/**/*', 'test/**/*', 'vendor/**/*'
36
+ ].exclude(/\bCVS\b|~$/)
37
+
38
+ spec = Gem::Specification.new do |s|
39
+ ## Basic information.
40
+ s.name = PKG_NAME
41
+ s.version = PKG_VERSION
42
+ s.summary = "Secure Direct Democracy on a forum"
43
+ s.description = <<EOF
44
+ This is a forum and mailing list project, which aims to be a complete Direct
45
+ Democracy implementation where everybody can propose polls, vote on them, or
46
+ delegate their voice to someone else.
47
+
48
+ Trust through:
49
+ - cluster
50
+ - PGP signatures
51
+ - electoral lists
52
+ EOF
53
+ s.files = PKG_FILES
54
+ s.require_path = 'lib'
55
+ s.autorequire = 'rails, meta_project'
56
+ s.has_rdoc = false
57
+ s.requirements << 'none'
58
+ s.test_files = Dir.glob('test/unit/*')
59
+
60
+ # Author and project details.
61
+ s.author = "Emmanuel Charpentier"
62
+ s.email = "emmanuel.charpentier@free.fr"
63
+ s.homepage = "http://leparlement.org"
64
+ s.rubyforge_project = PKG_NAME
65
+ s.platform = Gem::Platform::RUBY
66
+
67
+ #if ENV['CERT_DIR']
68
+ #s.signing_key = File.join(ENV['CERT_DIR'], 'gem-private_key.pem')
69
+ #s.cert_chain = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
70
+ #end
71
+ s.add_dependency('rails')
72
+ end
73
+
74
+ Rake::GemPackageTask.new(spec) do |pkg|
75
+ #pkg.gem_spec = spec
76
+ pkg.need_zip = true
77
+ pkg.need_tar = true
78
+ #pkg.package_files.include("*")
79
+ end
80
+
81
+ # Support Tasks ------------------------------------------------------
82
+
83
+ desc "Look for TODO and FIXME tags in the code"
84
+ task :todo do
85
+ Pathname.new(File.dirname(__FILE__)).egrep(/#.*(FIXME|TODO|TBD|DEPRECATED)/) do |match|
86
+ puts match
87
+ end
88
+ end
89
+
90
+ task :release => [:verify_env_vars, :release_files, :publish_doc, :publish_news, :tag]
91
+
92
+ task :verify_env_vars do
93
+ raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
94
+ raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
95
+ puts ENV['RUBYFORGE_USER']
96
+ puts ENV['RUBYFORGE_PASSWORD']
97
+ end
98
+
99
+ task :publish_doc do
100
+ publisher = Rake::RubyForgePublisher.new('xforge', ENV['RUBYFORGE_USER'])
101
+ publisher.upload
102
+ end
103
+
104
+ desc "Release files on RubyForge"
105
+ task :release_files => [:gem] do
106
+ release_files = FileList[ "pkg/#{PKG_FILE_NAME}.gem" ]
107
+
108
+ Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new('xforge')) do |release|
109
+ # Never hardcode user name and password in the Rakefile!
110
+ release.user_name = ENV['RUBYFORGE_USER']
111
+ release.password = ENV['RUBYFORGE_PASSWORD']
112
+ release.files = release_files.to_a
113
+ release.release_name = "#{PKG_NAME} #{PKG_VERSION}"
114
+ # The rest of the options are defaults (among others, release_notes and release_changes, parsed from CHANGES)
115
+ end
116
+ end
117
+
118
+ desc "Publish news on RubyForge"
119
+ task :publish_news => [:gem] do
120
+ release_files = FileList[ "pkg/#{PKG_FILE_NAME}.gem" ]
121
+
122
+ Rake::XForge::NewsPublisher.new(MetaProject::Project::XForge::RubyForge.new('xforge')) do |news|
123
+ # Never hardcode user name and password in the Rakefile!
124
+ news.user_name = ENV['RUBYFORGE_USER']
125
+ news.password = ENV['RUBYFORGE_PASSWORD']
126
+ end
127
+ end
128
+
129
+ desc "Tag all the CVS files with the latest release number (REL=x.y.z)"
130
+ task :tag do
131
+ reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
132
+ puts "Tagging CVS with [#{reltag}]"
133
+ sh %{cvs tag #{reltag}}
134
+ end
135
+
136
+
@@ -0,0 +1,181 @@
1
+ class AccountController < UserController
2
+ model :person
3
+ model :user
4
+
5
+ def login
6
+ # Cleaning up
7
+ @session[:person] = @session[:user] = nil
8
+
9
+ login = @params[:person][:name]
10
+ email = @params[:person][:email]
11
+ password = @params[:user][:password]
12
+
13
+ @person = Person.find_by_name(login)
14
+ @user = User.find_by_login(login) if @person
15
+
16
+ # First we eventually create a new pseudo
17
+ if not @person
18
+ # Create the pseudo
19
+ begin
20
+ Person.transaction(@person) do
21
+ @person = Person.new
22
+ @person.name = login
23
+ if @person.save
24
+ logger.info "person: "+@person.to_s
25
+ logger.info "person.id: "+@person.id.to_s
26
+ flash.now[:notice] = "Pseudo created"
27
+ @session[:person] = @person
28
+ else
29
+ flash.now[:error] = 'Error creating account'
30
+ end
31
+ end
32
+ rescue Exception => e
33
+ flash.now[:error] = 'Error creating account'
34
+ logger.error e
35
+ end
36
+ end
37
+
38
+ # Second we record the password or try to authenticate
39
+ if @person and @person.errors.empty?
40
+ if password.empty?
41
+ if not @user or not @user.salted_password \
42
+ or @user.salted_password.empty?
43
+ @session[:person] = @person
44
+ else
45
+ flash.now[:error] = "This pseudo is protected with a password"
46
+ end
47
+ elsif not @user
48
+ @user = User.new()
49
+ begin
50
+ User.transaction(@user) do
51
+ @user.login = login
52
+ @user.change_password(password)
53
+ # This is a hack, to make sure this user can login even if he
54
+ # didn't verify his email
55
+ @user.verified = true
56
+ if @user.save
57
+ flash['notice 2'] = 'Password recorded'
58
+
59
+ @session[:person] = @person
60
+ @session[:user] = @user
61
+ end
62
+ end
63
+ rescue
64
+ flash.now[:error] = 'Error with password'
65
+ end
66
+
67
+ elsif User.authenticate(login, password)
68
+ # There is a password protecting this pseudo
69
+ @session[:person] = @person
70
+ @session[:user] = @user
71
+
72
+ elsif not email.empty?
73
+ begin
74
+ User.transaction(@user) do
75
+ if User.authenticate_by_token(@user.id, email)
76
+ @user.change_password(password)
77
+ @user.security_token = nil
78
+ if @user.save
79
+ flash.now['notice 2'] = 'Password successfully modified!'
80
+ @session[:person] = @person
81
+ @session[:user] = @user
82
+ end
83
+ end
84
+ end
85
+ rescue
86
+ flash.now[:error] = 'Wrong check key'
87
+ end
88
+ else
89
+ flash.now[:error] = "Wrong password"
90
+ end
91
+
92
+ # Third we record the email or send a check_key for a password reset
93
+ if not email.empty?
94
+ if @session[:person]
95
+ if email == @person.email
96
+ flash.now['notice 3'] = "Email already recorded and verified"
97
+ else
98
+ signup
99
+ end
100
+
101
+ elsif email == @person.email
102
+ # User protected by password and with the same email as entered
103
+ key = @user.generate_security_token
104
+ url = url_for(:action => 'check_key')
105
+ url += "?user[id]=#{@user.id}&key=#{key}"
106
+ UserNotify::deliver_forgot_password(@user, url)
107
+ flash.now['notice 3'] = "Email with a check key sent to "+email
108
+ end
109
+ end
110
+ end
111
+
112
+ render :partial => 'show', :locals => { :divId => params[:divId] }
113
+ #render :partial => 'show', :locals => { :divId => 'test' }
114
+ end
115
+
116
+
117
+ def logout
118
+ @session[:person] = @person = nil
119
+ render :partial => 'login', :locals => { :divId => params[:divId] }
120
+ end
121
+
122
+ def check_key
123
+ if @user = User.authenticate_by_token(@params[:user][:id], @params[:key])
124
+ #@user = User.find(:first, :conditions => "security_token = '#{params[:key]}'")
125
+ @person = Person.find_by_name(@user.login) if @user
126
+ @person.email = @user.email
127
+ @person.save
128
+ flash.now[:notice] = "Email #{@person.email} verified."
129
+ @session[:person] = @person
130
+ @session[:user] = @user
131
+ render :text => "<h1>Email verified!</h1> \
132
+ <br/> \
133
+ <a href='#{url_for :controller => 'elt', :action => 'show', :id => nil }'>\
134
+ Back</a>",
135
+ :layout => 'top'
136
+ else
137
+ render :text => "<h3>Sorry, no corresponding check key :-(</h3> \
138
+ <br/> \
139
+ <a href='#{url_for :controller => 'elt', :action => 'show', :id => nil }'>\
140
+ Back</a>",
141
+ :layout => 'top'
142
+ end
143
+ end
144
+
145
+
146
+ protected
147
+ # Mostly copied from the login engine
148
+ def signup
149
+ if @person and not @user
150
+ @user = User.new
151
+ @user.login = @person.name
152
+ end
153
+
154
+ @user.email = @params[:person][:email]
155
+ begin
156
+ User.transaction(@user) do
157
+ unless LoginEngine.config(:use_email_notification)
158
+ @user.verified = 1
159
+ end
160
+ if @user.save
161
+ key = @user.generate_security_token
162
+ #url = url_for(:action => 'home', 'user[id]' => @user.id, :key => key)
163
+ url = url_for(:action => 'check_key')
164
+ url += "?user[id]=#{@user.id}&key=#{key}"
165
+ #flash[:notice] = 'Signup successful!'
166
+ flash.now['notice 3'] = 'Confirmation email sent to '+@user.email
167
+ if LoginEngine.config(:use_email_notification)
168
+ UserNotify.deliver_signup(@user, params[:user][:password], url)
169
+ flash['notice 4'] = ' Please check your registered email account to verify your account registration.'
170
+ end
171
+ #redirect_to :action => 'login'
172
+ end
173
+ end
174
+ rescue Exception => e
175
+ flash.now[:notice] = nil
176
+ flash.now[:warning] = 'Error creating account: confirmation email not sent'
177
+ logger.error e
178
+ end
179
+ end
180
+ end
181
+
@@ -0,0 +1,30 @@
1
+ # The filters added to this controller will be run for all controllers in the application.
2
+ # Likewese will all the methods added be available for all controllers.
3
+
4
+ require 'login_engine'
5
+
6
+ class ApplicationController < ActionController::Base
7
+ include LoginEngine
8
+ model :user
9
+
10
+ before_filter :set_charset
11
+ after_filter :fix_unicode_for_safari
12
+
13
+ include LiveTree
14
+ helper LiveTreeHelper
15
+
16
+ # automatically and transparently fixes utf-8 bug
17
+ # with Safari when using xmlhttp
18
+ def fix_unicode_for_safari
19
+ if @headers["Content-Type"] == "text/html; charset=utf-8" and
20
+ @request.env['HTTP_USER_AGENT'].to_s.include? 'AppleWebKit' then
21
+ @response.body = @response.body.gsub(/([^\x00-\xa0])/u) { |s| "&#x%x;" % $1.unpack('U')[0] }
22
+ end
23
+ end
24
+
25
+ def set_charset
26
+ #@headers["Content-Type"] = "text/html; charset=iso-8859-15"
27
+ @headers["Content-Type"] = "text/html; charset=utf-8"
28
+ end
29
+ end
30
+
@@ -0,0 +1,83 @@
1
+ """
2
+ This is the central component to parlement
3
+ An element is just the name for a poll/message/issue
4
+ """
5
+ class EltController < ApplicationController
6
+ def index
7
+ params[:id] = params[:id].gsub(/.html/, '')
8
+ show
9
+ end
10
+
11
+ def show
12
+ params[:id] = params[:id].gsub(/.html/, '')
13
+ @elt = Elt.find(params[:id])
14
+ @title = @elt.subject+' (parlement)'
15
+ render :layout => 'top'
16
+
17
+ # TODO
18
+ rescue ActiveRecord::RecordNotFound => e
19
+ flash[:error] = "Element '#{params[:id]}' does not exist"
20
+ redirect_to '/'
21
+ end
22
+
23
+ #def show
24
+ # @elt = Elt.find(params[:id]) if @elt == nil
25
+ # render :partial => 'show'
26
+ #end
27
+
28
+ def list
29
+ @elt = Elt.find(params[:id]) if @elt == nil
30
+ render :partial => 'list', :locals => { :elt => @elt }
31
+ end
32
+
33
+ def rss
34
+ @headers["Content-Type"] = "text/xml; charset=utf-8"
35
+ @elt = Elt.find(params[:id]) if @elt == nil
36
+ end
37
+
38
+ def new
39
+ @elt = Elt.new
40
+ @elt.parent = Elt.find(params[:id])
41
+ @elt.position = 0
42
+ @elt.person = Person.find_by_name(cookies[:person])
43
+ @elt.build_person if @elt.person == nil
44
+
45
+ @person = @elt.person
46
+
47
+ if @elt.parent.subject.include? 'Re: '
48
+ @elt.subject = @elt.parent.subject
49
+ else
50
+ @elt.subject = 'Re: '+@elt.parent.subject
51
+ end
52
+ end
53
+
54
+ def preview
55
+ render :inline => h(format(params[:elt][:body]))
56
+ end
57
+
58
+ def create
59
+ @elt = Elt.new(params[:elt])
60
+
61
+ @elt.person = @session[:person]
62
+
63
+ if params[:submit] == 'preview' or @elt.save
64
+ #cookies[:person] = { :value => @elt.person.name,
65
+ # :expires => Time.now + 360000 }
66
+ #flash[:notice] = 'Elt was successfully created.'
67
+ #redirect_to :action => 'top', :id => @elt.parent_id
68
+ #render_component(:action => 'show', :id => @elt.id )
69
+
70
+ render :partial => 'elt', :locals => { :elt => @elt, :eltTop => false }
71
+ else
72
+ flash[:notice] = 'Error'
73
+ render :action => 'new'
74
+ end
75
+ end
76
+
77
+ def raw_elt
78
+ @mail = Elt.find(params[:id]).mail
79
+ #@elt = TMail::Mail.parse(Elt.find(params[:id]).mail.id)
80
+ render :inline => "<pre><%= @mail.file %></pre>", :layout => 'top'
81
+ end
82
+ end
83
+
@@ -0,0 +1,2 @@
1
+ module AccountHelper
2
+ end
@@ -0,0 +1,4 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ include LoginEngine
4
+ end