1
0
mirror of https://gitlab.com/brutaldon/brutaldon synced 2025-03-28 17:30:35 +01:00

Complete searching feature for brutaldon

This commit is contained in:
Jason McBrayer 2018-06-09 13:49:04 -04:00
parent 5e2b025042
commit cce0fe0186
5 changed files with 68 additions and 14 deletions

View File

@ -48,6 +48,18 @@ figure.media-left p.image a img
background-color: #FFF8DC; background-color: #FFF8DC;
} }
article.media .content img
{
max-height: 1.5rem;
max-width: 1.5rem;
}
h2.subtitle
{
margin-top: 2rem;
margin-bottom: 1rem;
}
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
.media { .media {
display: block; display: block;

View File

@ -35,6 +35,9 @@
<a class="navbar-item" href="{% url "note" %}">Notifications</a> <a class="navbar-item" href="{% url "note" %}">Notifications</a>
<a class="navbar-item" href="{% url "local" %}">Local</a> <a class="navbar-item" href="{% url "local" %}">Local</a>
<a class="navbar-item" href="{% url "fed" %}">Federated</a> <a class="navbar-item" href="{% url "fed" %}">Federated</a>
<a class="navbar-item" href="{% url "search" %}">
<span class="fa fa-search"><span class="is-hidden">Search</span></span>
</a>
</div> </div>
<div class="navbar-end" > <div class="navbar-end" >
<a class="navbar-item" href="{% url "settings" %}">Settings</a> <a class="navbar-item" href="{% url "settings" %}">Settings</a>

View File

@ -15,7 +15,6 @@
</div> </div>
<form method="get" action="{% url "search_results" %}"> <form method="get" action="{% url "search_results" %}">
{% csrf_token %}
<div class="field"> <div class="field">
<label class="label">{{ form.instance.label }}</label> <label class="label">{{ form.instance.label }}</label>
<div class="control has-icons-left"> <div class="control has-icons-left">
@ -27,8 +26,7 @@
</div> </div>
<div class="field"> <div class="field">
<input type="submit" name="search" <input type="submit" value="Search" class="button is-primary" >
value="Search" class="button is-primary" >
</div> </div>
</form> </form>

View File

@ -1,30 +1,70 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load humanize %} {% load humanize %}
{% load taglinks %} {% load taglinks %}
{% load sanitizer %}
{% block title %} {% block title %}
Brutaldon - search results Brutaldon - search results
{% endblock %} {% endblock %}
{% comment %} {% comment %}
mastodon.search("<query>") mastodon.search("<query>")
# Returns the following dictionary # Returns the following dictionary
{ {
'accounts': # List of account dicts resulting from the query 'accounts': # List of account dicts resulting from the query
'hashtags': # List of hashtag dicts resulting from the query 'hashtags': # List of hashtag dicts resulting from the query
'statuses': # List of toot dicts resulting from the query 'statuses': # List of toot dicts resulting from the query
} }
{% endcomment %} {% endcomment %}
{% block content %} {% block content %}
<h1 class="title">Search results</h1> <h1 class="title">Search results</h1>
<div class="container">
<h2 class="subtitle">Users</h2>
{% for user in results.accounts %}
<article class="media">
<figure class="media-left">
<p class="image is-64x64">
<a href="{% url "user" user.acct %}">
<img src="{{ user.avatar }}"
alt="">
</a>
</p>
</figure>
<div class="media-content">
<div class="content">
<p>
<strong>{{ user.display_name }}</strong>
<small>
<a href="{% url "user" user.acct %}">
@{{ user.acct }}
</a>
</small>
</p>
{{ user.note | relink_toot | strip_html | safe }}
<p>
</p>
<h2 class="subtitle">Users</h2> </div>
</div>
</article>
<h2 class="subtitle">Tags</h2> {% endfor %}
<h2 class="subtitle">Toots</h2>
<h2 class="subtitle">Tags</h2>
<ul>
{% for tag in results.hashtags %}
<li><a href="{% url 'tag' tag %}">#{{ tag }}</a></li>
{% endfor %}
</ul>
<h2 class="subtitle">Toots</h2>
{% for toot in results.statuses %}
{% include "main/toot_partial.html" with toot=toot reblog=False %}
{% endfor %}
</div>
{% endblock %} {% endblock %}

View File

@ -7,6 +7,7 @@ from brutaldon.forms import LoginForm, OAuthLoginForm, SettingsForm, PostForm
from brutaldon.models import Client, Account from brutaldon.models import Client, Account
from mastodon import Mastodon from mastodon import Mastodon
from urllib import parse from urllib import parse
from pdb import set_trace
class NotLoggedInException(Exception): class NotLoggedInException(Exception):
pass pass