From 9e6ce909508013e80f49160bf629f00bed29faec Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 4 Jan 2017 11:08:32 -0500 Subject: [PATCH 01/10] update config for heroku and prod --- config/cable.yml | 2 +- config/environments/production.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/cable.yml b/config/cable.yml index 0bbde6f7..34eb5cdc 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -6,4 +6,4 @@ test: production: adapter: redis - url: redis://localhost:6379/1 + url: <%= ENV['REDISTOGO_URL'] %> diff --git a/config/environments/production.rb b/config/environments/production.rb index ab4769b6..fd7ff05a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -3,6 +3,8 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb + config.action_cable.allowed_request_origins = ['https://metamaps.herokuapp.com', 'http://metamaps.herokuapp.com', 'https://metamaps.cc'] + # log to stdout logger = Logger.new(STDOUT) logger.formatter = config.log_formatter From ae05fb35d365b26f5785c4f5407869ffd0462cac Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 4 Jan 2017 11:14:03 -0500 Subject: [PATCH 02/10] more config updates for heroku --- Gemfile | 2 +- Procfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 58e26f01..56ee0bd2 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,7 @@ gem 'rack-cors' gem 'redis' gem 'slack-notifier' gem 'snorlax' +gem 'puma' # asset stuff gem 'jquery-rails' @@ -44,7 +45,6 @@ group :test do end group :development, :test do - gem 'puma' gem 'better_errors' gem 'binding_of_caller' gem 'pry-byebug' diff --git a/Procfile b/Procfile index e00c3019..b6bae37c 100644 --- a/Procfile +++ b/Procfile @@ -1,3 +1,3 @@ -web: bundle exec rails server -p $PORT +web: bundle exec puma -p $PORT worker: bundle exec rake jobs:work From d3315d962da4c219b1f4b903ea9150446379650f Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 4 Jan 2017 12:08:12 -0500 Subject: [PATCH 03/10] only render google analytics if a tracking code envvar is set --- app/views/layouts/_foot.html.erb | 2 +- app/views/layouts/_googleanalytics.html.erb | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/views/layouts/_foot.html.erb b/app/views/layouts/_foot.html.erb index e309c65f..ea4ab671 100644 --- a/app/views/layouts/_foot.html.erb +++ b/app/views/layouts/_foot.html.erb @@ -10,6 +10,6 @@ Metamaps.Loading.setup() -<%= render :partial => 'layouts/googleanalytics' if Rails.env.production? %> +<%= render :partial => 'layouts/googleanalytics' if ENV["GA_TRACKING_CODE"].present? %> diff --git a/app/views/layouts/_googleanalytics.html.erb b/app/views/layouts/_googleanalytics.html.erb index 11d41495..2acb9501 100644 --- a/app/views/layouts/_googleanalytics.html.erb +++ b/app/views/layouts/_googleanalytics.html.erb @@ -3,16 +3,13 @@ # Google analytics, rendered on every page #%> - From cbf1ec3afb352497de164d54d838818b15615abd Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Wed, 4 Jan 2017 12:34:08 -0500 Subject: [PATCH 04/10] fix missing npm github dep (#1011) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 92d4ab25..e57c9a1e 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "babel-preset-es2015": "6.18.0", "babel-preset-react": "6.16.0", "backbone": "1.0.0", - "clipboard-js": "git://github.com/devvmh/clipboard.js#patch-1", + "clipboard-js": "0.3.2", "commonmark": "0.27.0", "csv-parse": "1.1.7", "getScreenMedia": "git://github.com/devvmh/getScreenMedia#patch-1", From 5ab5f6fec2986b445cde0c734c16de95714481e4 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 4 Jan 2017 17:17:53 -0500 Subject: [PATCH 05/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b3fdb8ab..67159c68 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY The license can be read [here][license]. -Copyright (c) 2016 Connor Turland +Copyright (c) 2017 Connor Turland [site-beta]: http://metamaps.cc [license]: https://github.com/metamaps/metamaps/blob/develop/LICENSE From 8e50efb3c18a3fe22815f335947723fb20b30cdf Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 4 Jan 2017 18:11:44 -0500 Subject: [PATCH 06/10] render messages nicer --- app/assets/stylesheets/junto.css.erb | 21 +++++++++++++-------- frontend/src/components/MapChat/Message.js | 9 ++++++--- frontend/src/components/MapChat/index.js | 18 +++++++++++++++++- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/junto.css.erb b/app/assets/stylesheets/junto.css.erb index f738705f..9dd94a91 100644 --- a/app/assets/stylesheets/junto.css.erb +++ b/app/assets/stylesheets/junto.css.erb @@ -271,7 +271,7 @@ } .chat-box .chat-messages { width: 100%; - padding: 16px 0px 0px 0px; + padding: 16px 0px; overflow-y: auto; flex-grow: 1; } @@ -296,7 +296,7 @@ text-decoration: underline; } .chat-box .chat-messages .chat-message .chat-message-user { - width: 15%; + width: 12%; float: left; overflow: hidden; color: #BBB; @@ -304,20 +304,25 @@ } .chat-box .chat-messages .chat-message .chat-message-user img { border: 2px solid #424242; - width: 32px; - height: 32px; - border-radius: 18px; + width: 26px; + height: 26px; + border-radius: 14px; +} +.chat-box .chat-messages .chat-message .chat-message-meta { + padding: 0 8px; + float: left; +} +.chat-box .chat-messages .chat-message .chat-message-username { + color: #4fc059; } .chat-box .chat-messages .chat-message .chat-message-text { - width: 73%; + width: 80%; float: left; - margin-top: 12px; padding: 2px 8px 0; text-align: left; word-wrap: break-word; } .chat-box .chat-messages .chat-message .chat-message-time { - float: right; font-size: 10px; color: #757575; } diff --git a/frontend/src/components/MapChat/Message.js b/frontend/src/components/MapChat/Message.js index b9ddeda1..a13bbf3b 100644 --- a/frontend/src/components/MapChat/Message.js +++ b/frontend/src/components/MapChat/Message.js @@ -18,15 +18,18 @@ function formatDate(created_at) { } const Message = props => { - const { user_image, user_name, message, created_at } = props + const { user_image, user_name, message, created_at, heading } = props const messageHtml = {__html: linker.link(message)} return (
- + {heading && }
+ {heading &&
+ {user_name}  + {formatDate(created_at)} +
}
-
{formatDate(created_at)}
) diff --git a/frontend/src/components/MapChat/index.js b/frontend/src/components/MapChat/index.js index 101b9755..aa5b354e 100644 --- a/frontend/src/components/MapChat/index.js +++ b/frontend/src/components/MapChat/index.js @@ -3,6 +3,22 @@ import Unread from './Unread' import Participant from './Participant' import Message from './Message' +function makeList(messages) { + let currentHeader + return messages ? messages.map(m => { + let heading = false + if (!currentHeader) { + heading = true + currentHeader = m + } else { + // not same user or time diff of greater than 3 minutes + heading = m.user_id !== currentHeader.user_id || Math.floor(Math.abs(new Date(currentHeader.created_at) - new Date(m.created_at)) / 60000) > 3 + currentHeader = heading ? m : currentHeader + } + return + }) : null +} + class MapChat extends Component { constructor(props) { super(props) @@ -125,7 +141,7 @@ class MapChat extends Component {
this.messagesDiv = div}> - {messages.map(message => )} + {makeList(messages)}