dropsite 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/Rakefile +12 -3
  2. data/bin/dropsite +1 -34
  3. data/dropsite.gemspec +1 -1
  4. data/lib/dropsite/application.rb +93 -0
  5. data/lib/dropsite/dir_renderer.rb +23 -25
  6. data/lib/dropsite/plugins/image_thumbnails/assets/css/image_thumbnails.css +87 -0
  7. data/lib/dropsite/plugins/image_thumbnails/assets/css/reset.css +30 -0
  8. data/lib/dropsite/plugins/image_thumbnails/assets/images/icons/directory-large.png +0 -0
  9. data/lib/dropsite/plugins/image_thumbnails/assets/images/icons/directory.png +0 -0
  10. data/lib/dropsite/plugins/image_thumbnails/assets/images/row-bg.png +0 -0
  11. data/lib/dropsite/plugins/image_thumbnails/image_thumbnails.erb +49 -0
  12. data/lib/dropsite/plugins/image_thumbnails/image_thumbnails.rb +65 -0
  13. data/lib/dropsite/plugins/simple_index/simple_index.erb +1 -1
  14. data/lib/dropsite/plugins/simple_index/simple_index.rb +1 -1
  15. data/lib/dropsite/render_helper.rb +60 -22
  16. data/lib/dropsite/site.rb +30 -28
  17. data/lib/dropsite/site_dir.rb +84 -32
  18. data/lib/dropsite/site_file.rb +12 -11
  19. data/lib/dropsite.rb +34 -9
  20. data/test/fixtures/many_folders_public/one/two/three/four/five/six/seven/eight/file.txt +1 -0
  21. data/test/helper.rb +17 -4
  22. data/test/{test_write_site.rb → integration/test_process_site.rb} +31 -44
  23. data/test/integration/test_process_site_many_folders.rb +18 -0
  24. data/test/integration/test_process_site_with_thumbnails.rb +40 -0
  25. data/test/unit/test_application.rb +19 -0
  26. data/test/unit/test_config_file.rb +34 -0
  27. data/test/{test_render_helper.rb → unit/test_render_helper.rb} +13 -13
  28. data/test/{test_site.rb → unit/test_site.rb} +19 -3
  29. data/test/unit/test_site_dir.rb +31 -0
  30. data/test/{test_site_file.rb → unit/test_site_file.rb} +9 -9
  31. metadata +27 -19
  32. data/lib/dropsite/plugins/simple_index/assets/simple_index.js +0 -3
  33. data/test/test_site_dir.rb +0 -20
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'helper')
1
+ require File.join(File.dirname(__FILE__), '..', 'helper')
2
2
  require 'nokogiri'
3
3
 
4
4
  # Tests for RenderHelper mixin using SiteItem, which mixes it in
@@ -11,7 +11,7 @@ class TestRenderHelper < Test::Unit::TestCase
11
11
  assert_equal '../people.html', SiteDir.new('pics/people/friends', [], '/tmp').back_link(1)
12
12
  assert_equal '../../pics.html', SiteDir.new('pics/people/friends', [], '/tmp').back_link(2)
13
13
  assert_equal '../../../index.html', SiteDir.new('pics/people/friends', [], '/tmp').back_link(3)
14
-
14
+
15
15
  # Test too many levels up and non-Integer arg
16
16
  assert_equal '../index.html', SiteDir.new('pics', [], '/tmp').back_link(2)
17
17
  assert_equal '../index.html', SiteDir.new('pics', [], '/tmp').back_link(3)
@@ -19,34 +19,34 @@ class TestRenderHelper < Test::Unit::TestCase
19
19
  assert_equal '', SiteDir.new('', [], '/tmp').back_link(1)
20
20
  assert_equal '', SiteDir.new('', [], '/tmp').back_link(nil)
21
21
  end
22
-
22
+
23
23
  def test_parent_directory_link_tag
24
24
  sd = SiteDir.new('pics/people/friends', [], '/tmp')
25
-
25
+
26
26
  basic_link_doc = Nokogiri::HTML(sd.parent_directory_link_tag(1))
27
27
  links = basic_link_doc.css('a')
28
28
  assert_equal 1, links.size
29
29
  assert_equal '../people.html', links[0].attribute('href').value
30
30
  assert_equal 'people', links[0].content
31
-
31
+
32
32
  basic_link_doc = Nokogiri::HTML(sd.parent_directory_link_tag(2))
33
33
  links = basic_link_doc.css('a')
34
34
  assert_equal 1, links.size
35
35
  assert_equal '../../pics.html', links[0].attribute('href').value
