Add 'hole' search operator.
parent
70c87140a3
commit
79ced3816c
|
@ -4,11 +4,11 @@ from sqlalchemy import *
|
|||
from flask import *
|
||||
from files.__main__ import app
|
||||
|
||||
|
||||
valid_params=[
|
||||
valid_params = [
|
||||
'author',
|
||||
'domain',
|
||||
'over18'
|
||||
'over18',
|
||||
'hole',
|
||||
]
|
||||
|
||||
def searchparse(text):
|
||||
|
@ -116,6 +116,8 @@ def searchposts(v):
|
|||
)
|
||||
)
|
||||
|
||||
if 'hole' in criteria:
|
||||
posts = posts.filter(Submission.sub == criteria['hole'])
|
||||
|
||||
if t:
|
||||
now = int(time.time())
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
{%- set search_placeholder = "Search" -%}
|
||||
{%- if sub -%}
|
||||
{%- set search_placeholder = "Search (try 'hole:" ~ sub.name ~ "')" -%}
|
||||
{%- endif -%}
|
||||
|
||||
<nav class=" shadow-md fixed-top">
|
||||
<style>
|
||||
|
@ -53,7 +57,7 @@
|
|||
|
||||
<div class="flex-grow-1 d-fl d-none d-md-block {% if not v %}pad{% endif %}">
|
||||
<form class="form-inline search flex-nowrap mx-0 mx-lg-auto" {% if err %}style="margin-right:40rem!important"{% endif %} action="{% if request.path.startswith('/search') %}{{request.path}}{% else %}/search/posts/{% endif %}" method="get">
|
||||
<input autocomplete="off" class="form-control w-100" type="search" placeholder="Search" aria-label="Search" name="q" value="{{request.values.get('q', '')}}">
|
||||
<input autocomplete="off" class="form-control w-100" type="search" placeholder="{{search_placeholder}}" aria-label="Search" name="q" value="{{request.values.get('q', '')}}">
|
||||
<span class="input-group-append">
|
||||
<span class="input-group-text border-0 bg-transparent" style="margin-left: -2.5rem;">
|
||||
<i class="fa fa-search" aria-hidden="true"></i>
|
||||
|
@ -227,7 +231,7 @@
|
|||
<ul style="overflow:auto" class="navbar-nav ml-auto d-flex d-md-none mt-3">
|
||||
<li class="nav-item pb-3">
|
||||
<form id="searchform" class="form-inline search flex-nowrap mx-0 mx-lg-auto" action="/search/posts/" method="get">
|
||||
<input autocomplete="off" class="form-control form-control-sm w-100" type="search" placeholder="Search" aria-label="Search" name="q">
|
||||
<input autocomplete="off" class="form-control form-control-sm w-100" type="search" placeholder="{{search_placeholder}}" aria-label="Search" name="q">
|
||||
<span class="input-group-append">
|
||||
<span class="input-group-text border-0 bg-transparent" style="margin-left: -2.5rem"onclick="document.getElementById('searchform').submit()">
|
||||
<i class="fa fa-search" aria-hidden="true"></i>
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<div class="pl-md-3">
|
||||
<div class="text-muted text-small mb-1">Advanced search parameters (with examples): "author:quadnarca", "domain:reddit.com", "over18:true"<div>
|
||||
<div class="text-muted text-small mb-1">Advanced search parameters (with examples): "author:quadnarca", "domain:reddit.com", "over18:true", "hole:music"<div>
|
||||
<br>
|
||||
<div class="text-muted text-small mb-1">Showing {% block listinglength %}{{listing | length}}{% endblock %} of {{total}} result{{'s' if total != 1 else ''}} for</div>
|
||||
<h1 class="h4 mb-0">{{query}}</h1>
|
||||
|
|
Loading…
Reference in New Issue