Skip to content

Commit

Permalink
Merge branch 'auto-thumbnails' of https://github.com/hasgeek/funnel i…
Browse files Browse the repository at this point in the history
…nto auto-thumbnails
  • Loading branch information
anishTP committed Sep 28, 2023
2 parents e44756f + 64a4f4f commit 4464ee9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
13 changes: 5 additions & 8 deletions funnel/templates/thumbnail_preview.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="{{ manifest('css/app.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ manifest('css/project.css') }}" />
</head>
Expand All @@ -11,15 +11,12 @@
<div class="main-wrapper">
<div class="title-wrapper">
<h5>{{project.account.title}}</h5>
<h1 class="post-title">
{{ project.title }}
</h1>
<h1 class="post-title">{{ project.title }}</h1>
<div class="mui--text-heading mui--text-light zero-bottom-margin">
{{ project.tagline }}
</div>
</div>
{{ project.datelocation }}
{{ project.primary_venue }}
{{ project.datelocation }} {{ project.primary_venue }}
</div>
</main>
</body>
Expand Down
2 changes: 1 addition & 1 deletion funnel/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
db,
sa,
)
from ..signals import project_role_change, project_data_changed
from ..signals import project_data_change, project_role_change
from ..typing import ReturnRenderWith, ReturnView
from .helpers import html_in_json, render_redirect
from .jobs import import_tickets, tag_locations
Expand Down
14 changes: 9 additions & 5 deletions funnel/views/thumnbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@
from .jobs import rqjob
from ..signals import project_data_changed

from ..models import Project
from ..signals import project_data_change
from .jobs import rqjob

thumbnail = Html2Image(size=(640, 360))


@project_data_changed.connect
def generate_thumbnail_image(project = Project) -> None:
render_thumbnail_image(project = project)
@project_data_change.connect
def generate_thumbnail_image(project=Project) -> None:
render_thumbnail_image(project=project)


@rqjob()
def render_thumbnail_image(project = Project) -> None:
def render_thumbnail_image(project=Project) -> None:
"""Render the thumbnail image and cache the file using a background task"""

image_html = render_template('thumbnail_preview.html.jinja2', project = project )
image_html = render_template('thumbnail_preview.html.jinja2', project=project)

thumbnail_image = thumbnail.screenshot(html_str=image_html, save_as=f'{project.id}_thumbnail.png', size=(640, 360))

Expand Down

0 comments on commit 4464ee9

Please sign in to comment.