From 6deb9f966eb9a280cc16428ba9324ffc15ea60a8 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 18 Aug 2016 15:49:51 +0200 Subject: Live timelines using ActionCable --- app/assets/javascripts/api/accounts.coffee | 3 --- app/assets/javascripts/api/accounts/lookup.coffee | 3 --- app/assets/javascripts/api/follows.coffee | 3 --- app/assets/javascripts/api/statuses.coffee | 3 --- app/assets/javascripts/application.js | 1 - app/assets/javascripts/cable.js | 13 +++++++++++++ app/assets/javascripts/channels/timeline.js | 13 +++++++++++++ app/assets/javascripts/oauth/applications.coffee | 3 --- app/assets/javascripts/profiler.coffee | 5 ----- app/assets/javascripts/settings.coffee | 3 --- app/assets/javascripts/statuses.coffee | 3 --- 11 files changed, 26 insertions(+), 27 deletions(-) delete mode 100644 app/assets/javascripts/api/accounts.coffee delete mode 100644 app/assets/javascripts/api/accounts/lookup.coffee delete mode 100644 app/assets/javascripts/api/follows.coffee delete mode 100644 app/assets/javascripts/api/statuses.coffee create mode 100644 app/assets/javascripts/cable.js create mode 100644 app/assets/javascripts/channels/timeline.js delete mode 100644 app/assets/javascripts/oauth/applications.coffee delete mode 100644 app/assets/javascripts/profiler.coffee delete mode 100644 app/assets/javascripts/settings.coffee delete mode 100644 app/assets/javascripts/statuses.coffee (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/api/accounts.coffee b/app/assets/javascripts/api/accounts.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/api/accounts.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/api/accounts/lookup.coffee b/app/assets/javascripts/api/accounts/lookup.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/api/accounts/lookup.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/api/follows.coffee b/app/assets/javascripts/api/follows.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/api/follows.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/api/statuses.coffee b/app/assets/javascripts/api/statuses.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/api/statuses.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e07c5a830..646c5aba4 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,5 +12,4 @@ // //= require jquery //= require jquery_ujs -//= require turbolinks //= require_tree . diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js new file mode 100644 index 000000000..71ee1e66d --- /dev/null +++ b/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the rails generate channel command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/app/assets/javascripts/channels/timeline.js b/app/assets/javascripts/channels/timeline.js new file mode 100644 index 000000000..ca7c50d12 --- /dev/null +++ b/app/assets/javascripts/channels/timeline.js @@ -0,0 +1,13 @@ +App.timeline = App.cable.subscriptions.create("TimelineChannel", { + connected: function() { + console.log('Connected'); + }, + + disconnected: function() { + console.log('Disconnected'); + }, + + received: function(data) { + console.log(JSON.parse(data.message)); + } +}); diff --git a/app/assets/javascripts/oauth/applications.coffee b/app/assets/javascripts/oauth/applications.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/oauth/applications.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/profiler.coffee b/app/assets/javascripts/profiler.coffee deleted file mode 100644 index 40dfd0af6..000000000 --- a/app/assets/javascripts/profiler.coffee +++ /dev/null @@ -1,5 +0,0 @@ -$ -> - $(document).on 'turbolinks:load', -> - unless typeof window.MiniProfiler == 'undefined' - window.MiniProfiler.init() - window.MiniProfiler.pageTransition() diff --git a/app/assets/javascripts/settings.coffee b/app/assets/javascripts/settings.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/settings.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/statuses.coffee b/app/assets/javascripts/statuses.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/statuses.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ -- cgit