Module: Octopress::Tags::ImageCaptionTag::ImageCaptionFunctions

Included in:
Block, Tag
Defined in:
lib/octopress-image-caption-tag.rb

Instance Method Summary collapse

Instance Method Details

#absolute_sized_figureObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/octopress-image-caption-tag.rb', line 36

def absolute_sized_figure
  "  <figure class='image-caption image-caption-absolute \#{@class.rstrip}'>\n    <a class='image-popup' href='\#{@img}'>\n      <img class='caption' src='\#{@img}' width='\#{@width}' height='\#{@height}' title='\#{@title}' alt='\#{@alt}'>\n    </a>\n    <figcaption class='caption-text'>\n      \#{@caption}\n    </figcaption>\n  </figure>\n  EOS\nend\n".gsub(/^ {10}/, '') # gsubm is to pretty up source by indenting

#em_sized_figureObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/octopress-image-caption-tag.rb', line 49

def em_sized_figure
  "  <figure class='image-caption image-caption-absolute \#{@class.rstrip}'>\n    <a class='image-popup' href='\#{@img}'>\n      <img class='caption' src='\#{@img}' style='width:\#{@width};height:\#{@height};' title='\#{@title}' alt='\#{@alt}'>\n    </a>\n    <figcaption class='caption-text'>\n      \#{@caption}\n    </figcaption>\n  </figure>\n  EOS\nend\n".gsub(/^ {10}/, '') # gsubm is to pretty up source by indenting

#parse_sizes(raw_size) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/octopress-image-caption-tag.rb', line 14

def parse_sizes(raw_size)
  if /\s*(?<w>\d+(\.\d+)?%?(em)?)\s+(?<h>\d+(\.\d+)?%?(em)?)/ =~ raw_size
    @width = w
    @height = h
  elsif @class.rstrip == 'right' || @class.rstrip == 'left'
    @width = '33%'
  else
    @width = '100%'
  end
end

#parse_title(raw_title) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/octopress-image-caption-tag.rb', line 25

def parse_title(raw_title)
  if /(?:"|')(?<title>[^"']+)?(?:"|')\s+(?:"|')(?<alt>[^"']+)?(?:"|')/ =~ raw_title
    @title  = title
    @alt    = alt
  else
    /(?:"|')(?<titlealt>[^"']+)?(?:"|')/ =~ raw_title
    @title = titlealt
    @alt = titlealt
  end
end

#relative_sized_figureObject



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/octopress-image-caption-tag.rb', line 62

def relative_sized_figure
  "  <figure class='image-caption \#{@class.rstrip}'>\n    <a class='image-popup' href='\#{@img}'>\n      <img class='caption' src='\#{@img}' width='100%' height='100%' title='\#{@title}' alt='\#{@alt}'>\n    </a>\n    <figcaption class='caption-text'>\n      \#{@caption}\n    </figcaption>\n  </figure>\n  EOS\nend\n".gsub(/^ {10}/, '') # gsubm is to pretty up source by indenting