simplesitesearch 0.0.5__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.
Files changed (21) hide show
  1. {simplesitesearch-0.0.5/simplesitesearch.egg-info → simplesitesearch-0.0.6}/PKG-INFO +5 -1
  2. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/README.md +4 -0
  3. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/pyproject.toml +1 -1
  4. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/setup.cfg +1 -1
  5. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/setup.py +1 -1
  6. simplesitesearch-0.0.6/simplesitesearch/__init__.py +1 -0
  7. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch/templates/simplesitesearch/pagination.html +1 -1
  8. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch/templates/simplesitesearch/search_results.html +19 -3
  9. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch/views.py +46 -3
  10. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6/simplesitesearch.egg-info}/PKG-INFO +5 -1
  11. simplesitesearch-0.0.5/simplesitesearch/__init__.py +0 -1
  12. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/LICENSE +0 -0
  13. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/MANIFEST.in +0 -0
  14. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch/cms_apps.py +0 -0
  15. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch/urls.py +0 -0
  16. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch/utils.py +0 -0
  17. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/SOURCES.txt +0 -0
  18. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/dependency_links.txt +0 -0
  19. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/not-zip-safe +0 -0
  20. {simplesitesearch-0.0.5 → simplesitesearch-0.0.6}/simplesitesearch.egg-info/requires.txt +0 -0
  21. {simplesitesearch-0.0.5 → 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.5
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,10 @@ 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
+
288
292
  ### 0.0.5
289
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.
290
294
 
@@ -239,6 +239,10 @@ 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
+
242
246
  ### 0.0.5
243
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.
244
248
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "simplesitesearch"
7
- version = "0.0.5"
7
+ version = "0.0.6"
8
8
  description = "Reptile Simple Site Search django app"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = simplesitesearch
3
- version = 0.0.4
3
+ version = 0.0.6
4
4
  author = Reptile Tech
5
5
  author_email = flouis@reptile.tech
6
6
  description = Reptile Simple Site Search django app
@@ -8,7 +8,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
8
8
 
9
9
  setup(
10
10
  name="simplesitesearch",
11
- version="0.0.5",
11
+ version="0.0.6",
12
12
  author="Reptile Tech",
13
13
  author_email="flouis@reptile.tech",
14
14
  description="Reptile Simple Site Search django app",
@@ -0,0 +1 @@
1
+ __version__ = "0.0.6"
@@ -1,4 +1,4 @@
1
- {% load i18n staticfiles cms_tags %}
1
+ {% load i18n static cms_tags %}
2
2
 
3
3
  <div class="search__pagination d-flex justify-content-between justify-sm-content-center align-items-center">
4
4
  <div class="search__pagination__nav search__pagination__nav--prev">
@@ -1,5 +1,5 @@
1
1
  {% extends "base.html" %}
2
- {% load i18n staticfiles cms_tags %}
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.title|safe }}</a>
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.highlight|safe}}...</p>
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">
@@ -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
- pages_count = get_total_pages(response_data["total_hits"])
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": response_data["total_hits"],
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": response_data["hits"],
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.5
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,10 @@ 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
+
288
292
  ### 0.0.5
289
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.
290
294
 
@@ -1 +0,0 @@
1
- __version__ = "0.0.5"