meme_captain 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/ChangeLog +4 -0
  2. data/README.md +0 -45
  3. data/lib/meme_captain.rb +0 -6
  4. data/lib/meme_captain/caption.rb +6 -4
  5. data/lib/meme_captain/caption_choice.rb +3 -1
  6. data/lib/meme_captain/image_list.rb +0 -5
  7. data/lib/meme_captain/text_pos.rb +8 -6
  8. data/lib/meme_captain/version.rb +1 -1
  9. data/meme_captain.gemspec +5 -18
  10. metadata +2 -181
  11. data/config.ru +0 -50
  12. data/doc/lightweight_front_end.md +0 -64
  13. data/doc/setup.md +0 -13
  14. data/lib/meme_captain/image_list/cache.rb +0 -49
  15. data/lib/meme_captain/image_list/fetch.rb +0 -28
  16. data/lib/meme_captain/image_list/fetch_error.rb +0 -17
  17. data/lib/meme_captain/image_list/source_image.rb +0 -30
  18. data/lib/meme_captain/meme_data.rb +0 -33
  19. data/lib/meme_captain/norm_params.rb +0 -92
  20. data/lib/meme_captain/pretty_format.rb +0 -12
  21. data/lib/meme_captain/server.rb +0 -303
  22. data/lib/meme_captain/source_fetch_fail.rb +0 -28
  23. data/lib/meme_captain/upload.rb +0 -30
  24. data/public/css/screen.css +0 -80
  25. data/public/favicon.ico +0 -0
  26. data/public/js/fabric.min.js +0 -4
  27. data/public/js/jquery-1.7.2.min.js +0 -4
  28. data/public/js/meme_captain.js +0 -391
  29. data/public/source_images.json +0 -234
  30. data/public/thumbs.jpg +0 -0
  31. data/public/thumbs_1330486916.jpg +0 -0
  32. data/public/thumbs_1333591668.jpg +0 -0
  33. data/public/thumbs_1334189407.jpg +0 -0
  34. data/public/thumbs_1334973608.jpg +0 -0
  35. data/public/thumbs_1336623277.jpg +0 -0
  36. data/public/thumbs_1336624196.jpg +0 -0
  37. data/public/thumbs_1339811279.jpg +0 -0
  38. data/public/tmp/.gitignore +0 -0
  39. data/script/thumb_sprites.rb +0 -76
  40. data/spec/image_list/fetch_spec.rb +0 -33
  41. data/spec/norm_params_spec.rb +0 -223
  42. data/spec/pretty_format_spec.rb +0 -9
  43. data/views/404.erb +0 -17
  44. data/views/index.erb +0 -130
  45. data/watermark.png +0 -0
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ 0.3.0 2013-06-25
2
+
3
+ Move Sinatra web application to meme_captain_web_v1 repo.
4
+
1
5
  0.2.0 2013-06-10
2
6
 
3
7
  Blur stroke.
data/README.md CHANGED
@@ -45,48 +45,3 @@ Text box sizes and positions can be specified as pixels (the origin is the top
45
45
  left corner of the image) or as floats which are percentages of the image
46
46
  width and height. The x and y coordinates of a text box are the coordinates
47
47
  of its top left corner.
