dropsite 0.3.1 → 0.3.2

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.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2010 Aaron Royer
3
+ Copyright (c) 2010-2011 Aaron Royer
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
data/README.rdoc ADDED
@@ -0,0 +1,88 @@
1
+ = Dropsite
2
+
3
+ Dropsite creates a site of interlinked file index pages in the Public directory
4
+ of your Dropbox. Dropsite is designed to be minimally invasive to your Public
5
+ directory by only creating one top-level HTML page and one folder, leaving your
6
+ directories unjunked.
7
+
8
+ BE WARNED: while this seems to work fine, it is presently considered
9
+ experimental.
10
+
11
+ == Installation
12
+
13
+ gem install dropsite
14
+
15
+ == Usage
16
+
17
+ To create the site:
18
+ dropsite
19
+
20
+ This deletes "index.html" and the directory "dropsite" in your Dropbox Public
21
+ directory if they exist, creates "index.html" as the top-level index, and puts
22
+ the rest of the index pages and assets in the "dropsite" directory.
23
+
24
+ To specify a different Dropbox directory:
25
+ dropsite --dropbox-home ~/Somewhere/Else
26
+
27
+ You can also use this if you want to test site generation elsewhere first.
28
+
29
+
30
+ For more help:
31
+
32
+ dropsite --help
33
+
34
+ == Development
35
+
36
+ === Source Repository
37
+
38
+ http://github.com/aaronroyer/dropsite
39
+
40
+ Git clone URL is
41
+
42
+ * git://github.com/aaronroyer/dropsite.git
43
+
44
+ === Issues and Bug Reports
45
+
46
+ You can open issues at Github
47
+
48
+ * http://github.com/aaronroyer/dropsite/issues
49
+
50
+ Or you can send me an email: aaronroyer@gmail.com
51
+
52
+ == Attribution
53
+
54
+ Dropsite uses icons from:
55
+
56
+ famfamfam.com
57
+
58
+ Echo Project (fedorahosted.org/echo-icon-theme/)
59
+
60
+ == License
61
+
62
+ (The MIT License)
63
+
64
+ Copyright (c) 2010-2011 Aaron Royer
65
+
66
+ Permission is hereby granted, free of charge, to any person obtaining a copy
67
+ of this software and associated documentation files (the 'Software'), to deal
68
+ in the Software without restriction, including without limitation the rights
69
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
70
+ copies of the Software, and to permit persons to whom the Software is
71
+ furnished to do so, subject to the following conditions:
72
+
73
+ The above copyright notice and this permission notice shall be included in all
74
+ copies or substantial portions of the Software.
75
+
76
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
77
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
78
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
79
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
80
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
81
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
82
+ SOFTWARE.
83
+
84
+
85
+ == Other stuff
86
+
87
+ Author:: Aaron Royer <aaronroyer@gmail.com>
88
+ Requires:: Ruby 1.8.6 or later
data/dropsite.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dropsite'
3
- s.version = '0.3.1'
3
+ s.version = '0.3.2'
4
4
  s.platform = Gem::Platform::RUBY
5
5
 
6
6
  s.description = "creates index pages in your Dropbox public directory"
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.email = "aaronroyer@gmail.com"
16
16
 
17
17
  s.files = Dir['{bin/*,lib/**/*,test/**/*}'] +
18
- %w(README LICENSE dropsite.gemspec Rakefile)
18
+ %w(README.rdoc LICENSE dropsite.gemspec Rakefile)
19
19
 
20
20
  s.executables << 'dropsite'
21
21
 
@@ -7,7 +7,7 @@ module Dropsite
7
7
  def run
8
8
  handle_options
9
9
 
10
- options.dropbox_home = dropbox_dir if not options.dropbox_home
10
+ options.dropbox_home = Dropsite.dropbox_dir if not options.dropbox_home
11
11
 
12
12
  if !options.dropbox_home || !File.exist?(options.dropbox_home)
13
13
  $stderr.puts 'Dropbox home directory cannot be found or does not exist'
@@ -33,12 +33,12 @@ module Dropsite
33
33
  end
34
34
 
35
35
  def create_config_dir
36
- if dropsite_config_dir
37
- puts "Config directory already exists at: #{dropsite_config_dir}"
36
+ if Dropsite.dropsite_config_dir
37
+ puts "Config directory already exists at: #{Dropsite.dropsite_config_dir}"
38
38
  exit
