dropsite 0.2 → 0.2.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 +2 -2
- data/lib/dropsite/render_helper.rb +15 -15
- data/test/test_site.rb +7 -7
- metadata +4 -3
data/dropsite.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'dropsite'
|
|
3
|
-
s.version = '0.2'
|
|
3
|
+
s.version = '0.2.1'
|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
|
5
5
|
|
|
6
6
|
s.description = "creates index pages in your Dropbox public directory"
|
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
"invasive to your Public directory by only creating one top-level " +
|
|
10
10
|
"HTML page and one folder, leaving your directories unjunked." +
|
|
11
11
|
"\nBE WARNED: while I _think_ this probably works fine, it is " +
|
|
12
|
-
"presently considered experimental."
|
|
12
|
+
"presently considered experimental."
|
|
13
13
|
|
|
14
14
|
s.authors = ["Aaron Royer"]
|
|
15
15
|
s.email = "aaronroyer@gmail.com"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module Dropsite
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
# Helper methods, accessible in templates, to be included in renderable items
|
|
4
4
|
module RenderHelper
|
|
5
5
|
attr_accessor :rendered_by
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
def link
|
|
8
8
|
# TODO: URL escape links
|
|
9
9
|
if top_level? && (!is_a? SiteDir)
|
|
@@ -19,38 +19,38 @@ module Dropsite
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
def stylesheet_link_tag(stylesheet_name)
|
|
24
24
|
stylesheet_name = "#{stylesheet_name}.css" if not stylesheet_name =~ /\.css$/
|
|
25
25
|
%{<link rel="stylesheet" href="#{assets_link_base}css/#{stylesheet_name}" type="text/css" media="screen">}
|
|
26
26
|
end
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
def javascript_include_tag(javascript_file_name)
|
|
29
29
|
javascript_file_name = "#{javascript_file_name}.js" if not javascript_file_name =~ /\.js$/
|
|
30
30
|
%{<script type="text/javascript" src="#{assets_link_base}js/#{javascript_file_name}"></script>}
|
|
31
31
|
end
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
def image_tag(image_file_name)
|
|
34
34
|
%{<img src="#{assets_link_base}images/#{image_file_name}" />}
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
def parent_directory_link_tag(levels_up=1, options={})
|
|
38
38
|
%{<a href="#{back_link(levels_up)}"#{tag_attributes(options)}>#{parent_dir_name(levels_up)}</a>}
|
|
39
39
|
end
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
def each_parent_directory_link_tag(*args)
|
|
42
42
|
include_root = true
|
|
43
43
|
include_root = args[0] if args.size > 0 && (!args[0].is_a? Hash)
|
|
44
44
|
options = args.find {|arg| arg.is_a? Hash}
|
|
45
45
|
options = {} if !options
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
levels_up = path.split('/').size
|
|
48
48
|
levels_up = levels_up - 1 if !include_root
|
|
49
|
-
levels_up.downto(1)
|
|
49
|
+
levels_up.downto(1) do |level_up|
|
|
50
50
|
yield parent_directory_link_tag(level_up, options)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
def assets_link_base
|
|
55
55
|
if root?
|
|
56
56
|
"dropsite/dropsite-assets/#{Dropsite.underscorize(rendered_by)}/"
|
|
@@ -60,7 +60,7 @@ module Dropsite
|
|
|
60
60
|
(['..'] * dirs_up).join('/') + "#{'/' if dirs_up > 0}dropsite-assets/#{Dropsite.underscorize(rendered_by)}/"
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
# Get a link to a parent page
|
|
65
65
|
def back_link(levels_up=1)
|
|
66
66
|
# TODO: factor this out a bit between parent_dir_name
|
|
@@ -73,7 +73,7 @@ module Dropsite
|
|
|
73
73
|
root? ? '' : (['..'] * (path.split('/').size)).join('/') + '/index.html'
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
def parent_dir_name(levels_up=1)
|
|
78
78
|
if levels_up.is_a?(Integer) && levels_up > 0 && levels_up < path.split('/').size
|
|
79
79
|
dir_name = path.split('/')[(levels_up + 1) * -1]
|
|
@@ -83,13 +83,13 @@ module Dropsite
|
|
|
83
83
|
'my files'
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
def get_binding
|
|
88
88
|
binding
|
|
89
89
|
end
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
protected
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
def tag_attributes(options)
|
|
94
94
|
options.empty? ? '' : ' ' + options.keys.map {|k| %{#{k.to_s}="#{options[k].to_s}"} }.join
|
|
95
95
|
end
|
data/test/test_site.rb
CHANGED
|
@@ -4,36 +4,36 @@ class TestSite < Test::Unit::TestCase
|
|
|
4
4
|
def test_create_site_tree_from_simple_public_dir
|
|
5
5
|
site = Site.new(File.join(FIXTURES_DIR, 'simple_public'))
|
|
6
6
|
root = site.read
|
|
7
|
-
|
|
8
|
-
assert root.is_a?
|
|
7
|
+
|
|
8
|
+
assert root.is_a?(SiteDir)
|
|
9
9
|
assert_equal '', root.path
|
|
10
10
|
assert_equal 2, root.files.size
|
|
11
11
|
assert root.files.find {|f| f.name == 'file1.txt'}
|
|
12
12
|
assert root.files.find {|f| f.name == 'file2.txt'}
|
|
13
13
|
assert_equal 1, root.dirs.size
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
pics_dir = root.dirs[0]
|
|
16
16
|
assert_equal 'pics', pics_dir.path
|
|
17
17
|
assert_equal 2, pics_dir.files.size
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
assert pics_dir.files.find {|f| f.name == 'leaves.jpg'}
|
|
20
20
|
assert pics_dir.files.find {|f| f.name == 'sculpture.jpg'}
|
|
21
21
|
assert_equal 1, pics_dir.dirs.size
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
people_dir = pics_dir.dirs[0]
|
|
24
24
|
assert_equal 2, people_dir.files.size
|
|
25
25
|
assert people_dir.files.find {|f| f.name == 'concert.jpg'}
|
|
26
26
|
assert people_dir.files.find {|f| f.name == 'beach.jpg'}
|
|
27
27
|
assert people_dir.dirs.empty?
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
def test_create_site_tree_from_simple_public_dir_with_exclusions
|
|
31
31
|
site = Site.new(
|
|
32
32
|
:public_dir => File.join(FIXTURES_DIR, 'simple_public'),
|
|
33
33
|
:excludes => ['pics', 'file1.txt']
|
|
34
34
|
)
|
|
35
35
|
root = site.read
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
assert_equal 1, root.files.size
|
|
38
38
|
assert root.files.find {|f| f.name == 'file2.txt'}
|
|
39
39
|
assert root.dirs.empty?
|
metadata
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dropsite
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 21
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 2
|
|
9
|
-
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.2.1
|
|
10
11
|
platform: ruby
|
|
11
12
|
authors:
|
|
12
13
|
- Aaron Royer
|
|
@@ -14,7 +15,7 @@ autorequire:
|
|
|
14
15
|
bindir: bin
|
|
15
16
|
cert_chain: []
|
|
16
17
|
|
|
17
|
-
date: 2010-11-
|
|
18
|
+
date: 2010-11-16 00:00:00 -05:00
|
|
18
19
|
default_executable:
|
|
19
20
|
dependencies: []
|
|
20
21
|
|