forked from rDrama/rDrama
Merge branch 'frost' of https://github.com/Aevann1/rDrama into frost
commit
f07445df31
|
@ -3637,7 +3637,7 @@ small, .small {
|
|||
color: var(--muted);
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
z-index: 3;
|
||||
z-index: 100;
|
||||
}
|
||||
.dropdown-actions .fa, .dropdown-actions .fas, .dropdown-actions .far {
|
||||
font-size: 12px;
|
||||
|
@ -6239,4 +6239,15 @@ div.custom-control:last-of-type {
|
|||
div.custom-control:last-of-type {
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-menu button.searchparam {
|
||||
color: var(--gray-100);
|
||||
text-decoration: none;
|
||||
text-transform: none;
|
||||
background-color: transparent;
|
||||
border: 2px solid gray;
|
||||
border-radius: 3px;
|
||||
padding: 6px;
|
||||
width: 150px;
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
|
@ -0,0 +1,8 @@
|
|||
function addParam(e) {
|
||||
e = e || window.event;
|
||||
let paramExample = e.target.innerText;
|
||||
let param = paramExample.split(":")[0];
|
||||
let searchInput = document.querySelector("#large_searchbar input");
|
||||
searchInput.value = `${searchInput.value} ${param}:`;
|
||||
searchInput.focus();
|
||||
}
|
|
@ -626,9 +626,6 @@ class User(Base):
|
|||
|
||||
if self.is_cakeday:
|
||||
return 'cakeday-1'
|
||||
elif SITE_NAME == 'rDrama': # temporary branch for flowercrown event
|
||||
flowercrowns = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15']
|
||||
return 'flowercrown-' + random.choice(flowercrowns)
|
||||
return ''
|
||||
|
||||
@property
|
||||
|
|
|
@ -17,6 +17,8 @@ valid_params = [
|
|||
"post",
|
||||
"before",
|
||||
"after",
|
||||
"title",
|
||||
"exact",
|
||||
search_operator_hole,
|
||||
]
|
||||
|
||||
|
@ -30,6 +32,7 @@ def searchparse(text):
|
|||
|
||||
text = text.strip()
|
||||
if text:
|
||||
criteria['full_text'] = text
|
||||
criteria['q'] = []
|
||||
for m in search_token_regex.finditer(text):
|
||||
token = m[1] if m[1] else m[2]
|
||||
|
@ -88,8 +91,19 @@ def searchposts(v):
|
|||
)
|
||||
else: posts = posts.filter(Submission.author_id == author.id)
|
||||
|
||||
if 'q' in criteria:
|
||||
words = [or_(Submission.title.ilike('%'+x+'%'), Submission.body.ilike('%'+x+'%')) \
|
||||
if 'exact' in criteria and 'full_text' in criteria:
|
||||
regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries"
|
||||
if 'title' in criteria:
|
||||
words = [Submission.title.regexp_match(regex_str)]
|
||||
else:
|
||||
words = [or_(Submission.title.regexp_match(regex_str), Submission.body.regexp_match(regex_str))]
|
||||
posts = posts.filter(*words)
|
||||
elif 'q' in criteria:
|
||||
if('title' in criteria):
|
||||
words = [or_(Submission.title.ilike('%'+x+'%')) \
|
||||
for x in criteria['q']]
|
||||
else:
|
||||
words = [or_(Submission.title.ilike('%'+x+'%'), Submission.body.ilike('%'+x+'%')) \
|
||||
for x in criteria['q']]
|
||||
posts = posts.filter(*words)
|
||||
|
||||
|
@ -196,8 +210,13 @@ def searchcomments(v):
|
|||
|
||||
else: comments = comments.filter(Comment.author_id == author.id)
|
||||
|
||||
if 'q' in criteria:
|
||||
words = [Comment.body.ilike('%'+x+'%') for x in criteria['q']]
|
||||
if 'exact' in criteria and 'full_text' in criteria:
|
||||
regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries"
|
||||
words = [Comment.body.regexp_match(regex_str)]
|
||||
comments = comments.filter(*words)
|
||||
elif 'q' in criteria:
|
||||
words = [or_(Comment.body.ilike('%'+x+'%')) \
|
||||
for x in criteria['q']]
|
||||
comments = comments.filter(*words)
|
||||
|
||||
if 'over18' in criteria: comments = comments.filter(Comment.over_18 == True)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block PseudoSubmitForm %}
|
||||
<form class="form-inline search flex-nowrap mx-0 mx-lg-auto mt-1" action="/search/{% if '/posts' in request.path %}posts{% elif '/comments' in request.path %}comments{% else %}users{% endif %}" method="get">
|
||||
<form id="large_searchbar" class="form-inline search flex-nowrap mx-0 mx-lg-auto mt-1" action="/search/{% if '/posts' in request.path %}posts{% elif '/comments' in request.path %}comments{% else %}users{% endif %}" method="get">
|
||||
<input autocomplete="off" class="form-control w-100" type="search" placeholder="Search" aria-label="Search" name="q" value="{{query}}">
|
||||
<span class="input-group-append">
|
||||
<span class="input-group-text border-0 bg-transparent" style="margin-left: -2.5rem;">
|
||||
|
@ -37,19 +37,53 @@
|
|||
<div class="card-body pb-2">
|
||||
<div class="pl-md-3">
|
||||
{% if not request.path.startswith('/search/users') %}
|
||||
<strong>Advanced search parameters (with examples)</strong>
|
||||
<ul class="mt-2">
|
||||
<li class="mb-1">author:quadnarca</li>
|
||||
<li class="mb-1">domain:reddit.com</li>
|
||||
<li class="mb-1">over18:true</li>
|
||||
<li class="mb-1">{{HOLE_NAME}}:music</li>
|
||||
<li class="mb-1">before:2022-12-30</li>
|
||||
<li class="mb-1">after:2022-12-30</li>
|
||||
{% if request.path.startswith('/search/comments') %}
|
||||
<li class="mb-1">post:504</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div class="dropdown dropdown-actions">
|
||||
<button class="btn btn-secondary dropdown-toggle" role="button" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><strong>Advanced search parameters (with examples)</strong></button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center;">Author:</div>
|
||||
<button onClick="addParam()" class="searchparam mb-1">author:quadnarca</button>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center;">Domain:</div>
|
||||
<button onClick="addParam()" class="searchparam mb-1">domain:reddit.com</button>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center;">NSFW:</div>
|
||||
<button onClick="addParam()" class="searchparam mb-1">over18:true</button>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center;">Hole:</div>
|
||||
<button onClick="addParam()" class="searchparam mb-1">{{HOLE_NAME}}:music</button>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center;">Before Date:</div>
|
||||
<button onClick="addParam()" class="searchparam mb-1">before:2022-12-30</button>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center;">After Date:</div>
|
||||
<button onClick="addParam()" class="searchparam mb-1">after:2022-12-30</button>
|
||||
</div>
|
||||
{% if request.path.startswith('/search/comments') %}
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center;">Post ID:</div>
|
||||
<button onClick="addParam()" class="searchparam mb-1">post:504</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if request.path.startswith('/search/posts') %}
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center;">Post Title Only:</div>
|
||||
<button onClick="addParam()" class="searchparam mb-1">title:true</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div>
|
||||
<div style="display: inline-block; width: 150px; text-align: center;">Exact Match Only:</div>
|
||||
<button onClick="addParam()" class="searchparam mb-1">exact:true</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<script src="{{asset('js/search.js')}}"></script>
|
||||
{% endif %}
|
||||
<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>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{%-
|
||||
set CACHE_VER = {
|
||||
'css/main.css': 480,
|
||||
'css/main.css': 481,
|
||||
'css/catalog.css': 2,
|
||||
|
||||
'css/4chan.css': 61,
|
||||
|
@ -25,6 +25,7 @@ set CACHE_VER = {
|
|||
'js/formatting.js': 240,
|
||||
'js/lottery.js': 256,
|
||||
'js/marked.js': 283,
|
||||
'js/search.js': 200,
|
||||
'js/submit.js': 270,
|
||||
'js/userpage.js': 244,
|
||||
'js/userpage_v.js': 245,
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
bind = '0.0.0.0:5000'
|
||||
|
||||
workers = 9
|
||||
worker_class = 'gevent'
|
||||
|
||||
max_requests = 30000
|
||||
max_requests_jitter = 30000
|
||||
|
||||
reload = True
|
||||
#print_config = True
|
||||
|
||||
def worker_abort(worker):
|
||||
import os
|
||||
worker.log.info("Worker %s received SIGABRT." % worker.pid)
|
||||
os.abort()
|
||||
|
Loading…
Reference in New Issue