dropsite 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -51,9 +51,14 @@ Or you can send me an email: aaronroyer@gmail.com
51
51
 
52
52
  == Attribution
53
53
 
54
+ Default Dropsite theme inspired by github.com
55
+
56
+
54
57
  Dropsite uses icons from:
55
58
 
56
- famfamfam.com
59
+ famfamfam.com Silk Icons
60
+
61
+ Yusuke Kamiyamane's Fugue icons (p.yusukekamiyamane.com)
57
62
 
58
63
  Echo Project (fedorahosted.org/echo-icon-theme/)
59
64
 
data/dropsite.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dropsite'
3
- s.version = '0.3.2'
3
+ s.version = '0.3.3'
4
4
  s.platform = Gem::Platform::RUBY
5
5
 
6
- s.description = "creates index pages in your Dropbox public directory"
6
+ s.description = "Non-invasive Dropbox Public directory index page generator"
7
7
  s.summary = "Dropsite creates a site of interlinked file index pages in " +
8
8
  "the Public directory of your Dropbox. The site created is minimally " +
9
9
  "invasive to your Public directory by only creating one top-level " +
@@ -4,6 +4,15 @@
4
4
  def thumb_name(image_file_name)
5
5
  File.basename(image_file_name).sub(/\.\w+$/, '') + '-thumb' + File.extname(image_file_name)
6
6
  end
7
+
8
+ def thumb_link(file_name)
9
+ if renderer.class::VALID_THUMBNAIL_EXTENSIONS.include? File.extname(file_name).sub(/^\./, '')
10
+ page_asset_image_tag thumb_name(file_name)
11
+ else
12
+ image_tag 'icons/image-large.png'
13
+ end
14
+ end
15
+
7
16
  def shorten(file_name)
8
17
  if file_name.size < 20
9
18
  file_name
@@ -40,7 +49,7 @@ end
40
49
  <% end %>
41
50
  <% files.sort.each do |file| %>
42
51
  <a class="thumb-link" href="<%= url_for file %>">
43
- <%= page_asset_image_tag thumb_name(file.name) %>
52
+ <%= thumb_link file.name %>
44
53
  <div class="name"><%= shorten file.name %></div>
45
54
  </a>
46
55
  <% end %>
@@ -1,6 +1,8 @@
1
1
  require 'fileutils'
2
2
 
3
3
  class ImageThumbnails < Dropsite::DirRenderer
4
+ VALID_THUMBNAIL_EXTENSIONS = %w[bmp gif jpeg jpg png tif tiff]
5
+
4
6
  def can_render?(site_dir)
5
7
  return false if not thumbnail_generator
6
8
  !site_dir.files.empty? && site_dir.files.all? {|e| e.file_type == :image}
@@ -78,13 +80,11 @@ class ImageThumbnails < Dropsite::DirRenderer
78
80
  end
79
81
 
80
82
  def write_default_thumbnail(src_image, site_dir)
81
- # Need to figure out what type of file this is to make it work
82
- default_thumb = File.join(plugin_assets_dir, 'images', 'icons', "image-large#{File.extname(src_image)}")
83
-
84
- if File.exist? default_thumb
85
- FileUtils.cp(default_thumb,File.join(site_dir.page_assets_dir, thumb_file_name(src_image)))
86
- else
87
- site_dir.error "BUG: no default thumb type exists for files with extension: #{File.extname(src_image)}"
83
+ # If not a valid extension then no thumbnail needs to be copied in, since at
84
+ # render time it should not expect it to be there
85
+ if VALID_THUMBNAIL_EXTENSIONS.include? File.extname(src_image).sub(/^\./, '')
86
+ default_thumb = File.join(plugin_assets_dir, 'images', 'icons', "image-large#{File.extname(src_image)}")
87
+ FileUtils.cp(default_thumb, File.join(site_dir.page_assets_dir, thumb_file_name(src_image)))
88
88
  end
89
89
  end
90
90
  end
@@ -1,9 +1,14 @@
1
1
  module Dropsite
2
2
  class SiteFile < SiteItem
3
3
  EXTENSIONS = {
4
- :image => %w[jpg jpeg gif png],
5
- :text => %w[txt],
6
- :pdf => %w[pdf]
4
+ :audio => %w[abs aif aifc aiff au kar m3u mid midi mp1 mp2 mp3 mpa mpega pls smf snd ulw wav],
5
+ :excel => %w[xls xlsx],
6
+ :image => %w[art bmp dib gif ief jpe jpeg jpg mac pbm pct pgm pic pict png pnm pnt ppm psd qti qtif ras rgb svg svgz tif tiff wbmp xbm xpm xwd],
7
+ :pdf => %w[pdf],
8
+ :ruby => %w[rb rhtml erb],
9
+ :text => %w[body css etx htc htm html jad java js rtf rtx tsv txt wml wmls],
10
+ :video => %w[asf asx avi avx dv flv mov movie mp4 mpe mpeg mpg mpv2 qt wmv],
11
+ :word => %w[doc docx]
7
12
  }
8
13
 
