carrier 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +27 -0
  4. data/LICENSE.txt +20 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.textile +111 -0
  7. data/Rakefile +48 -0
  8. data/VERSION +1 -0
  9. data/app/assets/images/.gitkeep +0 -0
  10. data/app/assets/javascripts/autocomplete.js +4 -0
  11. data/app/assets/javascripts/autocomplete/i18n/jquery-ui-i18n.js +1379 -0
  12. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-af.js +23 -0
  13. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ar-DZ.js +23 -0
  14. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ar.js +23 -0
  15. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-az.js +23 -0
  16. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-bg.js +24 -0
  17. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-bs.js +23 -0
  18. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ca.js +23 -0
  19. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-cs.js +23 -0
  20. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-da.js +23 -0
  21. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-de.js +23 -0
  22. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-el.js +23 -0
  23. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-en-AU.js +23 -0
  24. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-en-GB.js +23 -0
  25. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-en-NZ.js +23 -0
  26. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-eo.js +23 -0
  27. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-es.js +23 -0
  28. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-et.js +23 -0
  29. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-eu.js +23 -0
  30. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fa.js +23 -0
  31. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fi.js +23 -0
  32. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fo.js +23 -0
  33. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fr-CH.js +23 -0
  34. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fr.js +25 -0
  35. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-gl.js +23 -0
  36. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-he.js +23 -0
  37. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-hr.js +23 -0
  38. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-hu.js +23 -0
  39. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-hy.js +23 -0
  40. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-id.js +23 -0
  41. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-is.js +23 -0
  42. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-it.js +23 -0
  43. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ja.js +23 -0
  44. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ko.js +23 -0
  45. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-kz.js +23 -0
  46. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-lt.js +23 -0
  47. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-lv.js +23 -0
  48. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ml.js +23 -0
  49. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ms.js +23 -0
  50. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-nl.js +23 -0
  51. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-no.js +23 -0
  52. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-pl.js +23 -0
  53. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-pt-BR.js +23 -0
  54. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-pt.js +22 -0
  55. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-rm.js +21 -0
  56. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ro.js +26 -0
  57. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ru.js +23 -0
  58. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sk.js +23 -0
  59. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sl.js +24 -0
  60. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sq.js +23 -0
  61. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sr-SR.js +23 -0
  62. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sr.js +23 -0
  63. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sv.js +23 -0
  64. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ta.js +23 -0
  65. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-th.js +23 -0
  66. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-tj.js +23 -0
  67. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-tr.js +23 -0
  68. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-uk.js +23 -0
  69. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-vi.js +23 -0
  70. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-zh-CN.js +23 -0
  71. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-zh-HK.js +23 -0
  72. data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-zh-TW.js +23 -0
  73. data/app/assets/javascripts/autocomplete/jquery.ui.autocomplete.min.js +32 -0
  74. data/app/assets/javascripts/autocomplete/jquery.ui.core.min.js +17 -0
  75. data/app/assets/javascripts/autocomplete/jquery.ui.position.min.js +16 -0
  76. data/app/assets/javascripts/autocomplete/jquery.ui.widget.min.js +15 -0
  77. data/app/assets/javascripts/carrier.js +8 -0
  78. data/app/assets/javascripts/jquery.min.js +16 -0
  79. data/app/assets/javascripts/rails.js +169 -0
  80. data/app/assets/javascripts/rich-multiselect/jquery-ui.min.js +405 -0
  81. data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-de.js +11 -0
  82. data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-en.js +11 -0
  83. data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-es.js +11 -0
  84. data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-fr.js +11 -0
  85. data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-it.js +13 -0
  86. data/app/assets/javascripts/rich-multiselect/plugins/localisation/jquery.localisation-min.js +7 -0
  87. data/app/assets/javascripts/rich-multiselect/plugins/localisation/jquery.localisation-pack.js +7 -0
  88. data/app/assets/javascripts/rich-multiselect/plugins/localisation/jquery.localisation.js +99 -0
  89. data/app/assets/javascripts/rich-multiselect/plugins/scrollTo/README.txt +37 -0
  90. data/app/assets/javascripts/rich-multiselect/plugins/scrollTo/changes.txt +82 -0
  91. data/app/assets/javascripts/rich-multiselect/plugins/scrollTo/jquery.scrollTo-min.js +11 -0
  92. data/app/assets/javascripts/rich-multiselect/plugins/scrollTo/jquery.scrollTo.js +207 -0
  93. data/app/assets/javascripts/rich-multiselect/ui.multiselect.js +339 -0
  94. data/app/assets/stylesheets/carrier.css +227 -0
  95. data/app/assets/stylesheets/carrier_rich.css +48 -0
  96. data/app/assets/stylesheets/carrier_simple.css +15 -0
  97. data/app/assets/stylesheets/rich-multiselect/ui.multiselect.css +30 -0
  98. data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  99. data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_55_fbf9ee_40x100.png +0 -0
  100. data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_65_ffffff_40x100.png +0 -0
  101. data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_75_cccccc_40x100.png +0 -0
  102. data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_75_dadada_40x100.png +0 -0
  103. data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_75_e6e6e6_40x100.png +0 -0
  104. data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  105. data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_95_fef1ec_40x100.png +0 -0
  106. data/app/assets/stylesheets/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  107. data/app/assets/stylesheets/ui-lightness/images/ui-icons_2e83ff_256x240.png +0 -0
  108. data/app/assets/stylesheets/ui-lightness/images/ui-icons_454545_256x240.png +0 -0
  109. data/app/assets/stylesheets/ui-lightness/images/ui-icons_888888_256x240.png +0 -0
  110. data/app/assets/stylesheets/ui-lightness/images/ui-icons_cd0a0a_256x240.png +0 -0
  111. data/app/assets/stylesheets/ui-lightness/jquery-ui-1.8.14.custom.css +342 -0
  112. data/app/controllers/carrier/application_controller.rb +5 -0
  113. data/app/controllers/carrier/chains_controller.rb +16 -0
  114. data/app/controllers/carrier/messages_controller.rb +59 -0
  115. data/app/helpers/carrier/application_helper.rb +26 -0
  116. data/app/helpers/carrier/post_helper.rb +4 -0
  117. data/app/models/carrier/chain.rb +59 -0
  118. data/app/models/carrier/message.rb +118 -0
  119. data/app/models/carrier/message/scopes.rb +51 -0
  120. data/app/models/carrier/message/subject.rb +25 -0
  121. data/app/models/carrier/message/validations.rb +7 -0
  122. data/app/validators/recipients/exclude_self.rb +10 -0
  123. data/app/validators/recipients/recipients_validator.rb +10 -0
  124. data/app/views/carrier/chains/archive.js.erb +1 -0
  125. data/app/views/carrier/chains/unarchive.js.erb +1 -0
  126. data/app/views/carrier/messages/_archive_chain.html.erb +6 -0
  127. data/app/views/carrier/messages/_form.html.erb +30 -0
  128. data/app/views/carrier/messages/_head.html.erb +8 -0
  129. data/app/views/carrier/messages/_index_message.html.erb +13 -0
  130. data/app/views/carrier/messages/_message_collapsed.html.erb +12 -0
  131. data/app/views/carrier/messages/_message_expanded.html.erb +10 -0
  132. data/app/views/carrier/messages/_nav_messages.html.erb +15 -0
  133. data/app/views/carrier/messages/_reply.html.erb +19 -0
  134. data/app/views/carrier/messages/as_sent.html.erb +36 -0
  135. data/app/views/carrier/messages/collapsed.js.erb +1 -0
  136. data/app/views/carrier/messages/create.js.erb +1 -0
  137. data/app/views/carrier/messages/expanded.js.erb +1 -0
  138. data/app/views/carrier/messages/index.html.erb +9 -0
  139. data/app/views/carrier/messages/new.html.erb +7 -0
  140. data/app/views/carrier/messages/new.js.erb +1 -0
  141. data/app/views/carrier/messages/reply.js.erb +6 -0
  142. data/app/views/carrier/messages/rich/_multiselect.html.erb +18 -0
  143. data/app/views/carrier/messages/rich/_recipients.html.erb +6 -0
  144. data/app/views/carrier/messages/show.html.erb +35 -0
  145. data/app/views/carrier/messages/simple/_autocomplete.html.erb +45 -0
  146. data/app/views/carrier/messages/simple/_autocomplete_includes.html.erb +7 -0
  147. data/app/views/carrier/messages/simple/_recipients.html.erb +3 -0
  148. data/app/views/layouts/carrier/application.html.erb +16 -0
  149. data/app/views/partials/_error_messages_for.html.erb +9 -0
  150. data/carrier.gemspec +331 -0
  151. data/config/locales/carrier.en.yml +48 -0
  152. data/config/locales/carrier.ru.yml +48 -0
  153. data/config/routes.rb +24 -0
  154. data/db/migrate/001_create_messages.rb +26 -0
  155. data/db/migrate/002_create_chains.rb +34 -0
  156. data/db/migrate/003_create_read_marks +16 -0
  157. data/lib/carrier.rb +22 -0
  158. data/lib/carrier/configuration.rb +35 -0
  159. data/lib/carrier/configuration/models.rb +31 -0
  160. data/lib/carrier/configuration/ui.rb +28 -0
  161. data/lib/carrier/rails.rb +5 -0
  162. data/lib/carrier/rails/engine.rb +50 -0
  163. data/lib/carrier/rails/helpers.rb +30 -0
  164. data/lib/tasks/carrier_tasks.rake +4 -0
  165. data/script/rails +6 -0
  166. data/spec/carrier/app/controllers/application_controller_spec.rb +1 -0
  167. data/spec/carrier/app/models/message_scopes_spec.rb +25 -0
  168. data/spec/carrier/app/models/message_spec.rb +38 -0
  169. data/spec/dummy/Rakefile +7 -0
  170. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  171. data/spec/dummy/app/assets/javascripts/default.js +2 -0
  172. data/spec/dummy/app/assets/javascripts/jquery.js +16 -0
  173. data/spec/dummy/app/assets/javascripts/jquery_ujs.js +169 -0
  174. data/spec/dummy/app/assets/javascripts/posts.js +2 -0
  175. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  176. data/spec/dummy/app/assets/stylesheets/default.css +4 -0
  177. data/spec/dummy/app/assets/stylesheets/posts.css +4 -0
  178. data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
  179. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  180. data/spec/dummy/app/controllers/default_controller.rb +5 -0
  181. data/spec/dummy/app/controllers/posts_controller.rb +83 -0
  182. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  183. data/spec/dummy/app/helpers/default_helper.rb +2 -0
  184. data/spec/dummy/app/helpers/posts_helper.rb +2 -0
  185. data/spec/dummy/app/mailers/.gitkeep +0 -0
  186. data/spec/dummy/app/models/.gitkeep +0 -0
  187. data/spec/dummy/app/models/post.rb +2 -0
  188. data/spec/dummy/app/models/user.rb +15 -0
  189. data/spec/dummy/app/views/default/index.html.erb +4 -0
  190. data/spec/dummy/app/views/devise/confirmations/new.html.erb +12 -0
  191. data/spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  192. data/spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  193. data/spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  194. data/spec/dummy/app/views/devise/passwords/edit.html.erb +16 -0
  195. data/spec/dummy/app/views/devise/passwords/new.html.erb +12 -0
  196. data/spec/dummy/app/views/devise/registrations/edit.html.erb +25 -0
  197. data/spec/dummy/app/views/devise/registrations/new.html.erb +18 -0
  198. data/spec/dummy/app/views/devise/sessions/new.html.erb +17 -0
  199. data/spec/dummy/app/views/devise/shared/_links.erb +25 -0
  200. data/spec/dummy/app/views/devise/unlocks/new.html.erb +12 -0
  201. data/spec/dummy/app/views/layouts/application.html.erb +16 -0
  202. data/spec/dummy/app/views/posts/_form.html.erb +17 -0
  203. data/spec/dummy/app/views/posts/edit.html.erb +6 -0
  204. data/spec/dummy/app/views/posts/index.html.erb +21 -0
  205. data/spec/dummy/app/views/posts/new.html.erb +5 -0
  206. data/spec/dummy/app/views/posts/show.html.erb +5 -0
  207. data/spec/dummy/config.ru +4 -0
  208. data/spec/dummy/config/application.rb +51 -0
  209. data/spec/dummy/config/boot.rb +10 -0
  210. data/spec/dummy/config/database.yml +26 -0
  211. data/spec/dummy/config/database_mysql.yml +29 -0
  212. data/spec/dummy/config/database_pgsql.yml +35 -0
  213. data/spec/dummy/config/environment.rb +5 -0
  214. data/spec/dummy/config/environments/development.rb +24 -0
  215. data/spec/dummy/config/environments/production.rb +52 -0
  216. data/spec/dummy/config/environments/test.rb +39 -0
  217. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  218. data/spec/dummy/config/initializers/carrier.rb +3 -0
  219. data/spec/dummy/config/initializers/devise.rb +204 -0
  220. data/spec/dummy/config/initializers/inflections.rb +10 -0
  221. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  222. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  223. data/spec/dummy/config/initializers/session_store.rb +8 -0
  224. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  225. data/spec/dummy/config/locales/devise.en.yml +53 -0
  226. data/spec/dummy/config/locales/en.yml +5 -0
  227. data/spec/dummy/config/routes.rb +15 -0
  228. data/spec/dummy/db/migrate/007_devise_create_users.rb +29 -0
  229. data/spec/dummy/db/migrate/20110130210000_create_read_marks.rb +16 -0
  230. data/spec/dummy/db/migrate/20110814064637_create_posts.rb +8 -0
  231. data/spec/dummy/db/migrate/20110814164228_create_messages.rb +26 -0
  232. data/spec/dummy/db/migrate/20110814164229_create_chains.rb +34 -0
  233. data/spec/dummy/db/schema.rb +79 -0
  234. data/spec/dummy/db/seeds.rb +26 -0
  235. data/spec/dummy/log/.gitkeep +0 -0
  236. data/spec/dummy/public/404.html +26 -0
  237. data/spec/dummy/public/422.html +26 -0
  238. data/spec/dummy/public/500.html +26 -0
  239. data/spec/dummy/public/favicon.ico +0 -0
  240. data/spec/dummy/script/rails +6 -0
  241. data/spec/dummy/test/fixtures/posts.yml +11 -0
  242. data/spec/dummy/test/fixtures/users.yml +11 -0
  243. data/spec/dummy/test/functional/default_controller_test.rb +9 -0
  244. data/spec/dummy/test/functional/posts_controller_test.rb +49 -0
  245. data/spec/dummy/test/unit/helpers/default_helper_test.rb +4 -0
  246. data/spec/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
  247. data/spec/dummy/test/unit/post_test.rb +7 -0
  248. data/spec/dummy/test/unit/user_test.rb +7 -0
  249. data/spec/dummy_spec_helper.rb +70 -0
  250. data/spec/integration/carrier_spec.rb +71 -0
  251. data/spec/requests/main_spec.rb +31 -0
  252. data/spec/support/controller_macros.rb +10 -0
  253. data/spec/support/factories.rb +47 -0
  254. data/spec/support/rspec_helpers.rb +22 -0
  255. data/test/helper.rb +18 -0
  256. data/test/test_carrier.rb +7 -0
  257. metadata +450 -0