36
36
  assert_equal 'pics', links[0].content
37
-
37
+
38
38
  basic_link_doc = Nokogiri::HTML(sd.parent_directory_link_tag(3))
39
39
  links = basic_link_doc.css('a')
40
40
  assert_equal 1, links.size
41
41
  assert_equal '../../../index.html', links[0].attribute('href').value
42
42
  assert_equal 'my files', links[0].content
43
43
  end
44
-
44
+
45
45
  def test_parent_directory_link_tag_with_additional_attributes
46
46
  sd = SiteDir.new('pics/people/friends', [], '/tmp')
47
47
  id = 'the-id'
48
48
  css_class = 'the-css-class'
49
-
49
+
50
50
  link_doc = Nokogiri::HTML(sd.parent_directory_link_tag(1, :class => css_class))
51
51
  links = link_doc.css('a')
52
52
  assert_equal 1, links.size
@@ -54,7 +54,7 @@ class TestRenderHelper < Test::Unit::TestCase
54
54
  assert_equal '../people.html', link.attribute('href').value
55
55
  assert_equal 'people', link.content
56
56
  assert_equal css_class, link.attribute('class').value
57
-
57
+
58
58
  link_doc = Nokogiri::HTML(sd.parent_directory_link_tag(1, :id => id, :class => css_class))
59
59
  links = link_doc.css('a')
60
60
  assert_equal 1, links.size
@@ -64,7 +64,7 @@ class TestRenderHelper < Test::Unit::TestCase
64
64
  assert_equal id, link.attribute('id').value
65
65
  assert_equal css_class, link.attribute('class').value
66
66
  end
67
-
67
+
68
68
  def test_each_parent_directory_link_tag_with_root
69
69
  links = ''
70
70
  sd = SiteDir.new('pics/people/friends', [], '/tmp')
@@ -72,7 +72,7 @@ class TestRenderHelper < Test::Unit::TestCase
72
72
  links_doc = Nokogiri::HTML(links)
73
73
  links = links_doc.css('a')
74
74
  assert_equal 3, links.size
75
-
75
+
76
76
  root_link = links_doc.css('a').find {|a| a.content == 'my files'}
77
77
  assert_equal '../../../index.html', root_link.attribute('href').value
78
78
  pics_link = links_doc.css('a').find {|a| a.content == 'pics'}
@@ -80,7 +80,7 @@ class TestRenderHelper < Test::Unit::TestCase
80
80
  people_link = links_doc.css('a').find {|a| a.content == 'people'}
81
81
  assert_equal '../people.html', people_link.attribute('href').value
82
82
  end
83
-
83
+
84
84
  def test_each_parent_directory_link_tag_without_root
85
85
  links = ''
86
86
  sd = SiteDir.new('pics/people/friends', [], '/tmp')
@@ -88,7 +88,7 @@ class TestRenderHelper < Test::Unit::TestCase
88
88
  links_doc = Nokogiri::HTML(links)
89
89
  links = links_doc.css('a')
90
90
  assert_equal 2, links.size
91
-
91
+
92
92
  pics_link = links_doc.css('a').find {|a| a.content == 'pics'}
93
93
  assert_equal '../../pics.html', pics_link.attribute('href').value
94
94
  people_link = links_doc.css('a').find {|a| a.content == 'people'}
@@ -1,6 +1,8 @@
1
- require File.join(File.dirname(__FILE__), 'helper')
1
+ require File.join(File.dirname(__FILE__), '..', 'helper')
2
2
 
3
3
  class TestSite < Test::Unit::TestCase
4
+ include Fixtures
5
+
4
6
  def test_create_site_tree_from_simple_public_dir
5
7
  site = Site.new(File.join(FIXTURES_DIR, 'simple_public'))
6
8
  root = site.read
@@ -30,7 +32,7 @@ class TestSite < Test::Unit::TestCase
30
32
  def test_create_site_tree_from_simple_public_dir_with_exclusions
31
33
  site = Site.new(
32
34
  :public_dir => File.join(FIXTURES_DIR, 'simple_public'),
33
- :excludes => ['pics', 'file1.txt']
35
+ :exclude => ['pics', 'file1.txt']
34
36
  )
35
37
  root = site.read
36
38
 
@@ -38,4 +40,18 @@ class TestSite < Test::Unit::TestCase
38
40
  assert root.files.find {|f| f.name == 'file2.txt'}
39
41
  assert root.dirs.empty?
40
42
  end
