aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-07-31 20:53:24 -0400
committerBobby <[email protected]>2023-07-31 20:53:24 -0400
commit2b94b782ca5c7aa875c8c8451cd21e305fc89e4d (patch)
treeebce2f3f0a7a8ec78505e414850fa2bdca85ea4e /templates
parentcbce3e49fcec9fd1a5da03cdbe91d4297f66f11c (diff)
downloadthatcomputerscientist-2b94b782ca5c7aa875c8c8451cd21e305fc89e4d.tar.xz
thatcomputerscientist-2b94b782ca5c7aa875c8c8451cd21e305fc89e4d.zip
Search added
Diffstat (limited to 'templates')
-rw-r--r--templates/blog/partials/search/comment_list.html9
-rw-r--r--templates/blog/partials/search/post_list.html23
-rw-r--r--templates/blog/partials/search/user_list.html13
-rw-r--r--templates/blog/search.html37
4 files changed, 79 insertions, 3 deletions
diff --git a/templates/blog/partials/search/comment_list.html b/templates/blog/partials/search/comment_list.html
new file mode 100644
index 00000000..d45896bb
--- /dev/null
+++ b/templates/blog/partials/search/comment_list.html
@@ -0,0 +1,9 @@
+{% load static %}
+<ul style="list-style: none; padding: 0px; margin: 0px;">
+{% for comment in comments %}
+ <li style="background: #1c1c1c;padding: 10px; margin-bottom: 10px;border-radius: 8px;">
+ <p><a class="notranslate" {% if comment.user%}href="{% url 'blog:user_activity' comment.user.username %}"{% endif %}>{% if comment.user %}{{ comment.user.username }}{% else %}{{ comment.anonymous_user.name }}{% endif %}</a> commented on <a href="{% url 'blog:post' comment.post.slug %}#comment-{{ comment.id }}">{{ comment.post.title }}</a> on <em>{{ comment.created_at | date:"M d, Y" }}</em>:
+ <blockquote style="background: none; margin-top: 15px; padding: 0px 20px; margin-left: 20px;">{{ comment.body|safe }}</blockquote></p>
+ </li>
+{% endfor %}
+</ul>
diff --git a/templates/blog/partials/search/post_list.html b/templates/blog/partials/search/post_list.html
new file mode 100644
index 00000000..811c417e
--- /dev/null
+++ b/templates/blog/partials/search/post_list.html
@@ -0,0 +1,23 @@
+{% load tz %}
+{% load static %}
+{% for post in posts %}
+ {% comment %} This is the plain small version for search list {% endcomment %}
+ <h1 style="font-size: 16px; margin: 0 0 4px 0;">
+ <a style="color: #f4ebff;" href="{% url 'blog:post' post.slug %}">{{ post.title }}</a>
+ </h1>
+ <p>Posted by <a href="{% url 'blog:user_activity' post.author %}">{{ post.author.first_name }} {{ post.author.last_name }}</a> in <a href="{% url 'blog:categories' %}/{{ post.category.slug }}">{{ post.category }}</a> on {% localtime on %}{{ post.date | date:"M d, Y" }}{% endlocaltime %}</p>
+ <img style="width: 150px; height: auto; float: left; margin: 0 8px 8px 0;" src="{% url 'ignis:post_image' '150' post.id %}.gif">
+ <div style="margin: -4px 0 8px 0;">
+ {{ post.body|truncatewords:150|safe }}
+ </div>
+ <div style="clear: both; border-top: 1px dashed #fff;"></div>
+ <p><b>Tags:</b>
+ {% for tag in post.tags.all %}
+ <a class="tag" href="{% url 'blog:tag_posts' tag.slug %}">{{ tag.name }}</a>
+ {% endfor %}
+ </p>
+ <p>
+ <a href="{% url 'blog:post' post.slug %}">Read complete post...</a>
+ </p>
+ <br>
+{% endfor %} \ No newline at end of file
diff --git a/templates/blog/partials/search/user_list.html b/templates/blog/partials/search/user_list.html
new file mode 100644
index 00000000..3493508c
--- /dev/null
+++ b/templates/blog/partials/search/user_list.html
@@ -0,0 +1,13 @@
+{% load static %}
+{% for user in users %}
+<div class="user_info" style="border: 1px solid #ccc; padding: 10px; margin-bottom: 10px;">
+ <img src="{% static 'images/avatars/' %}{{ user.profile.avatar_url }}.gif" alt="Profile Picture" style="width: 50px; border-radius: 50%; float: left; margin-right: 10px; margin-top: 5px;">
+ <div>
+ <p><a href="{% url 'blog:user_activity' user.username %}">@{{ user.username }}</a> {% if user.first_name %}| <a href="{% url 'blog:user_activity' user.username %}">{{ user.first_name }}{% endif %} {% if user.last_name %}{{ user.last_name }}{% endif %}</a></p>
+ {% if user.profile.bio %}
+ <p><b>Bio:</b> {{ user.profile.bio }}</p>
+ {% endif %}
+ </div>
+ <div style="clear: both;"></div>
+</div>
+{% endfor %} \ No newline at end of file
diff --git a/templates/blog/search.html b/templates/blog/search.html
index a709ccb0..d5bf9812 100644
--- a/templates/blog/search.html
+++ b/templates/blog/search.html
@@ -14,7 +14,7 @@
<h2 class="mtsbitem">Sort By</h2>
<input type="radio" name="sort_by" value="relevance" {% if sort_by == 'relevance' %}checked{% endif %} style="margin: 5px 10px 5px 0px; vertical-align: middle;"/><label for="sort_by" style="vertical-align: middle;">Relevance</label><br>
<input type="radio" name="sort_by" value="date" {% if sort_by == 'date' %}checked{% endif %} style="margin: 5px 10px 5px 0px; vertical-align: middle;"/><label for="sort_by" style="vertical-align: middle;">Date</label><br>
- <input type="radio" name="sort_by" value="popularity" {% if sort_by == 'popularity' %}checked{% endif %} style="margin: 5px 10px 5px 0px; vertical-align: middle;"/><label for="sort_by" style="vertical-align: middle;">Popularity</label><br>
+ {% comment %} <input type="radio" name="sort_by" value="popularity" {% if sort_by == 'popularity' %}checked{% endif %} style="margin: 5px 10px 5px 0px; vertical-align: middle;"/><label for="sort_by" style="vertical-align: middle;">Popularity</label><br> {% endcomment %}
<h2 class="mtsbitem">Order</h2>
<input type="radio" name="order" value="ascending" {% if order == 'ascending' %}checked{% endif %} style="margin: 5px 10px 5px 0px; vertical-align: middle;"/><label for="order" style="vertical-align: middle;">Ascending</label><br>
<input type="radio" name="order" value="descending" {% if order == 'descending' %}checked{% endif %} style="margin: 5px 10px 5px 0px; vertical-align: middle;"/><label for="order" style="vertical-align: middle;">Descending</label><br>
@@ -29,9 +29,40 @@
</td>
<td id="search_results" style="width: 530px; vertical-align: top; padding-left: 20px;">
<h2>Search Results</h2>
- <p>Sorry, this feature is under construction, and will be available soon.</p>
- <p>In case, you were curious, your query returned {{ search_results|length }} results.</p>
+ <p style="margin-bottom: 20px;">Your search for "<strong>{{ request.GET.q }}</strong>" returned {{ search_results }} Result{% if search_results != 1 %}s{% endif %}.</p>
+
+ {% if 'posts' in search_in %}
+ <h2 style="background: #311b4f; margin: 0 0 10px 0; border: dotted 1px white; padding: 5px;">Posts</h2>
+ {% if posts|length != 0 %}
+ {% include 'blog/partials/search/post_list.html' %}
+ {% else %}
+ <p>No posts found.</p>
+ {% endif %}
+
+ {% endif %}
+
+ {% if 'users' in search_in %}
+ <h2 style="background: #311b4f; margin: 0 0 10px 0; border: dotted 1px white; padding: 5px;">Users</h2>
+ {% if users|length != 0 %}
+ {% include 'blog/partials/search/user_list.html' %}
+ {% else %}
+ <p>No users found.</p>
+ {% endif %}
+ {% endif %}
+
+ {% if 'comments' in search_in %}
+ <h2 style="background: #311b4f; margin: 0 0 10px 0; border: dotted 1px white; padding: 5px;">Comments</h2>
+ {% if comments|length != 0 %}
+ {% include 'blog/partials/search/comment_list.html' %}
+ {% else %}
+ <p>No comments found.</p>
+ {% endif %}
+ {% endif %}
+
</td>
</tr>
</table>
{% endblock %}
+{% block scripts %}
+{% include 'blog/partials/mathjax.html' %}
+{% endblock %} \ No newline at end of file