gallerby 0.1.1 → 0.1.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/bin/gallerby CHANGED
@@ -40,6 +40,10 @@ BANNER
40
40
  opts.on('-p', '--per-page [PER_PAGE]', Integer, 'Pictures to display per page (default is 20)') do |f|
41
41
  options[:per_page] = f || 20
42
42
  end
43
+
44
+ opts.on('-c', '--create-directories', 'Create the directories if not exists') do |f|
45
+ options[:create_directories] = true || false
46
+ end
43
47
  end
44
48
 
45
49
  begin # From http://stackoverflow.com/questions/1541294/how-do-you-specify-a-required-switch-not-argument-with-ruby-optionparser/2149183#2149183
@@ -56,7 +60,7 @@ rescue OptionParser::InvalidOption, OptionParser::MissingArgument
56
60
  end
57
61
 
58
62
  begin
59
- g = Gallerby.new(options[:directory], options[:per_page], options[:name], options[:summary])
63
+ g = Gallerby.new(options[:directory], options[:per_page], options[:name], options[:summary], options[:create_directories])
60
64
  g.verify_directory_structure
61
65
  g.scan_pictures
62
66
  puts "[WARNING ] Found 0 pictures in #{g.originals}. Your gallery will be empty!" if g.pictures.size == 0
data/gallerby.gemspec CHANGED
@@ -1,60 +1,58 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gallerby}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Waine Kerr"]
12
- s.date = %q{2010-09-18}
12
+ s.date = %q{2011-02-14}
13
13
  s.default_executable = %q{gallerby}
14
14
  s.description = %q{Think about a dead-simple static gallery generator, with nothing except pictures, thumbnails, previews. A kind of server directory listing for pictures. Enter Gallerby!}
15
15
  s.email = %q{wk@heldscalla.org}
16
16
  s.executables = ["gallerby"]
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE",
19
- "README.md"
19
+ "README.md"
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
23
- ".gitignore",
24
- "LICENSE",
25
- "README.md",
26
- "Rakefile",
27
- "VERSION",
28
- "bin/gallerby",
29
- "gallerby.gemspec",
30
- "lib/gallerby.rb",
31
- "lib/shared/assets/css/lightbox.css",
32
- "lib/shared/assets/img/bullet.gif",
33
- "lib/shared/assets/img/close.gif",
34
- "lib/shared/assets/img/closelabel.gif",
35
- "lib/shared/assets/img/donate-button.gif",
36
- "lib/shared/assets/img/download-icon.gif",
37
- "lib/shared/assets/img/loading.gif",
38
- "lib/shared/assets/img/nextlabel.gif",
39
- "lib/shared/assets/img/prevlabel.gif",
40
- "lib/shared/assets/js/builder.js",
41
- "lib/shared/assets/js/effects.js",
42
- "lib/shared/assets/js/lightbox.js",
43
- "lib/shared/assets/js/prototype.js",
44
- "lib/shared/assets/js/scriptaculous.js",
45
- "lib/shared/templates/gallerby.haml",
46
- "lib/shared/templates/gallerby.sass",
47
- "test/helper.rb",
48
- "test/test_gallerby.rb"
23
+ "LICENSE",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "bin/gallerby",
28
+ "gallerby.gemspec",
29
+ "lib/gallerby.rb",
30
+ "lib/shared/assets/css/lightbox.css",
31
+ "lib/shared/assets/img/bullet.gif",
32
+ "lib/shared/assets/img/close.gif",
33
+ "lib/shared/assets/img/closelabel.gif",
34
+ "lib/shared/assets/img/donate-button.gif",
35
+ "lib/shared/assets/img/download-icon.gif",
36
+ "lib/shared/assets/img/loading.gif",
37
+ "lib/shared/assets/img/nextlabel.gif",
38
+ "lib/shared/assets/img/prevlabel.gif",
39
+ "lib/shared/assets/js/builder.js",
40
+ "lib/shared/assets/js/effects.js",
41
+ "lib/shared/assets/js/lightbox.js",
42
+ "lib/shared/assets/js/prototype.js",
43
+ "lib/shared/assets/js/scriptaculous.js",
44
+ "lib/shared/templates/gallerby.haml",
45
+ "lib/shared/templates/gallerby.sass",
46
+ "test/helper.rb",
47
+ "test/test_gallerby.rb"
49
48
  ]
