Skip to content

Commit

Permalink
fix: News post images (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateus Santos | mateussm committed Nov 19, 2024
1 parent c3f5541 commit 204cf63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions back/raspa_tacho/models/news_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ def __init__(
self,
datetime,
title,
src_image,
cover_image_src,
post_images_srcs,
paragraphs,
related_links,
):
self.datetime = datetime
self.title = title
self.src_image = src_image
self.cover_image_src = cover_image_src
self.post_images_srcs = post_images_srcs
self.paragraphs = paragraphs
self.related_links = related_links

def __str__(self):
return '\n'.join([
f'Datetime: {self.datetime}',
f'Title: {self.title}',
f'Image src: {self.src_image}',
f'Cover image src: {self.cover_image_src}',
f'Post images srcs: {self.post_images_srcs}',
'\n\n'.join(self.paragraphs),
f'Related links: {self.related_links}'
])
8 changes: 5 additions & 3 deletions back/raspa_tacho/services/tome/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def info(self) -> NewsInfo:
"""
raw_datetime = self.content.select('header ul .meta-date')[0].text
title = self.content.select('.page-title')[0].text
# src_image = self.content.select('.panel .panel-body .container-fluid .row img')[0]['src']
cover_image_src = self.content.select('.hero-section img')[0]['src']
post_images_srcs = [image['src'] for image in self.content.select('.ct-container > article img')]
raw_paragraphs = self.content.select('article p')
raw_related_link_anchors = self.content.select('.panel .panel-body .panel-group .panel-default > a')
raw_related_link_titles = self.content.select('.panel .panel-body .panel-group .panel-default > a p')
Expand All @@ -38,9 +39,10 @@ def info(self) -> NewsInfo:
return NewsInfo(
str(datetime_object),
title,
'',
cover_image_src,
post_images_srcs,
paragraphs,
related_links
related_links,
)

@staticmethod
Expand Down

0 comments on commit 204cf63

Please sign in to comment.