fetty-generators 1.7.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/README.rdoc +42 -36
- data/Rakefile +1 -3
- data/lib/generators/fetty.rb +160 -10
- data/lib/generators/fetty/authentication/USAGE +4 -0
- data/lib/generators/fetty/authentication/authentication_generator.rb +171 -0
- data/lib/generators/fetty/authentication/templates/controllers/reset_passwords_controller.rb +45 -0
- data/lib/generators/fetty/authentication/templates/controllers/sessions_controller.rb +30 -0
- data/lib/generators/fetty/authentication/templates/controllers/users_controller.rb +78 -0
- data/lib/generators/fetty/authentication/templates/helpers/reset_passwords_helper.rb +2 -0
- data/lib/generators/fetty/authentication/templates/helpers/sessions_helper.rb +2 -0
- data/lib/generators/fetty/authentication/templates/helpers/users_helper.rb +2 -0
- data/lib/generators/fetty/authentication/templates/lib/sessions_authentication.rb +53 -0
- data/lib/generators/fetty/authentication/templates/lib/users_authentication.rb +110 -0
- data/lib/generators/fetty/authentication/templates/mailers/setup_mail.rb +11 -0
- data/lib/generators/fetty/authentication/templates/mailers/user_mailer.rb +14 -0
- data/lib/generators/fetty/authentication/templates/models/active_record/create_users.rb +17 -0
- data/lib/generators/fetty/authentication/templates/models/active_record/user.rb +15 -0
- data/lib/generators/fetty/authentication/templates/models/mongoid/user.rb +23 -0
- data/lib/generators/fetty/authentication/templates/spec/controllers/reset_passwords_controller_spec.rb +93 -0
- data/lib/generators/fetty/authentication/templates/spec/controllers/sessions_controller_spec.rb +61 -0
- data/lib/generators/fetty/authentication/templates/spec/controllers/users_controller_spec.rb +158 -0
- data/lib/generators/fetty/authentication/templates/spec/models/user_spec.rb +108 -0
- data/lib/generators/fetty/authentication/templates/spec/routing/reset_passwords_routing_spec.rb +21 -0
- data/lib/generators/fetty/authentication/templates/spec/routing/sessions_routing_spec.rb +17 -0
- data/lib/generators/fetty/authentication/templates/spec/routing/users_routing_spec.rb +37 -0
- data/lib/generators/fetty/authentication/templates/spec/support/user_factories.rb +6 -0
- data/lib/generators/fetty/authentication/templates/views/layouts/application.html.erb +33 -0
- data/lib/generators/fetty/authentication/templates/views/reset_passwords/edit.html.erb +19 -0
- data/lib/generators/fetty/authentication/templates/views/reset_passwords/new.html.erb +14 -0
- data/lib/generators/fetty/authentication/templates/views/sessions/new.html.erb +22 -0
- data/lib/generators/fetty/authentication/templates/views/user_mailer/user_activation.text.erb +4 -0
- data/lib/generators/fetty/authentication/templates/views/user_mailer/user_forgot_password.text.erb +7 -0
- data/lib/generators/fetty/authentication/templates/views/users/_table.html.erb +23 -0
- data/lib/generators/fetty/authentication/templates/views/users/edit.html.erb +21 -0
- data/lib/generators/fetty/authentication/templates/views/users/index.html.erb +7 -0
- data/lib/generators/fetty/authentication/templates/views/users/index.js.erb +1 -0
- data/lib/generators/fetty/authentication/templates/views/users/new.html.erb +23 -0
- data/lib/generators/fetty/authentication/templates/views/users/show.html.erb +19 -0
- data/lib/generators/fetty/messages/USAGE +4 -0
- data/lib/generators/fetty/messages/messages_generator.rb +136 -0
- data/lib/generators/fetty/messages/templates/assets/javascripts/jquery.tokeninput.js +718 -0
- data/lib/generators/fetty/messages/templates/assets/javascripts/messages.js +19 -0
- data/lib/generators/fetty/messages/templates/assets/stylesheets/messages.css +87 -0
- data/lib/generators/fetty/messages/templates/assets/stylesheets/token-input-facebook.css +122 -0
- data/lib/generators/fetty/messages/templates/controllers/messages_controller.rb +109 -0
- data/lib/generators/fetty/messages/templates/helpers/messages_helper.rb +2 -0
- data/lib/generators/fetty/messages/templates/lib/users_messages.rb +67 -0
- data/lib/generators/fetty/messages/templates/models/active_record/create_messages.rb +24 -0
- data/lib/generators/fetty/messages/templates/models/active_record/message.rb +67 -0
- data/lib/generators/fetty/messages/templates/models/mongoid/message.rb +81 -0
- data/lib/generators/fetty/messages/templates/spec/controllers/messages_controller_spec.rb +78 -0
- data/lib/generators/fetty/messages/templates/spec/models/message_spec.rb +53 -0
- data/lib/generators/fetty/messages/templates/spec/routing/messages_routing_spec.rb +61 -0
- data/lib/generators/fetty/messages/templates/spec/support/message_factories.rb +8 -0
- data/lib/generators/fetty/messages/templates/views/_head.html.erb +20 -0
- data/lib/generators/fetty/messages/templates/views/_messages.html.erb +56 -0
- data/lib/generators/fetty/messages/templates/views/_tabs_panel.html.erb +11 -0
- data/lib/generators/fetty/messages/templates/views/index.html.erb +10 -0
- data/lib/generators/fetty/messages/templates/views/index.js.erb +1 -0
- data/lib/generators/fetty/messages/templates/views/new.html.erb +26 -0
- data/lib/generators/fetty/messages/templates/views/show.html.erb +35 -0
- data/lib/generators/fetty/scaffold/USAGE +2 -52
- data/lib/generators/fetty/scaffold/scaffold_generator.rb +96 -329
- data/lib/generators/fetty/scaffold/templates/controllers/active_record/controller.rb +60 -0
- data/lib/generators/fetty/scaffold/templates/controllers/mongoid/controller.rb +60 -0
- data/lib/generators/fetty/scaffold/templates/helpers/helper.rb +2 -0
- data/lib/generators/fetty/scaffold/templates/models/active_record/migration.rb +16 -0
- data/lib/generators/fetty/scaffold/templates/models/active_record/model.rb +10 -0
- data/lib/generators/fetty/scaffold/templates/models/mongoid/model.rb +16 -0
- data/lib/generators/fetty/scaffold/templates/test/rspec/controller.rb +98 -0
- data/lib/generators/fetty/scaffold/templates/test/rspec/factories.rb +26 -0
- data/lib/generators/fetty/scaffold/templates/test/rspec/helper.rb +15 -0
- data/lib/generators/fetty/scaffold/templates/test/rspec/model.rb +9 -0
- data/lib/generators/fetty/scaffold/templates/test/rspec/request.rb +11 -0
- data/lib/generators/fetty/scaffold/templates/test/rspec/routing.rb +41 -0
- data/lib/generators/fetty/scaffold/templates/test/test_unit/controller.rb +62 -0
- data/lib/generators/fetty/scaffold/templates/{fixtures.yml → test/test_unit/fixtures.yml} +2 -0
- data/lib/generators/fetty/scaffold/templates/test/test_unit/helper.rb +4 -0
- data/lib/generators/fetty/scaffold/templates/test/test_unit/model.rb +7 -0
- data/lib/generators/fetty/scaffold/templates/views/_form.html.erb +20 -0
- data/lib/generators/fetty/scaffold/templates/views/_table.html.erb +48 -0
- data/lib/generators/fetty/scaffold/templates/views/edit.html.erb +13 -0
- data/lib/generators/fetty/scaffold/templates/views/index.html.erb +15 -0
- data/lib/generators/fetty/scaffold/templates/views/{erb/index.js.erb → index.js.erb} +0 -0
- data/lib/generators/fetty/scaffold/templates/views/new.html.erb +9 -0
- data/lib/generators/fetty/scaffold/templates/views/show.html.erb +28 -0
- data/lib/generators/fetty/setup/USAGE +3 -20
- data/lib/generators/fetty/setup/setup_generator.rb +122 -61
- data/lib/generators/fetty/setup/templates/ability.rb +0 -0
- data/lib/generators/fetty/setup/templates/ckeditor.rb +54 -0
- data/lib/generators/fetty/setup/templates/ckeditor.tar.gz +0 -0
- data/lib/generators/fetty/setup/templates/escape_utils.rb +7 -0
- data/lib/generators/fetty/setup/templates/file_uploader.rb +15 -0
- data/lib/generators/fetty/setup/templates/image_uploader.rb +48 -0
- data/lib/generators/fetty/setup/templates/spec_helper.rb +44 -0
- data/lib/generators/fetty/views/USAGE +5 -0
- data/lib/generators/fetty/{layout/templates/stylesheet.css → views/templates/application.css} +184 -166
- data/lib/generators/fetty/views/templates/application.html.erb +23 -0
- data/lib/generators/fetty/{layout → views}/templates/application.js +0 -0
- data/lib/generators/fetty/views/templates/application_helper.rb +10 -0
- data/lib/generators/fetty/views/templates/down_arrow.gif +0 -0
- data/lib/generators/fetty/{layout → views}/templates/error_messages_helper.rb +0 -0
- data/lib/generators/fetty/{layout → views}/templates/layout_helper.rb +0 -0
- data/lib/generators/fetty/views/templates/up_arrow.gif +0 -0
- data/lib/generators/fetty/views/views_generator.rb +51 -0
- data/lib/generators/scaffold.rb +204 -0
- metadata +126 -111
- data/LICENSE +0 -20
- data/lib/generators/fetty/layout/USAGE +0 -26
- data/lib/generators/fetty/layout/layout_generator.rb +0 -44
- data/lib/generators/fetty/layout/templates/layout.html.erb +0 -32
- data/lib/generators/fetty/layout/templates/layout.html.haml +0 -34
- data/lib/generators/fetty/layout/templates/no-devise-links-layout.html.erb +0 -23
- data/lib/generators/fetty/layout/templates/no-devise-links-layout.html.haml +0 -23
- data/lib/generators/fetty/layout/templates/stylesheet.sass +0 -163
- data/lib/generators/fetty/scaffold/templates/actions/create.rb +0 -8
- data/lib/generators/fetty/scaffold/templates/actions/destroy.rb +0 -5
- data/lib/generators/fetty/scaffold/templates/actions/edit.rb +0 -3
- data/lib/generators/fetty/scaffold/templates/actions/index.rb +0 -10
- data/lib/generators/fetty/scaffold/templates/actions/new.rb +0 -3
- data/lib/generators/fetty/scaffold/templates/actions/show.rb +0 -3
- data/lib/generators/fetty/scaffold/templates/actions/update.rb +0 -8
- data/lib/generators/fetty/scaffold/templates/controller.rb +0 -7
- data/lib/generators/fetty/scaffold/templates/helper.rb +0 -2
- data/lib/generators/fetty/scaffold/templates/migration.rb +0 -16
- data/lib/generators/fetty/scaffold/templates/model.rb +0 -7
- data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/create.rb +0 -11
- data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/destroy.rb +0 -6
- data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/edit.rb +0 -4
- data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/index.rb +0 -4
- data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/new.rb +0 -4
- data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/show.rb +0 -4
- data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/update.rb +0 -11
- data/lib/generators/fetty/scaffold/templates/tests/rspec/controller.rb +0 -8
- data/lib/generators/fetty/scaffold/templates/tests/rspec/model.rb +0 -7
- data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/create.rb +0 -13
- data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/destroy.rb +0 -8
- data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/edit.rb +0 -6
- data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/index.rb +0 -6
- data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/new.rb +0 -6
- data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/show.rb +0 -6
- data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/update.rb +0 -13
- data/lib/generators/fetty/scaffold/templates/tests/shoulda/controller.rb +0 -5
- data/lib/generators/fetty/scaffold/templates/tests/shoulda/model.rb +0 -7
- data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/create.rb +0 -11
- data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/destroy.rb +0 -6
- data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/edit.rb +0 -4
- data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/index.rb +0 -4
- data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/new.rb +0 -4
- data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/show.rb +0 -4
- data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/update.rb +0 -11
- data/lib/generators/fetty/scaffold/templates/tests/testunit/controller.rb +0 -5
- data/lib/generators/fetty/scaffold/templates/tests/testunit/model.rb +0 -7
- data/lib/generators/fetty/scaffold/templates/views/erb/_form.html.erb +0 -22
- data/lib/generators/fetty/scaffold/templates/views/erb/_table.html.erb +0 -50
- data/lib/generators/fetty/scaffold/templates/views/erb/edit.html.erb +0 -12
- data/lib/generators/fetty/scaffold/templates/views/erb/index.html.erb +0 -13
- data/lib/generators/fetty/scaffold/templates/views/erb/new.html.erb +0 -9
- data/lib/generators/fetty/scaffold/templates/views/erb/show.html.erb +0 -26
- data/lib/generators/fetty/scaffold/templates/views/haml/_form.html.haml +0 -8
- data/lib/generators/fetty/scaffold/templates/views/haml/_table.html.haml +0 -33
- data/lib/generators/fetty/scaffold/templates/views/haml/edit.html.haml +0 -14
- data/lib/generators/fetty/scaffold/templates/views/haml/index.html.haml +0 -12
- data/lib/generators/fetty/scaffold/templates/views/haml/index.js.haml +0 -1
- data/lib/generators/fetty/scaffold/templates/views/haml/new.html.haml +0 -8
- data/lib/generators/fetty/scaffold/templates/views/haml/show.html.haml +0 -23
@@ -0,0 +1,81 @@
|
|
1
|
+
class Message
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
include Mongoid::Ancestry
|
5
|
+
|
6
|
+
has_ancestry
|
7
|
+
|
8
|
+
belongs_to :user
|
9
|
+
|
10
|
+
field :user_id, :type => String
|
11
|
+
field :sender_id, :type => String
|
12
|
+
field :recipient_id, :type => String
|
13
|
+
field :subject_id, :type => String
|
14
|
+
field :subject, :type => String
|
15
|
+
field :content, :type => String
|
16
|
+
field :opened, :type => Boolean, :default => false
|
17
|
+
field :deleted, :type => Boolean, :default => false
|
18
|
+
field :copies, :type => Boolean, :default => false
|
19
|
+
field :ancestry, :type => String
|
20
|
+
|
21
|
+
validates_presence_of :user_id, :sender_id, :recipient_id, :subject_id, :subject, :content
|
22
|
+
|
23
|
+
attr_accessible :user_id,
|
24
|
+
:sender_id,
|
25
|
+
:recipient_id,
|
26
|
+
:subject_id,
|
27
|
+
:subject,
|
28
|
+
:content,
|
29
|
+
:opened,
|
30
|
+
:deleted,
|
31
|
+
:copies,
|
32
|
+
:parent_id
|
33
|
+
|
34
|
+
def self.sequence_subject_id
|
35
|
+
id = self.maximum(:subject_id).to_i
|
36
|
+
id = 0 if id.nil?
|
37
|
+
id += 1
|
38
|
+
id
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.next_parent_id(parent_id)
|
42
|
+
parent_id = parent_id.to_i - 1
|
43
|
+
if self.where(:id => parent_id).empty?
|
44
|
+
parent_id = nil
|
45
|
+
end
|
46
|
+
parent_id
|
47
|
+
end
|
48
|
+
|
49
|
+
def read?
|
50
|
+
self.opened?
|
51
|
+
end
|
52
|
+
|
53
|
+
def mark_as_read
|
54
|
+
self.update_attributes!(:opened => true)
|
55
|
+
end
|
56
|
+
|
57
|
+
def mark_as_unread
|
58
|
+
self.update_attributes!(:opened => false)
|
59
|
+
end
|
60
|
+
|
61
|
+
def delete
|
62
|
+
unless self.deleted?
|
63
|
+
self.update_attributes!(:deleted => true)
|
64
|
+
else
|
65
|
+
self.destroy
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def undelete
|
70
|
+
self.update_attributes!(:deleted => false)
|
71
|
+
end
|
72
|
+
|
73
|
+
def from
|
74
|
+
User.find_by_id(self.sender_id)
|
75
|
+
end
|
76
|
+
|
77
|
+
def to
|
78
|
+
User.find_by_id(self.recipient_id)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MessagesController do
|
4
|
+
before(:each) do
|
5
|
+
stub_authenticate_user
|
6
|
+
@user = Factory(:user)
|
7
|
+
controller.stub(:current_user).and_return(@user)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "GET index" do
|
11
|
+
it "should render index template" do
|
12
|
+
get :index
|
13
|
+
response.should render_template(:index)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "GET new" do
|
18
|
+
it "should render new message template" do
|
19
|
+
get :new
|
20
|
+
response.should render_template(:new)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "POST create" do
|
25
|
+
describe "with valid params" do
|
26
|
+
it "should create message and redirect to index page" do
|
27
|
+
post :create, :user_tokens => @user.id.to_s, :subject => "testing", :content => "test message!!!"
|
28
|
+
change{Message.count}.from(0).to(2)
|
29
|
+
flash[:notice].should_not be_nil
|
30
|
+
response.should redirect_to(box_messages_path(:inbox))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "with invalid params" do
|
35
|
+
it "should not create message and re-render the new template" do
|
36
|
+
post :create
|
37
|
+
flash[:alert].should_not be_nil
|
38
|
+
response.should render_template(:new)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "GET show" do
|
44
|
+
it "should assigns @messages" do
|
45
|
+
# pending
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "GET token" do
|
50
|
+
it "should respond json format" do
|
51
|
+
# pending
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "PUT update" do
|
56
|
+
|
57
|
+
describe "with valid params" do
|
58
|
+
it "should update message Read, Unread, Delete, Undelete" do
|
59
|
+
# pending
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "with invalid params" do
|
64
|
+
it "should update message Read, Unread, Delete, Undelete" do
|
65
|
+
# pending
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "POST empty" do
|
71
|
+
describe "with valid params" do
|
72
|
+
it "should delete all messages" do
|
73
|
+
# pending
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Message do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@message = Factory.build(:message)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be valid" do
|
10
|
+
@message.should be_valid
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have error on user_id if nil" do
|
14
|
+
@message.user_id = nil
|
15
|
+
@message.should have(1).error_on(:user_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have error on sender_id if nil" do
|
19
|
+
@message.sender_id = nil
|
20
|
+
@message.should have(1).error_on(:sender_id)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have error on recipient_id if nil" do
|
24
|
+
@message.recipient_id = nil
|
25
|
+
@message.should have(1).error_on(:recipient_id)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have error on subject_id if nil" do
|
29
|
+
@message.subject_id = nil
|
30
|
+
@message.should have(1).error_on(:subject_id)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have error on subject if nil" do
|
34
|
+
@message.subject = nil
|
35
|
+
@message.should have(1).error_on(:subject)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have error on content if nil" do
|
39
|
+
@message.content = nil
|
40
|
+
@message.should have(1).error_on(:content)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe Message, "Class Methods" do
|
46
|
+
it "subject id should increment by 1" do
|
47
|
+
change{Message.sequence_subject_id}.from(0).to(1)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe Message, "Instance Methods" do
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MessagesController do
|
4
|
+
describe "routing" do
|
5
|
+
it "routes to #index" do
|
6
|
+
get("/messages").should route_to("messages#index")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "routes to #inbox" do
|
10
|
+
get("/messages/inbox").should route_to("messages#index", :messagebox => "inbox")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "routes to #outbox" do
|
14
|
+
get("/messages/outbox").should route_to("messages#index", :messagebox => "outbox")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "routes to #trash" do
|
18
|
+
get("/messages/trash").should route_to("messages#index", :messagebox => "trash")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "routes to #show_inbox" do
|
22
|
+
get("/messages/inbox/show/1").should route_to("messages#show", :messagebox => "inbox", :id => "1")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "routes to #show_outbox" do
|
26
|
+
get("/messages/outbox/show/1").should route_to("messages#show", :messagebox => "outbox", :id => "1")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "routes to #show_trash" do
|
30
|
+
get("/messages/trash/show/1").should route_to("messages#show", :messagebox => "trash", :id => "1")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "routes to #new" do
|
34
|
+
get("/messages/new").should route_to("messages#new")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "routes to #create" do
|
38
|
+
post("/messages").should route_to("messages#create")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "routes to #update" do
|
42
|
+
put("/messages").should route_to("messages#update")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "routes to #token" do
|
46
|
+
get("/messages/token").should route_to("messages#token")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "routes to #empty_inbox" do
|
50
|
+
post("/messages/empty/inbox").should route_to("messages#empty", :messagebox => "inbox")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "routes to #empty_outbox" do
|
54
|
+
post("/messages/empty/outbox").should route_to("messages#empty", :messagebox => "outbox")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "routes to #empty_trash" do
|
58
|
+
post("/messages/empty/trash").should route_to("messages#empty", :messagebox => "trash")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% content_for :head do %>
|
2
|
+
|
3
|
+
<%= stylesheet_link_tag "messages" %>
|
4
|
+
<%= javascript_include_tag "messages" %>
|
5
|
+
|
6
|
+
<%- if controller.action_name == "new" -%>
|
7
|
+
<%= stylesheet_link_tag "token-input-facebook" %>
|
8
|
+
<%= javascript_include_tag "jquery.tokeninput" %>
|
9
|
+
<script type="text/javascript">
|
10
|
+
|
11
|
+
$(document).ready(function() {
|
12
|
+
$("#user_tokens").tokenInput("/messages/token.json", {
|
13
|
+
crossDomain: false,
|
14
|
+
theme: "facebook"
|
15
|
+
});
|
16
|
+
});
|
17
|
+
|
18
|
+
</script>
|
19
|
+
<%- end -%>
|
20
|
+
<% end %>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<%= form_tag messages_path, :method => :put, :remote => true do %>
|
2
|
+
<table class="pretty" width="100%">
|
3
|
+
<tbody>
|
4
|
+
<tr>
|
5
|
+
<td class="middle">
|
6
|
+
<input type="checkbox" class="checkall" id="checkbox" name="checkbox">
|
7
|
+
</td>
|
8
|
+
<td colspan="3">
|
9
|
+
<%= select_tag "option", options_for_select(@options) %>
|
10
|
+
<%= submit_tag "Apply to Selected" %>
|
11
|
+
<%= link_to "Empty #{@messagebox}", empty_messages_path(@messagebox), :confirm => "Are you sure want to delete all?", :method => :post %>
|
12
|
+
<%= hidden_field_tag :messagebox, @messagebox %>
|
13
|
+
</td>
|
14
|
+
</tr>
|
15
|
+
<!-- this will render the messages -->
|
16
|
+
<%-
|
17
|
+
x = 0
|
18
|
+
@messages.reverse_each do |message|
|
19
|
+
convTree = message.root.subtree
|
20
|
+
|
21
|
+
flag = convTree.where(:copies => false).empty?
|
22
|
+
display_names = convTree.collect do |c|
|
23
|
+
unless flag
|
24
|
+
c.copies ? "me" : c.from.username
|
25
|
+
else
|
26
|
+
c.to.username
|
27
|
+
end
|
28
|
+
end.uniq.join(", ").concat( convTree.count > 1 ? " (#{convTree.count})" : "")
|
29
|
+
|
30
|
+
style = ""
|
31
|
+
flag = convTree.where(:copies => false, :opened => false).empty?
|
32
|
+
unless flag
|
33
|
+
style = "unread "
|
34
|
+
end
|
35
|
+
style << "alt" if ((x += 1) % 2 == 0)
|
36
|
+
|
37
|
+
title = convTree.last.created_at.strftime("%a, %b %d, %Y at %I:%M %p")
|
38
|
+
created_at = convTree.last.created_at.strftime( ((convTree.last.created_at < 1.days.ago) ? "%b %d, %Y" : "%I:%M %p"))
|
39
|
+
-%>
|
40
|
+
<tr class="<%= style -%>">
|
41
|
+
<td><%= check_box_tag "[messages][]", message.id %></td>
|
42
|
+
<td><%= display_names %></td>
|
43
|
+
<td><%= link_to message.subject, show_messages_path(@messagebox, message.id) %></td>
|
44
|
+
<td title='<%= title %>'><%= created_at %></td>
|
45
|
+
</tr>
|
46
|
+
<%- end -%>
|
47
|
+
<!-- END MESSAGES -->
|
48
|
+
<tr>
|
49
|
+
<td colspan="4"><%= paginate @messages %></td>
|
50
|
+
</tr>
|
51
|
+
</tbody>
|
52
|
+
</table>
|
53
|
+
<%- end -%>
|
54
|
+
<p>
|
55
|
+
<%= link_to "Compose New Message", new_message_path %>
|
56
|
+
</p>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<ul class="tabs">
|
2
|
+
<li class=<%= "active" if @messagebox == "inbox" %>>
|
3
|
+
<%= link_to "Inbox", box_messages_path(:inbox) %>
|
4
|
+
</li>
|
5
|
+
<li class=<%= "active" if @messagebox == "outbox" %>>
|
6
|
+
<%= link_to "Outbox", box_messages_path(:outbox) %>
|
7
|
+
</li>
|
8
|
+
<li class=<%= "active" if @messagebox == "trash" %>>
|
9
|
+
<%= link_to "Trash", box_messages_path(:trash) %>
|
10
|
+
</li>
|
11
|
+
</ul>
|
@@ -0,0 +1 @@
|
|
1
|
+
$("#tabs-messages").html("<%= escape_javascript(render("messages")) %>");
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<% title "New Message" %>
|
2
|
+
|
3
|
+
<%= render "head" %>
|
4
|
+
|
5
|
+
<div>
|
6
|
+
<%= render :partial => "tabs_panel" %>
|
7
|
+
<div id="tabs-messages" style="padding-top:50px;">
|
8
|
+
<%= form_tag messages_path, :method => :post do %>
|
9
|
+
<p>
|
10
|
+
<%= label_tag :user_tokens, "User" %><br />
|
11
|
+
<%= text_field_tag :user_tokens %>
|
12
|
+
</p>
|
13
|
+
<p>
|
14
|
+
<%= label_tag :subject, "Subject" %><br />
|
15
|
+
<%= text_field_tag :subject, nil, :size => 75 %>
|
16
|
+
</p>
|
17
|
+
<p>
|
18
|
+
<%= label_tag :content, "Messages" %><br />
|
19
|
+
<%= text_area_tag :content, nil, :rows => 20, :cols => 55 %>
|
20
|
+
</p>
|
21
|
+
<p>
|
22
|
+
<%= submit_tag "Send" %>
|
23
|
+
</p>
|
24
|
+
<% end %>
|
25
|
+
</div>
|
26
|
+
</div>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<% title "Messages" %>
|
2
|
+
|
3
|
+
<%= render "head" %>
|
4
|
+
|
5
|
+
<div>
|
6
|
+
<%= render :partial => "tabs_panel" %>
|
7
|
+
<div id="tabs-messages" style="padding-top:50px;">
|
8
|
+
<%= form_tag messages_path, :method => :post do %>
|
9
|
+
<h3><%= @messages.last.subject %></h3>
|
10
|
+
|
11
|
+
<% for msg in @messages %>
|
12
|
+
<div class="message">
|
13
|
+
<div class="created_at"><%= msg.created_at.strftime("%B %d, %Y") %></div>
|
14
|
+
<div class="content">
|
15
|
+
<strong><%= msg.from.username %></strong><br />
|
16
|
+
<%= msg.content %>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<p>
|
22
|
+
<%= label_tag :content, "Reply Message" %><br />
|
23
|
+
<%= text_area_tag :content, nil, :rows => 20, :cols => 55 %>
|
24
|
+
</p>
|
25
|
+
<p>
|
26
|
+
<%= submit_tag "Reply" %>
|
27
|
+
</p>
|
28
|
+
<%= hidden_field_tag :user_tokens, @user_tokens %>
|
29
|
+
<%= hidden_field_tag :subject, @messages.last.subject %>
|
30
|
+
<%= hidden_field_tag :subject_id, @messages.last.subject_id %>
|
31
|
+
<%= hidden_field_tag :parent_id, @parent_id %>
|
32
|
+
<% end -%>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
|