murlsh 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/.gitignore +4 -0
  2. data/.htaccess +0 -3
  3. data/Gemfile +41 -0
  4. data/README.textile +68 -6
  5. data/Rakefile +65 -152
  6. data/config.ru +13 -2
  7. data/config.yaml +9 -4
  8. data/db/migrate/20110213023123_init.rb +20 -0
  9. data/lib/murlsh/atom_body.rb +78 -0
  10. data/lib/murlsh/atom_server.rb +38 -0
  11. data/lib/murlsh/auth.rb +12 -0
  12. data/lib/murlsh/build_query.rb +1 -1
  13. data/lib/murlsh/cat_files.rb +17 -0
  14. data/lib/murlsh/delicious_parse.rb +1 -0
  15. data/lib/murlsh/dispatch.rb +25 -11
  16. data/lib/murlsh/etag_add_encoding.rb +1 -1
  17. data/lib/murlsh/feed_body.rb +36 -0
  18. data/lib/murlsh/img_store.rb +27 -28
  19. data/lib/murlsh/install.rb +1 -0
  20. data/lib/murlsh/json_body.rb +5 -2
  21. data/lib/murlsh/json_server.rb +9 -13
  22. data/lib/murlsh/m3u_body.rb +28 -0
  23. data/lib/murlsh/m3u_server.rb +50 -0
  24. data/lib/murlsh/markup.rb +1 -1
  25. data/lib/murlsh/plugin.rb +5 -0
  26. data/lib/murlsh/podcast_server.rb +44 -0
  27. data/lib/murlsh/pop_server.rb +78 -0
  28. data/lib/murlsh/random_server.rb +41 -0
  29. data/lib/murlsh/rss_body.rb +46 -0
  30. data/lib/murlsh/rss_server.rb +38 -0
  31. data/lib/murlsh/search_conditions.rb +2 -2
  32. data/lib/murlsh/uri_ask.rb +2 -2
  33. data/lib/murlsh/url_body.rb +21 -6
  34. data/lib/murlsh/url_result_set.rb +2 -2
  35. data/lib/murlsh/url_server.rb +19 -16
  36. data/lib/murlsh/write_ordered_hash.rb +17 -0
  37. data/lib/murlsh.rb +13 -2
  38. data/murlsh.gemspec +41 -194
  39. data/plugins/add_post_60_notify_hubs.rb +3 -2
  40. data/plugins/add_pre_30_unajax_twitter.rb +1 -1
  41. data/plugins/add_pre_40_thumbnail_shortcuts.rb +23 -0
  42. data/plugins/add_pre_45_supplied_thumbnail.rb +4 -9
  43. data/plugins/add_pre_50_media_thumbnail.rb +4 -9
  44. data/plugins/add_pre_50_open_graph_image.rb +4 -8
  45. data/plugins/add_pre_60_github_title.rb +1 -1
  46. data/plugins/add_pre_65_html_thumb.rb +3 -8
  47. data/plugins/add_pre_65_img_thumb.rb +4 -9
  48. data/plugins/avatar_50_gravatar.rb +2 -1
  49. data/plugins/store_asset_40_s3.rb +40 -0
  50. data/plugins/store_asset_50_local.rb +22 -0
  51. data/public/js/js.js +0 -7
  52. data/spec/auth_spec.rb +7 -0
  53. data/spec/cat_files_spec.rb +49 -0
  54. data/spec/img_store_spec.rb +24 -8
  55. metadata +119 -76
  56. data/VERSION +0 -1
  57. data/lib/murlsh/build_md5.rb +0 -12
  58. data/lib/murlsh/head_from_get.rb +0 -15
  59. data/plugins/add_post_50_update_feed.rb +0 -84
  60. data/plugins/add_post_50_update_m3u.rb +0 -35
  61. data/plugins/add_post_50_update_podcast.rb +0 -44
  62. data/plugins/add_post_50_update_rss.rb +0 -51
  63. data/plugins/add_pre_60_s3_image.rb +0 -35
