parlement 0.14 → 0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. data/CHANGES +41 -1
  2. data/MEMORY +66 -5
  3. data/README +10 -5
  4. data/Rakefile +15 -23
  5. data/app/controllers/account_controller.rb +48 -43
  6. data/app/controllers/{application.rb → application_controller.rb} +15 -12
  7. data/app/controllers/elt_controller.rb +77 -32
  8. data/app/controllers/subscriber_controller.rb +11 -10
  9. data/app/helpers/application_helper.rb +14 -1
  10. data/app/helpers/elt_helper.rb +9 -7
  11. data/app/models/elt.rb +25 -24
  12. data/app/models/mail.rb +44 -47
  13. data/app/models/person_notify.rb +2 -2
  14. data/app/models/user.rb +128 -2
  15. data/app/models/user_notify.rb +15 -15
  16. data/app/views/account/_login.rhtml +39 -39
  17. data/app/views/account/_show.rhtml +22 -30
  18. data/app/views/account/signup.rhtml +2 -2
  19. data/app/views/elt/_choice.rhtml +6 -6
  20. data/app/views/elt/_elt.rhtml +27 -32
  21. data/app/views/elt/choices.rhtml +16 -18
  22. data/app/views/elt/list/_byDate.rhtml +14 -14
  23. data/app/views/elt/list/_byVote.rhtml +15 -15
  24. data/app/views/elt/list/_children.rhtml +48 -40
  25. data/app/views/elt/list/_subscribers.rhtml +1 -1
  26. data/app/views/elt/new.rhtml +22 -21
  27. data/app/views/elt/rss.rxml +4 -11
  28. data/app/views/elt/show.rhtml +65 -61
  29. data/app/views/elt/vote_rss.rxml +4 -11
  30. data/app/views/layouts/top.rhtml +39 -50
  31. data/app/views/person/_listElts.rhtml +1 -1
  32. data/app/views/person/show.rhtml +1 -1
  33. data/{vendor/plugins/login_engine/app → app}/views/user_notify/change_password.rhtml +0 -0
  34. data/{vendor/plugins/login_engine/app → app}/views/user_notify/delete.rhtml +0 -0
  35. data/{vendor/plugins/login_engine/app → app}/views/user_notify/forgot_password.rhtml +0 -0
  36. data/{vendor/plugins/login_engine/app → app}/views/user_notify/pending_delete.rhtml +0 -0
  37. data/{vendor/plugins/login_engine/app → app}/views/user_notify/signup.rhtml +0 -0
  38. data/config/boot.rb +97 -32
  39. data/config/environment.rb +37 -35
  40. data/config/environments/development.rb +2 -3
  41. data/config/environments/production.rb +3 -0
  42. data/config/initializers/string_ruby_1.8.rb +10 -0
  43. data/config/routes.rb +17 -22
  44. data/db/schema.rb +102 -74
  45. data/lib/tasks/rspec.rake +167 -0
  46. data/public/404.html +25 -7
  47. data/public/500.html +26 -7
  48. data/public/dispatch.cgi +0 -0
  49. data/public/dispatch.fcgi +0 -0
  50. data/public/dispatch.rb +0 -0
  51. data/public/images/live_tree_branch_collapsed_icon.gif +0 -0
  52. data/public/images/live_tree_branch_expanded_icon.gif +0 -0
  53. data/public/images/live_tree_leaf_icon.gif +0 -0
  54. data/public/javascripts/application.js +258 -0
  55. data/public/javascripts/controls.js +544 -414
  56. data/public/javascripts/dragdrop.js +229 -198
  57. data/public/javascripts/effects.js +499 -459
  58. data/public/javascripts/prototype.js +2926 -1121
  59. data/public/javascripts/shadedborder.js +68 -50
  60. data/public/stylesheets/default.css +34 -34
  61. data/public/stylesheets/live_tree.css +0 -0
  62. data/public/stylesheets/scaffold.css +6 -6
  63. data/script/about +0 -0
  64. data/script/autospec +6 -0
  65. data/script/benchmarker +0 -0
  66. data/script/breakpointer +0 -0
  67. data/script/console +0 -0
  68. data/script/dbconsole +3 -0
  69. data/script/destroy +0 -0
  70. data/script/generate +0 -0
  71. data/script/plugin +0 -0
  72. data/script/profiler +0 -0
  73. data/script/runner +0 -0
  74. data/script/server +0 -0
  75. data/script/spec +10 -0
  76. data/script/spec_server +9 -0
  77. data/test/unit/attachment_test.rb +4 -4
  78. data/test/unit/choice_test.rb +1 -1
  79. data/test/unit/elt_test.rb +9 -9
  80. data/test/unit/mail_notify_test.rb +2 -2
  81. data/test/unit/mail_test.rb +18 -11
  82. data/test/unit/person_notify_test.rb +1 -1
  83. data/test/unit/person_test.rb +1 -1
  84. data/test/unit/subscriber_test.rb +1 -1
  85. data/test/unit/user_test.rb +81 -0
  86. data/test/unit/visit_test.rb +6 -6
  87. data/vendor/plugins/activerecord_foreign_key_extensions/init.rb +2 -0
  88. data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +182 -0
  89. data/vendor/plugins/activerecord_text_id_extensions/init.rb +2 -0
  90. data/vendor/plugins/activerecord_text_id_extensions/lib/active_record_extensions.rb +24 -0
  91. data/vendor/plugins/acts_as_nested_set/README +15 -0
  92. data/vendor/plugins/acts_as_nested_set/init.rb +1 -0
  93. data/vendor/plugins/acts_as_nested_set/lib/active_record/acts/nested_set.rb +210 -0
  94. data/vendor/plugins/acts_as_nested_set/test/nested_set_test.rb +269 -0
  95. data/vendor/plugins/acts_as_tree/README +26 -0
  96. data/vendor/plugins/acts_as_tree/Rakefile +22 -0
  97. data/vendor/plugins/acts_as_tree/init.rb +1 -0
  98. data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
  99. data/vendor/plugins/{output_compression/CHANGELOG → acts_as_tree/test/abstract_unit.rb} +0 -0
  100. data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
  101. data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
  102. data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
  103. data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
  104. data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
  105. data/vendor/plugins/classic_pagination/CHANGELOG +152 -0
  106. data/vendor/plugins/classic_pagination/README +18 -0
  107. data/vendor/plugins/{output_compression/rakefile → classic_pagination/Rakefile} +22 -22
  108. data/vendor/plugins/classic_pagination/init.rb +33 -0
  109. data/vendor/plugins/classic_pagination/install.rb +1 -0
  110. data/vendor/plugins/classic_pagination/lib/pagination.rb +405 -0
  111. data/vendor/plugins/classic_pagination/lib/pagination_helper.rb +135 -0
  112. data/vendor/plugins/classic_pagination/test/fixtures/companies.yml +24 -0
  113. data/vendor/plugins/classic_pagination/test/fixtures/company.rb +9 -0
  114. data/vendor/plugins/classic_pagination/test/fixtures/developer.rb +7 -0
  115. data/vendor/plugins/classic_pagination/test/fixtures/developers.yml +21 -0
  116. data/vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml +13 -0
  117. data/vendor/plugins/classic_pagination/test/fixtures/project.rb +3 -0
  118. data/vendor/plugins/classic_pagination/test/fixtures/projects.yml +7 -0
  119. data/vendor/plugins/classic_pagination/test/fixtures/replies.yml +13 -0
  120. data/vendor/plugins/classic_pagination/test/fixtures/reply.rb +5 -0
  121. data/vendor/plugins/classic_pagination/test/fixtures/schema.sql +42 -0
  122. data/vendor/plugins/classic_pagination/test/fixtures/topic.rb +3 -0
  123. data/vendor/plugins/classic_pagination/test/fixtures/topics.yml +22 -0
  124. data/vendor/plugins/classic_pagination/test/helper.rb +117 -0
  125. data/vendor/plugins/classic_pagination/test/pagination_helper_test.rb +38 -0
  126. data/vendor/plugins/classic_pagination/test/pagination_test.rb +177 -0
  127. data/vendor/plugins/file_column/lib/file_column.rb +1 -1
  128. data/vendor/plugins/file_column/test/file_column_test.rb +0 -0
  129. metadata +151 -197
  130. data/app/helpers/live_tree.rb +0 -238
  131. data/app/views/elt/_form.rhtml +0 -31
  132. data/app/views/elt/show_tree.rhtml +0 -8
  133. data/config/environments/user_environment.rb +0 -1
  134. data/db/ROOT/Titemagli.txt +0 -3
  135. data/db/ROOT/titemagli.txt +0 -9
  136. data/public/javascripts/behaviour.js +0 -254
  137. data/public/javascripts/ie7-load.htc +0 -1
  138. data/public/javascripts/ie7.js +0 -6
  139. data/public/javascripts/live_tree.js +0 -749
  140. data/public/javascripts/mybehaviour.js +0 -225
  141. data/public/javascripts/scriptaculous.js +0 -47
  142. data/public/javascripts/slider.js +0 -283
  143. data/public/stylesheets/blue.css +0 -471
  144. data/vendor/plugins/engines/CHANGELOG +0 -241
  145. data/vendor/plugins/engines/MIT-LICENSE +0 -21
  146. data/vendor/plugins/engines/README +0 -64
  147. data/vendor/plugins/engines/Rakefile +0 -32
  148. data/vendor/plugins/engines/UPGRADING +0 -93
  149. data/vendor/plugins/engines/about.yml +0 -7
  150. data/vendor/plugins/engines/generators/plugin_migration/USAGE +0 -45
  151. data/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +0 -79
  152. data/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +0 -13
  153. data/vendor/plugins/engines/init.rb +0 -40
  154. data/vendor/plugins/engines/install.rb +0 -32
  155. data/vendor/plugins/engines/lib/engines.rb +0 -323
  156. data/vendor/plugins/engines/lib/engines/deprecated_config_support.rb +0 -135
  157. data/vendor/plugins/engines/lib/engines/plugin.rb +0 -214
  158. data/vendor/plugins/engines/lib/engines/plugin_list.rb +0 -31
  159. data/vendor/plugins/engines/lib/engines/plugin_migrator.rb +0 -60
  160. data/vendor/plugins/engines/lib/engines/rails_extensions.rb +0 -6
  161. data/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +0 -19
  162. data/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +0 -143
  163. data/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +0 -155
  164. data/vendor/plugins/engines/lib/engines/rails_extensions/public_asset_helpers.rb +0 -116
  165. data/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +0 -20
  166. data/vendor/plugins/engines/lib/engines/rails_extensions/rails_initializer.rb +0 -86
  167. data/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +0 -77
  168. data/vendor/plugins/engines/lib/engines/rails_extensions/templates.rb +0 -140
  169. data/vendor/plugins/engines/lib/engines/testing.rb +0 -87
  170. data/vendor/plugins/engines/tasks/engines.rake +0 -149
  171. data/vendor/plugins/login_engine/CHANGELOG +0 -22
  172. data/vendor/plugins/login_engine/README +0 -344
  173. data/vendor/plugins/login_engine/app/controllers/user_controller.rb +0 -262
  174. data/vendor/plugins/login_engine/app/helpers/user_helper.rb +0 -88
  175. data/vendor/plugins/login_engine/app/models/user.rb +0 -7
  176. data/vendor/plugins/login_engine/app/models/user_notify.rb +0 -75
  177. data/vendor/plugins/login_engine/app/views/user/_edit.rhtml +0 -11
  178. data/vendor/plugins/login_engine/app/views/user/_password.rhtml +0 -9
  179. data/vendor/plugins/login_engine/app/views/user/change_password.rhtml +0 -17
  180. data/vendor/plugins/login_engine/app/views/user/edit.rhtml +0 -23
  181. data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +0 -18
  182. data/vendor/plugins/login_engine/app/views/user/home.rhtml +0 -7
  183. data/vendor/plugins/login_engine/app/views/user/login.rhtml +0 -17
  184. data/vendor/plugins/login_engine/app/views/user/logout.rhtml +0 -8
  185. data/vendor/plugins/login_engine/app/views/user/signup.rhtml +0 -17
  186. data/vendor/plugins/login_engine/db/migrate/001_initial_schema.rb +0 -25
  187. data/vendor/plugins/login_engine/init_engine.rb +0 -11
  188. data/vendor/plugins/login_engine/install.rb +0 -4
  189. data/vendor/plugins/login_engine/lib/login_engine.rb +0 -62
  190. data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +0 -113
  191. data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +0 -155
  192. data/vendor/plugins/login_engine/public/stylesheets/login_engine.css +0 -81
  193. data/vendor/plugins/login_engine/test/fixtures/users.yml +0 -41
  194. data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +0 -536
  195. data/vendor/plugins/login_engine/test/mocks/mail.rb +0 -14
  196. data/vendor/plugins/login_engine/test/mocks/time.rb +0 -19
  197. data/vendor/plugins/login_engine/test/test_helper.rb +0 -11
  198. data/vendor/plugins/login_engine/test/unit/user_test.rb +0 -114
  199. data/vendor/plugins/output_compression/MIT-LICENSE +0 -20
  200. data/vendor/plugins/output_compression/README +0 -4
  201. data/vendor/plugins/output_compression/init.rb +0 -1
  202. data/vendor/plugins/output_compression/lib/output_compression.rb +0 -84
  203. data/vendor/plugins/output_compression/test/output_test.rb +0 -11
  204. data/vendor/plugins/output_compression/test/test_controller.rb +0 -3
  205. data/vendor/plugins/output_compression/test/test_helper.rb +0 -14
