Module: Middleman::Features::Webcomic::Helpers

Defined in:
lib/middleman-webcomic/feature.rb

Instance Method Summary collapse

Instance Method Details

#comic_image_url(comic) ⇒ Object Also known as: comic_image_for



103
104
105
# File 'lib/middleman-webcomic/feature.rb', line 103

def comic_image_url(comic)
  "/#{settings.webcomic_images}/#{comic.filename}"
end

#comic_path_url(comic) ⇒ Object Also known as: comic_path_for



113
114
115
# File 'lib/middleman-webcomic/feature.rb', line 113

def comic_path_url(comic)
  "/#{settings.webcomic_uri}/#{comic[settings.webcomic_slug_field]}"
end

#current_comicObject



83
84
85
# File 'lib/middleman-webcomic/feature.rb', line 83

def current_comic
  (@comic || last_comic)
end

#current_comic_imageObject Also known as: current_comic_image_url



108
109
110
# File 'lib/middleman-webcomic/feature.rb', line 108

def current_comic_image
  comic_image_for current_comic
end

#current_comic_pathObject



118
119
120
# File 'lib/middleman-webcomic/feature.rb', line 118

def current_comic_path
  comic_path_for current_comic
end

#feed_absolute_paths(source, path = settings.webcomic_domain) ⇒ Object



164
165
166
167
168
# File 'lib/middleman-webcomic/feature.rb', line 164

def feed_absolute_paths(source, path=settings.webcomic_domain)
  source.gsub( /src=(["']*)\//) do |match|
    "#{match[0...-1]}#{path}/"
  end
end

#first_comicObject



87
88
89
# File 'lib/middleman-webcomic/feature.rb', line 87

def first_comic
  data.webcomic.strips.last
end

#first_comic_pathObject



122
123
124
# File 'lib/middleman-webcomic/feature.rb', line 122

def first_comic_path
  comic_path_for first_comic
end

#last_comicObject



91
92
93
# File 'lib/middleman-webcomic/feature.rb', line 91

def last_comic
  data.webcomic.strips.first
end

#last_comic_pathObject



126
127
128
# File 'lib/middleman-webcomic/feature.rb', line 126

def last_comic_path
  comic_path_for last_comic
end

#next_comicObject



95
96
97
# File 'lib/middleman-webcomic/feature.rb', line 95

def next_comic
  current_comic.next
end

#next_comic_pathObject



130
131
132
# File 'lib/middleman-webcomic/feature.rb', line 130

def next_comic_path
  comic_path_for next_comic
end

#prev_comicObject



99
100
101
# File 'lib/middleman-webcomic/feature.rb', line 99

def prev_comic
  current_comic.prev
end

#prev_comic_pathObject



134
135
136
# File 'lib/middleman-webcomic/feature.rb', line 134

def prev_comic_path
  comic_path_for prev_comic
end

#start_story_path_for(object) ⇒ Object

Story Helpers



140
141
142
143
144
145
146
147
# File 'lib/middleman-webcomic/feature.rb', line 140

def start_story_path_for(object)
  story = if object.is_a? ::Middleman::Webcomic::Story
    object
  else # it's a comic... right?
    data.webcomic.stories.detect  {|s| s.title == object.story }
  end
  comic_path_for story.comics.last
end

#story_path_for(object) ⇒ Object



149
150
151
152
153
154
155
156
# File 'lib/middleman-webcomic/feature.rb', line 149

def story_path_for(object)
  story = if object.is_a? Story
    object
  else # it's a comic... right?
    data.webcomic.stories.detect  {|s| s.title == object.story }
  end
  "/#{settings.webcomic_story_uri}/#{story.slug}"
end

#webcomic_feed_dataObject

Feed Helpers



160
161
162
# File 'lib/middleman-webcomic/feature.rb', line 160

def webcomic_feed_data
  data.webcomic.strips[0...10]
end