Class: Jekyll::FlickrLoader
- Inherits:
-
Object
- Object
- Jekyll::FlickrLoader
- Defined in:
- lib/badpixxel-jekyll-flickr/loader.rb
Constant Summary collapse
- @@is_loaded =
false
Instance Attribute Summary collapse
-
#is_loaded ⇒ Object
Returns the value of attribute is_loaded.
Class Method Summary collapse
Instance Attribute Details
#is_loaded ⇒ Object
Returns the value of attribute is_loaded.
19 20 21 |
# File 'lib/badpixxel-jekyll-flickr/loader.rb', line 19 def is_loaded @is_loaded end |
Class Method Details
.is_ready(site) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/badpixxel-jekyll-flickr/loader.rb', line 52 def self.is_ready(site) # Check if Plugin Parameters Allow Cache Loading if site.config['flickr']['use_cache'] return false end if !site.config['flickr']['cache_dir'] return false end return true end |
.load(site) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/badpixxel-jekyll-flickr/loader.rb', line 23 def self.load(site) if @@is_loaded puts "Flickr: Photosets Already Loaded" return end # Setup Defaults Plugin Parameters if not self.is_ready(site) puts "Flickr: Using Cached Photosets" return end puts "Flickr: Update of Photosets cache" # Fetch list of Photosets nsid = flickr.people.findByUsername(:username => site.config['flickr']['screen_name']).id flickr_photosets = flickr.photosets.getList(:user_id => nsid) # Update All Photosets Cache flickr_photosets.each do |flickr_photoset| photoset = Photoset.new(site, flickr_photoset) puts "Flickr: Update Photosets #{flickr_photoset.title} (#{photoset.photos_from_cache} In Cache, #{photoset.photos_from_flickr} Loaded from Flickr)" end @@is_loaded = true puts "Flickr: Photosets cache updated" end |
.setup(site) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/badpixxel-jekyll-flickr/loader.rb', line 64 def self.setup(site) cache_dir = site.config['flickr']['cache_dir'] # Clear any existing cache if requested if site.config['flickr']['flush_cache'] if Dir.exists?(cache_dir) FileUtils.rm_rf(cache_dir) end end # Ensure Cache Dir Exists if !Dir.exists?(cache_dir) Dir.mkdir(cache_dir) end # Populate cache from Flickr FlickRaw.api_key = site.config['flickr']['api_key'] FlickRaw.shared_secret = site.config['flickr']['api_secret'] end |