39
39
  end
40
40
 
41
- config_dir = File.join(dropbox_dir, '.dropsite')
41
+ config_dir = File.join(Dropsite.dropbox_dir, '.dropsite')
42
42
  Dir.mkdir(config_dir)
43
43
  File.open(File.join(config_dir, 'config.yml'), 'w') do |f|
44
44
  # TODO: put the contents in there
@@ -78,7 +78,8 @@ module Dropsite
78
78
  attr_reader :path, :exclude
79
79
 
80
80
  def initialize(path=nil)
81
- @path = path || dropsite_config_dir ? File.join(dropsite_config_dir, 'config.yml') : ''
81
+ @path = path || Dropsite.dropsite_config_dir ?
82
+ File.join(Dropsite.dropsite_config_dir, 'config.yml') : ''
82
83
  end
83
84
 
84
85
  def read
@@ -50,5 +50,9 @@ module Dropsite
50
50
  def built_in?
51
51
  false
52
52
  end
53
+
54
+ def plugin_assets_dir
55
+ File.join(File.dirname(__FILE__), 'plugins', underscorize(self.class.name), 'assets')
56
+ end
53
57
  end
54
58
  end
@@ -1,44 +1,3 @@
1
- # Some utility methods to dump into Object
2
-
3
- # Attempts to find the Dropbox directory (not the Public directory, the Dropbox base
4
- # directory) on this box. Returns nil if an existing directory could not be found.
5
- def dropbox_dir
6
- return ENV['DROPBOX_HOME'] if ENV['DROPBOX_HOME']
7
-
8
- path = case RUBY_PLATFORM
9
- when /darwin/, /linux/, /freebsd/
10
- File.join(home_dir, 'Dropbox')
11
- when /win32/, /mingw/
12
- File.join(home_dir, 'My Documents', 'My Dropbox')
13
- end
14
-
15
- File.exist?(path) ? path : nil
16
- end
17
-
18
- # Find the configuration directory for Dropsite. The folder .dropsite is
19
- # looked for from most "local" to the Public folder outward. First in the
20
- # Public folder, then the Dropsite directory itself (recommended place) and
21
- # then the user's home directory.
22
- def dropsite_config_dir
23
- config_dir_name = '.dropsite'
24
- [
25
- File.join(dropbox_dir, 'Public', config_dir_name),
26
- File.join(dropbox_dir, config_dir_name),
27
- File.join(home_dir, config_dir_name)
28
- ].find {|dir| File.exist? dir}
29
- end
30
-
31
- # Platform-specific home directory
32
- def home_dir
33
- home = ENV['HOME']
34
- home = ENV['USERPROFILE'] if not home
35
- if !home && (ENV['HOMEDRIVE'] && ENV['HOMEPATH'])
36
- home = File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH'])
37
- end
38
- home = File.expand_path('~') if not home
39
- home = 'C:/' if !home && RUBY_PLATFORM =~ /mswin|mingw/
40
- home
41
- end
42
1
 
43
2
  # Convert a camel-cased string into a lowercase, underscore separated string
44
3
  def underscorize(camel_cased_word)
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  class ImageThumbnails < Dropsite::DirRenderer
2
4
  def can_render?(site_dir)
3
5
  return false if not thumbnail_generator
@@ -12,11 +14,23 @@ class ImageThumbnails < Dropsite::DirRenderer
12
14
  src_image = e.abs_path
13
15
  case thumbnail_generator
14
16
  when :image_science
15
- write_thumb_with_image_science(src_image, assets_dir)
17
+ begin
18
+ write_thumb_with_image_science(src_image, assets_dir)
19
+ rescue RuntimeError => e # I believe this is as specific as it gets
20
+ site_dir.warning "Could not create thumbnail for #{src_image} with ImageScience, " +
21
+ "a possible reason is that ImageScience cannot create thumbs for animated gifs" +
22
+ "\nError message: #{e.message}"
23
+ write_default_thumbnail(src_image, site_dir)
24
+ end
16
25
  when :rmagick