data/CHANGES CHANGED
@@ -1,10 +1,50 @@
1
1
  - parlement changelog
2
2
 
3
+ == Version 0.17 ==
4
+
5
+ Migration to latest rails 2.3 and better navigation
6
+
7
+ * better routes, particularly for rss
8
+ * no more fancy minus sign to decrease the filter, a straight -
9
+ * modified links
10
+ * iconv better managed to transform into utf8
11
+ * better 404 mgmt
12
+ * rss dates corresponding to ISO standard
13
+ * ie now also has rounded corners
14
+ * no more "show" action for elts, instead, an "index" one
15
+ * passage to rails 2.3
16
+ * session stored in cookies
17
+ * better next/back navigation
18
+
19
+ == Version 0.16 ==
20
+
21
+ Sub domains to directly access elements
22
+
23
+ * upgraded ie7 javascript hack
24
+ * updraded ruzze border script
25
+ * passage to full utf8
26
+ * default element is the oldest one
27
+ * subdomains redirect to the relevant element
28
+ * antispam: only authenticated users can vote
29
+ * better google sitesearch integration
30
+ * links now partly work with subdomain
31
+
32
+ == Version 0.15 ==
33
+
34
+ Automatic widening text area. Rails 2
35
+
36
+ * sidebar updates now defined as an environment constant
37
+ * edition text area is widened, its height now follows its content
38
+ * passage to rails 2.0.2
39
+ * easier db installation
40
+
3
41
  == Version 0.14 ==