50
49
  s.homepage = %q{http://wainekerr.github.com/gallerby}
51
- s.rdoc_options = ["--charset=UTF-8"]
52
50
  s.require_paths = ["lib"]
53
51
  s.rubygems_version = %q{1.3.6}
54
52
  s.summary = %q{Think about a webserver directory-listing for pictures.}
55
53
  s.test_files = [
56
54
  "test/helper.rb",
57
- "test/test_gallerby.rb"
55
+ "test/test_gallerby.rb"
58
56
  ]
59
57
 
60
58
  if s.respond_to? :specification_version then
data/lib/gallerby.rb CHANGED
@@ -5,7 +5,7 @@ class Gallerby
5
5
  SHARED_PATH = File.expand_path('../shared', __FILE__)
6
6
  HAML_OPTS = {:format => :html5, :escape_html => true}
7
7
  SASS_OPTS = {}
8
- attr_accessor :directory, :name, :pictures, :originals, :pages, :description, :pages_links
8
+ attr_accessor :directory, :name, :pictures, :originals, :pages, :description, :pages_links, :create_directories
9
9
 
10
10
  # Well... initialize the Gallerby.
11
11
  #
@@ -14,25 +14,35 @@ class Gallerby
14
14
  # @param [optional, String] name custom name for the gallery (default is the directory)
15
15
  # @param [optional, String] description description for the gallery (default is nothing)
16
16
  # @raise [RuntimeError] if gallery directory don't exists or don't match the required structure.
17
- def initialize(directory, per_page=20, name=nil, description=nil)
17
+ def initialize(directory, per_page=20, name=nil, description=nil, create_directories=false)
18
18
  @directory, @per_page, @name, @description = directory, per_page, name, description
19
19
  @thumbs, @previews, @originals = "#{@directory}/thumbnails", "#{@directory}/previews", "#{@directory}/originals"
20
- raise "Directory #{@directory} don't exists." unless File.exists?(@directory)
20
+ @create_directories = create_directories
21
21
  end
22
22
 
23
23
  # Verify if the directory structure match the gallerby requirements. See the README for more information
24
24
  #
25
25
  # @return [TrueClass, FalseClass]
26
26
  def verify_directory_structure
27
- raise "Thumbnails directory (#{@thumbs}) don't exist." unless File.exists?(@thumbs)
28
- raise "Previews directory (#{@previews}) don't exist." unless File.exists?(@previews)
29
- raise "Originals directory (#{@originals}) don't exist." unless File.exists?(@originals)
27
+ [@directory, @thumbs, @previews, @originals].each {|dir| exit_or_create_directory(dir) }
28
+ end
29
+
30
+ def exit_or_create_directory(directory)
31
+ if @create_directories
32
+ Dir.mkdir(directory)
33
+ puts "Created directory: #{directory}"
34
+ else
35
+ puts "Directory not found: #{directory}"
36
+ return false
37
+ end unless File.exists?(directory)
38
+ true
30
39
  end
31
40
 
32
41
  # Scan for pictures in the original directory.
33
42
  # @returns [Array] Filenames of the pictures
34
43
  def scan_pictures
35
44
  @pictures = Dir["#{@originals}/#{PICTURES_MATCHER}"]
45
+ @pictures.sort! { |a,b| a.downcase <=> b.downcase }
36
46
  end
37
47
 
38
48
  # Map pages/pictures for pagination purposes
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Waine Kerr
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-18 00:00:00 +02:00
17
+ date: 2011-02-14 00:00:00 +01:00
18
18
  default_executable: gallerby
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -80,7 +80,6 @@ extra_rdoc_files:
80
80
  - README.md
81
81
  files:
82
82
  - .document
83
- - .gitignore
84
83
  - LICENSE
85
84
  - README.md
86
85
  - Rakefile
@@ -111,8 +110,8 @@ homepage: http://wainekerr.github.com/gallerby
111
110
  licenses: []
112
111
 
113
112
  post_install_message:
114
- rdoc_options:
115
- - --charset=UTF-8
113
+ rdoc_options: []
114
+
116
115
  require_paths:
117
116
  - lib
118
117
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,23 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- .yardoc
19
- doc
20
- pkg
21
-
22
- ## PROJECT::SPECIFIC
23
- .sass-cache