17
- write_thumb_with_rmagick(src_image, assets_dir)
26
+ begin
27
+ write_thumb_with_rmagick(src_image, assets_dir)
28
+ rescue ImageMagickError => e
29
+ site_dir.warning "Could not create thumbnail for #{src_image} with RMagick\n#{e.message}"
30
+ write_default_thumbnail(src_image, assets_dir)
31
+ end
18
32
  else
19
- raise "Unrecognized thumbnail generator: #{thumbnail_generator}"
33
+ site_dir.error "Unrecognized thumbnail generator: #{thumbnail_generator}"
20
34
  end
21
35
  end
22
36
  end
@@ -62,4 +76,15 @@ class ImageThumbnails < Dropsite::DirRenderer
62
76
  def thumb_file_name(image_file_name)
63
77
  File.basename(image_file_name).sub(/\.\w+$/, '') + '-thumb' + File.extname(image_file_name)
64
78
  end
79
+
80
+ 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)}"
88
+ end
89
+ end
65
90
  end
data/lib/dropsite/site.rb CHANGED
@@ -76,9 +76,26 @@ module Dropsite
76
76
  File.join(@site_files_dir, 'dropsite-assets')
77
77
  end
78
78
 
79
- def notice(message)
79
+ # User message themes loosely based on those from github.com/mxcl/homebrew
80
+
81
+ # Output a normal user message
82
+ def notice(msg, strong=false)
83
+ # TODO: add a verbosity setting and use it here
84
+ return if @quiet
85
+ puts "#{Tty.blue}==>#{strong ? Tty.bold_white : Tty.reset + Tty.white} #{msg}#{Tty.reset}"
86
+ end
87
+
88
+ # Output a warning message
89
+ def warning(msg)
90
+ return if @quiet
91
+ puts "#{Tty.yellow}Warning#{Tty.reset}: #{msg}"
92
+ end
93
+
94
+ # Output an error message
95
+ def error(msg, err=nil)
80
96
  return if @quiet
81
- warn "#{File.basename($0)}: #{message}"
97
+ puts "#{Tty.red}Error#{Tty.reset}: #{msg}#{', details follow...' if err}"
98
+ puts err.to_s if err
82
99
  end
83
100
 
84
101
  protected
@@ -112,3 +129,22 @@ module Dropsite
112
129
  end
113
130
  end
114
131
  end
132
+
133
+ # Add a little color - based on some stuff from github.com/mxcl/homebrew
134
+ class Tty
135
+ class << self
136
+ def blue; bold 34; end
137
+ def white; escape 39; end
138
+ def bold_white; bold 39; end
139
+ def red; underline 31; end
140
+ def yellow; underline 33 ; end
141
+ def reset; escape 0; end
142
+ def em; underline 39; end
143
+
144
+ private
145
+ def color(n); escape "0;#{n}" end
146
+ def bold(n); escape "1;#{n}" end
147
+ def underline(n); escape "4;#{n}" end
148
+ def escape(n); "\033[#{n}m" if $stdout.tty? end
149
+ end
150
+ end
@@ -1,25 +1,31 @@
1
1
  module Dropsite
2
2
  class SiteItem
3
3
  include Enumerable, RenderHelper
4
-
4
+
5
5
  attr_accessor :path
6
-
6
+
7
7
  def name
8
8
  File.basename @path
9
9
  end
10
-
10
+
11
11
  def top_level?