@@ -0,0 +1,48 @@
1
+ en:
2
+ activerecord:
3
+ attributes:
4
+ carrier/message:
5
+ recipients: "'Recipients' field"
6
+ content: "'Content' field"
7
+ errors:
8
+ models:
9
+ carrier/message:
10
+ attributes:
11
+ recipients:
12
+ wrong:
13
+ "is wrong!"
14
+ #blank:
15
+ #""
16
+
17
+ models:
18
+ carrier:
19
+ no_subject: "(No subject)"
20
+
21
+ views:
22
+ carrier:
23
+ title: "Simple Messages"
24
+ description: "Description goes here..."
25
+ new_link: "New"
26
+ inbox_link: "Inbox"
27
+ inbox_back_link: "Back to Inbox"
28
+ reply_link: "Reply into thread"
29
+ sent_link: "Sent"
30
+ archived_link: "Archived"
31
+
32
+ participants: "Participants: "
33
+ me: "Me"
34
+
35
+ archive_link: "Archive!"
36
+ unarchive_link: "Unarchive?"
37
+ thread_archived: "Thread archived"
38
+
39
+ new_header: "Creating message"
40
+ new_recipients: "Recipients"
41
+ new_subject: "Subject"
42
+ new_content: "Message"
43
+ new_send: "Send"
44
+
45
+ #last: "Last »"
46
+ #previous: "‹ Prev"
47
+ #next: "Next ›"
48
+ #truncate: "..."
@@ -0,0 +1,48 @@
1
+ ru:
2
+ activerecord:
3
+ attributes:
4
+ carrier/message:
5
+ recipients: "Поле 'получатели'"
6
+ content: "Текст сообщения"
7
+ errors:
8
+ models:
9
+ carrier/message:
10
+ attributes:
11
+ recipients:
12
+ wrong:
13
+ "заполнено неверно"
14
+ blank:
15
+ "не может быть пустым"
16
+ models:
17
+ carrier:
18
+ no_subject: "(Без темы)"
19
+
20
+ views:
21
+ carrier:
22
+ title: "Личные сообщения"
23
+ description: "Описание плагина..."
24
+ new_link: "Новое"
25
+ inbox_link: "Входящие"
26
+ inbox_back_link: "Назад к входящие"
27
+ reply_link: "Ответить в ветку"
28
+ sent_link: "Отправленные"
29
+ archived_link: "Архив"
30
+
31
+ participants: "Участники:"
32
+ me: "Я"
33
+
34
+ archive_link: "Архивировать!"
35
+ unarchive_link: "Переместить во входящие!"
36
+ thread_archived: "Цепочка в архиве"
37
+
38
+ new_header: "Новое сообщение"
39
+ new_recipients: "Получатели"
40
+ new_subject: "Тема"
41
+ new_content: "Сообщение"
42
+ new_send: "Отправить"
43
+ #last: "Last »"
44
+ #previous: "‹ Prev"
45
+ #next: "Next ›"
46
+ #truncate: "..."
47
+ #
48
+
@@ -0,0 +1,24 @@
1
+ Carrier::Engine.routes.draw do
2
+
3
+ resources :messages do
4
+ member do
5
+ get :as_sent
6
+ get :reply
7
+ get :expanded
8
+ get :collapsed
9
+ end
10
+ collection do
11
+ get :sent
12
+ get :archive
13
+ end
14
+ end
15
+
16
+ resources :chains do
17
+ member do
18
+ post :archive
19
+ post :unarchive
20
+ end
21
+ end
22
+
23
+ root :to => "messages#index"
24
+ end
@@ -0,0 +1,26 @@
1
+ class CreateMessages < ActiveRecord::Migration
2
+ def up
3
+ create_table table_name do |t|
4
+ t.integer :sender
5
+ t.string :recipients, :default => [].to_yaml
6
+ t.string :subject
7
+ t.text :content
8
+
9
+ t.boolean :last, :default => false, :null => :false
10
+
11
+ t.integer :chain_id
12
+
13
+ t.timestamps
14
+ end
15
+ add_index table_name, :created_at
16
+ add_index table_name, :chain_id
17
+ end
18
+
19
+ def down
20
+ drop_table table_name
21
+ end
22
+
23
+ def table_name
24
+ Carrier.config.models.table_for(:message)
25
+ end
26
+ end
@@ -0,0 +1,34 @@
1
+ class CreateChains < ActiveRecord::Migration
2
+
3
+ def up
4
+ create_chains
5
+ end
6
+
7
+ def down
8
+ drop_chains
9
+ end
10
+
11
+ protected
12
+
13
+ def create_chains
14
+ create_table table_name do |t|
15
+ t.string :participants, :default => [].to_yaml
16
+ t.string :archived_for, :default => [].to_yaml
17
+ t.references :having_chain, :polymorphic => true
18
+ t.string :chain_type, :default => :simple.to_yaml
19
+ t.integer :messages_count, :default => 0
20
+ t.timestamps
21
+ end
22
+ add_index table_name, [:archived_for, :participants], :name => :participants_and_archived_index
23
+ add_index table_name, [:having_chain_id, :having_chain_type], :name => :having_index
24
+ add_index table_name, :created_at
25
+ end
26
+
27
+ def drop_chains
28
+ drop_table table_name
29
+ end
30
+
31
+ def table_name
32
+ Carrier.config.models.table_for(:chain)
33
+ end
34
+ end
@@ -0,0 +1,16 @@
1
+ class CreateReadMarks < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :read_marks, :force => true do |t|
4
+ t.integer :readable_id
5
+ t.integer :user_id, :null => false
6
+ t.string :readable_type, :null => false, :limit => 20
7
+ t.datetime :timestamp
8
+ end
9
+ add_index :read_marks, [:user_id, :readable_type, :readable_id]
10
+ end
11
+
12
+ def self.down
13
+ drop_table :read_marks
14
+ end
15
+ end
16
+
@@ -0,0 +1,22 @@
1
+ require "carrier/rails/engine" if defined?(Rails)
2
+
3
+ require 'sweetloader'
4
+
5
+ require 'sugar-high/array'
6
+ require 'sugar-high/class_ext'
7
+ require 'sugar-high/rails/concerns'
8
+ require 'sugar-high/dsl'
9
+
10
+ module Carrier
11
+ autoload_modules :Configuration, :Rails
12
+
13
+ class << self
14
+ def config &block
15
+ conf = Carrier::Configuration.instance
16
+ yield conf if block
17
+ conf
18
+ end
19
+
20
+ alias_method :configure, :config
21
+ end
22
+ end
@@ -0,0 +1,35 @@
1
+ require 'singleton'
2
+ module Carrier
3
+ class Configuration
4
+
5
+ autoload_modules :Models, :UI
6
+
7
+ include Singleton
8
+
9
+ [:models].each do |component|
10
+ define_method component do
11
+ conf_class(component).instance
12
+ end
13
+ end
14
+
15
+ def conf_class component
16
+ "#{conf}::#{component.to_s.camelize}".constantize
17
+ end
18
+
19
+ def ui
20
+ conf::UI.instance
21
+ end
22
+
23
+ def conf
24
+ Carrier::Configuration
25
+ end
26
+
27
+ def root
28
+ File.expand_path("../../..", __FILE__)
29
+ end
30
+
31
+ def check_unread!
32
+ raise "Add 'acts_as_reader' into your User model" unless ReadMark.reader_class
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ require 'singleton'
2
+ module Carrier
3
+ class Configuration
4
+ class Models
5
+ include Singleton
6
+
7
+ attr_accessor :tables
8
+
9
+ def table_for model
10
+ tables[model]
11
+ end
12
+
13
+ def tables= hash
14
+ raise "Must be a Hash like {:messages => 'messages'}" if !hash.is_a?(Hash)
15
+ tables.merge! hash
16
+ end
17
+
18
+ def tables
19
+ @tables ||= default_tables
20
+ end
21
+
22
+ def default_tables
23
+ {
24
+ :message => 'messages',
25
+ :chain => 'chains'
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,28 @@
1
+ require 'singleton'
2
+ module Carrier
3
+ class Configuration
4
+ class UI
5
+ include Singleton
6
+
7
+ def set style = :simple
8
+ @state = style
9
+ end
10
+
11
+ def style
12
+ @state || default
13
+ end
14
+
15
+ def default
16
+ :simple
17
+ end
18
+
19
+ [:simple, :rich].each do |type|
20
+ define_method(:"#{type}?") do
21
+ @state == type
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,5 @@
1
+ module Carrier
2
+ module Rails
3
+ autoload_modules :Helpers
4
+ end
5
+ end
@@ -0,0 +1,50 @@
1
+ module Carrier
2
+
3
+ def self.carrier_requires
4
+ validators = Dir[File.join ::Carrier.config.root, "app/validators/**/*.rb"]
5
+ models = Dir[File.join ::Carrier.config.root, "app/models/**/*.rb"]
6
+
7
+ (validators + models).each do |rb_file|
8
+ require_dependency rb_file
9
+ end
10
+ end
11
+
12
+ def self.models_requires
13
+ app_models = Dir[File.join ::Rails.root, "app/models/**/*.rb"]
14
+
15
+ (app_models).each do |rb_file|
16
+ require_dependency rb_file
17
+ end
18
+ end
19
+
20
+ def self.include_helpers
21
+ ActiveSupport.on_load(:action_controller) do
22
+ include Carrier::Rails::Helpers
23
+ end
24
+
25
+ ActiveSupport.on_load(:action_view) do
26
+ end
27
+ end
28
+
29
+ def self.check_unread!
30
+ Carrier.config.check_unread!
31
+ end
32
+ end
33
+
34
+ module Carrier
35
+ class Engine < Rails::Engine
36
+ engine_name :carrier
37
+ isolate_namespace Carrier
38
+
39
+ initializer "carrier" do
40
+ Carrier.models_requires
41
+ Carrier.carrier_requires
42
+ Carrier.check_unread!
43
+ Carrier.include_helpers
44
+ end
45
+
46
+ config.to_prepare do
47
+ Carrier.carrier_requires
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,30 @@
1
+ module Carrier
2
+ module Rails
3
+ module Helpers
4
+
5
+ def self.included base
6
+ base.send :helper_method, :unread_messages, :all_messages
7
+ base.send :helper_method, :current_user
8
+ base.send :helper_method, :carrier_ui
9
+ end
10
+
11
+ def carrier_ui
12
+ Carrier.config.ui.style
13
+ end
14
+
15
+ def current_user
16
+ raise "Define #current_user method!" if !defined?(super)
17
+ super
18
+ end
19
+
20
+ def all_messages
21
+ @all_messages ||= Carrier::Message.for_or_by(current_user)
22
+ end
23
+
24
+ def unread_messages
25
+ @unread_messages ||= Carrier::Message.unread(current_user)
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :carrier do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ #!/usr/bin/env ruby
3
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
4
+
5
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
6
+ load File.expand_path('../../spec/dummy/script/rails', __FILE__)
@@ -0,0 +1,25 @@
1
+ Message = Carrier::Message
2
+ Chain = Carrier::Chain
3
+
4
+ describe Carrier::Message do
5
+ concern "Scopes" do
6
+
7
+ let(:user) do
8
+ @user ||= create(:user)
9
+ end
10
+
11
+ specify {
12
+ Message.count.should == 0
13
+ Chain.count.should == 0
14
+ Message.for_or_by(user).size.should == 0
15
+ create(:first_message, :sender_user => user)
16
+ Message.for(user).size.should == 0
17
+ Message.by(user).size.should == 1
18
+ Message.for_or_by(user).size.should == 1
19
+ create(:second_message)
20
+ Message.for(user).size.should == 1
21
+ Message.by(user).size.should == 1
22
+ Message.for_or_by(user).size.should == 2
23
+ }
24
+ end
25
+ end