murlsh 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.htaccess +5 -0
  2. data/COPYING +27 -0
  3. data/README.textile +2 -2
  4. data/Rakefile +133 -66
  5. data/VERSION +1 -1
  6. data/config.ru +9 -8
  7. data/config.yaml +3 -2
  8. data/lib/murlsh/auth.rb +6 -8
  9. data/lib/murlsh/config_server.rb +4 -6
  10. data/lib/murlsh/dispatch.rb +5 -7
  11. data/lib/murlsh/doc.rb +1 -1
  12. data/lib/murlsh/etag_add_encoding.rb +1 -3
  13. data/lib/murlsh/failproof.rb +0 -1
  14. data/lib/murlsh/far_future_expires.rb +2 -4
  15. data/lib/murlsh/head_from_get.rb +2 -2
  16. data/lib/murlsh/image_list.rb +32 -0
  17. data/lib/murlsh/img_store.rb +47 -9
  18. data/lib/murlsh/markup.rb +53 -20
  19. data/lib/murlsh/must_revalidate.rb +2 -4
  20. data/lib/murlsh/plugin.rb +1 -1
  21. data/lib/murlsh/sqlite3_adapter.rb +2 -4
  22. data/lib/murlsh/time_ago.rb +6 -8
  23. data/lib/murlsh/uri.rb +1 -3
  24. data/lib/murlsh/uri_ask.rb +23 -25
  25. data/lib/murlsh/url.rb +4 -6
  26. data/lib/murlsh/url_body.rb +19 -21
  27. data/lib/murlsh/url_server.rb +8 -10
  28. data/lib/murlsh/yaml_ordered_hash.rb +2 -4
  29. data/lib/murlsh.rb +21 -4
  30. data/murlsh.gemspec +95 -90
  31. data/plugins/add_post_50_update_feed.rb +22 -10
  32. data/plugins/add_post_50_update_podcast.rb +3 -5
  33. data/plugins/add_post_50_update_rss.rb +4 -6
  34. data/plugins/add_post_60_notify_hubs.rb +3 -5
  35. data/plugins/add_pre_40_convert_mobile.rb +4 -10
  36. data/plugins/add_pre_50_lookup_content_type_title.rb +4 -6
  37. data/plugins/add_pre_60_flickr.rb +3 -14
  38. data/plugins/add_pre_60_github_title.rb +4 -6
  39. data/plugins/add_pre_60_google_code_title.rb +4 -6
  40. data/plugins/add_pre_60_imgur.rb +4 -16
  41. data/plugins/add_pre_60_s3_image.rb +7 -6
  42. data/plugins/add_pre_60_twitter.rb +3 -14
  43. data/plugins/add_pre_60_vimeo.rb +7 -6
  44. data/plugins/add_pre_60_youtube.rb +8 -7
  45. data/plugins/add_pre_65_html_thumb.rb +41 -0
  46. data/plugins/add_pre_65_img_thumb.rb +39 -0
  47. data/plugins/html_parse_50_hpricot.rb +2 -4
  48. data/plugins/url_display_add_45_audio.rb +28 -0
  49. data/plugins/url_display_add_50_hostrec.rb +15 -18
  50. data/plugins/url_display_add_55_content_type.rb +6 -8
  51. data/plugins/url_display_add_60_via.rb +12 -19
  52. data/plugins/url_display_add_65_time.rb +4 -6
  53. data/public/css/screen.css +2 -3
  54. data/public/img/thumb/.gitignore +3 -0
  55. data/public/js/jquery-1.4.4.min.js +167 -0
  56. data/public/js/js.js +6 -5
  57. data/public/js/{twitter-text-1.0.3.js → twitter-text-1.0.4.js} +3 -1
  58. data/spec/auth_spec.rb +4 -6
  59. data/spec/dispatch_spec.rb +3 -5
  60. data/spec/doc_spec.rb +2 -4
  61. data/spec/img_store_spec.rb +46 -20
  62. data/spec/markup_spec.rb +22 -24
  63. data/spec/uri_ask_spec.rb +5 -7
  64. data/spec/uri_spec.rb +2 -4
  65. data/spec/url_spec.rb +5 -9
  66. data/spec/yaml_ordered_hash_spec.rb +1 -3
  67. metadata +85 -53
  68. data/.gitignore +0 -6
  69. data/plugins/add_pre_60_imageshack.rb +0 -31
  70. data/plugins/url_display_add_45_mp3.rb +0 -30
  71. data/public/img/thumb/README +0 -0
  72. data/public/js/jquery-1.4.3.min.js +0 -166
  73. data/public/swf/player_mp3_mini.swf +0 -0