48
-
49
- Also includes a Sinatra app that exposes the API over HTTP which is currently
50
- running http://memecaptain.com/
51
-
52
- You can use the memecaptain.com API if you prefer it to using the gem.
53
-
54
- Simplest API:
55
-
56
- ```
57
- http://memecaptain.com/i?u=<url encoded source image url>&t1=<url encoded top text>&t2=<url encoded bottom text>
58
- ```
59
-
60
- Example:
61
-
62
- ```
63
- http://memecaptain.com/i?u=http%3A%2F%2Fmemecaptain.com%2Fyao_ming.jpg&t1=sure+i%27ll+test&t2=the+api
64
- ```
65
-
66
- ![Sure I'll test the API](http://memecaptain.com/i?u=http%3A%2F%2Fmemecaptain.com%2Fyao_ming.jpg&t1=sure+i%27ll+test&t2=the+api)
67
-
68
- If you want better error messages, use this which will return JSON:
69
-
70
- ```
71
- http://memecaptain.com/g?u=<url encoded source image url>&t1=<url encoded top text>&t2=<url encoded bottom text>
72
- ```
73
-
74
- Example:
75
-
76
- ```
77
- http://memecaptain.com/g?u=http%3A%2F%2Fmemecaptain.com%2Fyao_ming.jpg&t1=sure+i%27ll+test&t2=the+api
78
- ```
79
-
80
- ```json
81
- {
82
- imageUrl: "http://memecaptain.com/c7757f.jpg",
83
- templateUrl: "http://memecaptain.com/?u=c7757f.jpg"
84
- }
85
- ```
86
-
87
- Optional parameters t1x, t1y, t1w, t1h, t2x, t2y, t2w, t2h can be added to
88
- position and size text (see example above).
89
-
90
- If you want to host a customized version of the memecaptain.com web interface
91
- on your own web server but use the memecaptain.com backend see
92
- [lightweight front end](https://github.com/mmb/meme_captain/blob/master/doc/lightweight_front_end.md).
@@ -4,11 +4,5 @@ require 'meme_captain/draw'
4
4
  require 'meme_captain/image_list'
5
5
  require 'meme_captain/meme'
6
6
  require 'meme_captain/memebg'
7
- require 'meme_captain/meme_data'
8
- require 'meme_captain/norm_params'
9
- require 'meme_captain/pretty_format'
10
- require 'meme_captain/server'
11
- require 'meme_captain/source_fetch_fail'
12
7
  require 'meme_captain/text_pos'
13
- require 'meme_captain/upload'
14
8
  require 'meme_captain/version'
@@ -1,8 +1,10 @@
1
+ # encoding: UTF-8
2
+
1
3
  module MemeCaptain
2
4
 
3
5
  class Caption < String
4
6
 
5
- def initialize(s='')
7
+ def initialize(s = '')
6
8
  super s.to_s
7
9
  end
8
10
 
@@ -27,9 +29,9 @@ module MemeCaptain
27
29
  if lines.empty?
28
30
  lines << word
29
31
  else
30
- if (lines[-1].size + 1 + word.size) <= chars_per_line or
31
- lines.size >= num_lines
32
- lines[-1] << ' ' unless lines[-1].empty?
32
+ if (lines[-1].size + 1 + word.size) <= chars_per_line ||
33
+ lines.size >= num_lines
34
+ lines[-1] << ' ' unless lines[-1].empty?
33
35
  lines[-1] << word
34
36
  else
35
37
  lines << word
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  module MemeCaptain
2
4
 
3
5
  # For comparing different caption line break and pointsize choices.
@@ -17,7 +19,7 @@ module MemeCaptain
17
19
  end
18
20
 
19
21
  def fits
20
- metrics.width <= bound_width and metrics.height <= bound_height
22
+ metrics.width <= bound_width && metrics.height <= bound_height
21
23
  end
22
24
 
23
25
  def fits_i
@@ -1,6 +1 @@
1
- require 'meme_captain/image_list/cache'
2
- require 'meme_captain/image_list/fetch'
3
- require 'meme_captain/image_list/fetch_error'
4
1
  require 'meme_captain/image_list/watermark'
5
-
6
- require 'meme_captain/image_list/source_image'
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'RMagick'
2
4
 
3
5
  module MemeCaptain
@@ -13,7 +15,7 @@ module MemeCaptain
13
15
  #
14
16
  # x, y, width and height can be in pixels or a float that represents a
15
17
  # percentage of the width and height of the image the text is put onto.
16
- def initialize(text, x, y, width, height, options={})
18
+ def initialize(text, x, y, width, height, options = {})
17
19
  @text = text
18
20
  @x = x
19
21
  @y = y
@@ -24,11 +26,11 @@ module MemeCaptain
24
26
  @min_pointsize = options.delete(:min_pointsize) || 12
25
27
 
26
28
  @draw_options = {
27
- :fill => 'white',
28
- :font => 'Impact',
29
- :gravity => Magick::CenterGravity,
30
- :stroke => 'black',
31
- :stroke_width => 8,
29
+ fill: 'white',
30
+ font: 'Impact',
31
+ gravity: Magick::CenterGravity,
32
+ stroke: 'black',
33
+ stroke_width: 8,
32
34
  }.merge(options)
33
35
  end
34
36
 
@@ -1,3 +1,3 @@
1
1
  module MemeCaptain
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -13,25 +13,12 @@ Gem::Specification.new do |s|
13
13
  s.authors = ['Matthew M. Boedicker']
14
14
  s.email = %w{matthewm@boedicker.org}
15
15
 
16
- %w{
17
- bson_ext
18
- curb
19
- json
20
- mime-types
21
- mongo
22
- mongo_mapper
23
- rack
24
- rack-contrib
25
- rack-rewrite
26
- rmagick
27
- sinatra
28
- }.each { |g| s.add_dependency g }
16
+ s.add_dependency 'mime-types'
17
+ s.add_dependency 'rmagick'
29
18
 
30
- %w{
31
- rake
32
- rspec
33
- webmock
34
- }.each { |g| s.add_development_dependency g }
19
+ s.add_development_dependency 'rake'
20
+ s.add_development_dependency 'rspec'
21
+ s.add_development_dependency 'webmock'
35
22
 
36
23
  s.files = `git ls-files`.split("\n")
37
24
  s.executables = %w{memecaptain}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meme_captain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,56 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-11 00:00:00.000000000 Z
12
+ date: 2013-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: bson_ext
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: curb
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: json
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
14
  - !ruby/object:Gem::Dependency
63
15
  name: mime-types
64
16
  requirement: !ruby/object:Gem::Requirement
@@ -75,86 +27,6 @@ dependencies:
75
27
  - - ! '>='
76
28
  - !ruby/object:Gem::Version
77
29
  version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: mongo
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :runtime
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: mongo_mapper
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :runtime
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: rack
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: rack-contrib
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :runtime
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
- - !ruby/object:Gem::Dependency
143
- name: rack-rewrite
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - ! '>='
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
- type: :runtime
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ! '>='
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
30
  - !ruby/object:Gem::Dependency
159
31
  name: rmagick
160
32
  requirement: !ruby/object:Gem::Requirement
@@ -171,22 +43,6 @@ dependencies:
171
43
  - - ! '>='
172
44
  - !ruby/object:Gem::Version
173
45
  version: '0'
174
- - !ruby/object:Gem::Dependency
175
- name: sinatra
176
- requirement: !ruby/object:Gem::Requirement
177
- none: false
178
- requirements:
179
- - - ! '>='
180
- - !ruby/object:Gem::Version
181
- version: '0'
182
- type: :runtime
183
- prerelease: false
184
- version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
- requirements:
187
- - - ! '>='
188
- - !ruby/object:Gem::Version
189
- version: '0'
190
46
  - !ruby/object:Gem::Dependency
191
47
  name: rake
192
48
  requirement: !ruby/object:Gem::Requirement
@@ -251,60 +107,25 @@ files:
251
107
  - README.md
252
108
  - Rakefile
253
109
  - bin/memecaptain
254
- - config.ru
255
- - doc/lightweight_front_end.md
256
- - doc/setup.md
257
110
  - lib/meme_captain.rb
258
111
  - lib/meme_captain/caption.rb
259
112
  - lib/meme_captain/caption_choice.rb
260
113
  - lib/meme_captain/draw.rb
261
114
  - lib/meme_captain/image_list.rb
262
- - lib/meme_captain/image_list/cache.rb
263
- - lib/meme_captain/image_list/fetch.rb
264
- - lib/meme_captain/image_list/fetch_error.rb
265
- - lib/meme_captain/image_list/source_image.rb
266
115
  - lib/meme_captain/image_list/watermark.rb
267
116
  - lib/meme_captain/meme.rb
268
- - lib/meme_captain/meme_data.rb
269
117
  - lib/meme_captain/memebg.rb
270
- - lib/meme_captain/norm_params.rb
271
- - lib/meme_captain/pretty_format.rb
272
- - lib/meme_captain/server.rb
273
- - lib/meme_captain/source_fetch_fail.rb
274
118
  - lib/meme_captain/text_pos.rb
275
- - lib/meme_captain/upload.rb
276
119
  - lib/meme_captain/version.rb
277
120
  - meme_captain.gemspec
278
- - public/css/screen.css
279
- - public/favicon.ico
280
- - public/js/fabric.min.js
281
- - public/js/jquery-1.7.2.min.js
282
- - public/js/meme_captain.js
283
- - public/source_images.json
284
- - public/thumbs.jpg
285
- - public/thumbs_1330486916.jpg
286
- - public/thumbs_1333591668.jpg
287
- - public/thumbs_1334189407.jpg
288
- - public/thumbs_1334973608.jpg
289
- - public/thumbs_1336623277.jpg
290
- - public/thumbs_1336624196.jpg
291
- - public/thumbs_1339811279.jpg
292
- - public/tmp/.gitignore
293
- - script/thumb_sprites.rb
294
121
  - spec/assets/me_gusta.png
295
122
  - spec/assets/otter.gif
296
123
  - spec/assets/town_crier.jpg
297
124
  - spec/caption_choice_spec.rb
298
125
  - spec/caption_spec.rb
299
- - spec/image_list/fetch_spec.rb
300
126
  - spec/meme_captain_spec.rb
301
127
  - spec/memebg_spec.rb
302
- - spec/norm_params_spec.rb
303
- - spec/pretty_format_spec.rb
304
128
  - spec/text_pos_spec.rb
305
- - views/404.erb
306
- - views/index.erb
307
- - watermark.png
308
129
  homepage: https://github.com/mmb/meme_captain
309
130
  licenses: []
310
131
  post_install_message:
data/config.ru DELETED
@@ -1,50 +0,0 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
2
-
3
- require 'mongo'
4
- require 'mongo_mapper'
5
- require 'rack'
6
- require 'rack/contrib/jsonp'
7
- require 'rack/rewrite'
8
-
9
- require 'meme_captain'
10
-
11
- use Rack::ConditionalGet
12
- use Rack::Sendfile
13
- use Rack::JSONP
14
-
15
- use Rack::Static, :urls => %w{/tmp}, :root => 'public'
16
-
17
- MongoMapper.connection = Mongo::Connection.new
18
- MongoMapper.database = 'memecaptain'
19
-
20
- MemeCaptain::MemeData.ensure_index :meme_id
21
-
22
- MemeCaptain::MemeData.ensure_index [
23
- [:source_url, 1],
24
- [:texts, 1],
25
- ]
26
-
27
- MemeCaptain::Upload.ensure_index :upload_id
28
-
29
- MemeCaptain::SourceFetchFail.ensure_index :url
30
-
31
- use Rack::Rewrite do
32
- rewrite %r{/([gi])\?(.+)}, lambda { |match, rack_env|
33
- result = match[0]
34
-
35
- if match[2].index('tt=') or match[2].index('tb=')
36
- q = Rack::Utils.parse_query(match[2])
37
- if q.key?('tt') or q.key?('tb')
38
- q['t1'] = q.delete('tt') if q.key?('tt')
39
- q['t2'] = q.delete('tb') if q.key?('tb')
40
- new_q = q.map { |k,v|
41
- "#{Rack::Utils.escape(k)}=#{Rack::Utils.escape(v)}" }.join('&')
42
- result = "#{match[1]}?#{new_q}"
43
- end
44
- end
45
-
46
- result
47
- }
48
- end
49
-
50
- run MemeCaptain::Server