parlement 0.2 → 0.3

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 (125) hide show
  1. data/CHANGES +14 -4
  2. data/README +25 -5
  3. data/Rakefile +21 -21
  4. data/app/controllers/account_controller.rb +5 -1
  5. data/app/controllers/elt_controller.rb +7 -10
  6. data/app/controllers/person_controller.rb +9 -0
  7. data/app/controllers/subscriber_controller.rb +21 -0
  8. data/app/helpers/elt_helper.rb +25 -13
  9. data/app/helpers/mailman.rb +9 -92
  10. data/app/helpers/subscriber_helper.rb +2 -0
  11. data/app/models/attachment.rb +2 -0
  12. data/app/models/elt.rb +64 -2
  13. data/app/models/mail.rb +198 -0
  14. data/app/models/mail_notify.rb +63 -0
  15. data/app/models/person.rb +8 -1
  16. data/app/views/account/_login.rhtml +31 -28
  17. data/app/views/account/_show.rhtml +4 -4
  18. data/app/views/elt/_elt.rhtml +23 -28
  19. data/app/views/elt/_list.rhtml +6 -2
  20. data/app/views/elt/new.rhtml +1 -1
  21. data/app/views/elt/show.rhtml +32 -10
  22. data/app/views/layouts/top.rhtml +16 -10
  23. data/app/views/mail_notify/publish.text.html.rhtml +46 -0
  24. data/app/views/mail_notify/publish.text.plain.rhtml +2 -0
  25. data/app/views/person/_listElts.rhtml +33 -0
  26. data/app/views/person/show.rhtml +21 -19
  27. data/config/boot.rb +2 -0
  28. data/config/environment.rb +19 -13
  29. data/config/environments/development.rb +3 -1
  30. data/config/environments/production.rb +2 -0
  31. data/config/environments/test.rb +2 -0
  32. data/config/routes.rb +5 -2
  33. data/db/ROOT/mail.txt +2 -0
  34. data/db/ROOT/parlement/news/release0.2.txt +8 -0
  35. data/db/ROOT/parlement/news/release0.3.txt +11 -0
  36. data/db/ROOT/parlement/test.txt +6 -1
  37. data/db/ROOT/parlement.txt +23 -30
  38. data/db/ROOT/perso.txt +17 -18
  39. data/db/development_structure.sql +133 -217
  40. data/db/schema.rb +83 -0
  41. data/db/schema.sql +11 -15
  42. data/lib/data_import.rb +3 -1
  43. data/public/attachment/file/architecture.png +0 -0
  44. data/public/attachment/file/architecture.svg +8972 -0
  45. data/public/attachment/file/security.svg +8960 -0
  46. data/public/images/Sleep-Deprivation-5.JPG +0 -0
  47. data/public/images/eltBackground.png +0 -0
  48. data/public/images/eltBackground.svg +89 -0
  49. data/public/images/orange_by_darren_Hester_350o.jpg +0 -0
  50. data/public/images/rails.png +0 -0
  51. data/public/images/smile.png +0 -0
  52. data/public/images/smile.svg +257 -0
  53. data/public/images/world.png +0 -0
  54. data/public/images/world.svg +170 -0
  55. data/public/javascripts/controls.js +30 -1
  56. data/public/javascripts/dragdrop.js +210 -145
  57. data/public/javascripts/effects.js +261 -399
  58. data/public/javascripts/ie7.js +6 -0
  59. data/public/javascripts/prototype.js +131 -72
  60. data/public/oldindex.html +270 -71
  61. data/public/stylesheets/default.css +189 -215
  62. data/script/about +1 -1
  63. data/script/breakpointer +1 -1
  64. data/script/console +1 -1
  65. data/script/destroy +1 -1
  66. data/script/generate +1 -1
  67. data/script/performance/benchmarker +1 -1
  68. data/script/performance/profiler +1 -1
  69. data/script/plugin +1 -1
  70. data/script/process/reaper +1 -1
  71. data/script/process/spawner +1 -1
  72. data/script/process/spinner +1 -1
  73. data/script/runner +1 -1
  74. data/script/server +1 -1
  75. data/test/fixtures/elts.yml +2 -0
  76. data/test/fixtures/mail/mail_ruby +27 -0
  77. data/test/fixtures/mail/mail_rubyChild +28 -0
  78. data/test/fixtures/mail/mail_rubyWithAttachment +7932 -0
  79. data/test/fixtures/mail/mail_rubyWithSubject +27 -0
  80. data/test/fixtures/mails.yml +7 -1
  81. data/test/fixtures/people.yml +5 -0
  82. data/test/fixtures/subscribers.yml +11 -0
  83. data/test/functional/account_controller_test.rb +38 -37
  84. data/test/functional/subscriber_controller_test.rb +128 -0
  85. data/test/test_helper.rb +44 -0
  86. data/test/unit/attachment_test.rb +1 -1
  87. data/test/unit/elt_test.rb +3 -2
  88. data/test/unit/mail_notify_test.rb +37 -0
  89. data/test/unit/mail_test.rb +124 -1
  90. data/test/unit/notifier_test.rb +0 -14
  91. data/test/unit/person_test.rb +2 -1
  92. data/test/unit/subscriber_test.rb +35 -0
  93. data/test/unit/user_test.rb +3 -3
  94. data/vendor/plugins/file_column/CHANGELOG +64 -0
  95. data/vendor/plugins/file_column/README +54 -0
  96. data/vendor/plugins/file_column/Rakefile +36 -0
  97. data/vendor/plugins/file_column/TODO +6 -0
  98. data/vendor/plugins/file_column/init.rb +12 -0
  99. data/vendor/plugins/file_column/lib/file_column.rb +719 -0
  100. data/vendor/plugins/file_column/lib/file_column_helper.rb +145 -0
  101. data/vendor/plugins/file_column/lib/file_compat.rb +28 -0
  102. data/vendor/plugins/file_column/lib/magick_file_column.rb +188 -0
  103. data/vendor/plugins/file_column/lib/validations.rb +112 -0
  104. data/vendor/plugins/file_column/test/abstract_unit.rb +90 -0
  105. data/vendor/plugins/file_column/test/connection.rb +17 -0
  106. data/vendor/plugins/file_column/test/file_column_helper_test.rb +97 -0
  107. data/vendor/plugins/file_column/test/file_column_test.rb +630 -0
  108. data/vendor/plugins/file_column/test/fixtures/entry.rb +32 -0
  109. data/vendor/plugins/file_column/test/fixtures/invalid-image.jpg +1 -0
  110. data/vendor/plugins/file_column/test/fixtures/kerb.jpg +0 -0
  111. data/vendor/plugins/file_column/test/fixtures/mysql.sql +25 -0
  112. data/vendor/plugins/file_column/test/fixtures/schema.rb +10 -0
  113. data/vendor/plugins/file_column/test/fixtures/skanthak.png +0 -0
  114. data/vendor/plugins/file_column/test/magick_test.rb +251 -0
  115. data/vendor/plugins/file_column/test/magick_view_only_test.rb +21 -0
  116. data/vendor/plugins/guid/README.TXT +19 -0
  117. data/vendor/plugins/guid/init.rb +23 -0
  118. data/vendor/plugins/guid/lib/usesguid.rb +37 -0
  119. data/vendor/plugins/guid/lib/uuid22.rb +43 -0
  120. data/vendor/plugins/guid/lib/uuidtools.rb +565 -0
  121. metadata +83 -15
  122. data/db/ROOT/CV.txt +0 -166
  123. data/lib/file_column.rb +0 -263
  124. data/lib/file_column_helper.rb +0 -45
  125. /data/{lib → vendor/plugins/file_column/lib}/rails_file_column.rb +0 -0
