Module: Shi::Jekyll::Images::Config
Instance Method Summary collapse
- #config ⇒ Object
- #get_value(page, name) ⇒ Object
- #path_by_page(page) ⇒ Object
- #site ⇒ Object
- #site_config ⇒ Object
Instance Method Details
#config ⇒ Object
22 23 24 25 |
# File 'lib/shi/jekyll/images/config.rb', line 22 def config @@config ||= Jekyll::configuration['shi_images'] || {} @@config end |
#get_value(page, name) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/shi/jekyll/images/config.rb', line 27 def get_value page, name result = page.data[name] if result == nil layout_name = page.data['layout'] if layout_name layout_object = site.layouts[page.data['layout']] if layout_object result = layout_object.data[name] end end end if result == nil result = config[name] end result end |
#path_by_page(page) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/shi/jekyll/images/config.rb', line 48 def path_by_page page target_root = config['target_root'] || 'img' result = target_root by_url = true if page.respond_to?(:date) && page.date != nil result = Jekyll::PathManager::join result, page.date.strftime('%Y/%m/%d') by_url = false end if page.respond_to?(:data) && page.data['slug'] != nil result = Jekyll::PathManager::join result, page.data['slug'] by_url = false end if by_url if page.respond_to?(:url) && page.url != nil result = Jekyll::PathManager::join result, page.url else raise ArgumentError, "Invalid Page object: #{page.inspect}" end end result end |
#site ⇒ Object
44 45 46 |
# File 'lib/shi/jekyll/images/config.rb', line 44 def site Jekyll::sites.first end |
#site_config ⇒ Object
17 18 19 20 |
# File 'lib/shi/jekyll/images/config.rb', line 17 def site_config @@site_config ||= Jekyll::configuration || {} @@site_config end |