Skip to content

Commit

Permalink
open source
Browse files Browse the repository at this point in the history
  • Loading branch information
daisycamber committed Jan 29, 2025
1 parent 5d0f1ad commit 2058ab0
Show file tree
Hide file tree
Showing 12 changed files with 1,015 additions and 281 deletions.
721 changes: 721 additions & 0 deletions backup.log

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backup_date.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Wed Jan 29 12:12:59 PM PST 2025
Wed Jan 29 02:20:35 PM PST 2025
2 changes: 1 addition & 1 deletion backup_init_date.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Wed Jan 29 12:00:01 PM PST 2025
Wed Jan 29 02:20:17 PM PST 2025
2 changes: 1 addition & 1 deletion feed/nude.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os, uuid
from django.conf import settings

FAST_SCALE = 0.2
FAST_SCALE = 0.1

def get_nude_fast(image_path):
from PIL import Image
Expand Down
1 change: 1 addition & 0 deletions feed/templates/feed/profile_grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<h1>Search</h1>
<p>{{ 'Your search'|etrans }}, "{{ request.GET.q }}", {% blocktrans %}returned {{ count|nts }} results.{% endblocktrans %}</p>
<a class="btn btn-sm btn-outline-info" href="{{ request.path }}?q={{ query }}" title="{{ 'Standard view'|etrans }}">{{ 'Standard'|etrans }}</a>
{% include 'language.html' %}
{% include 'search.html' %}
<div class="gcse-search"></div>
{% endif %}
Expand Down
Binary file modified feed/templatetags/__pycache__/app_filters.cpython-312.pyc
Binary file not shown.
17 changes: 12 additions & 5 deletions feed/templatetags/app_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,18 +459,25 @@ def highlightsearchquery(text):
q = request.GET['q']
from django.conf import settings
from translate.translate import translate
oq = q
q = translate(request, q, target=settings.DEFAULT_LANG)
from misc.sitemap import languages
threads = [None] * len(languages)
results = [None] * len(languages)
threads = [None] * (len(languages) + 1)
results = [None] * (len(languages) + 1)
thread_count = 0
def highlight_lang(q, lang, text, results, count):
def highlight_lang(q, lang, text, results, count, src):
from translate.translate import translate
res = highlight_query_raw(translate(None, q, target=lang), text)
from django.conf import settings
res = highlight_query_raw(translate(None, q, target=lang, src=src), text)
results[count] = res
import threading
src = settings.DEFAULT_LANG
threads[thread_count] = threading.Thread(target=highlight_lang, args=(q, src, text, results, thread_count, src))
threads[thread_count].start()
thread_count += 1
src = request.LANGUAGE_CODE if request and not request.GET.get('lang', None) else request.GET.get('lang', None) if request.GET.get('lang', None) else settings.DEFAULT_LANG
for lang in languages:
threads[thread_count] = threading.Thread(target=highlight_lang, args=(q, lang, text, results, thread_count, ))
threads[thread_count] = threading.Thread(target=highlight_lang, args=(oq, lang, text, results, thread_count, src))
threads[thread_count].start()
thread_count += 1
for i in range(len(threads)):
Expand Down
Binary file modified misc/__pycache__/views.cpython-312.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions misc/templates/misc/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ <h1>{{ 'Search'|etrans }}</h1>
{% if request.GET.q %}
<p>{% blocktrans %}Your search, "{{ request.GET.q }}", returned {{ count|nts }} results.{% endblocktrans %}</p>
<a class="btn btn-sm btn-outline-info" title="Grid view" href="{{ request.path }}?grid=true&{% get_qs %}">Grid</a>
{% include 'language.html' %}
<hr style="background-color: red;">
{% for post in posts %}
{% include 'feed/_post.html' %}
Expand Down
29 changes: 17 additions & 12 deletions misc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ def get_posts_for_query(request, qs):
pos = []
for post in posts:
count = 0
matches = regex.findall(SEARCH_REGEX.format(qs.lower()), post.content.lower(), flags=regex.IGNORECASE | regex.BESTMATCH)
matches = regex.findall(SEARCH_REGEX.format(qs.lower()), post.content.lower(), flags=regex.IGNORECASE)
count = count + len(matches) * len(qsplit)
for q in qsplit:
matches = regex.findall(SEARCH_REGEX.format(q.lower()), post.content.lower(), flags=regex.IGNORECASE | regex.BESTMATCH)
matches = regex.findall(SEARCH_REGEX.format(q.lower()), post.content.lower(), flags=regex.IGNORECASE) # | regex.BESTMATCH)
for match in matches:
if not match in ESCAPED_QUERIES:
count = count + 1
Expand Down Expand Up @@ -162,18 +162,20 @@ def get_posts_for_multilingual_query(request, qs):
from misc.sitemap import languages
posts = []
count = 0
results = [None] * len(languages)
results = [None] * (len(languages) + 1)
last_threads = []
threads = [None] * len(languages)
threads = [None] * (len(languages) + 1)
thread_count = 0
def get_posts_for_query_lang(qs, lang, results, res_count):
def get_posts_for_query_lang(qs, lang, results, res_count, src):
pos = []
from translate.translate import translate
from feed.models import Post
import regex
from misc.regex import SEARCH_REGEX
from misc.regex import ESCAPED_QUERIES
qs = translate(None, qs, target=lang)
from django.conf import settings
if src != lang:
qs = translate(None, qs, target=lang, src=settings.DEFAULT_LANG if not src else src)
qsplit = qs.split(' ')
from django.utils import timezone
now = timezone.now()
Expand All @@ -196,14 +198,17 @@ def get_posts_for_query_lang(qs, lang, results, res_count):
if count > 0:
pos = pos + [(post.id, count)]
results[res_count] = pos
lang = request.GET.get('lang') if request.GET.get('lang', None) else request.LANGUAGE_CODE if request else settings.DEFAULT_LANG
if lang == 'en':
spell = Speller()
qs = spell(qs)
oqs = qs
qs = translate(request, qs, target=settings.DEFAULT_LANG)
print('QS is ' + qs)
print('OQS is ' + oqs)
import threading
src = request.LANGUAGE_CODE if request and not request.GET.get('lang', None) else request.GET.get('lang', None) if request.GET.get('lang', None) else settings.DEFAULT_LANG
threads[thread_count] = threading.Thread(target=get_posts_for_query_lang, args=(qs, settings.DEFAULT_LANG, results, thread_count, settings.DEFAULT_LANG))
threads[thread_count].start()
thread_count = thread_count + 1
for lang in languages:
import threading
threads[thread_count] = threading.Thread(target=get_posts_for_query_lang, args=(qs, lang, results, thread_count,))
threads[thread_count] = threading.Thread(target=get_posts_for_query_lang, args=(oqs, lang, results, thread_count, src))
threads[thread_count].start()
thread_count = thread_count + 1
for i in range(len(threads)):
Expand Down
Loading

0 comments on commit 2058ab0

Please sign in to comment.