9
14
  attr_accessor :size_in_bytes, :abs_path
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'helper')
2
+ require 'nokogiri'
3
+
4
+ class TestImageThumbnails < Test::Unit::TestCase
5
+
6
+ def test_thumbnail_link
7
+ sd = SiteDir.new('', [SiteFile.new('pic.jpg')], Site.new('/tmp'))
8
+ sd.render
9
+
10
+ doc = Nokogiri::HTML(sd.content)
11
+ thumb_links = doc.css('.thumb-link')
12
+
13
+ assert_equal 1, thumb_links.size
14
+ assert_equal 'pic-thumb.jpg', File.basename(thumb_links.first.css('img').first.attribute('src').value)
15
+ end
16
+
17
+ # Test that a default thumbnail is linked for an image type for which a thumbnail
18
+ # cannot be created
19
+ def test_non_generateable_thumbnail_link
20
+ sd = SiteDir.new('', [SiteFile.new('pic.art')], Site.new('/tmp'))
21
+ sd.render
22
+
23
+ doc = Nokogiri::HTML(sd.content)
24
+ thumb_links = doc.css('.thumb-link')
25
+
26
+ assert_equal 1, thumb_links.size
27
+ assert_equal 'dropsite/dropsite-assets/image_thumbnails/images/icons/image-large.png',
28
+ thumb_links.first.css('img').first.attribute('src').value
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'helper')
2
+ require 'nokogiri'
3
+
4
+ class TestSimpleIndex < Test::Unit::TestCase
5
+ def test_file_names_and_icons
6
+ entries = [
7
+ SiteFile.new('pic.jpg'),
8
+ SiteFile.new('stuff.pdf'),
9
+ SiteFile.new('tps-report.doc'),
10
+ ]
11
+ sd = SiteDir.new('', entries, Site.new('/tmp'))
12
+ sd.render
13
+
14
+ doc = Nokogiri::HTML(sd.content)
15
+ entry_rows = doc.css('tr.entry')
16
+
17
+ assert_equal entries.size, entry_rows.size
18
+ assert_file_has_icon 'pic.jpg', 'image', entry_rows
19
+ assert_file_has_icon 'stuff.pdf', 'pdf', entry_rows
20
+ assert_file_has_icon 'tps-report.doc', 'word', entry_rows
21
+ end
22
+
23
+ protected
24
+
25
+ def assert_file_has_icon(file_name, icon_name, entry_rows)
26
+ row = entry_rows.find {|er| er.css('a').first.content.strip == file_name}
27
+ assert_equal "dropsite/dropsite-assets/simple_index/images/icons/#{icon_name}.png",
28
+ row.css('img').first.attribute('src').value
29
+ end
30
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dropsite
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aaron Royer
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-27 00:00:00 -05:00
18
+ date: 2011-03-01 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
22
- description: creates index pages in your Dropbox public directory
22
+ description: Non-invasive Dropbox Public directory index page generator
23
23
  email: aaronroyer@gmail.com
24
24
  executables:
25
25
  - dropsite
@@ -41,18 +41,24 @@ files:
41
41
  - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.jpeg
42
42
  - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.jpg
43
43
  - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.png
44
+ - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.tif
44
45
  - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.tiff
45
46
  - lib/dropsite/plugins/image_thumbnails/assets/images/row-bg.png
46
47
  - lib/dropsite/plugins/image_thumbnails/image_thumbnails.erb
47
48
  - lib/dropsite/plugins/image_thumbnails/image_thumbnails.rb
48
49
  - lib/dropsite/plugins/simple_index/assets/css/reset.css
49
50
  - lib/dropsite/plugins/simple_index/assets/css/simple_index.css
51
+ - lib/dropsite/plugins/simple_index/assets/images/icons/audio.png
50
52
  - lib/dropsite/plugins/simple_index/assets/images/icons/directory.png
53
+ - lib/dropsite/plugins/simple_index/assets/images/icons/excel.png
51
54
  - lib/dropsite/plugins/simple_index/assets/images/icons/image.png
52
55
  - lib/dropsite/plugins/simple_index/assets/images/icons/pdf.png
56
+ - lib/dropsite/plugins/simple_index/assets/images/icons/ruby.png
53
57
  - lib/dropsite/plugins/simple_index/assets/images/icons/script.png
54
58
  - lib/dropsite/plugins/simple_index/assets/images/icons/text.png
55
59
  - lib/dropsite/plugins/simple_index/assets/images/icons/unknown.png
60
+ - lib/dropsite/plugins/simple_index/assets/images/icons/video.png
61
+ - lib/dropsite/plugins/simple_index/assets/images/icons/word.png
56
62
  - lib/dropsite/plugins/simple_index/assets/images/row-bg.png
57
63
  - lib/dropsite/plugins/simple_index/simple_index.erb
58
64
  - lib/dropsite/plugins/simple_index/simple_index.rb
@@ -77,7 +83,9 @@ files:
77
83
  - test/integration/test_process_site_with_thumbnails.rb
78
84
  - test/unit/test_application.rb
79
85
  - test/unit/test_config_file.rb
86
+ - test/unit/test_image_thumbnails.rb
80
87
  - test/unit/test_render_helper.rb
88
+ - test/unit/test_simple_index.rb
81
89
  - test/unit/test_site.rb
82
90
  - test/unit/test_site_dir.rb
83
91
  - test/unit/test_site_file.rb