Class: Jekyll::GalleryPage
- Inherits:
-
Page
- Object
- Page
- Jekyll::GalleryPage
- Defined in:
- lib/jekyll-photo-gallery.rb
Instance Method Summary collapse
- #discover ⇒ Object
-
#initialize(site, base, dir, name, parent = nil) ⇒ GalleryPage
constructor
A new instance of GalleryPage.
Constructor Details
#initialize(site, base, dir, name, parent = nil) ⇒ GalleryPage
Returns a new instance of GalleryPage.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/jekyll-photo-gallery.rb', line 126 def initialize(site, base, dir, name, parent=nil) @site = site @base = base @dir = dir @name = 'index.html' self.process(@name) # Read template @path = File.realpath(File.join(File.dirname(__FILE__), "jekyll-photo-gallery.html")) self.read_yaml(File.dirname(@path), File.basename(@path)) # Only display root page if parent.nil? name = "Photos" self.data["title"] = name end self.data["title_deferred"] = name self.data["parent"] = parent self.data["photos"] = discover self.data["children"] = [] Jekyll::Hooks.trigger :pages, :post_init, self end |
Instance Method Details
#discover ⇒ Object
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/jekyll-photo-gallery.rb', line 115 def discover photos = [] image_extensions = [".png", ".jpg", ".jpeg", ".gif"] Dir.foreach(@dir) do |item| # Skip files with wrong extension next unless item.downcase().end_with?(*image_extensions) photos << GalleryPhoto.new(@site, @base, @dir, item) end photos end |