Class: RageRender::ComicDrop
- Inherits:
-
Jekyll::Drops::DocumentDrop
- Object
- Jekyll::Drops::DocumentDrop
- RageRender::ComicDrop
- Extended by:
- Pipettes
- Defined in:
- lib/ragerender/jekyll/comics.rb
Constant Summary collapse
- PAGINATION_FIELDS =
%w[ comicurl comictitle posttime ]
Instance Method Summary collapse
- #authornotes ⇒ Object
- #comicdescription ⇒ Object
-
#comicimage ⇒ Object
An HTML tag to print for the comic image.
- #comickeywords ⇒ Object
- #comicnumber ⇒ Object
- #comicsnum ⇒ Object
- #comictitle ⇒ Object
- #custom ⇒ Object
- #dropdown ⇒ Object
- #haschapter ⇒ Object
- #isfirstcomic ⇒ Object
- #isfirstcomicinchapter ⇒ Object
- #islastcomic ⇒ Object
- #islastcomicinchapter ⇒ Object
- #keys ⇒ Object
- #nextcomicbychapter ⇒ Object
- #postmonth ⇒ Object
- #posttime ⇒ Object
- #postyear ⇒ Object
- #prevcomicbychapter ⇒ Object
- #to_liquid ⇒ Object
- #transcript ⇒ Object
Methods included from Pipettes
clean_payload, def_data_delegator, def_image_metadata, def_loop, def_safe_delegator, extended, loops
Instance Method Details
#authornotes ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/ragerender/jekyll/comics.rb', line 198 def @obj.data['authornotes'] || [{ 'is_reply' => false, 'comment' => maybe_escape(@obj.content), 'isguest' => false, 'avatar' => nil, 'authorname' => @obj.data['author'], 'commentanchor' => "comment-#{@obj.date.strftime('%s')}", 'posttime' => comicfury_date(@obj.date), 'profilelink' => nil, # TODO }] end |
#comicdescription ⇒ Object
112 113 114 |
# File 'lib/ragerender/jekyll/comics.rb', line 112 def comicdescription escape @obj.data['description'] end |
#comicimage ⇒ Object
An HTML tag to print for the comic image. If there is a future image, then this is also a link to the next comic page.
255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/ragerender/jekyll/comics.rb', line 255 def comicimage linkopen = nextcomic ? <<~HTML : '' <a href="#{nextcomic}"> HTML image = <<~HTML <img id="comicimage" src="#{comicimageurl}" alt="#{comictitle}" width="#{comicwidth}" height="#{comicheight}" title="#{comicdescription}"> HTML linkclose = nextcomic ? <<~HTML : '' </a> HTML [linkopen, image, linkclose].join end |
#comickeywords ⇒ Object
120 121 122 |
# File 'lib/ragerender/jekyll/comics.rb', line 120 def comickeywords (@obj.data['keywords'] || []).map {|k| escape k }.join(', ') end |
#comicnumber ⇒ Object
124 125 126 |
# File 'lib/ragerender/jekyll/comics.rb', line 124 def comicnumber 1 + all_comics.index(@obj) end |
#comicsnum ⇒ Object
128 129 130 |
# File 'lib/ragerender/jekyll/comics.rb', line 128 def comicsnum all_comics.size end |
#comictitle ⇒ Object
108 109 110 |
# File 'lib/ragerender/jekyll/comics.rb', line 108 def comictitle escape @obj.data['title'] end |
#custom ⇒ Object
211 212 213 214 215 216 217 218 219 |
# File 'lib/ragerender/jekyll/comics.rb', line 211 def custom chapter_data = chapter.nil? ? {} : chapter.data.fetch('custom', {}) comic_data = @obj.data.fetch('custom', {}) chapter_data.merge(comic_data).reject do |k, v| v.nil? || (v.respond_to?(:empty?) && v.empty?) end.transform_values do |v| v.is_a?(String) ? escape(v) : v end end |
#dropdown ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/ragerender/jekyll/comics.rb', line 165 def dropdown all_comics.each_with_object([]) do |c, dropdown| new_group = dropdown.last.nil? ? true : dropdown.last['grouplabel'] != c.data['chapter'] if new_group && !dropdown.last.nil? && dropdown.last['title'] == c.data['chapter'] dropdown.last['endgroup'] = true end in_this_chapter = @obj.data['chapter'] == c.data['chapter'] if in_this_chapter dropdown << { 'is_selected' => @obj == c, 'is_disabled' => false, 'title' => escape(c.data['title']), 'grouplabel' => c.data['chapter'], 'newgroup' => new_group, 'endgroup' => false, 'url' => c.url, } elsif new_group dropdown << { 'is_selected' => false, 'is_disabled' => false, 'title' => c.data['chapter'], 'grouplabel' => c.data['chapter'], 'newgroup' => false, 'endgroup' => false, 'url' => c.url, # navigating to chapter just goes to first page } end end end |
#haschapter ⇒ Object
144 145 146 |
# File 'lib/ragerender/jekyll/comics.rb', line 144 def haschapter @obj.data.include? 'chapter' end |
#isfirstcomic ⇒ Object
221 222 223 |
# File 'lib/ragerender/jekyll/comics.rb', line 221 def isfirstcomic all_comics.first == @obj end |
#isfirstcomicinchapter ⇒ Object
156 157 158 |
# File 'lib/ragerender/jekyll/comics.rb', line 156 def isfirstcomicinchapter (chapterdrop&.send(:comics) || []).first == @obj end |
#islastcomic ⇒ Object
225 226 227 |
# File 'lib/ragerender/jekyll/comics.rb', line 225 def islastcomic all_comics.last == @obj end |
#islastcomicinchapter ⇒ Object
160 161 162 |
# File 'lib/ragerender/jekyll/comics.rb', line 160 def islastcomicinchapter (chapterdrop&.send(:comics) || []).last == @obj end |
#keys ⇒ Object
270 271 272 |
# File 'lib/ragerender/jekyll/comics.rb', line 270 def keys super.reject {|k| private_methods.include? k.to_sym } end |
#nextcomicbychapter ⇒ Object
245 246 247 248 249 250 251 |
# File 'lib/ragerender/jekyll/comics.rb', line 245 def nextcomicbychapter if islastcomicinchapter nextchapterdrop&.send(:first_comic) else (chapterdrop&.send(:comics) || []).each_cons(2).detect {|this, _| this == @obj }&.last end&.url end |
#postmonth ⇒ Object
140 141 142 |
# File 'lib/ragerender/jekyll/comics.rb', line 140 def postmonth @obj.date.month end |
#posttime ⇒ Object
132 133 134 |
# File 'lib/ragerender/jekyll/comics.rb', line 132 def posttime comicfury_date(@obj.date) end |
#postyear ⇒ Object
136 137 138 |
# File 'lib/ragerender/jekyll/comics.rb', line 136 def postyear @obj.date.year end |
#prevcomicbychapter ⇒ Object
237 238 239 240 241 242 243 |
# File 'lib/ragerender/jekyll/comics.rb', line 237 def prevcomicbychapter if isfirstcomicinchapter (prevchapterdrop&.send(:comics) || []).last else (chapterdrop&.send(:comics) || []).each_cons(2).detect {|_, this| this == @obj }&.first end&.url end |
#to_liquid ⇒ Object
274 275 276 277 278 |
# File 'lib/ragerender/jekyll/comics.rb', line 274 def to_liquid super.reject do |k, v| Jekyll::Drops::DocumentDrop::NESTED_OBJECT_FIELD_BLACKLIST.include? k end.to_h end |
#transcript ⇒ Object
116 117 118 |
# File 'lib/ragerender/jekyll/comics.rb', line 116 def transcript escape @obj.data['transcript'] end |