41
- end
43
+
44
+ def test_find_correct_plugin
45
+ # TODO: implement
46
+ end
47
+
48
+ def test_disable_plugins
49
+ site = Site.new(
50
+ :public_dir => File.join(FIXTURES_DIR, 'simple_public'),
51
+ :disabled_plugins => ['image_thumbnails']
52
+ )
53
+
54
+ assert_equal 1, site.disabled_plugins.size
55
+ assert site.disabled_plugins.include?('image_thumbnails')
56
+ end
57
+ end
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'helper')
2
+
3
+ class TestSiteDir < Test::Unit::TestCase
4
+ def test_name
5
+ assert_equal 'pic1.jpg', SiteDir.new('pic1.jpg', [], Site.new('/tmp')).name
6
+ assert_equal 'pic1.jpg', SiteDir.new('/pics/pic1.jpg', [], Site.new('/tmp')).name
7
+ end
8
+
9
+ def test_root_name
10
+ assert_equal '', SiteDir.new('/', [], Site.new('/tmp')).name
11
+ assert_equal '', SiteDir.new('', [], Site.new('/tmp')).name
12
+ end
13
+
14
+ def test_root
15
+ assert SiteDir.new('', [], Site.new('/tmp')).root?
16
+ assert !SiteDir.new('/file.txt', [], Site.new('/tmp')).root?
17
+ assert !SiteDir.new('/dir', [], Site.new('/tmp')).root?
18
+ assert !SiteDir.new('/dir/file.txt', [], Site.new('/tmp')).root?
19
+ end
20
+
21
+ def test_page_assets_dir
22
+ sd = SiteDir.new('', [], Site.new('/tmp'))
23
+ assert_equal '/tmp/dropsite/dropsite-root-index-directory-assets', sd.page_assets_dir
24
+
25
+ sd = SiteDir.new('/thisisadir', [], Site.new('/tmp'))
26
+ assert_equal '/tmp/dropsite/dropsite-thisisadir-assets', sd.page_assets_dir
27
+
28
+ sd = SiteDir.new('/two/dirs-up', [], Site.new('/tmp'))
29
+ assert_equal '/tmp/dropsite/two/dropsite-dirs-up-assets', sd.page_assets_dir
30
+ end
31
+ end
@@ -1,24 +1,24 @@
1
- require File.join(File.dirname(__FILE__), 'helper')
1
+ require File.join(File.dirname(__FILE__), '..', 'helper')
2
2
 
3
3
  class TestSiteFile < Test::Unit::TestCase
4
4
  def test_name
5
5
  assert_equal 'pic1.jpg', SiteFile.new('pic1.jpg').name
6
6
  assert_equal 'pic1.jpg', SiteFile.new('/pics/pic1.jpg').name
7
7
  end
8
-
8
+
9
9
  def test_type
10
- assert_equal 'image', SiteFile.new('/pics/pic1.jpg').file_type
11
- assert_equal 'image', SiteFile.new('/pics/pic1.gif').file_type
12
- assert_equal 'text', SiteFile.new('/pics/pic1.txt').file_type
13
- assert_equal 'unknown', SiteFile.new('/pics/plainoldfile').file_type
14
- assert_equal 'unknown', SiteFile.new('/pics/file.asdf').file_type
10
+ assert_equal :image, SiteFile.new('/pics/pic1.jpg').file_type
11
+ assert_equal :image, SiteFile.new('/pics/pic1.gif').file_type
12
+ assert_equal :text, SiteFile.new('/pics/pic1.txt').file_type
13
+ assert_equal :unknown, SiteFile.new('/pics/plainoldfile').file_type
14
+ assert_equal :unknown, SiteFile.new('/pics/file.asdf').file_type
15
15
  end
16
-
16
+
17
17
  def test_top_level
18
18
  assert SiteFile.new('/pic1.jpg').top_level?
19
19
  assert !SiteFile.new('/pics/pic1.jpg').top_level?
20
20
  end
21
-
21
+
22
22
  def test_size
23
23
  sf = SiteFile.new('/pic1.jpg')
24
24
  sf.size_in_bytes = 100
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: 21
5
- prerelease: false
4
+ hash: 19
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
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: 2010-11-16 00:00:00 -05:00
18
+ date: 2011-02-26 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -29,7 +29,15 @@ extra_rdoc_files: []
29
29
 
30
30
  files:
31
31
  - bin/dropsite
32
+ - lib/dropsite/application.rb
32
33
  - lib/dropsite/dir_renderer.rb
