Class: Alula::Fancybox

Inherits:
ImageTag
  • Object
show all
Defined in:
lib/alula/plugins/fancybox.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.install(options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/alula/plugins/fancybox.rb', line 14

def self.install(options)
  # Display license unless acknoledged
  unless options.kind_of?(Hash) and options['personal']
    puts <<-ENDOFNOTICE
*** fancyBox
Please note, that fancyBox is licensed under the therms of the
Creative Commons Attribution-NonCommercial 3.0 License
(http://creativecommons.org/licenses/by-nc/3.0/).

If you would like to use fancyBox for commercial purposes,
you can purchase a license from http://fancyapps.com/store/

To remove this notice, please include following options in config.yml
---
plugins:
  fancybox:
    personal: true
    ENDOFNOTICE
  end
  
  # Register for image tags
  Alula::Tag.register :image, self
end

.pathObject



6
7
8
# File 'lib/alula/plugins/fancybox.rb', line 6

def self.path
  File.join(File.dirname(__FILE__), %w{.. .. .. plugins fancybox})
end

.versionObject



10
11
12
# File 'lib/alula/plugins/fancybox.rb', line 10

def self.version
  Alula::Plugins::VERSION::STRING
end

Instance Method Details

#contentObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/alula/plugins/fancybox.rb', line 38

def content
  # FeedBuilder support, skip sublime extensions for feeds
  return super if self.context.item..renderer.class.to_s[/FeedBuilder/]
  
  image = attachment_url(@source, :image)
  thumbnail = attachment_url(@source, :thumbnail)
  hires = hires_url(@source, :image)
  info = info(@source, :image)
  tn_info = info(@source, :thumbnail)

  return super unless image and thumbnail
  
  unless @options['alternative'] or @options['title']
    @options['title'] = info(@source, :image).title
    @options['alternative'] = info(@source, :image).title
  end
  
  tag = "<a"
  tag += " class=\"img fancybox fb_zoomable #{@options["classes"].join(" ")}\""
  tag += " href=\"#{image}\""
  tag += " data-width=\"#{info.width}\""
  tag += " data-height=\"#{info.height}\""
  tag += " data-hires=\"#{hires}\"" if context.site.config.attachments.image.hires and hires
  tag += " data-fancybox-group=\"#{context.item.id}\""
  tag += " title=\"#{@options["title"]}\"" if @options["title"]
  tag += " style=\"width: #{tn_info.width}px; height: #{tn_info.height}px;\""
  tag += ">"
  tag += imagetag(@source, :thumbnail, classes: [])
  tag += "  <span class=\"fb_zoom_icon\"></span>"
  tag += "</a>"
end