dropsite 0.3.0 → 0.3.1

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/dropsite.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dropsite'
3
- s.version = '0.3.0'
3
+ s.version = '0.3.1'
4
4
  s.platform = Gem::Platform::RUBY
5
5
 
6
6
  s.description = "creates index pages in your Dropbox public directory"
@@ -7,7 +7,7 @@ module Dropsite
7
7
  def run
8
8
  handle_options
9
9
 
10
- options.dropbox_home = Dropsite.dropbox_dir if not options.dropbox_home
10
+ options.dropbox_home = 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'
@@ -19,8 +19,10 @@ module Dropsite
19
19
  create_config_dir
20
20
  else
21
21
  options.public_dir = File.join(options.dropbox_home, 'Public')
22
- cf = ConfigFile.new.read
23
- options.exclude = cf.exclude if cf.exist?
22
+ cf = ConfigFile.new
23
+ if cf.exist?
24
+ options.exclude = cf.exclude
25
+ end
24
26
  site = Dropsite::Site.new(options)
25
27
  site.process
26
28
  end
@@ -31,12 +33,12 @@ module Dropsite
31
33
  end
32
34
 
33
35
  def create_config_dir
34
- if Dropsite.dropsite_config_dir
35
- puts "Config directory already exists at: #{Dropsite.dropsite_config_dir}"
36
+ if dropsite_config_dir
37
+ puts "Config directory already exists at: #{dropsite_config_dir}"
36
38
  exit
37
39
  end
38
40
 
39
- config_dir = File.join(Dropsite.dropbox_dir, '.dropsite')
41
+ config_dir = File.join(dropbox_dir, '.dropsite')
40
42
  Dir.mkdir(config_dir)
41
43
  File.open(File.join(config_dir, 'config.yml'), 'w') do |f|
42
44
  # TODO: put the contents in there
@@ -76,7 +78,7 @@ module Dropsite
76
78
  attr_reader :path, :exclude
77
79
 
78
80
  def initialize(path=nil)
79
- @path = path || File.join(Dropsite.dropsite_config_dir, 'config.yml')
81
+ @path = path || dropsite_config_dir ? File.join(dropsite_config_dir, 'config.yml') : ''
80
82
  end
81
83
 
82
84
  def read
@@ -0,0 +1,49 @@
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
+
43
+ # Convert a camel-cased string into a lowercase, underscore separated string
44
+ def underscorize(camel_cased_word)
45
+ camel_cased_word.to_s.gsub(/::/, '/').
46
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
47
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
48
+ tr("-", "_").downcase
49
+ end
@@ -110,11 +110,11 @@ module Dropsite
110
110
 
111
111
  def plugin_assets_link_base
112
112
  if root?
113
- "dropsite/dropsite-assets/#{Dropsite.underscorize(rendered_by)}/"
113
+ "dropsite/dropsite-assets/#{underscorize(rendered_by)}/"
114
114
  else
115
115
  # Work our way BACK up the path - crazy, right? Gotta do it though.
116
116
  dirs_up = path.split(File::SEPARATOR).size - 1
117
- (['..'] * dirs_up).join('/') + "#{'/' if dirs_up > 0}dropsite-assets/#{Dropsite.underscorize(rendered_by)}/"
117
+ (['..'] * dirs_up).join('/') + "#{'/' if dirs_up > 0}dropsite-assets/#{underscorize(rendered_by)}/"
118
118
  end
119
119
  end
120
120
 
data/lib/dropsite/site.rb CHANGED
@@ -10,7 +10,13 @@ module Dropsite
10
10
  @public_dir = config
11
11
  @exclude, @disabled_plugins = [], []
12
12
  @quiet = false
13
- else
13
+ elsif config.is_a? OpenStruct
14
+ @config = config.clone
15
+ @public_dir = config.public_dir
16
+ @exclude = config.exclude || []
17
+ @disabled_plugins = config.disabled_plugins || []
18
+ @quiet = config.quiet || false
19
+ elsif config.is_a? Hash
14
20
  @config = config.clone
15
21
  @public_dir = config[:public_dir]
16
22
  @exclude = config[:exclude] || []
@@ -61,7 +67,7 @@ module Dropsite
61
67
  Dir.mkdir(assets_dir)
62
68
  DirRenderer.renderers.each do |r|
63
69
  if File.exist? r.assets_dir
64
- FileUtils.cp_r(r.assets_dir, File.join(assets_dir, Dropsite.underscorize(r.class.to_s)))
70
+ FileUtils.cp_r(r.assets_dir, File.join(assets_dir, underscorize(r.class.to_s)))
65
71
  end
66
72
  end
67
73
  end
data/lib/dropsite.rb CHANGED
@@ -1,55 +1,9 @@
1
1
  module Dropsite
2
- VERSION = '0.2.1'
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
43
-
44
- # Convert a camel-cased string into a lowercase, underscore separated string
45
- def underscorize(camel_cased_word)
46
- camel_cased_word.to_s.gsub(/::/, '/').
47
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
48
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
49
- tr("-", "_").downcase
50
- end
2
+ VERSION = '0.3.1'
51
3
  end
52
4
 
53
- %w[dir_renderer render_helper plugins site site_item site_dir site_file application].each do |lib|
5
+ include Dropsite
6
+
7
+ %w[globals dir_renderer render_helper plugins site site_item site_dir site_file application].each do |lib|
54
8
  require File.join('dropsite', lib)
55
9
  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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aaron Royer
@@ -31,6 +31,7 @@ files:
31
31
  - bin/dropsite
32
32
  - lib/dropsite/application.rb
33
33
  - lib/dropsite/dir_renderer.rb
34
+ - lib/dropsite/globals.rb
34
35
  - lib/dropsite/plugins/image_thumbnails/assets/css/image_thumbnails.css
35
36
  - lib/dropsite/plugins/image_thumbnails/assets/css/reset.css
36
37
  - lib/dropsite/plugins/image_thumbnails/assets/images/icons/directory-large.png