data/murlsh.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{murlsh}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matthew M. Boedicker"]
12
- s.date = %q{2010-11-03}
12
+ s.date = %q{2010-11-21}
13
13
  s.default_executable = %q{murlsh}
14
14
  s.description = %q{url sharing site framework with easy adding, title lookup, atom feed, thumbnails and embedding}
15
15
  s.email = %q{matthewm@boedicker.org}
@@ -18,93 +18,92 @@ Gem::Specification.new do |s|
18
18
  "README.textile"
19
19
  ]
20
20
  s.files = [
21
- ".gitignore",
22
- ".htaccess",
23
- "COPYING",
24
- "README.textile",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/murlsh",
28
- "config.ru",
29
- "config.yaml",
30
- "lib/murlsh.rb",
31
- "lib/murlsh/auth.rb",
32
- "lib/murlsh/config_server.rb",
33
- "lib/murlsh/dispatch.rb",
34
- "lib/murlsh/doc.rb",
35
- "lib/murlsh/etag_add_encoding.rb",
36
- "lib/murlsh/failproof.rb",
37
- "lib/murlsh/far_future_expires.rb",
38
- "lib/murlsh/head_from_get.rb",
39
- "lib/murlsh/img_store.rb",
40
- "lib/murlsh/markup.rb",
41
- "lib/murlsh/must_revalidate.rb",
42
- "lib/murlsh/openlock.rb",
43
- "lib/murlsh/plugin.rb",
44
- "lib/murlsh/sqlite3_adapter.rb",
45
- "lib/murlsh/time_ago.rb",
46
- "lib/murlsh/uri.rb",
47
- "lib/murlsh/uri_ask.rb",
48
- "lib/murlsh/url.rb",
49
- "lib/murlsh/url_body.rb",
50
- "lib/murlsh/url_server.rb",
51
- "lib/murlsh/yaml_ordered_hash.rb",
52
- "murlsh.gemspec",
53
- "plugins/add_post_50_update_feed.rb",
54
- "plugins/add_post_50_update_podcast.rb",
55
- "plugins/add_post_50_update_rss.rb",
56
- "plugins/add_post_60_notify_hubs.rb",
57
- "plugins/add_pre_40_convert_mobile.rb",
58
- "plugins/add_pre_50_lookup_content_type_title.rb",
59
- "plugins/add_pre_60_flickr.rb",
60
- "plugins/add_pre_60_github_title.rb",
61
- "plugins/add_pre_60_google_code_title.rb",
62
- "plugins/add_pre_60_imageshack.rb",
63
- "plugins/add_pre_60_imgur.rb",
64
- "plugins/add_pre_60_s3_image.rb",
65
- "plugins/add_pre_60_twitter.rb",
66
- "plugins/add_pre_60_vimeo.rb",
67
- "plugins/add_pre_60_youtube.rb",
68
- "plugins/html_parse_50_hpricot.rb",
69
- "plugins/url_display_add_45_mp3.rb",
70
- "plugins/url_display_add_50_hostrec.rb",
71
- "plugins/url_display_add_55_content_type.rb",
72
- "plugins/url_display_add_60_via.rb",
73
- "plugins/url_display_add_65_time.rb",
74
- "public/css/jquery.jgrowl.css",
75
- "public/css/screen.css",
76
- "public/img/thumb/README",
77
- "public/js/comments.json",
78
- "public/js/jquery-1.4.3.min.js",
79
- "public/js/jquery.jgrowl_compressed.js",
80
- "public/js/js.js",
81
- "public/js/twitter-text-1.0.3.js",
82
- "public/swf/player_mp3_mini.swf",
83
- "spec/auth_spec.rb",
84
- "spec/dispatch_spec.rb",
85
- "spec/doc_spec.rb",
86
- "spec/img_store_spec.rb",
87
- "spec/markup_spec.rb",
88
- "spec/uri_ask_spec.rb",
89
- "spec/uri_spec.rb",
90
- "spec/url_spec.rb",
91
- "spec/yaml_ordered_hash_spec.rb"
21
+ ".htaccess",
22
+ "COPYING",
23
+ "README.textile",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/murlsh",
27
+ "config.ru",
28
+ "config.yaml",
29
+ "lib/murlsh.rb",
30
+ "lib/murlsh/auth.rb",
31
+ "lib/murlsh/config_server.rb",
32
+ "lib/murlsh/dispatch.rb",
33
+ "lib/murlsh/doc.rb",
34
+ "lib/murlsh/etag_add_encoding.rb",
35
+ "lib/murlsh/failproof.rb",
36
+ "lib/murlsh/far_future_expires.rb",
37
+ "lib/murlsh/head_from_get.rb",
38
+ "lib/murlsh/image_list.rb",
39
+ "lib/murlsh/img_store.rb",
40
+ "lib/murlsh/markup.rb",
41
+ "lib/murlsh/must_revalidate.rb",
42
+ "lib/murlsh/openlock.rb",
43
+ "lib/murlsh/plugin.rb",
44
+ "lib/murlsh/sqlite3_adapter.rb",
45
+ "lib/murlsh/time_ago.rb",
46
+ "lib/murlsh/uri.rb",
47
+ "lib/murlsh/uri_ask.rb",
48
+ "lib/murlsh/url.rb",
49
+ "lib/murlsh/url_body.rb",
50
+ "lib/murlsh/url_server.rb",
51
+ "lib/murlsh/yaml_ordered_hash.rb",
52
+ "murlsh.gemspec",
53
+ "plugins/add_post_50_update_feed.rb",
54
+ "plugins/add_post_50_update_podcast.rb",
55
+ "plugins/add_post_50_update_rss.rb",
56
+ "plugins/add_post_60_notify_hubs.rb",
57
+ "plugins/add_pre_40_convert_mobile.rb",
58
+ "plugins/add_pre_50_lookup_content_type_title.rb",
59
+ "plugins/add_pre_60_flickr.rb",
60
+ "plugins/add_pre_60_github_title.rb",
61
+ "plugins/add_pre_60_google_code_title.rb",
62
+ "plugins/add_pre_60_imgur.rb",
63
+ "plugins/add_pre_60_s3_image.rb",
64
+ "plugins/add_pre_60_twitter.rb",
65
+ "plugins/add_pre_60_vimeo.rb",
66
+ "plugins/add_pre_60_youtube.rb",
67
+ "plugins/add_pre_65_html_thumb.rb",
68
+ "plugins/add_pre_65_img_thumb.rb",
69
+ "plugins/html_parse_50_hpricot.rb",
70
+ "plugins/url_display_add_45_audio.rb",
71
+ "plugins/url_display_add_50_hostrec.rb",
72
+ "plugins/url_display_add_55_content_type.rb",
73
+ "plugins/url_display_add_60_via.rb",
74
+ "plugins/url_display_add_65_time.rb",
75
+ "public/css/jquery.jgrowl.css",
76
+ "public/css/screen.css",
77
+ "public/img/thumb/.gitignore",
78
+ "public/js/comments.json",
79
+ "public/js/jquery-1.4.4.min.js",
80
+ "public/js/jquery.jgrowl_compressed.js",
81
+ "public/js/js.js",
82
+ "public/js/twitter-text-1.0.4.js",
83
+ "spec/auth_spec.rb",
84
+ "spec/dispatch_spec.rb",
85
+ "spec/doc_spec.rb",
86
+ "spec/img_store_spec.rb",
87
+ "spec/markup_spec.rb",
88
+ "spec/uri_ask_spec.rb",
89
+ "spec/uri_spec.rb",
90
+ "spec/url_spec.rb",
91
+ "spec/yaml_ordered_hash_spec.rb"
92
92
  ]