12
12
  @path.sub(/^\//, '') == name
13
13
  end
14
-
14
+
15
15
  def <=>(other)
16
16
  name <=> other.name
17
17
  end
18
-
19
- protected
20
-
21
- def notice(message)
22
- @site.notice(message) if @site
18
+
19
+ def notice(msg)
20
+ @site.notice(msg) if @site
21
+ end
22
+
23
+ def warning(msg)
24
+ @site.warning(msg) if @site
25
+ end
26
+
27
+ def error(msg)
28
+ @site.error(msg) if @site
23
29
  end
24
30
  end
25
31
  end
data/lib/dropsite.rb CHANGED
@@ -1,5 +1,45 @@
1
1
  module Dropsite
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
+
4
+ # Attempts to find the Dropbox directory (not the Public directory, the Dropbox base
5
+ # directory) on this box. Returns nil if an existing directory could not be found.
6
+ def dropbox_dir
7
+ return ENV['DROPBOX_HOME'] if ENV['DROPBOX_HOME']
8
+
9
+ path = case RUBY_PLATFORM
10
+ when /darwin/, /linux/, /freebsd/
11
+ File.join(home_dir, 'Dropbox')
12
+ when /win32/, /mingw/
13
+ File.join(home_dir, 'My Documents', 'My Dropbox')
14
+ end
15
+
16
+ File.exist?(path) ? path : nil
17
+ end
18
+
19
+ # Find the configuration directory for Dropsite. The folder .dropsite is
20
+ # looked for from most "local" to the Public folder outward. First in the
21
+ # Public folder, then the Dropsite directory itself (recommended place) and
22
+ # then the user's home directory.
23
+ def dropsite_config_dir
24
+ config_dir_name = '.dropsite'
25
+ [
26
+ File.join(dropbox_dir, 'Public', config_dir_name),
27
+ File.join(dropbox_dir, config_dir_name),
28
+ File.join(home_dir, config_dir_name)
29
+ ].find {|dir| File.exist? dir}
30
+ end
31
+
32
+ # Platform-specific home directory
33
+ def home_dir
34
+ home = ENV['HOME']
35
+ home = ENV['USERPROFILE'] if not home
36
+ if !home && (ENV['HOMEDRIVE'] && ENV['HOMEPATH'])
37
+ home = File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH'])
38
+ end
39
+ home = File.expand_path('~') if not home
40
+ home = 'C:/' if !home && RUBY_PLATFORM =~ /mswin|mingw/
41
+ home
42
+ end
3
43
  end
4
44
 
5
45
  include Dropsite
data/test/helper.rb CHANGED
@@ -16,12 +16,20 @@ module Fixtures
16
16
 
17
17
  def clean_tmp_dir
18
18
  Dir.entries(TMP_DIR).reject {|e| %w[. .. .gitignore].include? e}.each do |entry|
19
- file = File.join(TMP_DIR, entry)
20
- if File.directory?(file)
21
- FileUtils.rm_rf(file)
22
- else
23
- File.delete(file)
19
+ file = File.join(TMP_DIR, entry)
20
+ if File.directory?(file)
21
+ FileUtils.rm_rf(file)
22
+ else
23
+ File.delete(file)
24
+ end
24
25
  end
25
- end
26
+ end
27
+
28
+ def use_tmp_ruby_inline_dir
29
+ # Don't use the regular ~/.ruby_inline dir (ImageScience uses RubyInline) and leave
30
+ # the cached compiled code there, it causes some problems when testing with different
31
+ # Ruby versions. Delete it after every test.
32
+ ENV['INLINEDIR'] = File.join(TMP_DIR, 'ruby_inline')
33
+ #Dir.mkdir(ENV['INLINEDIR'])
26
34
  end
27
35
  end
@@ -5,7 +5,10 @@ require 'nokogiri'
5
5
  class TestProcessSite < Test::Unit::TestCase
6
6
  include Fixtures
7
7
 
8
- def setup; clean_tmp_dir end
8
+ def setup
9
+ clean_tmp_dir
10
+ use_tmp_ruby_inline_dir
11
+ end
9
12
  def teardown; clean_tmp_dir end
10
13
 
11
14
  def test_process_with_only_simple_index_pages
@@ -5,7 +5,12 @@ require 'nokogiri'
5
5
  class TestProcessSiteManyFolders < Test::Unit::TestCase
6
6
  include Fixtures
7
7
 
8
- def setup; clean_tmp_dir end
8
+ def setup
9
+ clean_tmp_dir
10
+ use_tmp_ruby_inline_dir
11
+ end
12
+
13
+ def teardown; clean_tmp_dir end
9
14
 
10
15
  def test_process_with_many_folders
11
16
  test_public_dir = File.join(TMP_DIR, 'many_folders_public')
@@ -7,16 +7,10 @@ class TestProcessSiteWithThumbnails < Test::Unit::TestCase
7
7
 
8
8
  def setup
9
9
  clean_tmp_dir
10
- # Don't use the regular ~/.ruby_inline dir (ImageScience uses RubyInline) and leave
11
- # the cached compiled code there, it causes some problems when testing with different
12
- # Ruby versions. Delete it after every test.
13
- ENV['INLINEDIR'] = File.join(TMP_DIR, 'ruby_inline')
14
- Dir.mkdir(ENV['INLINEDIR'])
10
+ use_tmp_ruby_inline_dir
15
11
  end
16
12
 
17
- def teardown
18
- clean_tmp_dir
19
- end
13
+ def teardown; clean_tmp_dir end
20
14
 
21
15
  def test_process_with_image_thumbnails
22
16
  test_public_dir = File.join(TMP_DIR, 'simple_public')
@@ -37,4 +31,15 @@ class TestProcessSiteWithThumbnails < Test::Unit::TestCase
37
31
  assert File.exist?(File.join(people_thumbs_dir, 'beach-thumb.jpg'))
38
32
  assert File.exist?(File.join(people_thumbs_dir, 'concert-thumb.jpg'))
39
33
  end
34
+
35
+ def test_process_with_image_thumbnails
36
+ test_public_dir = File.join(TMP_DIR, 'pics_with_animated_gif_public')
37
+ FileUtils.cp_r(File.join(FIXTURES_DIR, 'pics_with_animated_gif_public'), test_public_dir)
38
+ Site.new(:public_dir => test_public_dir, :quiet => true).process
39
+
40
+ # ImageScience can't create thumbs for animated gifs, but a default should be copied in its place
41
+
42
+ assert File.exist?(File.join(test_public_dir, *%w[dropsite dropsite-root-index-directory-assets kdog-thumb.gif]))
43
+ # Should be linked in the page as normal
44
+ end
40
45
  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: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aaron Royer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-26 00:00:00 -05:00
18
+ date: 2011-02-27 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -36,6 +36,12 @@ files:
36
36
  - lib/dropsite/plugins/image_thumbnails/assets/css/reset.css
37
37
  - lib/dropsite/plugins/image_thumbnails/assets/images/icons/directory-large.png
38
38
  - lib/dropsite/plugins/image_thumbnails/assets/images/icons/directory.png
39
+ - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.bmp
40
+ - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.gif
41
+ - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.jpeg
42
+ - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.jpg
43
+ - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.png
44
+ - lib/dropsite/plugins/image_thumbnails/assets/images/icons/image-large.tiff
39
45
  - lib/dropsite/plugins/image_thumbnails/assets/images/row-bg.png
40
46
  - lib/dropsite/plugins/image_thumbnails/image_thumbnails.erb
41
47
  - lib/dropsite/plugins/image_thumbnails/image_thumbnails.rb
@@ -58,6 +64,7 @@ files:
58
64
  - lib/dropsite/site_item.rb
59
65
  - lib/dropsite.rb
60
66
  - test/fixtures/many_folders_public/one/two/three/four/five/six/seven/eight/file.txt
67
+ - test/fixtures/pics_with_animated_gif_public/kdog.gif
61
68
  - test/fixtures/simple_public/file1.txt
62
69
  - test/fixtures/simple_public/file2.txt
63
70
  - test/fixtures/simple_public/pics/leaves.jpg
@@ -74,7 +81,7 @@ files:
74
81
  - test/unit/test_site.rb
75
82
  - test/unit/test_site_dir.rb
76
83
  - test/unit/test_site_file.rb
77
- - README
84
+ - README.rdoc
78
85
  - LICENSE
79
86
  - dropsite.gemspec
80
87
  - Rakefile
data/README DELETED
@@ -1,25 +0,0 @@
1
- dropsite
2
- gem install dropsite
3
-
4
- Dropsite creates a site of interlinked file index pages in the Public directory
5
- of your Dropbox. The site created is minimally invasive to your Public
6
- directory by only creating one top-level HTML page and one folder, leaving your
7
- directories unjunked.
8
-
9
- BE WARNED: while this seems to work fine, it is presently considered
10
- experimental.
11
-
12
- To create the site:
13
- $ dropsite
14
-
15
- This deletes "index.html" and the directory "dropsite" in your Dropbox Public
16
- directory if they exist, creates "index.html" as the top-level index, and puts
17
- the rest of the index pages and assets in the "dropsite" directory.
18
-
19
- To specify a different Dropbox directory:
20
- $ dropsite --dropbox-home ~/Somewhere/Else
21
-
22
- You can also use this if you just want to test this elsewhere before turning
23
- it loose on your precious files.
24
-
25
- MIT licensed - see LICENSE