@@ -1,44 +0,0 @@
1
- require 'rss/maker'
2
- require 'uri'
3
-
4
- require 'murlsh'
5
-
6
- module Murlsh
7
-
8
- # Regenerate podcast RSS feed after a new audio/mpeg url has been added.
9
- class AddPost50UpdatePodcast < Plugin
10
-
11
- @hook = 'add_post'
12
-
13
- def self.run(url, config)
14
- if url.content_type == 'audio/mpeg'
15
- output_file = 'podcast.rss'
16
-
17
- feed = RSS::Maker.make('2.0') do |f|
18
- f.channel.title = f.channel.description = config.fetch(
19
- 'page_title', '')
20
- f.channel.link = URI.join(config.fetch('root_url'), output_file)
21
- f.items.do_sort = true
22
-
23
- Murlsh::Url.all(:conditions => { :content_type => 'audio/mpeg' },
24
- :order => 'time DESC',
25
- :limit => config.fetch('num_posts_feed', 25)).each do |mu|
26
- i = f.items.new_item
27
- i.title = mu.title_stripped
28
- i.link = mu.url
29
- i.date = mu.time
30
-
31
- i.enclosure.url = mu.url
32
- i.enclosure.type = mu.content_type
33
- i.enclosure.length = mu.content_length
34
- end
35
-
36
- end
37
-
38
- Murlsh::openlock(output_file, 'w') { |f| f.write(feed) }
39
- end
40
- end
41
-
42
- end
43
-
44
- end
@@ -1,51 +0,0 @@
1
- require 'rss/maker'
2
- require 'uri'
3
-
4
- require 'murlsh'
5
-
6
- module Murlsh
7
-
8
- # Regenerate RSS feed after a new url has been added.
9
- class AddPost50UpdateRss < Plugin
10
-
11
- @hook = 'add_post'
12
-
13
- # Content types to add an enclosure for.
14
- EnclosureContentTypes = %w{
15
- application/pdf
16
- audio/mpeg
17
- image/gif
18
- image/jpeg
19
- image/png
20
- }
21
-
22
- def self.run(url, config)
23
- output_file = 'rss.rss'
24
-
25
- feed = RSS::Maker.make('2.0') do |f|
26
- f.channel.title = f.channel.description = config.fetch('page_title', '')
27
- f.channel.link = URI.join(config.fetch('root_url'), output_file)
28
- f.items.do_sort = true
29
-
30
- Murlsh::Url.all(:order => 'time DESC',
31
- :limit => config.fetch('num_posts_feed', 25)).each do |mu|
32
- i = f.items.new_item
33
- i.title = mu.title_stripped
34
- i.link = mu.url
35
- i.date = mu.time
36
-
37
- if EnclosureContentTypes.include?(mu.content_type)
38
- i.enclosure.url = mu.url
39
- i.enclosure.type = mu.content_type
40
- i.enclosure.length = mu.content_length
41
- end
42
- end
43
-
44
- end
45
-
46
- Murlsh::openlock(output_file, 'w') { |f| f.write(feed) }
47
- end
48
-
49
- end
50
-
51
- end
@@ -1,35 +0,0 @@
1
- require 'cgi'
2
-
3
- require 'murlsh'
4
-
5
- module Murlsh
6
-
7
- # Set the thumbnail of s3 hosted images.
8
- class AddPre60S3Image < Plugin
9
-
10
- @hook = 'add_pre'
11
-
12
- S3ImageRe = %r{^(http://static\.mmb\.s3\.amazonaws\.com/)([\w\-]+)\.(jpe?g|gif|pdf|png)$}i
13
- StorageDir = File.join(File.dirname(__FILE__), '..', 'public', 'img',
14
- 'thumb')
15
-
16
- def self.run(url, config)
17
- if match = S3ImageRe.match(url.url)
18
- extension = match[3].downcase == 'pdf' ? 'png' : match[3]
19
-
20
- thumb_storage = Murlsh::ImgStore.new(StorageDir,
21
- :user_agent => config['user_agent'])
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
27
-
28
- url.thumbnail_url = "img/thumb/#{CGI.escape(stored_filename)}"
29
- url.title = match[2] unless url.user_supplied_title?
30
- end
31
- end
32
-
33
- end
34
-
35
- end