93
93
  s.homepage = %q{http://github.com/mmb/murlsh}
94
- s.rdoc_options = ["--charset=UTF-8"]
95
94
  s.require_paths = ["lib"]
96
95
  s.rubygems_version = %q{1.3.7}
97
96
  s.summary = %q{url sharing site framework}
98
97
  s.test_files = [
99
98
  "spec/auth_spec.rb",
100
- "spec/yaml_ordered_hash_spec.rb",
101
- "spec/uri_ask_spec.rb",
102
- "spec/img_store_spec.rb",
103
- "spec/dispatch_spec.rb",
104
- "spec/markup_spec.rb",
105
- "spec/url_spec.rb",
106
- "spec/uri_spec.rb",
107
- "spec/doc_spec.rb"
99
+ "spec/dispatch_spec.rb",
100
+ "spec/doc_spec.rb",
101
+ "spec/img_store_spec.rb",
102
+ "spec/markup_spec.rb",
103
+ "spec/uri_ask_spec.rb",
104
+ "spec/uri_spec.rb",
105
+ "spec/url_spec.rb",
106
+ "spec/yaml_ordered_hash_spec.rb"
108
107
  ]
109
108
 
110
109
  if s.respond_to? :specification_version then
@@ -116,38 +115,42 @@ Gem::Specification.new do |s|
116
115
  s.add_runtime_dependency(%q<bcrypt-ruby>, [">= 2.1.2"])
117
116
  s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
118
117
  s.add_runtime_dependency(%q<flickraw>, [">= 0.8.3"])
119
- s.add_runtime_dependency(%q<flog>, [">= 2.5.0"])
120
118
  s.add_runtime_dependency(%q<hpricot>, [">= 0.8.1"])
121
119
  s.add_runtime_dependency(%q<htmlentities>, [">= 4.2.0"])
122
120
  s.add_runtime_dependency(%q<json>, [">= 1.2.3"])
121
+ s.add_runtime_dependency(%q<plumnailer>, [">= 0.1.0"])
123
122
  s.add_runtime_dependency(%q<push-notify>, [">= 0.1.0"])
124
123
  s.add_runtime_dependency(%q<rack>, [">= 1.0.0"])
125
124
  s.add_runtime_dependency(%q<rack-cache>, [">= 0.5.2"])
126
125
  s.add_runtime_dependency(%q<rack-rewrite>, [">= 1.0.2"])
127
126
  s.add_runtime_dependency(%q<rack-throttle>, [">= 0.3.0"])
127
+ s.add_runtime_dependency(%q<rmagick>, [">= 1.15.14"])
128
128
  s.add_runtime_dependency(%q<sqlite3-ruby>, [">= 1.2.1"])
129
- s.add_runtime_dependency(%q<tinyatom>, [">= 0.2.0"])
129
+ s.add_runtime_dependency(%q<tinyatom>, [">= 0.3.3"])
130
130
  s.add_runtime_dependency(%q<twitter>, [">= 0.9.12"])
131
131
  s.add_runtime_dependency(%q<vimeo>, [">= 1.2.2"])
132
- s.add_runtime_dependency(%q<rspec>, ["~> 1.3"])
132
+ s.add_development_dependency(%q<flog>, [">= 2.5.0"])
133
+ s.add_development_dependency(%q<rspec>, ["~> 1.3"])
133
134
  else
134
135
  s.add_dependency(%q<activerecord>, [">= 2.3.4"])
135
136
  s.add_dependency(%q<bcrypt-ruby>, [">= 2.1.2"])
136
137
  s.add_dependency(%q<builder>, [">= 2.1.2"])
137
138
  s.add_dependency(%q<flickraw>, [">= 0.8.3"])
138
- s.add_dependency(%q<flog>, [">= 2.5.0"])
139
139
  s.add_dependency(%q<hpricot>, [">= 0.8.1"])
140
140
  s.add_dependency(%q<htmlentities>, [">= 4.2.0"])
141
141
  s.add_dependency(%q<json>, [">= 1.2.3"])
142
+ s.add_dependency(%q<plumnailer>, [">= 0.1.0"])
142
143
  s.add_dependency(%q<push-notify>, [">= 0.1.0"])
143
144
  s.add_dependency(%q<rack>, [">= 1.0.0"])
144
145
  s.add_dependency(%q<rack-cache>, [">= 0.5.2"])
145
146
  s.add_dependency(%q<rack-rewrite>, [">= 1.0.2"])
146
147
  s.add_dependency(%q<rack-throttle>, [">= 0.3.0"])
148
+ s.add_dependency(%q<rmagick>, [">= 1.15.14"])
147
149
  s.add_dependency(%q<sqlite3-ruby>, [">= 1.2.1"])
148
- s.add_dependency(%q<tinyatom>, [">= 0.2.0"])
150
+ s.add_dependency(%q<tinyatom>, [">= 0.3.3"])
149
151
  s.add_dependency(%q<twitter>, [">= 0.9.12"])
150
152
  s.add_dependency(%q<vimeo>, [">= 1.2.2"])
153
+ s.add_dependency(%q<flog>, [">= 2.5.0"])
151
154
  s.add_dependency(%q<rspec>, ["~> 1.3"])
152
155
  end
153
156
  else
@@ -155,19 +158,21 @@ Gem::Specification.new do |s|
155
158
  s.add_dependency(%q<bcrypt-ruby>, [">= 2.1.2"])
156
159
  s.add_dependency(%q<builder>, [">= 2.1.2"])
157
160
  s.add_dependency(%q<flickraw>, [">= 0.8.3"])
158
- s.add_dependency(%q<flog>, [">= 2.5.0"])
159
161
  s.add_dependency(%q<hpricot>, [">= 0.8.1"])
160
162
  s.add_dependency(%q<htmlentities>, [">= 4.2.0"])
161
163
  s.add_dependency(%q<json>, [">= 1.2.3"])
164
+ s.add_dependency(%q<plumnailer>, [">= 0.1.0"])
162
165
  s.add_dependency(%q<push-notify>, [">= 0.1.0"])
163
166
  s.add_dependency(%q<rack>, [">= 1.0.0"])
164
167
  s.add_dependency(%q<rack-cache>, [">= 0.5.2"])
165
168
  s.add_dependency(%q<rack-rewrite>, [">= 1.0.2"])
166
169
  s.add_dependency(%q<rack-throttle>, [">= 0.3.0"])
170
+ s.add_dependency(%q<rmagick>, [">= 1.15.14"])
167
171
  s.add_dependency(%q<sqlite3-ruby>, [">= 1.2.1"])
168
- s.add_dependency(%q<tinyatom>, [">= 0.2.0"])
172
+ s.add_dependency(%q<tinyatom>, [">= 0.3.3"])
169
173
  s.add_dependency(%q<twitter>, [">= 0.9.12"])
170
174
  s.add_dependency(%q<vimeo>, [">= 1.2.2"])
175
+ s.add_dependency(%q<flog>, [">= 2.5.0"])
171
176
  s.add_dependency(%q<rspec>, ["~> 1.3"])
172
177
  end
173
178
  end
@@ -1,19 +1,17 @@
1
- %w{
2
- uri
1
+ require 'uri'
3
2
 
4
- tinyatom
3
+ require 'tinyatom'
5
4
 
6
- murlsh
7
- }.each { |m| require m }
5
+ require 'murlsh'
8
6
 
9
7
  module Murlsh
10
8
 
11
- # regenerate atom feed after a new url has been added
9
+ # Regenerate atom feed after a new url has been added.
12
10
  class AddPost50UpdateFeed < Plugin
13
11
 
14
12
  @hook = 'add_post'
15
13
 
16
- # content types to add an enclosure for
14
+ # Content types to add an enclosure for.
17
15
  EnclosureContentTypes = %w{
18
16
  application/pdf
19
17
  audio/mpeg
@@ -44,7 +42,21 @@ module Murlsh
44
42
  :enclosure_title => mu.title
45
43
  )
46
44
  if mu.content_length
47
- options.merge!(:enclosure_length => mu.content_length)
45
+ options.merge! :enclosure_length => mu.content_length
46
+ end
47
+ end
48
+
49
+ if mu.thumbnail_url
50
+ begin
51
+ # Add root url to relative urls.
52
+ tu = URI(mu.thumbnail_url)
53
+ abs_url = if tu.is_a?(URI::HTTP)
54
+ tu
55
+ else
56
+ URI.join config['root_url'], tu
57
+ end
58
+ options.merge! :media_thumbnail_url => abs_url
59
+ rescue URI::InvalidURIError
48
60
  end
49
61
  end
50
62
 
@@ -58,11 +70,11 @@ module Murlsh
58
70
  end
59
71
  end
60
72
 
61
- feed.add_entry(mu.id, mu.title_stripped, mu.time, mu.url, options)
73
+ feed.add_entry mu.id, mu.title_stripped, mu.time, mu.url, options
62
74
  end
63
75
 
64
76
  Murlsh::openlock(config.fetch('feed_file'), 'w') do |f|
65
- feed.make(:target => f)
77
+ feed.make :target => f
66
78
  end
67
79
 
68
80
  end
@@ -1,9 +1,7 @@
1
- %w{
2
- rss/maker
3
- uri
1
+ require 'rss/maker'
2
+ require 'uri'
4
3
 
5
- murlsh
6
- }.each { |m| require m }
4
+ require 'murlsh'
7
5
 
8
6
  module Murlsh
9
7
 
@@ -1,9 +1,7 @@
1
- %w{
2
- rss/maker
3
- uri
1
+ require 'rss/maker'
2
+ require 'uri'
4
3
 
5
- murlsh
6
- }.each { |m| require m }
4
+ require 'murlsh'
7
5
 
8
6
  module Murlsh
9
7
 
@@ -12,7 +10,7 @@ module Murlsh
12
10
 
13
11
  @hook = 'add_post'
14
12
 
15
- # content types to add an enclosure for
13
+ # Content types to add an enclosure for.
16
14
  EnclosureContentTypes = %w{
17
15
  application/pdf
18
16
  audio/mpeg
@@ -1,12 +1,10 @@
1
- %w{
2
- uri
1
+ require 'uri'
3
2
 
4
- murlsh
5
- }.each { |m| require m }
3
+ require 'murlsh'
6
4
 
7
5
  module Murlsh
8
6
 
9
- # notify PubSubHubbub hubs that feed has been updated
7
+ # Notify PubSubHubbub hubs that feed has been updated.
10
8
  class AddPost60NotifyHubs < Plugin
11
9
 
12
10
  @hook = 'add_post'
@@ -1,10 +1,7 @@
1
- %w{
2
- murlsh
3
- }.each { |m| require m }
1
+ require 'murlsh'
4
2
 
5
3
  module Murlsh
6
4
 
7
-
8
5
  # Convert urls specifically for use on mobile devices into their non-mobile
9
6
  # equivalents.
10
7
  class AddPre40ConvertMobile < Plugin
@@ -16,12 +13,9 @@ module Murlsh
16
13
 
17
14
  def self.run(url, config)
18
15
  url.url = case
19
- when match = TwitterRe.match(url.url)
20
- "#{match[1]}#{match[2]}"
21
- when match = WikipediaRe.match(url.url)
22
- "#{match[1]}#{match[2]}"
23
- else
24
- url.url
16
+ when match = TwitterRe.match(url.url); "#{match[1]}#{match[2]}"
17
+ when match = WikipediaRe.match(url.url); "#{match[1]}#{match[2]}"
18
+ else; url.url
25
19
  end
26
20
  end
27
21
 
@@ -1,12 +1,10 @@
1
- %w{
2
- uri
1
+ require 'uri'
3
2
 
4
- murlsh
5
- }.each { |m| require m }
3
+ require 'murlsh'
6
4
 
7
5
  module Murlsh
8
6
 
9
- # try to fetch the content length, content type and title of a url
7
+ # Try to fetch the content length, content type and title of a url.
10
8
  class AddPre50LookupContentTypeTitle < Plugin
11
9
 
12
10
  @hook = 'add_pre'
@@ -14,7 +12,7 @@ module Murlsh
14
12
  def self.run(url, config)
15
13
  ask = URI(url.url).extend(Murlsh::UriAsk)
16
14
  headers = {}
17
- headers['User-Agent'] = config['user_agent'] if config['user_agent']
15
+ headers['User-Agent'] = config['user_agent'] if config['user_agent']
18
16
 
19
17
  content_length = ask.content_length(:headers => headers)
20
18
  if content_length and not content_length.empty?
@@ -1,21 +1,15 @@
1
- %w{
2
- cgi
1
+ require 'flickraw'
3
2
 
4
- flickraw
5
-
6
- murlsh
7
- }.each { |m| require m }
3
+ require 'murlsh'
8
4
 
9
5
  module Murlsh
10
6
 
11
- # Set the title and thumbnail url of Flickr photos.
7
+ # Set the title of Flickr photos.
12
8
  class AddPre60Flickr < Plugin
13
9
 
14
10
  @hook = 'add_pre'
15
11
 
16
12
  FlickrRe = %r{^http://(?:www\.)?flickr\.com/photos/[@\w\-]+?/([\d]+)}i
17
- StorageDir = File.join(File.dirname(__FILE__), '..', 'public', 'img',
18
- 'thumb')
19
13
 
20
14
  def self.run(url, config)
21
15
  if config['flickr_api_key'] and not config['flickr_api_key'].empty?
@@ -24,11 +18,6 @@ module Murlsh
24
18
  info = flickr.photos.getInfo(:photo_id => photo_id)
25
19
 
26
20
  url.title = "#{info.title} by #{info.owner.username}"
27
-
28
- thumb_storage = Murlsh::ImgStore.new(StorageDir,
29
- :user_agent => config['user_agent'])
30
- stored_filename = thumb_storage.store(FlickRaw.url_s(info))
31
- url.thumbnail_url = "img/thumb/#{CGI.escape(stored_filename)}"
32
21
  end
33
22
  end
34
23
  end
@@ -1,8 +1,6 @@
1
- %w{
2
- uri
1
+ require 'uri'
3
2
 
4
- murlsh
5
- }.each { |m| require m }
3
+ require 'murlsh'
6
4
 
7
5
  module Murlsh
8
6
 
@@ -12,12 +10,12 @@ module Murlsh
12
10
 
13
11
  @hook = 'add_pre'
14
12
 
15
- GithubRe = %r{^http://github\.com/\w+/[\w.-]+$}i
13
+ GithubRe = %r{^https?://github\.com/\w+/[\w.-]+$}i
16
14
 
17
15
  def self.run(url, config)
18
16
  if url.url[GithubRe]
19
17
  ask = URI(url.url).extend(Murlsh::UriAsk)
20
- url.title << " - #{ask.description}" unless ask.description.empty?
18
+ url.title << " - #{ask.description}" unless ask.description.empty?
21
19
  end
22
20
  end
23
21
 
@@ -1,13 +1,11 @@
1
- %w{
2
- uri
1
+ require 'uri'
3
2
 
4
- murlsh
5
- }.each { |m| require m }
3
+ require 'murlsh'
6
4
 
7
5
  module Murlsh
8
6
 
9
7
  # Google Code project page titles are not very descriptive so add summary
10
- # from page
8
+ # from page.
11
9
  class AddPre60GoogleCodeTitle < Plugin
12
10
 
13
11
  @hook = 'add_pre'
@@ -19,7 +17,7 @@ module Murlsh
19
17
  ask = URI(url.url).extend(Murlsh::UriAsk)
20
18
  ask.doc.xpath_search("//a[@id='project_summary_link']") do |node|
21
19
  summary = node ? node.inner_html : nil
22
- url.title << " - #{ask.decode(summary)}" unless !summary or
20
+ url.title << " - #{ask.decode(summary)}" unless not summary or
23
21
  summary.empty?
24
22
  end
25
23
  end
@@ -1,29 +1,17 @@
1
- %w{
2
- cgi
3
-
4
- murlsh
5
- }.each { |m| require m }
1
+ require 'murlsh'
6
2
 
7
3
  module Murlsh
8
4
 
9
- # Add YouTube thumbnail.
5
+ # Set the title of imgur images.
10
6
  class AddPre60Imgur < Plugin
11
7
 
12
8
  @hook = 'add_pre'
13
9
 
14
- ImgurRe = %r{^(http://(?:i\.)?imgur\.com/)([a-z\d]+)(\.(?:jpe?g|gif|png))$}i
15
- StorageDir = File.join(File.dirname(__FILE__), '..', 'public', 'img',
16
- 'thumb')
10
+ ImgurRe = %r{^http://(?:i\.)?imgur\.com/([a-z\d]+)(\.(?:jpe?g|gif|png))$}i
17
11
 
18
12
  def self.run(url, config)
19
13
  if match = ImgurRe.match(url.url)
20
- url.title = "imgur/#{match[2]}s#{match[3]}"
21
-
22
- thumb_storage = Murlsh::ImgStore.new(StorageDir,
23
- :user_agent => config['user_agent'])
24
- stored_filename = thumb_storage.store(
25
- "#{match[1]}#{match[2]}s#{match[3]}")
26
- url.thumbnail_url = "img/thumb/#{CGI.escape(stored_filename)}"
14
+ url.title = "imgur/#{match[1]}s#{match[2]}"
27
15
  end
28
16
  end
29
17
 
@@ -1,8 +1,6 @@
1
- %w{
2
- cgi
1
+ require 'cgi'
3
2
 
4
- murlsh
5
- }.each { |m| require m }
3
+ require 'murlsh'
6
4
 
7
5
  module Murlsh
8
6
 
@@ -21,8 +19,11 @@ module Murlsh
21
19
 
22
20
  thumb_storage = Murlsh::ImgStore.new(StorageDir,
23
21
  :user_agent => config['user_agent'])
24
- stored_filename = thumb_storage.store(
25
- "#{match[1]}#{match[2]}.th.#{extension}")
22
+ stored_filename = thumb_storage.store_url(
23
+ "#{match[1]}#{match[2]}.th.#{extension}") do |i|
24
+ max_side = config.fetch('thumbnail_max_side', 90)
25
+ i.extend(Murlsh::ImageList).resize_down!(max_side)
26
+ end
26
27
 
27
28
  url.thumbnail_url = "img/thumb/#{CGI.escape(stored_filename)}"
28
29
  url.title = match[2]
@@ -1,32 +1,21 @@
1
- %w{
2
- cgi
1
+ require 'twitter'
3
2
 
4
- twitter
5
-
6
- murlsh
7
- }.each { |m| require m }
3
+ require 'murlsh'
8
4
 
9
5
  module Murlsh
10
6
 
11
- # Set title to entire tweet and set thumbnail url.
7
+ # Set title of twitter status urls to entire tweet.
12
8
  class AddPre60Twitter < Plugin
13
9
 
14
10
  @hook = 'add_pre'
15
11
 
16
12
  TwitterRe = %r{^https?://twitter\.com/\w+/status(?:es)?/(\d+)$}i
17
- StorageDir = File.join(File.dirname(__FILE__), '..', 'public', 'img',
18
- 'thumb')
19
13
 
20
14
  def self.run(url, config)
21
15
  if tweet_id = url.url[TwitterRe, 1]
22
16
  tweet = Twitter.status(tweet_id)
23
17
 
24
18
  url.title = "@#{tweet.user.screen_name}: #{tweet.text}"
25
-
26
- thumb_storage = Murlsh::ImgStore.new(StorageDir,
27
- :user_agent => config['user_agent'])
28
- stored_filename = thumb_storage.store(tweet.user.profile_image_url)
29
- url.thumbnail_url = "img/thumb/#{CGI.escape(stored_filename)}"
30
19
  end
31
20
  end
32
21
 
@@ -1,10 +1,8 @@
1
- %w{
2
- cgi
1
+ require 'cgi'
3
2
 
4
- vimeo
3
+ require 'vimeo'
5
4
 
6
- murlsh
7
- }.each { |m| require m }
5
+ require 'murlsh'
8
6
 
9
7
  module Murlsh
10
8
 
@@ -25,7 +23,10 @@ module Murlsh
25
23
 
26
24
  thumb_storage = Murlsh::ImgStore.new(StorageDir,
27
25
  :user_agent => config['user_agent'])
28
- stored_filename = thumb_storage.store(info['thumbnail_small'])
26
+ stored_filename = thumb_storage.store_url(info['thumbnail_small']) do |i|
27
+ max_side = config.fetch('thumbnail_max_side', 90)
28
+ i.extend(Murlsh::ImageList).resize_down!(max_side)
29
+ end
29
30
  url.thumbnail_url = "img/thumb/#{CGI.escape(stored_filename)}"
30
31
  end
31
32
  end