File tree 5 files changed +25
-11
lines changed
5 files changed +25
-11
lines changed Original file line number Diff line number Diff line change 1
1
express = require ' express'
2
2
bodyParser = require ' body-parser'
3
+ cors = require ' cors'
4
+
3
5
app = express ()
4
6
7
+ app .use (cors (
8
+ origin : (origin , callback ) ->
9
+ if origin
10
+ allow = origin .match (/ \. kosendj-bu\. in\/ / ) != null
11
+ if app .get (' env' ) == " development"
12
+ allow = allow || origin .match (/ localhost/ ) != null
13
+
14
+ callback (null , allow)
15
+ else
16
+ callback (null , false )
17
+ ))
18
+
5
19
http = require (' http' ).Server app
6
20
io = require (' socket.io' )(http)
7
21
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ request = require 'request'
4
4
io = process .globals .io
5
5
6
6
check = (url , callback )->
7
- if url .match (/ ^ http: \/\/ sorah-gif / )
7
+ if url .match (/ \. kosendj-bu \. in \/ / )
8
8
callback (null , true )
9
9
return
10
10
Original file line number Diff line number Diff line change @@ -2,15 +2,15 @@ Twit = require 'twit'
2
2
3
3
io = process .globals .io
4
4
5
- twitter = new Twit
6
- consumer_key : process .env .CONSUMER_KEY
7
- consumer_secret : process .env .CONSUMER_SECRET
8
- access_token : process .env .ACCESS_TOKEN
9
- access_token_secret : process .env .ACCESS_TOKEN_SECRET
5
+ unless process .env .DISABLE_TWITTER == ' 1'
6
+ twitter = new Twit
7
+ consumer_key : process .env .CONSUMER_KEY
8
+ consumer_secret : process .env .CONSUMER_SECRET
9
+ access_token : process .env .ACCESS_TOKEN
10
+ access_token_secret : process .env .ACCESS_TOKEN_SECRET
10
11
11
- replaceHashtag = new RegExp process .env .HASH_TAG , ' g'
12
+ replaceHashtag = new RegExp " # #{ process .env .HASH_TAG } " , ' g'
12
13
13
- unless process .env .DISABLE_TWITTER == ' 1'
14
14
stream = twitter .stream ' statuses/filter' ,
15
15
track : " ##{ process .env .HASH_TAG } "
16
16
Original file line number Diff line number Diff line change 12
12
"dependencies" : {
13
13
"body-parser" : " ^1.13.1" ,
14
14
"coffee-script" : " ^1.9.3" ,
15
+ "cors" : " ^2.7.1" ,
15
16
"express" : " ^4.12.4" ,
16
17
"jade" : " ^1.11.0" ,
17
18
"livescript" : " ^1.4.0" ,
Original file line number Diff line number Diff line change @@ -44,9 +44,8 @@ change = ->
44
44
setTimeout change , (main .$data .bpm / 60 ) * 1000
45
45
46
46
processUrls = (urls ) ->
47
- for x in urls
48
- url = x .replace /^https?:\/\/img\.sorah\.jp/ , \http://sorah-pub.s3.amazonaws.com
49
- if url .match /^https?:\/\/(?:sorah-pub\.s3\.amazonaws\.com|192\.168|10\.|sorah-gif)/
47
+ for url in urls
48
+ if url .match /\.kosendj-bu\.in\//
50
49
url
51
50
else
52
51
" /gifs/retrieve/#{ url } "
You can’t perform that action at this time.
0 commit comments