aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/inboxes/base_controller.rb3
-rw-r--r--app/controllers/inboxes/discussions_controller.rb (renamed from app/controllers/discussions_controller.rb)18
-rw-r--r--app/controllers/inboxes/messages_controller.rb (renamed from app/controllers/messages_controller.rb)2
-rw-r--r--app/controllers/inboxes/speakers_controller.rb (renamed from app/controllers/speakers_controller.rb)2
-rw-r--r--app/helpers/inboxes_helper.rb9
-rw-r--r--app/views/inboxes/discussions/_form.html.haml (renamed from app/views/discussions/_form.html.haml)0
-rw-r--r--app/views/inboxes/discussions/index.html.haml (renamed from app/views/discussions/index.html.haml)3
-rw-r--r--app/views/inboxes/discussions/new.html.haml (renamed from app/views/discussions/new.html.haml)0
-rw-r--r--app/views/inboxes/discussions/show.html.haml (renamed from app/views/discussions/show.html.haml)22
-rw-r--r--app/views/inboxes/messages/_form.html.haml (renamed from app/views/messages/_form.html.haml)0
-rw-r--r--app/views/inboxes/messages/_message.html.haml8
11 files changed, 40 insertions, 27 deletions
diff --git a/app/controllers/inboxes/base_controller.rb b/app/controllers/inboxes/base_controller.rb
new file mode 100644
index 0000000..54767d2
--- /dev/null
+++ b/app/controllers/inboxes/base_controller.rb
@@ -0,0 +1,3 @@
+class Inboxes::BaseController < ApplicationController
+
+end \ No newline at end of file
diff --git a/app/controllers/discussions_controller.rb b/app/controllers/inboxes/discussions_controller.rb
index 5e769fb..d901a80 100644
--- a/app/controllers/discussions_controller.rb
+++ b/app/controllers/inboxes/discussions_controller.rb
@@ -1,7 +1,6 @@
-class DiscussionsController < ApplicationController
+class Inboxes::DiscussionsController < Inboxes::BaseController
before_filter :authenticate_user!
- # before_filter :check_permissions, :only => :show
-
+ before_filter :init_and_check_permissions, :only => :show
before_filter :load_and_check_discussion_recipient, :only => [:create, :new]
def index
@@ -11,10 +10,7 @@ class DiscussionsController < ApplicationController
# GET /discussions/1
# GET /discussions/1.json
def show
- @discussion = Discussion.includes(:messages, :speakers).find(params[:id])
- redirect_to discussions_url, :notice => t("inboxes.discussions.can_not_participate") unless @discussion.can_participate?(current_user)
-
- # @discussion.mark_as_read_for(current_user)
+ @discussion.mark_as_read_for(current_user)
end
# GET /discussions/new
@@ -44,6 +40,11 @@ class DiscussionsController < ApplicationController
private
+ def init_and_check_permissions
+ @discussion = Discussion.includes(:messages, :speakers).find(params[:id])
+ redirect_to discussions_url, :notice => t("inboxes.discussions.can_not_participate") unless @discussion.can_participate?(current_user)
+ end
+
def load_and_check_discussion_recipient
# initializing model fir new and create actions
@discussion = Discussion.new((params[:discussion] ? params[:discussion] : {}))
@@ -63,5 +64,4 @@ class DiscussionsController < ApplicationController
end
end
end
-
-end
+end \ No newline at end of file
diff --git a/app/controllers/messages_controller.rb b/app/controllers/inboxes/messages_controller.rb
index 7baf8df..1c63221 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/inboxes/messages_controller.rb
@@ -1,4 +1,4 @@
-class MessagesController < ApplicationController
+class Inboxes::MessagesController < Inboxes::BaseController
def create
@discussion = Discussion.find(params[:discussion_id])
diff --git a/app/controllers/speakers_controller.rb b/app/controllers/inboxes/speakers_controller.rb
index db90dbe..035df98 100644
--- a/app/controllers/speakers_controller.rb
+++ b/app/controllers/inboxes/speakers_controller.rb
@@ -1,4 +1,4 @@
-class SpeakersController < ApplicationController
+class Inboxes::SpeakersController < Inboxes::BaseController
before_filter :init_and_check_permissions
def create
diff --git a/app/helpers/inboxes_helper.rb b/app/helpers/inboxes_helper.rb
new file mode 100644
index 0000000..87bb763
--- /dev/null
+++ b/app/helpers/inboxes_helper.rb
@@ -0,0 +1,9 @@
+require 'net/http'
+module InboxesHelper
+ def inboxes_faye_broadcast(channel, &block)
+ message = {:channel => channel, :data => capture(&block), :ext => {:auth_token => defined?(FAYE_TOKEN) ? FAYE_TOKEN : ""}}
+ uri = URI.parse("http://#{Inboxes::config.faye_host}:#{Inboxes::config.faye_port}/faye")
+ # Rails.logger.info "Faye URL: #{uri}"
+ res = Net::HTTP.post_form(uri, :message => message.to_json)
+ end
+end \ No newline at end of file
diff --git a/app/views/discussions/_form.html.haml b/app/views/inboxes/discussions/_form.html.haml
index 303f0bb..303f0bb 100644
--- a/app/views/discussions/_form.html.haml
+++ b/app/views/inboxes/discussions/_form.html.haml
diff --git a/app/views/discussions/index.html.haml b/app/views/inboxes/discussions/index.html.haml
index 8060254..7c4de6e 100644
--- a/app/views/discussions/index.html.haml
+++ b/app/views/inboxes/discussions/index.html.haml
@@ -1,5 +1,6 @@
%h1 Discussions list
-
+%p
+ Unread messages:
%table
%tr
%th Last message
diff --git a/app/views/discussions/new.html.haml b/app/views/inboxes/discussions/new.html.haml
index 6bcf481..6bcf481 100644
--- a/app/views/discussions/new.html.haml
+++ b/app/views/inboxes/discussions/new.html.haml
diff --git a/app/views/discussions/show.html.haml b/app/views/inboxes/discussions/show.html.haml
index e25d0a2..a910b51 100644
--- a/app/views/discussions/show.html.haml
+++ b/app/views/inboxes/discussions/show.html.haml
@@ -1,3 +1,6 @@
+- if Inboxes::config.faye_enabled
+ = javascript_include_tag "messaging"
+
%h1 Discussion
%h3
@@ -17,22 +20,11 @@
%h3 Messages
-%table
- %tr
- %th User
- %th Message
- %th Posted at
- - @discussion.messages.each do |message|
- %tr
- %td
- = message.user[Inboxes::config.user_name]
- %td
- = message.body
- %td
- = l(message.created_at)
-
+#messages_box
+ = render @discussion.messages, :as => :message
+
%h3 Add message
-= render "messages/form"
+= render "inboxes/messages/form"
%p
= link_to "Leave discussion", discussion_speaker_path(@discussion, @discussion.find_speaker_by_user(current_user)), :method => :delete unless @discussion.private?
diff --git a/app/views/messages/_form.html.haml b/app/views/inboxes/messages/_form.html.haml
index f85ed37..f85ed37 100644
--- a/app/views/messages/_form.html.haml
+++ b/app/views/inboxes/messages/_form.html.haml
diff --git a/app/views/inboxes/messages/_message.html.haml b/app/views/inboxes/messages/_message.html.haml
new file mode 100644
index 0000000..639f130
--- /dev/null
+++ b/app/views/inboxes/messages/_message.html.haml
@@ -0,0 +1,8 @@
+.message
+ %p
+ %span
+ = message.user[Inboxes::config.user_name]
+ @
+ = l(message.created_at)
+ =":"
+ %b= message.body \ No newline at end of file