refactor: create story card partial

This commit is contained in:
Neetpone 2024-04-13 18:21:51 -04:00
parent f45ce86842
commit 9bc91be23f
2 changed files with 50 additions and 47 deletions

View file

@ -9,54 +9,10 @@
= render partial: 'advanced', locals: { show_button: true } = render partial: 'advanced', locals: { show_button: true }
- @records.each do |rec| - @records.each do |rec|
- character_tags = rec.tags.where(type: 'character')
- normal_tags = rec.tags.where.not(type: 'character')
section.result section.result
section.fic-cell = render partial: 'stories/card', locals: { story: rec }
header
- if rec.cover_image
= image_tag '/images?url=' + CGI.escape(rec.cover_image), alt: 'Cover Image'
.details
h2= link_to rec.title, story_path(rec)
span.author
' by
= link_to rec.author.name, author_path(rec.author)
br
span.popular
span.stats
- if rec.short_description
p.description= rec.short_description
- else
div.description
== rec.description_html
footer
.rating
= rating_display(rec.rating)
= status_display(rec.completion_status)
- normal_tags.each do |t|
= tag_to_html(t)
.characters
- character_tags.each do |t|
= character_display(t)
br
.ficstats
span.chapters
= pluralize(rec.chapters.count, 'Chapter') + ','
' 
span.words
=<> rec.num_words
' Words:&nbsp;
span.time_est
' Estimated
=> reading_time(rec.num_words)
| to read
.published
' Published
span= rec.date_published
.updated
' Last Update
span= rec.date_updated
.searchnav .searchnav
= paginate(@records, params: { scope: @scope.scope_key }) = paginate(@records, params: { scope: @scope.scope_key })
br br
span.searchtime Found #{@search.total_count} results. span.searchtime Found #{pluralize(@search.total_count, 'result')}.

View file

@ -0,0 +1,47 @@
/ A "card" that displays a story in a list
- character_tags = story.tags.where(type: 'character')
- normal_tags = story.tags.where.not(type: 'character')
section.fic-cell
header
- if story.cover_image
= image_tag "/images?url=#{CGI.escape(story.cover_image)}", alt: 'Cover Image'
.details
h2= link_to story.title, story_path(story)
span.author
' by
= link_to story.author.name, author_path(story.author)
br
span.popular
span.stats
- if story.short_description
p.description= story.short_description
- else
div.description
== story.description_html
footer
.rating
= rating_display(story.rating)
= status_display(story.completion_status)
- normal_tags.each do |t|
= tag_to_html(t)
.characters
- character_tags.each do |t|
= character_display(t)
br
.ficstats
span.chapters
= pluralize(story.chapters.count, 'Chapter') + ','
'&nbsp;
span.words
=<> story.num_words
' Words:&nbsp;
span.time_est
' Estimated
=> reading_time(story.num_words)
| to read
.published
' Published
span= story.date_published
.updated
' Last Update
span= story.date_updated