-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/354 add htmx home page tabs (#362)
* Adding HTMX dependencies Adding HTMX behaviour to users tab * HTMX for languages on home page * Initial tests * Remove unneccessary trigger * HTMX HTML * top rated and tag list * Touch ups and changing tests * flake8 fix * isort fix
- Loading branch information
1 parent
99a3a8d
commit 9e0c9a9
Showing
15 changed files
with
319 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
|
||
.htmx-request .results{ | ||
display:none; | ||
} | ||
|
||
#base-container .bars{ | ||
display:none; | ||
} | ||
.htmx-request .bars{ | ||
display:block !important; | ||
opacity:1; | ||
} | ||
|
||
|
||
|
||
|
||
@tailwind base; | ||
|
||
@tailwind components; | ||
|
||
@tailwind utilities; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% load static %} | ||
|
||
|
||
<img class="bars" src="{% static 'img/bars.svg' %}"/> | ||
<h1>All languages</h1> | ||
<div id="content"> | ||
<ul> | ||
{% for language in object_list %} | ||
<li><a href="{{ language.get_absolute_url }}">{{ language.name }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
|
||
<p class="pagination">{% if has_previous %}<a href="?page={{ previous }}">< Previous {{ results_per_page }}</a>{% endif %} {% if has_next %}<a href="?page={{ next }}">Next {{ results_per_page }} ></a>{% endif %}</p> | ||
|
||
</div> |
69 changes: 69 additions & 0 deletions
69
djangosnippets/templates/cab/partials/most_bookmarked.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
{% load core_tags %} | ||
{% load static %} | ||
|
||
<h1>Most bookmarked snippets{% if months %} last {{ months }} months{% endif %}</h1> | ||
|
||
<div id="content"> | ||
|
||
|
||
{% if object_list %} | ||
<table class="snippet_list"> | ||
<thead> | ||
<tr> | ||
<th>Title</th> | ||
<th>Author</th> | ||
<th>Tags</th> | ||
<th>Publication date</th> | ||
<th>Rating</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for snippet in object_list %} | ||
<tr> | ||
<td><a href="{{ snippet.get_absolute_url }}">{% if not snippet.title|strip %}Untitled{% else %}{{ snippet.title }}{% endif %}</a></td> | ||
<td><a href="{{ snippet.author.get_absolute_url }}">{{ snippet.author.username }}</a></td> | ||
<td>{% for tag in snippet.tags.all %}<a href="{% url 'cab_snippet_matches_tag' tag.slug %}">{{ tag.name }}</a> {% endfor %}</td> | ||
<td>{{ snippet.pub_date }}</td> | ||
<td><span class="rating-{% if snippet.rating_score >= 0 %}positive{% else %}negative{% endif %}">{% if snippet.rating_score >= 0 %}+{% endif %}{{ snippet.rating_score }}</span></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<p class="pagination"> | ||
{% if has_previous %} | ||
<a href="?page={{ previous }}{% if months %}&months={{ months }}{% endif %}">< Previous {{ results_per_page }}</a> | ||
{% endif %} | ||
| ||
{% if has_next %} | ||
<a href="?page={{ next }}{% if months %}&months={{ months }}{% endif %}">Next {{ results_per_page }} ></a> | ||
{% endif %} | ||
</p> | ||
<p class="count">{{ hits }} snippet{{ hits|pluralize }} posted so far.</p> | ||
{% else %} | ||
<p class="empty">No snippets posted yet.</p> | ||
{% endif %} | ||
</div> | ||
|
||
|
||
<div id="sidebar"> | ||
<p>You're looking at the most-bookmarked snippets on the site; {% if user.is_authenticated %}you can help useful snippets show up here by clicking the "bookmark this snippet" link on their pages and ading them to <a href="{% url 'cab_user_bookmarks' %}">your bookmarks</a>{% else %}if you'd like to help useful snippets show up here, <a href="{% url 'account_login' %}">sign up for an account</a> and you'll get your own bookmarks list{% endif %}.</p> | ||
|
||
<nav class="filter"> | ||
<h3>Filter by date</h3> | ||
<ul> | ||
<li{% if not months %} class="active"{% endif %}><a href="{{ request.path }}">Any time</a></li> | ||
<li{% if months == 3 %} class="active"{% endif %}><a href="{{ request.path }}?months=3">3 months</a></li> | ||
<li{% if months == 6 %} class="active"{% endif %}><a href="{{ request.path }}?months=6">6 months</a></li> | ||
<li{% if months == 12 %} class="active"{% endif %}><a href="{{ request.path }}?months=12">1 year</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<p><a rel="alternate" href="{% url 'cab_feed_latest' %}" type="application/atom+xml"><i class="fa fa-fw fa-rss-square"></i>Feed of latest snippets</a></p> | ||
</div> | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
{% load core_tags %} | ||
<h1>All tags</h1> | ||
<div id="content"> | ||
{% if object_list %} | ||
<ul> | ||
{% for tag in object_list %} | ||
<li><a href="{% url 'cab_snippet_matches_tag' tag.slug %}">{{ tag.name }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
|
||
<p class="pagination">{% if has_previous %}<a href="?page={{ previous }}">< Previous {{ results_per_page }}</a>{% endif %} {% if has_next %}<a href="?page={{ next }}">Next {{ results_per_page }} ></a>{% endif %}</p> | ||
{% else %} | ||
<p>No tags have been used yet.</p> | ||
{% endif %} | ||
|
||
</div> | ||
<div id="sidebar"> | ||
<h2>Most popular tags</h2> | ||
|
||
<ol> | ||
{% for tag in "cab.snippet"|call_manager:"top_tags"|slice:":5" %} | ||
<li><a href="{% url 'cab_snippet_matches_tag' tag.slug %}">{{ tag.name }}</a></li> | ||
{% endfor %} | ||
</ol> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% load static %} | ||
|
||
<img class="bars" src="{% static 'img/bars.svg' %}"/> | ||
<h1>Top authors</h1> | ||
<div id="content"> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Number of snippets</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for author in object_list %} | ||
<tr><td><a href="{{ author.get_absolute_url }}">{{ author.username }}</a></td><td>({{ author.snippet_set.count }} snippet{{ author.snippet_set.count|pluralize }})</td></tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
|
Oops, something went wrong.