Skip to content

Commit ebdca75

Browse files
authored
Merge pull request #46 from edne/master
Changes to run the server locally
2 parents c89367a + ecd59ef commit ebdca75

File tree

5 files changed

+47
-29
lines changed

5 files changed

+47
-29
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ source 'http://rubygems.org'
33
gem 'sinatra'
44
gem 'mongo'
55
gem 'bson_ext'
6-
gem 'json'
6+
gem 'json', '>= 1.8.2'
77
gem 'cloudinary'
88

Gemfile.lock

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
11
GEM
22
remote: http://rubygems.org/
33
specs:
4-
aws_cf_signer (0.1.1)
5-
bson (1.4.0)
6-
bson_ext (1.4.0)
7-
cloudinary (1.0.37)
4+
aws_cf_signer (0.1.3)
5+
bson (1.12.5)
6+
bson_ext (1.12.5)
7+
bson (~> 1.12.5)
8+
cloudinary (1.2.3)
89
aws_cf_signer
910
rest-client
10-
json (1.6.1)
11-
mime-types (1.19)
12-
mongo (1.4.0)
13-
bson (= 1.4.0)
14-
rack (1.3.5)
15-
rack-protection (1.1.4)
11+
domain_name (0.5.20160826)
12+
unf (>= 0.0.5, < 1.0.0)
13+
http-cookie (1.0.2)
14+
domain_name (~> 0.5)
15+
json (2.0.2)
16+
mime-types (3.1)
17+
mime-types-data (~> 3.2015)
18+
mime-types-data (3.2016.0521)
19+
mongo (1.12.5)
20+
bson (= 1.12.5)
21+
netrc (0.11.0)
22+
rack (1.6.4)
23+
rack-protection (1.5.3)
1624
rack
17-
rest-client (1.6.7)
18-
mime-types (>= 1.16)
19-
sinatra (1.3.1)
20-
rack (~> 1.3, >= 1.3.4)
21-
rack-protection (~> 1.1, >= 1.1.2)
22-
tilt (~> 1.3, >= 1.3.3)
23-
tilt (1.3.3)
25+
rest-client (2.0.0)
26+
http-cookie (>= 1.0.2, < 2.0)
27+
mime-types (>= 1.16, < 4.0)
28+
netrc (~> 0.8)
29+
sinatra (1.4.7)
30+
rack (~> 1.5)
31+
rack-protection (~> 1.4)
32+
tilt (>= 1.3, < 3)
33+
tilt (2.0.5)
34+
unf (0.1.4)
35+
unf_ext
36+
unf_ext (0.0.7.2)
2437

2538
PLATFORMS
2639
ruby
2740

2841
DEPENDENCIES
2942
bson_ext
3043
cloudinary
31-
json
44+
json (>= 1.8.2)
3245
mongo
3346
sinatra
47+
48+
BUNDLED WITH
49+
1.12.5

server/assets/gallery.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<body>
7474

7575
<div id="header">
76-
<h1><a href="http://glsl.heroku.com/">GLSL Sandbox</a></h1>
76+
<h1><a href="/">GLSL Sandbox</a></h1>
7777
<a href="/e">Create new effect!</a> &nbsp;&nbsp;/&nbsp;
7878
<a href="https://github.com/mrdoob/glsl-sandbox">github</a> &nbsp;&nbsp;/&nbsp;
7979
gallery by <a href="http://twitter.com/thevaw">@thevaw</a> and <a href="http://twitter.com/feiss">@feiss</a> &nbsp;/&nbsp; editor by <a href="http://twitter.com/mrdoob">@mrdoob</a>, <a href="http://twitter.com/mrkishi">@mrkishi</a>, <a href="http://twitter.com/p01">@p01</a>, <a href="http://twitter.com/alteredq">@alteredq</a>, <a href="http://twitter.com/kusmabite">@kusmabite</a> and <a href="http://twitter.com/emackey">@emackey</a>

server/model.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,21 @@ def save_version(code_id, code)
6666
:code => code_data['code']
6767
}
6868

69-
res=Cloudinary::Uploader.upload(
70-
code_data['image'],
71-
:public_id => code_id.to_s)
69+
begin
70+
res=Cloudinary::Uploader.upload(
71+
code_data['image'],
72+
:public_id => code_id.to_s)
7273

73-
image_url=res['url']
74+
image_data={ :image_url => res['url'] }
75+
76+
rescue CloudinaryException
77+
image_data={ :image => code_data['image'] }
78+
end
7479

7580
@code.find_and_modify({
7681
:query => { :_id => code_id },
7782
:update => {
78-
'$set' => {
79-
:modified_at => time,
80-
:image_url => image_url
81-
},
83+
'$set' => image_data.merge({ :modified_at => time }),
8284
'$push' => { :versions => data }
8385
}
8486
})

static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224

225225
var button = document.createElement( 'a' );
226226
button.textContent = 'gallery';
227-
button.href = 'http://glsl.heroku.com/';
227+
button.href = '/';
228228
rightside.appendChild( button );
229229

230230
var button = document.createElement( 'button' );

0 commit comments

Comments
 (0)