forked from retoor/devplacepy
feat: add dynamic gist language sidebar filtering based on existing database entries
Add a new `get_gist_languages()` function in database.py that queries distinct language codes from the gists table and caches results for 60 seconds. Create a database index on the `language` column of the gists table for efficient queries. Update the gists router to pass the set of active language codes to the template. Modify the gists.html sidebar to only display language filter links for codes that actually have gists in the database, hiding empty language categories and conditionally showing the plaintext link.
This commit is contained in:
@@ -15,15 +15,17 @@
|
||||
<span class="icon">📋</span>All
|
||||
</a>
|
||||
{% for code, name in languages %}
|
||||
{% if code != 'plaintext' %}
|
||||
{% if code != 'plaintext' and code in gist_language_codes %}
|
||||
<a href="/gists?language={{ code }}" class="sidebar-link {% if current_language == code %}active{% endif %}">
|
||||
<span class="icon">📝</span>{{ name }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if 'plaintext' in gist_language_codes %}
|
||||
<a href="/gists?language=plaintext" class="sidebar-link {% if current_language == 'plaintext' %}active{% endif %}">
|
||||
<span class="icon">📝</span>Plain Text
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if user %}
|
||||
|
||||
Reference in New Issue
Block a user