carrier 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +27 -0
- data/LICENSE.txt +20 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +111 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/app/assets/images/.gitkeep +0 -0
- data/app/assets/javascripts/autocomplete.js +4 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery-ui-i18n.js +1379 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-af.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ar-DZ.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ar.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-az.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-bg.js +24 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-bs.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ca.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-cs.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-da.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-de.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-el.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-en-AU.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-en-GB.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-en-NZ.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-eo.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-es.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-et.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-eu.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fa.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fi.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fo.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fr-CH.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-fr.js +25 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-gl.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-he.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-hr.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-hu.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-hy.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-id.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-is.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-it.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ja.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ko.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-kz.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-lt.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-lv.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ml.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ms.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-nl.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-no.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-pl.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-pt-BR.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-pt.js +22 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-rm.js +21 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ro.js +26 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ru.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sk.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sl.js +24 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sq.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sr-SR.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sr.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-sv.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-ta.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-th.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-tj.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-tr.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-uk.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-vi.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-zh-CN.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-zh-HK.js +23 -0
- data/app/assets/javascripts/autocomplete/i18n/jquery.ui.datepicker-zh-TW.js +23 -0
- data/app/assets/javascripts/autocomplete/jquery.ui.autocomplete.min.js +32 -0
- data/app/assets/javascripts/autocomplete/jquery.ui.core.min.js +17 -0
- data/app/assets/javascripts/autocomplete/jquery.ui.position.min.js +16 -0
- data/app/assets/javascripts/autocomplete/jquery.ui.widget.min.js +15 -0
- data/app/assets/javascripts/carrier.js +8 -0
- data/app/assets/javascripts/jquery.min.js +16 -0
- data/app/assets/javascripts/rails.js +169 -0
- data/app/assets/javascripts/rich-multiselect/jquery-ui.min.js +405 -0
- data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-de.js +11 -0
- data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-en.js +11 -0
- data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-es.js +11 -0
- data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-fr.js +11 -0
- data/app/assets/javascripts/rich-multiselect/locale/ui-multiselect-it.js +13 -0
- data/app/assets/javascripts/rich-multiselect/plugins/localisation/jquery.localisation-min.js +7 -0
- data/app/assets/javascripts/rich-multiselect/plugins/localisation/jquery.localisation-pack.js +7 -0
- data/app/assets/javascripts/rich-multiselect/plugins/localisation/jquery.localisation.js +99 -0
- data/app/assets/javascripts/rich-multiselect/plugins/scrollTo/README.txt +37 -0
- data/app/assets/javascripts/rich-multiselect/plugins/scrollTo/changes.txt +82 -0
- data/app/assets/javascripts/rich-multiselect/plugins/scrollTo/jquery.scrollTo-min.js +11 -0
- data/app/assets/javascripts/rich-multiselect/plugins/scrollTo/jquery.scrollTo.js +207 -0
- data/app/assets/javascripts/rich-multiselect/ui.multiselect.js +339 -0
- data/app/assets/stylesheets/carrier.css +227 -0
- data/app/assets/stylesheets/carrier_rich.css +48 -0
- data/app/assets/stylesheets/carrier_simple.css +15 -0
- data/app/assets/stylesheets/rich-multiselect/ui.multiselect.css +30 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_55_fbf9ee_40x100.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_65_ffffff_40x100.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_75_cccccc_40x100.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_75_dadada_40x100.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_75_e6e6e6_40x100.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-bg_flat_95_fef1ec_40x100.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-icons_888888_256x240.png +0 -0
- data/app/assets/stylesheets/ui-lightness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/stylesheets/ui-lightness/jquery-ui-1.8.14.custom.css +342 -0
- data/app/controllers/carrier/application_controller.rb +5 -0
- data/app/controllers/carrier/chains_controller.rb +16 -0
- data/app/controllers/carrier/messages_controller.rb +59 -0
- data/app/helpers/carrier/application_helper.rb +26 -0
- data/app/helpers/carrier/post_helper.rb +4 -0
- data/app/models/carrier/chain.rb +59 -0
- data/app/models/carrier/message.rb +118 -0
- data/app/models/carrier/message/scopes.rb +51 -0
- data/app/models/carrier/message/subject.rb +25 -0
- data/app/models/carrier/message/validations.rb +7 -0
- data/app/validators/recipients/exclude_self.rb +10 -0
- data/app/validators/recipients/recipients_validator.rb +10 -0
- data/app/views/carrier/chains/archive.js.erb +1 -0
- data/app/views/carrier/chains/unarchive.js.erb +1 -0
- data/app/views/carrier/messages/_archive_chain.html.erb +6 -0
- data/app/views/carrier/messages/_form.html.erb +30 -0
- data/app/views/carrier/messages/_head.html.erb +8 -0
- data/app/views/carrier/messages/_index_message.html.erb +13 -0
- data/app/views/carrier/messages/_message_collapsed.html.erb +12 -0
- data/app/views/carrier/messages/_message_expanded.html.erb +10 -0
- data/app/views/carrier/messages/_nav_messages.html.erb +15 -0
- data/app/views/carrier/messages/_reply.html.erb +19 -0
- data/app/views/carrier/messages/as_sent.html.erb +36 -0
- data/app/views/carrier/messages/collapsed.js.erb +1 -0
- data/app/views/carrier/messages/create.js.erb +1 -0
- data/app/views/carrier/messages/expanded.js.erb +1 -0
- data/app/views/carrier/messages/index.html.erb +9 -0
- data/app/views/carrier/messages/new.html.erb +7 -0
- data/app/views/carrier/messages/new.js.erb +1 -0
- data/app/views/carrier/messages/reply.js.erb +6 -0
- data/app/views/carrier/messages/rich/_multiselect.html.erb +18 -0
- data/app/views/carrier/messages/rich/_recipients.html.erb +6 -0
- data/app/views/carrier/messages/show.html.erb +35 -0
- data/app/views/carrier/messages/simple/_autocomplete.html.erb +45 -0
- data/app/views/carrier/messages/simple/_autocomplete_includes.html.erb +7 -0
- data/app/views/carrier/messages/simple/_recipients.html.erb +3 -0
- data/app/views/layouts/carrier/application.html.erb +16 -0
- data/app/views/partials/_error_messages_for.html.erb +9 -0
- data/carrier.gemspec +331 -0
- data/config/locales/carrier.en.yml +48 -0
- data/config/locales/carrier.ru.yml +48 -0
- data/config/routes.rb +24 -0
- data/db/migrate/001_create_messages.rb +26 -0
- data/db/migrate/002_create_chains.rb +34 -0
- data/db/migrate/003_create_read_marks +16 -0
- data/lib/carrier.rb +22 -0
- data/lib/carrier/configuration.rb +35 -0
- data/lib/carrier/configuration/models.rb +31 -0
- data/lib/carrier/configuration/ui.rb +28 -0
- data/lib/carrier/rails.rb +5 -0
- data/lib/carrier/rails/engine.rb +50 -0
- data/lib/carrier/rails/helpers.rb +30 -0
- data/lib/tasks/carrier_tasks.rake +4 -0
- data/script/rails +6 -0
- data/spec/carrier/app/controllers/application_controller_spec.rb +1 -0
- data/spec/carrier/app/models/message_scopes_spec.rb +25 -0
- data/spec/carrier/app/models/message_spec.rb +38 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/javascripts/default.js +2 -0
- data/spec/dummy/app/assets/javascripts/jquery.js +16 -0
- data/spec/dummy/app/assets/javascripts/jquery_ujs.js +169 -0
- data/spec/dummy/app/assets/javascripts/posts.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/assets/stylesheets/default.css +4 -0
- data/spec/dummy/app/assets/stylesheets/posts.css +4 -0
- data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/default_controller.rb +5 -0
- data/spec/dummy/app/controllers/posts_controller.rb +83 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/default_helper.rb +2 -0
- data/spec/dummy/app/helpers/posts_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/post.rb +2 -0
- data/spec/dummy/app/models/user.rb +15 -0
- data/spec/dummy/app/views/default/index.html.erb +4 -0
- data/spec/dummy/app/views/devise/confirmations/new.html.erb +12 -0
- data/spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/spec/dummy/app/views/devise/passwords/edit.html.erb +16 -0
- data/spec/dummy/app/views/devise/passwords/new.html.erb +12 -0
- data/spec/dummy/app/views/devise/registrations/edit.html.erb +25 -0
- data/spec/dummy/app/views/devise/registrations/new.html.erb +18 -0
- data/spec/dummy/app/views/devise/sessions/new.html.erb +17 -0
- data/spec/dummy/app/views/devise/shared/_links.erb +25 -0
- data/spec/dummy/app/views/devise/unlocks/new.html.erb +12 -0
- data/spec/dummy/app/views/layouts/application.html.erb +16 -0
- data/spec/dummy/app/views/posts/_form.html.erb +17 -0
- data/spec/dummy/app/views/posts/edit.html.erb +6 -0
- data/spec/dummy/app/views/posts/index.html.erb +21 -0
- data/spec/dummy/app/views/posts/new.html.erb +5 -0
- data/spec/dummy/app/views/posts/show.html.erb +5 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +51 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +26 -0
- data/spec/dummy/config/database_mysql.yml +29 -0
- data/spec/dummy/config/database_pgsql.yml +35 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +24 -0
- data/spec/dummy/config/environments/production.rb +52 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/carrier.rb +3 -0
- data/spec/dummy/config/initializers/devise.rb +204 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/devise.en.yml +53 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +15 -0
- data/spec/dummy/db/migrate/007_devise_create_users.rb +29 -0
- data/spec/dummy/db/migrate/20110130210000_create_read_marks.rb +16 -0
- data/spec/dummy/db/migrate/20110814064637_create_posts.rb +8 -0
- data/spec/dummy/db/migrate/20110814164228_create_messages.rb +26 -0
- data/spec/dummy/db/migrate/20110814164229_create_chains.rb +34 -0
- data/spec/dummy/db/schema.rb +79 -0
- data/spec/dummy/db/seeds.rb +26 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/test/fixtures/posts.yml +11 -0
- data/spec/dummy/test/fixtures/users.yml +11 -0
- data/spec/dummy/test/functional/default_controller_test.rb +9 -0
- data/spec/dummy/test/functional/posts_controller_test.rb +49 -0
- data/spec/dummy/test/unit/helpers/default_helper_test.rb +4 -0
- data/spec/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
- data/spec/dummy/test/unit/post_test.rb +7 -0
- data/spec/dummy/test/unit/user_test.rb +7 -0
- data/spec/dummy_spec_helper.rb +70 -0
- data/spec/integration/carrier_spec.rb +71 -0
- data/spec/requests/main_spec.rb +31 -0
- data/spec/support/controller_macros.rb +10 -0
- data/spec/support/factories.rb +47 -0
- data/spec/support/rspec_helpers.rb +22 -0
- data/test/helper.rb +18 -0
- data/test/test_carrier.rb +7 -0
- 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
|
+
|
data/config/routes.rb
ADDED
@@ -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
|
+
|
data/lib/carrier.rb
ADDED
@@ -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,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
|
data/script/rails
ADDED
@@ -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 @@
|
|
1
|
+
#
|
@@ -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
|