4
42
 
5
43
  Heavily modified skin where anonymous users can no longer vote. Simplified and
6
44
  faster HTML. Shaded border.
7
45
 
46
+ Anonymous users can write and login at the same time.
47
+
8
48
  * protection against some browsers who update too frequently their views
9
49
  * no more deprecations and errors
10
50
  * moved all elt lists to app/views/elt/list directory
@@ -13,7 +53,7 @@ faster HTML. Shaded border.
13
53
  * anonymous users are not able to vote anymore
14
54
  * results displayed only to those who have voted
15
55
  * faster view update
16
- * anonymous users can write and create their login at the same time, blog like
56
+ * anonymous users can write and login at the same time
17
57
 
18
58
  == Version 0.13 ==
19
59
 
data/MEMORY CHANGED
@@ -1,13 +1,22 @@
1
- TODO
2
- * factorise paginations
3
- * new and preview using tabs
1
+ # To delete spam
2
+ e = Elt.find_by_sql("SELECT * FROM elts ORDER BY created_on DESC LIMIT 1").first; puts e.id; e.person.id; puts e.children.size; puts e.person.elts.size if e.person
3
+
4
+ puts e.destroy; e.person.destroy
5
+ e.person.elts.each { |c| puts c.destroy }.size if e.person; e.person.destroy
6
+
7
+
8
+
9
+
10
+ create/delete el
11
+ add/see/remove user(s)
12
+ mail, name
4
13
 
