Display entry favorite count, refactored entry templates

pull/6/head
Furkan 1 year ago
parent 889bde7ba6
commit 63a0363124
  1. 4
      ozgursozluk/api.py
  2. 2
      ozgursozluk/configs.py
  3. 8
      ozgursozluk/models.py
  4. 18
      ozgursozluk/templates/entry.html
  5. 31
      ozgursozluk/templates/entry_macro.html
  6. 21
      ozgursozluk/templates/topic.html

@ -44,6 +44,7 @@ class EksiSozluk:
entry.find("div", class_="content"),
entry.find("a", class_="entry-author").text,
entry.find("a", class_="entry-date permalink", href=True).text,
int(entry.attrs["data-favorite-count"])
)
def search_topic(self, query: str) -> Topic:
@ -94,9 +95,10 @@ class EksiSozluk:
entry.find("div", class_="content"),
entry.find("a", class_="entry-author").text,
entry.find("a", class_="entry-date permalink", href=True).text,
int(entry.attrs["data-favorite-count"]),
int(h1.attrs["data-id"]),
h1.attrs["data-title"],
h1.find("a")["href"][1:],
h1.find("a")["href"][1:]
)
def get_author(self, nickname: str) -> Author:

@ -7,12 +7,14 @@ SECRET_KEY: Final = environ.get("OZGURSOZLUK_SECRET_KEY", "Some secret string")
DEFAULT_THEME: Final = "light"
DEFAULT_DISPLAY_PINNED_TOPICS: Final = "true"
DEFAULT_DISPLAY_AUTHOR_NICKNAMES: Final = "false"
DEFAULT_DISPLAY_ENTRY_FAVORITE_COUNT: Final = "false"
DEFAULT_EKSI_SOZLUK_BASE_URL: Final = "https://eksisozluk.com"
DEFAULT_COOKIES: Final = {
"theme": DEFAULT_THEME,
"display_pinned_topics": DEFAULT_DISPLAY_PINNED_TOPICS,
"display_author_nicknames": DEFAULT_DISPLAY_AUTHOR_NICKNAMES,
"display_entry_favorite_count": DEFAULT_DISPLAY_ENTRY_FAVORITE_COUNT,
"eksi_sozluk_base_url": DEFAULT_EKSI_SOZLUK_BASE_URL
}

@ -9,15 +9,11 @@ class Entry:
content_html: str
author: str
datetime: str
favorite_count: int
@dataclass
class EntryTopic:
id: int
content: str
content_html: str
author: str
datetime: str
class EntryTopic(Entry):
topic_id: int
topic_title: str
topic_path: str

@ -17,20 +17,8 @@
</p>
</div>
</div>
<div class="entry">
{{ entry.content_html|safe }}
</br>
<div style="text-align: right;">
{% if request.cookies.get('display_author_nicknames') == 'true' %}
<small>
<a href="{{ url_for('author', nickname=entry.author) }}">
{{ entry.author }}
</a>
</small>
-
{% endif %}
<small>{{ entry.datetime }}</small>
</div>
</div>
{% from "entry_macro.html" import render_entry %}
{{ render_entry(entry, False) }}
</div>
{% endblock %}

@ -0,0 +1,31 @@
{% macro render_entry(entry, clickable_date) %}
<div class="entry">
{{ entry.content_html|safe }}
</br>
<div style="text-align: right;">
{% if request.cookies.get('display_entry_favorite_count') == 'true' %}
<small>
{{ entry.favorite_count }} favorites
</small>
-
{% endif %}
{% if request.cookies.get('display_author_nicknames') == 'true' %}
<small>
<a href="{{ url_for('author', nickname=entry.author) }}">
{{ entry.author }}
</a>
</small>
-
{% endif %}
<small>
{% if clickable_date %}
<a href="{{ url_for('entry', id=entry.id) }}">
{{ entry.datetime }}
</a>
{% else %}
{{ entry.datetime }}
{% endif %}
</small>
</div>
</div>
{% endmacro %}

@ -23,25 +23,8 @@
{% include "paginate.html" %}
</div>
{% for entry in topic.entrys %}
<div class="entry">
{{ entry.content_html|safe }}
</br>
<div style="text-align: right;">
{% if request.cookies.get('display_author_nicknames') == 'true' %}
<small>
<a href="{{ url_for('author', nickname=entry.author) }}">
{{ entry.author }}
</a>
</small>
-
{% endif %}
<small>
<a href="{{ url_for('entry', id=entry.id) }}">
{{ entry.datetime }}
</a>
</small>
</div>
</div>
{% from "entry_macro.html" import render_entry %}
{{ render_entry(entry, True) }}
{% endfor %}
<div class="info" style="padding-top: 0;">
<div></div>

Loading…
Cancel
Save