@@ -0,0 +1,251 @@
1
+ require File.dirname(__FILE__) + '/abstract_unit'
2
+ require 'RMagick'
3
+ require File.dirname(__FILE__) + '/fixtures/entry'
4
+
5
+
6
+ class AbstractRMagickTest < Test::Unit::TestCase
7
+ def teardown
8
+ FileUtils.rm_rf File.dirname(__FILE__)+"/public/entry/"
9
+ end
10
+
11
+ def test_truth
12
+ assert true
13
+ end
14
+
15
+ private
16
+
17
+ def read_image(path)
18
+ Magick::Image::read(path).first
19
+ end
20
+
21
+ def assert_max_image_size(img, s)
22
+ assert img.columns <= s, "img has #{img.columns} columns, expected: #{s}"
23
+ assert img.rows <= s, "img has #{img.rows} rows, expected: #{s}"
24
+ assert_equal s, [img.columns, img.rows].max
25
+ end
26
+ end
27
+
28
+ class RMagickSimpleTest < AbstractRMagickTest
29
+ def setup
30
+ Entry.file_column :image, :magick => { :geometry => "100x100" }
31
+ end
32
+
33
+ def test_simple_resize_without_save
34
+ e = Entry.new
35
+ e.image = upload("kerb.jpg")
36
+
37
+ img = read_image(e.image)
38
+ assert_max_image_size img, 100
39
+ end
40
+
41
+ def test_simple_resize_with_save
42
+ e = Entry.new
43
+ e.image = upload("kerb.jpg")
44
+ assert e.save
45
+ e.reload
46
+
47
+ img = read_image(e.image)
48
+ assert_max_image_size img, 100
49
+ end
50
+
51
+ def test_resize_on_saved_image
52
+ Entry.file_column :image, :magick => { :geometry => "100x100" }
53
+
54
+ e = Entry.new
55
+ e.image = upload("skanthak.png")
56
+ assert e.save
57
+ e.reload
58
+ old_path = e.image
59
+
60
+ e.image = upload("kerb.jpg")
61
+ assert e.save
62
+ assert "kerb.jpg", File.basename(e.image)
63
+ assert !File.exists?(old_path), "old image '#{old_path}' still exists"
64
+
65
+ img = read_image(e.image)
66
+ assert_max_image_size img, 100
67
+ end
68
+
69
+ def test_invalid_image
70
+ e = Entry.new
71
+ assert_nothing_raised { e.image = upload("invalid-image.jpg") }
72
+ assert !e.valid?
73
+ end
74
+
75
+ def test_serializable
76
+ e = Entry.new
77
+ e.image = upload("skanthak.png")
78
+ assert_nothing_raised {
79
+ flash = Marshal.dump(e)
80
+ e = Marshal.load(flash)
81
+ }
82
+ assert File.exists?(e.image)
83
+ end
84
+
85
+ def test_imagemagick_still_usable
86
+ e = Entry.new
87
+ assert_nothing_raised {
88
+ img = e.load_image_with_rmagick(file_path("skanthak.png"))
89
+ assert img.kind_of?(Magick::Image)
90
+ }
91
+ end
92
+ end
93
+
94
+ class RMagickVersionsTest < AbstractRMagickTest
95
+ def setup
96
+ Entry.file_column :image, :magick => {:geometry => "200x200",
97
+ :versions => {
98
+ :thumb => "50x50",
99
+ :medium => {:geometry => "100x100", :name => "100_100"},
100
+ :large => {:geometry => "150x150", :lazy => true}
101
+ }
102
+ }
103
+ end
104
+
105
+
106
+ def test_should_create_thumb
107
+ e = Entry.new("image" => upload("skanthak.png"))
108
+
109
+ assert File.exists?(e.image("thumb")), "thumb-nail not created"
110
+
111
+ assert_max_image_size read_image(e.image("thumb")), 50
112
+ end
113
+
114
+ def test_version_name_can_be_different_from_key
115
+ e = Entry.new("image" => upload("skanthak.png"))
116
+
117
+ assert File.exists?(e.image("100_100"))
118
+ assert !File.exists?(e.image("medium"))
119
+ end
120
+
121
+ def test_should_not_create_lazy_versions
122
+ e = Entry.new("image" => upload("skanthak.png"))
123
+ assert !File.exists?(e.image("large")), "lazy versions should not be created unless needed"
124
+ end
125
+
126
+ def test_should_create_lazy_version_on_demand
127
+ e = Entry.new("image" => upload("skanthak.png"))
128
+
129
+ e.send(:image_state).create_magick_version_if_needed(:large)
130
+
131
+ assert File.exists?(e.image("large")), "lazy version should be created on demand"
132
+
133
+ assert_max_image_size read_image(e.image("large")), 150
134
+ end
135
+
136
+ def test_generated_name_should_not_change
137
+ e = Entry.new("image" => upload("skanthak.png"))
138
+
139
+ name1 = e.send(:image_state).create_magick_version_if_needed("50x50")
140
+ name2 = e.send(:image_state).create_magick_version_if_needed("50x50")
141
+ name3 = e.send(:image_state).create_magick_version_if_needed(:geometry => "50x50")
142
+ assert_equal name1, name2, "hash value has changed"
143
+ assert_equal name1, name3, "hash value has changed"
144
+ end
145
+
146
+ def test_should_create_version_with_string
147
+ e = Entry.new("image" => upload("skanthak.png"))
148
+
149
+ name = e.send(:image_state).create_magick_version_if_needed("32x32")
150
+
151
+ assert File.exists?(e.image(name))
152
+
153
+ assert_max_image_size read_image(e.image(name)), 32
154
+ end
155
+
156
+ def test_should_create_safe_auto_id
157
+ e = Entry.new("image" => upload("skanthak.png"))
158
+
159
+ name = e.send(:image_state).create_magick_version_if_needed("32x32")
160
+
161
+ assert_match /^[a-zA-Z0-9]+$/, name
162
+ end
163
+ end
164
+
165
+ class RMagickCroppingTest < AbstractRMagickTest
166
+ def setup
167
+ Entry.file_column :image, :magick => {:geometry => "200x200",
168
+ :versions => {
169
+ :thumb => {:crop => "1:1", :geometry => "50x50"}
170
+ }
171
+ }
172
+ end
173
+
174
+ def test_should_crop_image_on_upload
175
+ e = Entry.new("image" => upload("skanthak.png"))
176
+
177
+ img = read_image(e.image("thumb"))
178
+
179
+ assert_equal 50, img.rows
180
+ assert_equal 50, img.columns
181
+ end
182
+
183
+ end
184
+
185
+ class UrlForImageColumnTest < AbstractRMagickTest
186
+ include FileColumnHelper
187
+
188
+ def setup
189
+ Entry.file_column :image, :magick => {
190
+ :versions => {:thumb => "50x50"}
191
+ }
192
+ @request = RequestMock.new
193
+ end
194
+
195
+ def test_should_use_version_on_symbol_option
196
+ e = Entry.new(:image => upload("skanthak.png"))
197
+
198
+ url = url_for_image_column(e, "image", :thumb)
199
+ assert_match %r{^/entry/image/tmp/.+/thumb/skanthak.png$}, url
200
+ end
201
+
202
+ def test_should_use_string_as_size
203
+ e = Entry.new(:image => upload("skanthak.png"))
204
+
205
+ url = url_for_image_column(e, "image", "50x50")
206
+
207
+ assert_match %r{^/entry/image/tmp/.+/.+/skanthak.png$}, url
208
+
209
+ url =~ /\/([^\/]+)\/skanthak.png$/
210
+ dirname = $1
211
+
212
+ assert_max_image_size read_image(e.image(dirname)), 50
213
+ end
214
+
215
+ def test_should_accept_version_hash
216
+ e = Entry.new(:image => upload("skanthak.png"))
217
+
218
+ url = url_for_image_column(e, "image", :size => "50x50", :crop => "1:1", :name => "small")
219
+
220
+ assert_match %r{^/entry/image/tmp/.+/small/skanthak.png$}, url
221
+
222
+ img = read_image(e.image("small"))
223
+ assert_equal 50, img.rows
224
+ assert_equal 50, img.columns
225
+ end
226
+ end
227
+
228
+ class RMagickPermissionsTest < AbstractRMagickTest
229
+ def setup
230
+ Entry.file_column :image, :magick => {:geometry => "200x200",
231
+ :versions => {
232
+ :thumb => {:crop => "1:1", :geometry => "50x50"}
233
+ }
234
+ }, :permissions => 0616
235
+ end
236
+
237
+ def check_permissions(e)
238
+ assert_equal 0616, (File.stat(e.image).mode & 0777)
239
+ assert_equal 0616, (File.stat(e.image("thumb")).mode & 0777)
240
+ end
241
+
242
+ def test_permissions_with_rmagick
243
+ e = Entry.new(:image => upload("skanthak.png"))
244
+
245
+ check_permissions e
246
+
247
+ assert e.save
248
+
249
+ check_permissions e
250
+ end
251
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/abstract_unit'
2
+ require File.dirname(__FILE__) + '/fixtures/entry'
3
+
4
+ class RMagickViewOnlyTest < Test::Unit::TestCase
5
+ include FileColumnHelper
6
+
7
+ def setup
8
+ Entry.file_column :image
9
+ @request = RequestMock.new
10
+ end
11
+
12
+ def teardown
13
+ FileUtils.rm_rf File.dirname(__FILE__)+"/public/entry/"
14
+ end
15
+
16
+ def test_url_for_image_column_without_model_versions
17
+ e = Entry.new(:image => upload("skanthak.png"))
18
+
19
+ assert_nothing_raised { url_for_image_column e, "image", "50x50" }
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ This plugin for ActiveRecord makes the "ID" field into a URL-safe GUID
2
+ # It is a mashup by Andy Singleton <andy@assembla.com> that includes
3
+ # * the UUID class from Bob Aman.
4
+ # * the plugin skeleton from Demetrius Nunes
5
+ # * the 22 character URL-safe format from Andy Singleton
6
+ # You can get standard 36 char UUID formats instead
7
+ # TODO: Auto-detect a character ID field and use a GUID in this case (DRY principle)
8
+ #
9
+ # This library is free software; you can redistribute it and/or modify it
10
+ # under the terms of the MIT license.
11
+ #
12
+ # TO USE
13
+ # Install as a plugin in the rails directory vendor/plugin/guid
14
+ # define ID as char(22)
15
+ # call "usesguid" in ActiveRecord class declaration, like
16
+ # class Mymodel < ActiveRecord::Base
17
+ # usesguid
18
+ #
19
+ # if your ID field is not called "ID", call "usesguid :column =>'IdColumnName' "
@@ -0,0 +1,23 @@
1
+ # Copyright (c) 2005 Assembla, Inc.
2
+ #
3
+ # This plugin for ActiveRecord makes the "ID" field into a URL-safe GUID
4
+ # It is a mashup by Andy Singleton <andy@assembla.com> that includes
5
+ # * the UUID class from Bob Aman.
6
+ # * the plugin skeleton from Demetrius Nunes
7
+ # * the 22 character URL-safe format from Andy Singleton
8
+ # You can get standard 36 char UUID formats instead
9
+ # TODO: Auto-detect a character ID field and use a GUID in this case (DRY principle)
10
+ #
11
+ # This library is free software; you can redistribute it and/or modify it
12
+ # under the terms of the MIT license.
13
+ #
14
+ # TO USE
15
+ # Install as a plugin in the rails directory vendor/plugin/guid
16
+ # define ID as char(22)
17
+ # call "usesguid" in ActiveRecord class declaration, like
18
+ # class Mymodel < ActiveRecord::Base
19
+ # usesguid
20
+ #
21
+ # if your ID field is not called "ID", call "usesguid :column =>'IdColumnName' "
22
+
23
+ require 'usesguid'
@@ -0,0 +1,37 @@
1
+ # from Demetrio Nunes
2
+ # Modified by Andy Singleton to use different GUID generator
3
+ #
4
+ # MIT License
5
+
6
+ require 'uuid22'
7
+
8
+ module ActiveRecord
9
+ module Usesguid #:nodoc:
10
+
11
+ def self.append_features(base)
12
+ super
13
+ base.extend(ClassMethods)
14
+ end
15
+
16
+
17
+ module ClassMethods
18
+
19
+ def usesguid(options = {})
20
+
21
+ class_eval do
22
+ set_primary_key options[:column] if options[:column]
23
+
24
+ def after_initialize
25
+ self.id ||= UUID.timestamp_create().to_s22
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+
35
+ ActiveRecord::Base.class_eval do
36
+ include ActiveRecord::Usesguid
37
+ end
@@ -0,0 +1,43 @@
1
+ # Copyright (c) 2005 Assembla, Inc.
2
+ # MIT License
3
+
4
+ require 'uuidtools'
5
+
6
+ class UUID
7
+
8
+ # Make an array of 64 URL-safe characters
9
+ @@chars64=('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + ['-','_']
10
+ #return a 22 byte URL-safe string, encoded six bits at a time using 64 characters
11
+ def to_s22
12
+ integer=self.to_i
13
+ rval=''
14
+ 22.times do
15
+ c=(integer & 0x3F)
16
+ rval+=@@chars64[c]
17
+ integer =integer >> 6
18
+ end
19
+ return rval.reverse
20
+ end
21
+ # Create a new UUID from a 22char string
22
+ def self.parse22(s)
23
+ # get the integer representation
24
+ integer=0
25
+ s.each_byte {|c|
26
+ integer = integer << 6
27
+ pos=@@chars64.index(c.chr)
28
+ integer+=pos
29
+ }
30
+
31
+ time_low = (integer >> 96) & 0xFFFFFFFF
32
+ time_mid = (integer >> 80) & 0xFFFF
33
+ time_hi_and_version = (integer >> 64) & 0xFFFF
34
+ clock_seq_hi_and_reserved = (integer >> 56) & 0xFF
35
+ clock_seq_low = (integer >> 48) & 0xFF
36
+ nodes = []
37
+ for i in 0..5 do
38
+ nodes << ((integer >> (40 - (i * 8))) & 0xFF)
39
+ end
40
+ return new(time_low, time_mid, time_hi_and_version,
41
+ clock_seq_hi_and_reserved, clock_seq_low, nodes)
42
+ end
43
+ end