simplesitesearch 0.0.4__tar.gz → 0.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {simplesitesearch-0.0.4/simplesitesearch.egg-info → simplesitesearch-0.0.6}/PKG-INFO +11 -1
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/README.md +10 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/pyproject.toml +1 -1
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/setup.cfg +1 -1
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/setup.py +1 -1
- simplesitesearch-0.0.6/simplesitesearch/__init__.py +1 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch/templates/simplesitesearch/pagination.html +1 -1
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch/templates/simplesitesearch/search_results.html +19 -3
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch/utils.py +8 -2
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch/views.py +46 -3
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6/simplesitesearch.egg-info}/PKG-INFO +11 -1
- simplesitesearch-0.0.4/simplesitesearch/__init__.py +0 -1
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/LICENSE +0 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/MANIFEST.in +0 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch/cms_apps.py +0 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch/urls.py +0 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/SOURCES.txt +0 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/dependency_links.txt +0 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/not-zip-safe +0 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/requires.txt +0 -0
- {simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simplesitesearch
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: Reptile Simple Site Search django app
|
|
5
5
|
Home-page: https://github.com/FlavienLouis/simplesitesearch
|
|
6
6
|
Author: Reptile Tech
|
|
@@ -285,6 +285,16 @@ For support and questions, please open an issue on the [GitHub repository](https
|
|
|
285
285
|
|
|
286
286
|
## Changelog
|
|
287
287
|
|
|
288
|
+
### 0.0.6
|
|
289
|
+
- **Changed** search results: API hits normalized for templates (`display_title`, `snippet`, domain/type/language/tags/date metadata); highlighted title when available.
|
|
290
|
+
- **Changed** templates: `{% load static %}` instead of deprecated `staticfiles` (Django 4+).
|
|
291
|
+
|
|
292
|
+
### 0.0.5
|
|
293
|
+
- **Fixed** tag parsing: single tag string (e.g. `Hometag`) no longer sent as `H,o,m,e,t,a,g`; string is treated as one tag. API URL keeps commas unencoded so multiple tags parse correctly.
|
|
294
|
+
|
|
295
|
+
### 0.0.4
|
|
296
|
+
- SSL verification configurable via `SITE_SEARCH_VERIFY_SSL` (default `True`).
|
|
297
|
+
|
|
288
298
|
### 0.0.3
|
|
289
299
|
- Added `simplesitesearch.utils` QOL helpers: `get_search_results`, `get_search_api_url`, `build_search_query_string`, `parse_comma_separated_tags`, `normalize_search_term`, `safe_int`
|
|
290
300
|
- Tag filter: `tag` (or `tags`) query parameter forwarded to API as comma-separated `tags`; pagination links preserve tags
|
|
@@ -239,6 +239,16 @@ For support and questions, please open an issue on the [GitHub repository](https
|
|
|
239
239
|
|
|
240
240
|
## Changelog
|
|
241
241
|
|
|
242
|
+
### 0.0.6
|
|
243
|
+
- **Changed** search results: API hits normalized for templates (`display_title`, `snippet`, domain/type/language/tags/date metadata); highlighted title when available.
|
|
244
|
+
- **Changed** templates: `{% load static %}` instead of deprecated `staticfiles` (Django 4+).
|
|
245
|
+
|
|
246
|
+
### 0.0.5
|
|
247
|
+
- **Fixed** tag parsing: single tag string (e.g. `Hometag`) no longer sent as `H,o,m,e,t,a,g`; string is treated as one tag. API URL keeps commas unencoded so multiple tags parse correctly.
|
|
248
|
+
|
|
249
|
+
### 0.0.4
|
|
250
|
+
- SSL verification configurable via `SITE_SEARCH_VERIFY_SSL` (default `True`).
|
|
251
|
+
|
|
242
252
|
### 0.0.3
|
|
243
253
|
- Added `simplesitesearch.utils` QOL helpers: `get_search_results`, `get_search_api_url`, `build_search_query_string`, `parse_comma_separated_tags`, `normalize_search_term`, `safe_int`
|
|
244
254
|
- Tag filter: `tag` (or `tags`) query parameter forwarded to API as comma-separated `tags`; pagination links preserve tags
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.6"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{% extends "base.html" %}
|
|
2
|
-
{% load i18n
|
|
2
|
+
{% load i18n static cms_tags %}
|
|
3
3
|
|
|
4
4
|
{% block template_class %}template_search{% endblock %}
|
|
5
5
|
|
|
@@ -27,13 +27,29 @@
|
|
|
27
27
|
{% for result in results %}
|
|
28
28
|
<div class="search__content__result">
|
|
29
29
|
<div class="headings__third-container">
|
|
30
|
-
<a class="headings headings__third headings--blue" href="{{result.url}}">{{ result.
|
|
30
|
+
<a class="headings headings__third headings--blue" href="{{ result.url }}">{{ result.display_title|safe }}</a>
|
|
31
31
|
</div>
|
|
32
|
+
{% if result.snippet %}
|
|
32
33
|
<div class="text-container">
|
|
33
34
|
<div class="text text--graydark">
|
|
34
|
-
<p>{{result.
|
|
35
|
+
<p>{{ result.snippet|safe }}…</p>
|
|
35
36
|
</div>
|
|
36
37
|
</div>
|
|
38
|
+
{% endif %}
|
|
39
|
+
{% if result.domain or result.type or result.language or result.last_modified %}
|
|
40
|
+
<div class="text-container">
|
|
41
|
+
<div class="text text--graydark">
|
|
42
|
+
<p>{% if result.domain %}{{ result.domain }}{% endif %}{% if result.type %}{% if result.domain %} · {% endif %}{{ result.type }}{% endif %}{% if result.language %}{% if result.domain or result.type %} · {% endif %}{{ result.language }}{% endif %}{% if result.last_modified %}{% if result.domain or result.type or result.language %} · {% endif %}{{ result.last_modified|date:"SHORT_DATETIME_FORMAT" }}{% endif %}</p>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
{% endif %}
|
|
46
|
+
{% if result.tags %}
|
|
47
|
+
<div class="text-container">
|
|
48
|
+
<div class="text text--graydark">
|
|
49
|
+
<p>{% for t in result.tags %}{{ t }}{% if not forloop.last %}, {% endif %}{% endfor %}</p>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
{% endif %}
|
|
37
53
|
</div>
|
|
38
54
|
{% empty %}
|
|
39
55
|
<div class="search__content--empty">
|
|
@@ -35,11 +35,16 @@ def tags_to_query_value(tags):
|
|
|
35
35
|
Convert a list of tags to a comma-separated string for query params or API.
|
|
36
36
|
|
|
37
37
|
Args:
|
|
38
|
-
tags: Iterable of tag strings.
|
|
38
|
+
tags: Iterable of tag strings, or a single tag string (e.g. "Hometag").
|
|
39
|
+
A string is treated as one tag, not iterated by character.
|
|
39
40
|
|
|
40
41
|
Returns:
|
|
41
42
|
Comma-separated string, or None if tags is empty.
|
|
42
43
|
"""
|
|
44
|
+
if not tags:
|
|
45
|
+
return None
|
|
46
|
+
if isinstance(tags, str):
|
|
47
|
+
tags = [tags.strip()] if tags.strip() else []
|
|
43
48
|
if not tags:
|
|
44
49
|
return None
|
|
45
50
|
return ",".join(str(t).strip() for t in tags if str(t).strip())
|
|
@@ -128,7 +133,8 @@ def get_search_api_url(term, current_page, tags=None):
|
|
|
128
133
|
)
|
|
129
134
|
tag_value = tags_to_query_value(tags)
|
|
130
135
|
if tag_value:
|
|
131
|
-
|
|
136
|
+
# Keep commas unencoded so the API can split tags (e.g. tags=Home,tag)
|
|
137
|
+
url += "&tags=%s" % quote_plus(tag_value, safe=",")
|
|
132
138
|
return url
|
|
133
139
|
|
|
134
140
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from math import floor
|
|
2
2
|
|
|
3
|
+
from django.utils.dateparse import parse_datetime
|
|
3
4
|
from django.views.generic import TemplateView
|
|
4
5
|
|
|
5
6
|
from .utils import (
|
|
@@ -59,6 +60,46 @@ def get_total_pages(total_hits):
|
|
|
59
60
|
return pages_count
|
|
60
61
|
|
|
61
62
|
|
|
63
|
+
def _optional_datetime(value):
|
|
64
|
+
if not value or not isinstance(value, str):
|
|
65
|
+
return None
|
|
66
|
+
return parse_datetime(value)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def normalize_search_hit(hit):
|
|
70
|
+
"""
|
|
71
|
+
Reduce each API hit to fields useful for templates (omit bulky nested blobs).
|
|
72
|
+
"""
|
|
73
|
+
if not isinstance(hit, dict):
|
|
74
|
+
return hit
|
|
75
|
+
|
|
76
|
+
highlights = hit.get("highlights") or {}
|
|
77
|
+
title_highlight = None
|
|
78
|
+
title_snippets = highlights.get("title")
|
|
79
|
+
if title_snippets and isinstance(title_snippets, list) and title_snippets[0]:
|
|
80
|
+
title_highlight = title_snippets[0]
|
|
81
|
+
|
|
82
|
+
snippet = (
|
|
83
|
+
hit.get("highlight")
|
|
84
|
+
or hit.get("description")
|
|
85
|
+
or hit.get("content_preview")
|
|
86
|
+
or ""
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
modified_raw = hit.get("last_modified") or hit.get("indexed_at") or ""
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
"url": hit.get("url") or "",
|
|
93
|
+
"display_title": title_highlight or hit.get("title") or "",
|
|
94
|
+
"snippet": snippet,
|
|
95
|
+
"domain": hit.get("domain") or "",
|
|
96
|
+
"type": hit.get("type") or "",
|
|
97
|
+
"tags": hit.get("tags") if isinstance(hit.get("tags"), list) else [],
|
|
98
|
+
"language": hit.get("language") or "",
|
|
99
|
+
"last_modified": _optional_datetime(modified_raw),
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
62
103
|
def get_api_re_path(term, current_page, tags=None):
|
|
63
104
|
"""Build the search API URL (delegates to utils for consistency)."""
|
|
64
105
|
return get_search_api_url(term, current_page, tags=tags)
|
|
@@ -84,21 +125,23 @@ class SearchResult(TemplateView):
|
|
|
84
125
|
response_data = get_search_results(
|
|
85
126
|
term, current_page, tags=tags_list or None
|
|
86
127
|
)
|
|
87
|
-
|
|
128
|
+
total_hits = response_data.get("total_hits", 0)
|
|
129
|
+
pages_count = get_total_pages(total_hits)
|
|
88
130
|
prev_page_number, next_page_number = get_prev_next_page_number(pages_count, current_page)
|
|
89
131
|
prev_link, next_link = get_prev_next_links(
|
|
90
132
|
next_page_number, prev_page_number, term, tags=tags_list or None
|
|
91
133
|
)
|
|
92
134
|
page_links = get_page_links(pages_count, current_page, term, tags=tags_list or None)
|
|
93
135
|
|
|
136
|
+
raw_hits = response_data.get("hits") or []
|
|
94
137
|
context.update({
|
|
95
138
|
"pages_count": pages_count,
|
|
96
139
|
"current_page": current_page,
|
|
97
|
-
"results_count":
|
|
140
|
+
"results_count": total_hits,
|
|
98
141
|
"prev_link": prev_link,
|
|
99
142
|
"next_link": next_link,
|
|
100
143
|
"page_links": page_links,
|
|
101
|
-
"results":
|
|
144
|
+
"results": [normalize_search_hit(h) for h in raw_hits],
|
|
102
145
|
})
|
|
103
146
|
else:
|
|
104
147
|
context.update({"results": None})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simplesitesearch
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: Reptile Simple Site Search django app
|
|
5
5
|
Home-page: https://github.com/FlavienLouis/simplesitesearch
|
|
6
6
|
Author: Reptile Tech
|
|
@@ -285,6 +285,16 @@ For support and questions, please open an issue on the [GitHub repository](https
|
|
|
285
285
|
|
|
286
286
|
## Changelog
|
|
287
287
|
|
|
288
|
+
### 0.0.6
|
|
289
|
+
- **Changed** search results: API hits normalized for templates (`display_title`, `snippet`, domain/type/language/tags/date metadata); highlighted title when available.
|
|
290
|
+
- **Changed** templates: `{% load static %}` instead of deprecated `staticfiles` (Django 4+).
|
|
291
|
+
|
|
292
|
+
### 0.0.5
|
|
293
|
+
- **Fixed** tag parsing: single tag string (e.g. `Hometag`) no longer sent as `H,o,m,e,t,a,g`; string is treated as one tag. API URL keeps commas unencoded so multiple tags parse correctly.
|
|
294
|
+
|
|
295
|
+
### 0.0.4
|
|
296
|
+
- SSL verification configurable via `SITE_SEARCH_VERIFY_SSL` (default `True`).
|
|
297
|
+
|
|
288
298
|
### 0.0.3
|
|
289
299
|
- Added `simplesitesearch.utils` QOL helpers: `get_search_results`, `get_search_api_url`, `build_search_query_string`, `parse_comma_separated_tags`, `normalize_search_term`, `safe_int`
|
|
290
300
|
- Tag filter: `tag` (or `tags`) query parameter forwarded to API as comma-separated `tags`; pagination links preserve tags
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.4"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simplesitesearch-0.0.4 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|