5
14
  What is below is just for future personal reference...
6
15
 
7
16
  http://www.ajaxchat.org/chat/
8
17
 
9
18
 
10
- # Here is my console code to reset threads from their original mails:
19
+ # Console code to reset threads from their original mails:
11
20
  >> elts=Mail.find_all.select{|m|m.file and mail=TMail::Mail.parse(m.file) and reply=mail.in_reply_to and mailObject=Mail.find_by_message(reply) and mailObject.elt.id!=m.elt.parent_id}.collect{|m| {:elt=>m.elt.id, :parent=>Mail.find_by_message(TMail::Mail.parse(m.file).in_reply_to).elt.id}}; puts elts.size
12
21
  >> elts.each{|e|print e[:elt], ' ', e[:parent], ' '; puts Elt.update_all("parent_id='#{e[:parent]}'", "id='#{e[:elt]}'")}; puts elts.size
13
22
 
@@ -23,6 +32,7 @@ elts.each { |e| e.vote(Regexp.last_match(1), e.person) if e.body =~ /^\s*(-1|0|\
23
32
 
24
33
 
25
34
  UPDATE elts SET elts_count = (SELECT COUNT(*) FROM elts e2 WHERE e2.parent_id = elts.id);
35
+ UPDATE elts SET lft = NULL, rgt = NULL;
26
36
 
27
37
  # To reconstruct the nested tree set
28
38
  def construction(e, counter)
@@ -39,7 +49,6 @@ end
39
49
  e=Elt.find('ROOT')
40
50
  construction(e, 0)
41
51
 
42
- UPDATE elts SET lft = NULL, rgt = NULL;
43
52
  ALTER TABLE elts ADD CONSTRAINT elts_unique_lft UNIQUE (lft);
44
53
  ALTER TABLE elts ADD CONSTRAINT elts_unique_rgt UNIQUE (rgt);
45
54
 
@@ -49,6 +58,7 @@ INSERT INTO person_mails (person_id, mail_id, created_on) VALUES ('first', 'aGaG
49
58
  select id from mails;
50
59
  select count(*) from mails;
51
60
  select * from people;
61
+ select * from users;
52
62
  select * from subscriptions;
53
63
  select * from person_mails;
54
64
  select distinct last_activity from elts;
@@ -61,3 +71,54 @@ Processing EltController#create (for 192.168.0.254 at 2007-02-11 00:07:05) [POST
61
71
  Response body was encoded with gzip
62
72
  Completed in 0.05879 (17 reqs/sec) | Rendering: 0.05682 (96%) | DB: 0.00072 (1%) | 200 OK [http://leparlement.org/elt/create/Testez?submit=preview]
63
73
 
74
+ # To get anonymous votes
75
+ Elt.find_all_by_person_id(nil).select { |e| e.body == "+1" or e.body == "0" or e.body == "-1" }.select { |e| e.children_count == 0 }.each { |e| e.reload; puts e.id }.size
76
+ Choice.find_all_by_person_id(nil).each { |c| c.reload; puts c.destroy }.size
77
+
78
+ Elt.find_all_by_person_id(nil).select { |e| e.body == "+1" or e.body == "0" or e.body == "-1" }.select { |e| e.children_count == 0 }.each { |e| e.reload; e.parent.choices.select { |c| not c.person }.each { |c| print c.elt_id }; puts e.id }.size
79
+
80
+
81
+ # UTF 8 goodness!
82
+ def u(tStrin)
83
+ tStrin.gsub(/\xC3 /, "à").gsub(/\xC3 /, "à").gsub(/\x9E/, "Ẑ").gsub(/\xA0/, " ").gsub(/\xA4/, "€").gsub(/\xA7/, "§").gsub(/\xAB/, "«").gsub(/\xAD/, " ").gsub(/\xB0/, "°").gsub(/\xB4/, "'").gsub(/\xB7/, "·").gsub(/\xBB/, "»").gsub(/\xC4/, "Ä").gsub(/\xC5/, "Å").gsub(/\xC8/, "È").gsub(/\xC9/, "É").gsub(/\xD0/, "Ð").gsub(/\xD6/, "Ö").gsub(/\xE0/, "à").gsub(/\xE2/, "â").gsub(/\xE4/, "ä").gsub(/\xE5/, "å").gsub(/\xE7/, "ç").gsub(/\xE8/, "è").gsub(/\xE9/, "é").gsub(/\xEA/, "ê").gsub(/\xEA/, "ê").gsub(/\xEB/, "ë").gsub(/\xEE/, "î").gsub(/\xEF/, "ï").gsub(/\xF4/, "ô").gsub(/\xF6/, "ö").gsub(/\xF8/, "ø").gsub(/\xF9/, "ù").gsub(/\xFB/, "û").gsub(/\x85/, "…").gsub(/\x91/, "‘").gsub(/\x92/, "’").gsub(/\x93/, "“").gsub(/\x94/, "”").gsub(/\x96/, "–")
84
+ end
85
+ mails2.each { |m| m.file.each { |l| puts "\n#{l} --- #{u(l)} #{l.to_yaml}" unless (l.isutf8 or u(l).isutf8) } }.size
86
+
87
+ elts = Elt.find(:all).select { |e| !e.body.isutf8 if e.body }; puts elts.size
88
+ elts2 = elts.reject { |e| u(e.body).isutf8 }; puts elts2.size
89
+ elts2.each { |e| e.body.each { |l| puts "#{l} #{l.to_yaml}" unless l.isutf8 or u(l).isutf8 } }.size
90
+ elts2.each { |e| e.body = u(e.body); e.save }.size
91
+
92
+ mails = Mail.find(:all).select { |m| !m.file.isutf8 if m.file }; puts mails.size
93
+ mails2 = mails.reject { |m| u(m.file).isutf8 }; puts mails2.size
94
+ mails2.reject { |m| u(m.file).each { |l| puts l.to_yaml unless l.isutf8 } }.size
95
+ mails2.reject { |m| m.file.each { |l| puts "#{l} #{u(l)}" unless (l.isutf8 or u(l).isutf8) } }.size
96
+ mails.each { |m| m.file = u(m.file); m.save }.size
97
+
98
+
99
+ ---------------
100
+ Electoral lists
101
+
102
+ How to be sure that our voice counts? That it counts equally to all others.
103
+
104
+ In politics, a mere one can subvert the whole, and use his power to tilt the balance all the way toward him. To that end
105
+
106
+ ______________________________________________________________________________________________________________________________
107
+ ------------------------------------------------------------------------------------------------------------------------------
108
+ Listes électorale
109
+
110
+ Comment être sûr que notre voix compte? Qu'elle compte à égalité de toutes les autres.
111
+
112
+ Les arrangements sont multiples, on ne fait voter que les riches, on écarte les femmes ou les étrangers, on s'arrange pour que la population votant pour son opposant soit disqualifiée, on fait voter les morts, un grand classique!
113
+
114
+ - intro
115
+ - les problèmes potentiels
116
+ * manipulation
117
+ - les délais
118
+ - l'identité
119
+ - conclusion
120
+
121
+ =======
122
+ What it is
123
+ Why it is so important
124
+ Who should be concerned with it
data/README CHANGED
@@ -11,10 +11,12 @@ On debian, here are the commands used to setup a parlement server:
11
11
  ~ createuser /your_login/
12
12
  ~ exit
13
13
  # apt-get install ruby
14
+ # apt-get install ruby-dev
14
15
  # apt-get install libpgsql-ruby
15
16
  # apt-get install irb
16
17
  # apt-get install rdoc
17
18
  # apt-get install rake
19
+ # apt-get install make
18
20
 
19
21
  Basically this install postgresql, ruby and the ruby driver to psql. Ruby on
20
22
  Rails is database agnostic, parlement will be sometimes in the future.
@@ -23,7 +25,8 @@ You need to install "ruby gems":http://docs.rubygems.org
23
25
 
24
26
  And then:
25
27
  # gem install rails
26
- # gem install redcloth
28
+ # gem install RedCloth
29
+ # gem install ruby-debug
27
30
  # gem install term-ansicolor
28
31
 
29
32
  Only if you expect to develop and do any release:
@@ -52,14 +55,16 @@ initialise and launch parlement this way:
52
55
  # Get the source code
53
56
  ~ svn checkout svn://rubyforge.org/var/svn/parlement/trunk parlement
54
57
  ~ cd parlement # Go into the right folder
55
- ~ createdb parlement_development # Create database
56
- ~ psql -q template1 -f db/schema.sql # Initiate the db schema
57
- ~ rake migrate # Get the db to its last version
58
- ~ ruby lib/data_import.rb # Populate the db
58
+ ~ rake db:create # Create the db
59
59
  ~ ruby ./script/server # Launch the server
60
60
 
61
61
  Now you can go to http://localhost:3000 with your browser.
62
62
 
63
+ To setup an apache configuration:
64
+ # apt-get install libapache2-mod-fcgid
65
+ # a2enmod fcgid
66
+
67
+
63
68
  You can check that everything works all right on your machine with the testing suite:
64
69
  ~ rake
65
70
 
data/Rakefile CHANGED
@@ -17,17 +17,6 @@ require 'rake/contrib/rubyforgepublisher'
17
17
  require 'meta_project/release/freshmeat'
18
18
  require 'meta_project/release/raa'
19
19
 
20
- desc "Deploy basic application directories"
21
- task :deploy => :environment do
22
- # public is missing
23
- dirs = %w{ app lib test config}
24
- onserver = "manu@vvv:/home/manu/develop/parlement/"
25
- dirs.each do | dir|
26
- `rsync -a --delete "#{RAILS_ROOT}/#{dir}" "#{onserver}" --exclude ".svn"`
27
- end
28
- end
29
-
30
-
31
20
  PKG_NAME = "parlement"
32
21
  PKG_VERSION = PARLEMENT_VERSION
33
22
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
@@ -45,18 +34,18 @@ spec = Gem::Specification.new do |s|
45
34
  s.version = PKG_VERSION
46
35
  s.summary = "Trusted Direct Democracy on a forum"
47
36
  s.description = <<EOF
48
- This is a forum and mailing list project, which aims to be a complete Direct
49
- Democracy implementation where everybody can propose polls, vote on them, or
50
- delegate their voice to someone else.
37
+ Forum and mailing list project aiming to be a complete Direct Democracy
38
+ implementation where everybody can propose polls, vote on them, or delegate
39
+ their voice to someone else.
51
40
 
52
41
  Trust through:
53
- - cluster
42
+ - P2P cluster
54
43
  - PGP signatures
55
44
  - electoral lists
56
45
  EOF
57
46
  s.files = PKG_FILES
58
47
  s.require_path = 'lib'
59
- s.autorequire = 'rails redcloth term-ansicolor'
48
+ #s.autorequire = 'rails RedCloth ruby-debug term-ansicolor gettext'
60
49
  s.has_rdoc = false
61
50
  s.requirements << 'none'
62
51
  s.test_files = Dir.glob('test/unit/*')
@@ -72,7 +61,11 @@ EOF
72
61
  #s.signing_key = File.join(ENV['CERT_DIR'], 'gem-private_key.pem')
73
62
  #s.cert_chain = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
74
63
  #end
75
- s.add_dependency('rails redcloth term-ansicolor')
64
+ s.add_dependency('rails')
65
+ s.add_dependency('gettext')
66
+ s.add_dependency('RedCloth')
67
+ s.add_dependency('ruby-debug')
68
+ s.add_dependency('term-ansicolor')
76
69
  end
77
70
 
78
71
  desc "Build Gem"
@@ -179,14 +172,13 @@ end
179
172
 
180
173
  desc "Update pot/po files."
181
174
  task :updatepo do
182
- require 'gettext/utils'
183
- GetText.update_pofiles(PKG_NAME, Dir.glob("{app}/{views,controllers}/**/*.{rb,rhtml}"), "#{PKG_NAME} #{PKG_VERSION}")
175
+ require 'gettext_rails/tools'
176
+ GetText.update_pofiles(PKG_NAME, Dir.glob("{app}/{views,controllers}/**/*.{rb,rhtml}"), "#{PKG_NAME} #{PKG_VERSION}")
184
177
  end
185
178
 
186
179
  desc "Create mo-files"
187
180
  task :makemo do
188
- require 'gettext/utils'
189
- #GetText.create_mofiles(true)
190
- GetText.create_mofiles(true, "po", "locale") # This is for "Ruby on Rails".
181
+ require 'gettext_rails/tools'
182
+ GetText.create_mofiles(true)
183
+ #GetText.create_mofiles(true, "po", "locale") # This is for "Ruby on Rails".
191
184
  end
192
-
@@ -1,10 +1,10 @@
1
1
  #
2
2
  # This class manages users inscription, login and logout
3
3
  #
4
- class AccountController < UserController
4
+ class AccountController < ApplicationController
5
5
  def login
6
6
  # Cleaning up
7
- session[:person] = @person = session[:user] = @user = nil
7
+ session[:person_id] = session[:person_name] = @person = session[:user_id] = @user = nil
8
8
  cookies.delete :person_name
9
9
  cookies.delete :salted_password
10
10
 
@@ -24,7 +24,8 @@ class AccountController < UserController
24
24
  if @person.save
25
25
  logger.info yellow { bold { "Person: #{@person.name}, id: #{@person.id}" } }
26
26
  flash.now[:notice] = _("Pseudo recorded")
27
- session[:person] = @person
27
+ session[:person_id] = @person.id
28
+ session[:person_name] = @person.name
28
29
  else
29
30
  flash.now[:error] = _('Error creating account')
30
31
  end
@@ -40,19 +41,22 @@ class AccountController < UserController
40
41
  if password and password.empty?
41
42
  if not @user or not @user.salted_password \
42
43
  or @user.salted_password.empty?
43
- session[:person] = @person
44
+ session[:person_id] = @person.id
45
+ session[:person_name] = @person.name
44
46
  else
45
47
  flash.now[:error] = _("This pseudo is protected with a password")
46
48
  end
47
49
  elsif not @user
48
50
  # Record password
49
- session[:person] = @person
51
+ session[:person_id] = @person.id
52
+ session[:person_name] = @person.name
50
53
  mngPassword
51
54
  elsif User.authenticate(login, password)
52
55
  logger.info yellow { bold { "#{@person.name} logged in" } }
53
56
  # Authenticate
54
- session[:person] = @person
55
- session[:user] = @user
57
+ session[:person_id] = @person.id
58
+ session[:person_name] = @person.name
59
+ session[:user_id] = @user.id if @user
56
60
  elsif email and not email.empty?
57
61
  # There is a check key, used to change the password
58
62
  begin
@@ -63,8 +67,9 @@ class AccountController < UserController
63
67
  if @user.save
64
68
  logger.info yellow { "Person: #{@person.name} changed its password" }
65
69
  flash.now['notice 2'] = _('Password successfully modified!')
66
- session[:person] = @person
67
- session[:user] = @user
70
+ session[:person_id] = @person.id
71
+ session[:person_name] = @person.name
72
+ session[:user_id] = @user.id if @user
68
73
  else
69
74
  @user.errors.each_full { |msg| logger.error msg }
70
75
  end
@@ -79,7 +84,7 @@ class AccountController < UserController
79
84
 
80
85
  # Record the email or send a check_key for a password reset
81
86
  if email and not email.empty?
82
- if session[:person]
87
+ if session[:person_id]
83
88
  if email == @person.email
84
89
  flash.now['notice 3'] = _("Email already recorded and verified")
85
90
  else
@@ -97,9 +102,9 @@ class AccountController < UserController
97
102
  end
98
103
 
99
104
  # Record cookies for re authentication
100
- if session[:person]
101
- cookies[:person_name] = { :value => session[:person].name, :expires => 3.years.from_now }
102
- cookies[:salted_password] = { :value => @user.salted_password, :expires => 3.years.from_now } if @user
105
+ if session[:person_id]
106
+ cookies[:person_name] = { :value => @person.name }
107
+ cookies[:salted_password] = { :value => @user.salted_password } if @user
103
108
 
104
109
  @person.last_login = Time.now
105
110
  @person.save
@@ -110,13 +115,13 @@ class AccountController < UserController
110
115
 
111
116
  render :partial => 'show',
112
117
  :locals => { :choices => getAllVotes },
113
- :status => (session[:person] ? 200 : 403)
118
+ :status => (session[:person_id] ? 200 : 403)
114
119
  end
115
120
 
116
121
  def logout
117
122
  logger.info yellow { bold { "Bye bye" } }
118
123
  # Cleaning up
119
- session[:person] = @person = session[:user] = @user = nil
124
+ session[:person_id] = session[:person_name] = @person = session[:user_id] = @user = nil
120
125
  cookies.delete :person_name
121
126
  cookies.delete :salted_password
122
127
 
@@ -133,58 +138,57 @@ class AccountController < UserController
133
138
  @person.email = @user.email
134
139
  @person.save
135
140
  flash.now[:notice] = "Email #{@person.email} verified."
136
- session[:person] = @person
137
- session[:user] = @user
141
+ session[:person_id] = @person.id
142
+ session[:person_name] = @person.name
143
+ session[:user_id] = @user.id
138
144
  render :text => "<h1>Email verified!</h1> \
139
145
  <br/> \
140
- <a href='#{url_for :controller => 'elt', :action => 'show', :id => nil }'>\
141
- Back</a>",
146
+ <a href='#{url_for :controller => 'elt', :id => nil }'>Back</a>",
142
147
  :layout => 'top'
143
148
  else
144
149
  render :text => "<h3>Sorry, no corresponding check key :-(</h3> \
145
150
  <br/> \
146
- <a href='#{url_for :controller => 'elt', :action => 'show', :id => nil }'>\
147
- Back</a>",
151
+ <a href='#{url_for :controller => 'elt', :id => nil }'>Back</a>",
148
152
  :layout => 'top'
149
153
  end
150
154
  end
151
155
 
152
156
  def setPassword
153
- logger.info yellow { "Person #{session[:person].name} sets/changes his password" } if session[:person]
154
- @person = session[:person]
155
- @user = session[:user]
157
+ @person = Person.find_by_id(session[:person_id])
158
+ @user = User.find_by_id(session[:user_id])
159
+ logger.info yellow { "Person #{@person.name} sets/changes his password" }
156
160
  mngPassword
157
161
  render :partial => 'show'
158
162
  end
159
163
 
160
164
  def setEmail
161
- logger.info yellow { "Person #{session[:person].name} set his email to #{params[:person][:email]}" } if session[:person]
162
- @person = session[:person]
163
- @user = session[:user]
165
+ @person = Person.find_by_id(session[:person_id])
166
+ @user = User.find_by_id(session[:user_id])
167
+ logger.info yellow { "Person #{@person.name} set his email to #{params[:person][:email]}" }
164
168
  mngEmail
165
169
  render :partial => 'show'
166
170
  end
167
171
 
168
172
  def setAvatar
169
- return render(:text => _("Not logged in"), :status => 403) unless session[:person]
170
- logger.info yellow { "Setting up an avatar for person #{session[:person].name}" }
173
+ return render(:text => _("Not logged in"), :status => 403) unless session[:person_id]
171
174
 
172
175
  @elt = Elt.find_by_id 'people'
173
- if !@elt
176
+ unless @elt
174
177
  @elt = Elt.new :parent_id => 'ROOT', :subject => 'people', :body => ''
175
178
  @elt.save!
176
179
  @elt.publish
177
- @elt.parent.add_child @elt
178
180
  end
179
- avatar = @elt.children.build :person => session[:person], :body => ""
180
- att = avatar.attachments.build :file => params[:person][:image],
181
- :content_type => params[:person][:image].content_type
181
+ @person = Person.find_by_id(session[:person_id])
182
+ logger.info yellow { "Setting up an avatar for person #{@person.name}" }
183
+ avatar = @elt.children.build :person => @person,
184
+ :subject => params[:person][:image].original_filename,
185
+ :body => ""
186
+ avatar.save!
187
+ att = avatar.attachments.build :file => params[:person][:image]
188
+ att.save!
182
189
 
183
- avatar.subject = att.file.gsub /^.*public.*\//, ''
184
190
  avatar.publish
185
- @elt.add_child avatar
186
191
 
187
- @person = session[:person]
188
192
  @person.image = "/attachment/file/#{att.file_relative_path}"
189
193
  @person.save!
190
194
 
@@ -213,7 +217,7 @@ class AccountController < UserController
213
217
  if @user.save
214
218
  logger.info yellow { "Password changed" }
215
219
  flash['notice 2'] = 'Password recorded'
216
- session[:user] = @user
220
+ session[:user_id] = @user.id
217
221
  else
218
222
  @user.errors.each_full { |msg| logger.error msg }
219
223
  end
@@ -234,7 +238,7 @@ class AccountController < UserController
234
238
  @user.email = params[:person][:email]
235
239
  begin
236
240
  User.transaction do
237
- unless LoginEngine.config(:use_email_notification)
241
+ unless LOGIN_ENGINE[:use_email_notification]
238
242
  @user.verified = 1
239
243
  end
240
244
  if @user.save
@@ -243,7 +247,7 @@ class AccountController < UserController
243
247
  #url = url_for(:action => 'check_key')
244
248
  #url += "?user[id]=#{@user.id}&key=#{key}"
245
249
  #flash[:notice] = 'Signup successful!'
246
- if LoginEngine.config(:use_email_notification)
250
+ if LOGIN_ENGINE[:use_email_notification]
247
251
  PersonNotify.deliver_setEmail(@person, url)
248
252
  flash.now['notice 3'] = "Confirmation email sent to #{@user.email}"
249
253
  end
@@ -259,12 +263,13 @@ class AccountController < UserController
259
263
 
260
264
  def getAllVotes
261
265
  if @elt then
262
- Choice.find_all_by_person_id((session[:person] ? session[:person].id : nil),
266
+ Choice.find(:all,
263
267
  :include => 'elt',
264
- :conditions => "elts.lft >= '#{@elt.lft}' AND elts.rgt <= '#{@elt.rgt}'")
268
+ :conditions => "choices.person_id = '#{session[:person_id]}' \
269
+ AND elts.lft >= '#{@elt.lft}' AND elts.rgt <= '#{@elt.rgt}'")
265
270
  else
266
271
  # This should only happen for very new people
267
- Choice.find_all_by_person_id((session[:person] ? session[:person].id : nil))
272
+ Choice.find(:all, :conditions => "person_id = '#{session[:person_id]}'")
268
273
  end
269
274
  end
270
275
  end