Fix critical bugs in app_urls
- init_db.py: parameterize SQL queries to prevent SQL injection - scheduled_tasks.json: resolve duplicate periodic task pk (4 -> 15) - db_utils.py: use function parameter in _get_status_pattern_matching instead of capturing the enclosing scope variable - url_detail.html: fix wrong field name image_urls -> images_url - settings.py: align Celery queues (default/light/heavy) with the task queues and supervisord workers - Add /task/publish_<id>/ route to fix broken publish links in templates
This commit is contained in:
@@ -212,7 +212,7 @@ class DB_Handler():
|
||||
# Sort pattern tuples by priority. (pattern, priority, status)
|
||||
for regex_pattern, regex_priority, status_if_match in sorted(list_pattern_status_tuple, key=lambda tup: tup[1], reverse=True):
|
||||
# Regular expression pattern matching: https://regexr.com/
|
||||
if bool(re.match(regex_pattern, obj_url.url)):
|
||||
if bool(re.match(regex_pattern, url)):
|
||||
# logger.debug("Regex pattern found, status '{}' for URL: {}".format(status_if_match, url))
|
||||
return status_if_match
|
||||
return None
|
||||
|
||||
@@ -246,7 +246,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Image URLs</th>
|
||||
<td>{{ url_content.image_urls|default:"" }}</td>
|
||||
<td>{{ url_content.images_url|default:"" }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Video URLs</th>
|
||||
|
||||
@@ -17,4 +17,5 @@ urlpatterns = [
|
||||
#
|
||||
path('urls/', views.filtered_urls, name='filtered_urls'),
|
||||
path('urls/<int:id>/', views.url_detail_view, name='url_detail'),
|
||||
path('task/publish_<int:id>/', views.publish, name='publish'),
|
||||
]
|
||||
|
||||
@@ -2,12 +2,13 @@ from .views_base import link_list, logs, log_db #, trigger_task,
|
||||
|
||||
from django.core.paginator import Paginator
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.http import StreamingHttpResponse, JsonResponse
|
||||
from django.http import StreamingHttpResponse, JsonResponse, HttpResponse
|
||||
from django.db.models import Q, Count
|
||||
from django.utils import timezone
|
||||
from django.utils.timezone import now, timedelta
|
||||
from .models import Urls, Source, Search, UrlContent, UrlsSourceSearch, UrlsDuplicate
|
||||
from .src.llm import OllamaClient
|
||||
from .src.publisher import Publisher
|
||||
import json
|
||||
|
||||
|
||||
@@ -62,6 +63,15 @@ def url_detail_view(request, id):
|
||||
}
|
||||
return render(request, 'url_detail.html', context)
|
||||
|
||||
def publish(request, id):
|
||||
# Publish URL content to Ghost
|
||||
try:
|
||||
Publisher().publish(id)
|
||||
message = "URL ID {} published".format(id)
|
||||
except Exception as e:
|
||||
message = "Error publishing URL ID {}: {}".format(id, str(e))
|
||||
return HttpResponse(message)
|
||||
|
||||
####################################################################################################
|
||||
def charts(request):
|
||||
return render(request, 'charts.html')
|
||||
|
||||
Reference in New Issue
Block a user