Add display pinned topic option

pull/6/head
beucismis 1 year ago
parent 0878bfddcc
commit 60183fcd8c
  1. 3
      ozgursozluk/config.py
  2. 37
      ozgursozluk/templates/index.html
  3. 19
      ozgursozluk/templates/settings.html
  4. 2
      ozgursozluk/templates/topic.html
  5. 23
      ozgursozluk/views.py

@ -4,5 +4,6 @@ from os import environ
SECRET_KEY = environ.get("OZGURSOZLUK_SECRET_KEY", "Some secret string")
DEFAULT_THEME = "light"
DEFAULT_DISPLAY_AUTHOR_NICKNAME = "false"
DEFAULT_DISPLAY_PINNED_TOPICS = "true"
DEFAULT_DISPLAY_AUTHOR_NICKNAMES = "false"
DEFAULT_EKSI_BASE_URL = "https://eksisozluk.com"

@ -18,17 +18,36 @@
</div>
</div>
{% for topic in gundem %}
<div class="entry">
<div style="display: flex; justify-content: space-between;">
<div>
<a style="text-decoration: none;" href="{{ topic.permalink }}">{{ topic.title }}</a>
</div>
<div>
{% if topic.pinned %}<small style="opacity: 0.5;">pinned</small>{% endif %}
{% if topic.views %}{{ topic.views|safe }}{% endif %}
{% if request.cookies.get('display_pinned_topics') == 'true' %}
<div class="entry">
<div style="display: flex; justify-content: space-between;">
<div>
<a style="text-decoration: none;" href="{{ topic.permalink }}">
{{ topic.title }}
</a>
</div>
<div>
{% if topic.pinned %}<small style="opacity: 0.5;">pinned</small>{% endif %}
{% if topic.views %}{{ topic.views|safe }}{% endif %}
</div>
</div>
</div>
</div>
{% else %}
{% if not topic.pinned %}
<div class="entry">
<div style="display: flex; justify-content: space-between;">
<div>
<a style="text-decoration: none;" href="{{ topic.permalink }}">
{{ topic.title }}
</a>
</div>
<div>
{% if topic.views %}{{ topic.views|safe }}{% endif %}
</div>
</div>
</div>
{% endif %}
{% endif %}
{% endfor %}
<div class="info" style="padding-top: 0;">
<div></div>

@ -17,10 +17,17 @@
</select>
</div>
<div class="settings-group">
display author nickname:
<select name="display_author_nickname">
<option value="false" {% if display_author_nickname == 'false' %}selected{% endif %}>no</option>
<option value="true" {% if display_author_nickname == 'true' %}selected{% endif %}>yes</option>
display pinned topics:
<select name="display_pinned_topics">
<option value="true" {% if display_pinned_topics == 'true' %}selected{% endif %}>yes</option>
<option value="false" {% if display_pinned_topics == 'false' %}selected{% endif %}>no</option>
</select>
</div>
<div class="settings-group">
display author nicknames:
<select name="display_author_nicknames">
<option value="true" {% if display_author_nicknames == 'true' %}selected{% endif %}>yes</option>
<option value="false" {% if display_author_nicknames == 'false' %}selected{% endif %}>no</option>
</select>
</div>
<div class="settings-group">
@ -35,13 +42,13 @@
</div>
</form>
<div style="text-align: center;">
note: settings are saved in browser cookies.</br>clearing your cookies will reset them.
note: settings are saved in browser cookies. clearing your cookies will reset them.
</br></br>
v{{ version }}
-
last commit:
<a href="{{ source }}/commit/{{ last_commit }}" target="_blank">{{ last_commit[:8] }}</a>
</br>
-
made with <3 on the <a href="{{ url_for('topic', title='thinkpad-t61--1883047') }}">t61</a>
</div>
</div>

@ -27,7 +27,7 @@
{{ entry.content|safe }}
</br>
<div style="text-align: right;">
{% if request.cookies.get('display_author_nickname') == 'true' %}
{% if request.cookies.get('display_author_nicknames') == 'true' %}
<small>
<a href="{{ url_for('author', nickname=entry.author) }}">{{ entry.author }}</a>
</small>

@ -6,7 +6,8 @@ import ozgursozluk
from ozgursozluk.api import Eksi
from ozgursozluk.config import (
DEFAULT_THEME,
DEFAULT_DISPLAY_AUTHOR_NICKNAME,
DEFAULT_DISPLAY_PINNED_TOPICS,
DEFAULT_DISPLAY_AUTHOR_NICKNAMES,
DEFAULT_EKSI_BASE_URL,
)
@ -94,8 +95,13 @@ def settings():
expires=_expires(),
)
response.set_cookie(
"display_author_nickname",
request.form["display_author_nickname"],
"display_pinned_topics",
request.form["display_pinned_topics"],
expires=_expires(),
)
response.set_cookie(
"display_author_nicknames",
request.form["display_author_nicknames"],
expires=_expires(),
)
response.set_cookie(
@ -109,13 +115,16 @@ def settings():
return render_template(
"settings.html",
theme=request.cookies.get(
"theme", DEFAULT_THEME
"theme", DEFAULT_THEME,
),
display_pinned_topics=request.cookies.get(
"display_pinned_topics", DEFAULT_DISPLAY_PINNED_TOPICS,
),
display_author_nickname=request.cookies.get(
"display_author_nickname", DEFAULT_DISPLAY_AUTHOR_NICKNAME
display_author_nicknames=request.cookies.get(
"display_author_nicknames", DEFAULT_DISPLAY_AUTHOR_NICKNAMES,
),
eksi_base_url=request.cookies.get(
"eksi_base_url", DEFAULT_EKSI_BASE_URL
"eksi_base_url", DEFAULT_EKSI_BASE_URL,
),
)

Loading…
Cancel
Save