fix bugs on develop branch

This commit is contained in:
Devin Howard 2016-11-08 15:51:39 -05:00
parent 5851d57eef
commit ce2d462578
9 changed files with 29 additions and 12 deletions

View file

@ -1,10 +1,14 @@
# Node JS env
export NODE_REALTIME_PORT='5000' # should match REALTIME_SERVER, below
# Rails env
export DB_USERNAME='postgres' export DB_USERNAME='postgres'
export DB_PASSWORD='3112' export DB_PASSWORD='3112'
export DB_HOST='localhost' export DB_HOST='localhost'
export DB_PORT='5432' export DB_PORT='5432'
export DB_NAME='metamap002' export DB_NAME='metamap002'
export REALTIME_SERVER='http://localhost:5001' export REALTIME_SERVER='http://localhost:5000'
export MAILER_DEFAULT_URL='localhost:3000' export MAILER_DEFAULT_URL='localhost:3000'
export DEVISE_MAILER_SENDER='team@metamaps.cc' export DEVISE_MAILER_SENDER='team@metamaps.cc'

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# bad code that should be checked over before entering one of the # bad code that should be checked over before entering one of the
# nice files from the right side of this repo # nice files from the right side of this repo
class HacksController < ApplicationController class HacksController < ApplicationController
@ -11,7 +12,7 @@ class HacksController < ApplicationController
response, url = get_with_redirects(url) response, url = get_with_redirects(url)
title = get_encoded_title(response) title = get_encoded_title(response)
render json: { success: true, title: title, url: url } render json: { success: true, title: title, url: url }
rescue StandardError => e rescue StandardError
render json: { success: false } render json: { success: false }
end end
@ -28,7 +29,13 @@ class HacksController < ApplicationController
end end
def get_encoded_title(http_response) def get_encoded_title(http_response)
title = http_response.body.sub(/.*<title>(.*)<\/title>.*/m, '\1') # ensure there's actually an html title tag
title = http_response.body.sub(%r{.*(<title>.*</title>).*}m, '\1')
return '' unless title.starts_with?('<title>')
return '' unless title.ends_with?('</title>')
title = title.sub('<title>', '').sub(%r{</title>$}, '')
# encode and trim the title to 140 usable characters
charset = http_response['content-type'].sub(/.*charset=(.*);?.*/, '\1') charset = http_response['content-type'].sub(/.*charset=(.*);?.*/, '\1')
charset = nil if charset == 'text/html' charset = nil if charset == 'text/html'
title = title.force_encoding(charset) if charset title = title.force_encoding(charset) if charset

View file

@ -93,10 +93,10 @@ server to see what problems show up:
#### Realtime server: #### Realtime server:
sudo npm install -g forever sudo npm install -g forever
(crontab -u metamaps -l 2>/dev/null; echo "@reboot $(which forever) --append -l /home/metamaps/logs/forever.realtime.log start /home/metamaps/metamaps/realtime/realtime-server.js") | crontab -u metamaps - (crontab -u metamaps -l 2>/dev/null; echo "@reboot env NODE_REALTIME_PORT=5000 $(which forever) --append -l /home/metamaps/logs/forever.realtime.log start /home/metamaps/metamaps/realtime/realtime-server.js") | crontab -u metamaps -
mkdir -p /home/metamaps/logs mkdir -p /home/metamaps/logs
forever --append \ env NODE_REALTIME_PORT=5000 forever --append \
-c /home/metamaps/metamaps/node_modules/.bin/babel-node \ -c /home/metamaps/metamaps/node_modules/.bin/babel-node \
-l /home/metamaps/logs/forever.realtime.log \ -l /home/metamaps/logs/forever.realtime.log \
start /home/metamaps/metamaps/realtime/realtime-server.js start /home/metamaps/metamaps/realtime/realtime-server.js

View file

@ -375,6 +375,7 @@ const Import = {
$.get('/hacks/load_url_title', { $.get('/hacks/load_url_title', {
url url
}, function success(data, textStatus) { }, function success(data, textStatus) {
if (data.trim() === '') return
var selector = '#showcard #topic_' + topic.get('id') + ' .best_in_place' var selector = '#showcard #topic_' + topic.get('id') + ' .best_in_place'
if ($(selector).find('form').length > 0) { if ($(selector).find('form').length > 0) {
$(selector).find('textarea, input').val(data.title) $(selector).find('textarea, input').val(data.title)

View file

@ -25,7 +25,7 @@ const PasteInput = {
self.handleFile(e.dataTransfer.files[0], coords) self.handleFile(e.dataTransfer.files[0], coords)
} }
// OMG import bookmarks 😍 // OMG import bookmarks 😍
if (e.dataTransfer.items.length > 0) { if (e.dataTransfer.items && e.dataTransfer.items.length > 0) {
e.dataTransfer.items[0].getAsString(function(text) { e.dataTransfer.items[0].getAsString(function(text) {
if (text.match(self.URL_REGEX)) { if (text.match(self.URL_REGEX)) {
self.handle(text, coords) self.handle(text, coords)

View file

@ -172,7 +172,11 @@ let Realtime = {
room: 'global', room: 'global',
$video: self.localVideo.$video, $video: self.localVideo.$video,
myVideoView: self.localVideo.view, myVideoView: self.localVideo.view,
config: { DOUBLE_CLICK_TOLERANCE: 200 } config: { DOUBLE_CLICK_TOLERANCE: 200 },
soundUrls: [
serverData['sounds/MM_sounds.mp3'],
serverData['sounds/MM_sounds.ogg']
]
}) })
self.room.videoAdded(self.handleVideoAdded) self.room.videoAdded(self.handleVideoAdded)

View file

@ -226,7 +226,7 @@ var Handlers = {
} }
} }
const ChatView = function(messages, mapper, room) { const ChatView = function(messages, mapper, room, opts = {}) {
this.room = room this.room = room
this.mapper = mapper this.mapper = mapper
this.messages = messages // backbone collection this.messages = messages // backbone collection
@ -243,7 +243,7 @@ const ChatView = function(messages, mapper, room) {
Private.attachElements.call(this) Private.attachElements.call(this)
Private.addEventListeners.call(this) Private.addEventListeners.call(this)
Private.initialMessages.call(this) Private.initialMessages.call(this)
Private.initializeSounds.call(this, room.soundUrls) Private.initializeSounds.call(this, opts.soundUrls)
this.$container.css({ this.$container.css({
right: '-300px' right: '-300px'
}) })

View file

@ -26,10 +26,11 @@ const Room = function(opts = {}) {
this.messages = new Backbone.Collection() this.messages = new Backbone.Collection()
this.currentMapper = new Backbone.Model({ name: opts.username, image: opts.image }) this.currentMapper = new Backbone.Model({ name: opts.username, image: opts.image })
this.chat = new ChatView(this.messages, this.currentMapper, this.room) this.chat = new ChatView(this.messages, this.currentMapper, this.room, {
soundUrls: opts.soundUrls
})
this.videos = {} this.videos = {}
this.soundUrls = opts.soundUrls
this.init() this.init()
} }

View file

@ -15,4 +15,4 @@ signalling(io, stunservers, store)
junto(io, store) junto(io, store)
map(io, store) map(io, store)
io.listen(5001) io.listen(parseInt(process.env.NODE_REALTIME_PORT) || 5000)