34
+ - lib/dropsite/plugins/image_thumbnails/assets/css/image_thumbnails.css
35
+ - lib/dropsite/plugins/image_thumbnails/assets/css/reset.css
36
+ - lib/dropsite/plugins/image_thumbnails/assets/images/icons/directory-large.png
37
+ - lib/dropsite/plugins/image_thumbnails/assets/images/icons/directory.png
38
+ - lib/dropsite/plugins/image_thumbnails/assets/images/row-bg.png
39
+ - lib/dropsite/plugins/image_thumbnails/image_thumbnails.erb
40
+ - lib/dropsite/plugins/image_thumbnails/image_thumbnails.rb
33
41
  - lib/dropsite/plugins/simple_index/assets/css/reset.css
34
42
  - lib/dropsite/plugins/simple_index/assets/css/simple_index.css
35
43
  - lib/dropsite/plugins/simple_index/assets/images/icons/directory.png
@@ -39,7 +47,6 @@ files:
39
47
  - lib/dropsite/plugins/simple_index/assets/images/icons/text.png
40
48
  - lib/dropsite/plugins/simple_index/assets/images/icons/unknown.png
41
49
  - lib/dropsite/plugins/simple_index/assets/images/row-bg.png
42
- - lib/dropsite/plugins/simple_index/assets/simple_index.js
43
50
  - lib/dropsite/plugins/simple_index/simple_index.erb
44
51
  - lib/dropsite/plugins/simple_index/simple_index.rb
45
52
  - lib/dropsite/plugins.rb
@@ -49,6 +56,7 @@ files:
49
56
  - lib/dropsite/site_file.rb
50
57
  - lib/dropsite/site_item.rb
51
58
  - lib/dropsite.rb
59
+ - test/fixtures/many_folders_public/one/two/three/four/five/six/seven/eight/file.txt
52
60
  - test/fixtures/simple_public/file1.txt
53
61
  - test/fixtures/simple_public/file2.txt
54
62
  - test/fixtures/simple_public/pics/leaves.jpg
@@ -56,11 +64,15 @@ files:
56
64
  - test/fixtures/simple_public/pics/people/concert.jpg
57
65
  - test/fixtures/simple_public/pics/sculpture.jpg
58
66
  - test/helper.rb
59
- - test/test_render_helper.rb
60
- - test/test_site.rb
61
- - test/test_site_dir.rb
62
- - test/test_site_file.rb
63
- - test/test_write_site.rb
67
+ - test/integration/test_process_site.rb
68
+ - test/integration/test_process_site_many_folders.rb
69
+ - test/integration/test_process_site_with_thumbnails.rb
70
+ - test/unit/test_application.rb
71
+ - test/unit/test_config_file.rb
72
+ - test/unit/test_render_helper.rb
73
+ - test/unit/test_site.rb
74
+ - test/unit/test_site_dir.rb
75
+ - test/unit/test_site_file.rb
64
76
  - README
65
77
  - LICENSE
66
78
  - dropsite.gemspec
@@ -96,13 +108,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
108
  requirements: []
97
109
 
98
110
  rubyforge_project:
99
- rubygems_version: 1.3.7
111
+ rubygems_version: 1.5.2
100
112
  signing_key:
101
113
  specification_version: 3
102
114
  summary: "Dropsite creates a site of interlinked file index pages in the Public directory of your Dropbox. The site created is minimally invasive to your Public directory by only creating one top-level HTML page and one folder, leaving your directories unjunked. BE WARNED: while I _think_ this probably works fine, it is presently considered experimental."
103
- test_files:
104
- - test/test_render_helper.rb
105
- - test/test_site.rb
106
- - test/test_site_dir.rb
107
- - test/test_site_file.rb
108
- - test/test_write_site.rb
115
+ test_files: []
116
+
@@ -1,3 +0,0 @@
1
- if (console && console.log) {
2
- console.log("included...");
3
- }
@@ -1,20 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'helper')
2
-
3
- class TestSiteDir < Test::Unit::TestCase
4
- def test_name
5
- assert_equal 'pic1.jpg', SiteDir.new('pic1.jpg', [], '/tmp').name
6
- assert_equal 'pic1.jpg', SiteDir.new('/pics/pic1.jpg', [], '/tmp').name
7
- end
8
-
9
- def test_root_name
10
- assert_equal '', SiteDir.new('/', [], '/tmp').name
11
- assert_equal '', SiteDir.new('', [], '/tmp').name
12
- end
13
-
14
- def test_is_root
15
- assert SiteDir.new('', [], '/tmp').root?
16
- assert !SiteDir.new('/file.txt', [], '/tmp').root?
17
- assert !SiteDir.new('/dir', [], '/tmp').root?
18
- assert !SiteDir.new('/dir/file.txt', [], '/tmp').root?
19
- end
20
- end