simplesitesearch 0.0.1__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.1/LICENSE +23 -0
- simplesitesearch-0.0.1/MANIFEST.in +9 -0
- simplesitesearch-0.0.1/PKG-INFO +256 -0
- simplesitesearch-0.0.1/README.md +210 -0
- simplesitesearch-0.0.1/pyproject.toml +61 -0
- simplesitesearch-0.0.1/setup.cfg +62 -0
- simplesitesearch-0.0.1/setup.py +55 -0
- simplesitesearch-0.0.1/simplesitesearch/__init__.py +1 -0
- simplesitesearch-0.0.1/simplesitesearch/cms_apps.py +13 -0
- simplesitesearch-0.0.1/simplesitesearch/templates/simplesitesearch/pagination.html +43 -0
- simplesitesearch-0.0.1/simplesitesearch/templates/simplesitesearch/search_results.html +55 -0
- simplesitesearch-0.0.1/simplesitesearch/urls.py +7 -0
- simplesitesearch-0.0.1/simplesitesearch/views.py +151 -0
- simplesitesearch-0.0.1/simplesitesearch.egg-info/PKG-INFO +256 -0
- simplesitesearch-0.0.1/simplesitesearch.egg-info/SOURCES.txt +18 -0
- simplesitesearch-0.0.1/simplesitesearch.egg-info/dependency_links.txt +1 -0
- simplesitesearch-0.0.1/simplesitesearch.egg-info/not-zip-safe +1 -0
- simplesitesearch-0.0.1/simplesitesearch.egg-info/requires.txt +3 -0
- simplesitesearch-0.0.1/simplesitesearch.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Simple Site Search
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: simplesitesearch
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Reptile Simple Site Search django app
|
|
5
|
+
Home-page: https://github.com/reptiletech/simplesitesearch
|
|
6
|
+
Author: Reptile Tech
|
|
7
|
+
Author-email: Reptile Tech <flouis@reptile.tech>
|
|
8
|
+
Maintainer-email: Reptile Tech <flouis@reptile.tech>
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Homepage, https://github.com/reptiletech/simplesitesearch
|
|
11
|
+
Project-URL: Documentation, https://github.com/reptiletech/simplesitesearch#readme
|
|
12
|
+
Project-URL: Repository, https://github.com/reptiletech/simplesitesearch.git
|
|
13
|
+
Project-URL: Bug Tracker, https://github.com/reptiletech/simplesitesearch/issues
|
|
14
|
+
Keywords: django,search,cms,django-cms
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Framework :: Django
|
|
28
|
+
Classifier: Framework :: Django :: 2.2
|
|
29
|
+
Classifier: Framework :: Django :: 3.2
|
|
30
|
+
Classifier: Framework :: Django :: 4.0
|
|
31
|
+
Classifier: Framework :: Django :: 4.1
|
|
32
|
+
Classifier: Framework :: Django :: 4.2
|
|
33
|
+
Classifier: Framework :: Django :: 5.0
|
|
34
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
35
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
36
|
+
Requires-Python: >=3.6
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
License-File: LICENSE
|
|
39
|
+
Requires-Dist: Django>=2.2
|
|
40
|
+
Requires-Dist: django-cms>=3.2
|
|
41
|
+
Requires-Dist: requests>=2.22.0
|
|
42
|
+
Dynamic: author
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
Dynamic: requires-python
|
|
46
|
+
|
|
47
|
+
# Simple Site Search
|
|
48
|
+
|
|
49
|
+
A simple Django app for site search functionality with Django CMS integration. This package provides a clean, easy-to-use search interface that can be integrated into Django CMS projects.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
- **Django CMS Integration**: Seamlessly integrates with Django CMS as an apphook
|
|
55
|
+
- **Pagination Support**: Built-in pagination for search results
|
|
56
|
+
- **Multi-language Support**: Supports internationalization with Django's i18n framework
|
|
57
|
+
- **Customizable Templates**: Easy to customize search result templates
|
|
58
|
+
- **API Integration**: Connects to external search APIs (like AddSearch)
|
|
59
|
+
- **Responsive Design**: Bootstrap-compatible templates
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
Install the package using pip:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install simplesitesearch
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
### 1. Add to INSTALLED_APPS
|
|
72
|
+
|
|
73
|
+
Add `simplesitesearch` to your Django project's `INSTALLED_APPS`:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
INSTALLED_APPS = [
|
|
77
|
+
# ... other apps
|
|
78
|
+
'simplesitesearch',
|
|
79
|
+
# ... other apps
|
|
80
|
+
]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. Required Settings
|
|
84
|
+
|
|
85
|
+
Add the following settings to your Django settings file:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
# Search API Configuration
|
|
89
|
+
SITE_SEARCH_API_BASE_URL = "https://search.rt5.ca/reptile_search/api/search/"
|
|
90
|
+
SITE_SEARCH_SITE_KEY = "your-site-key-here"
|
|
91
|
+
SITE_SEARCH_API_KEY = "your-api-key-here" # Optional, if required by your API
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 3. URL Configuration
|
|
95
|
+
|
|
96
|
+
Include the app's URLs in your main `urls.py`:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from django.urls import path, include
|
|
100
|
+
|
|
101
|
+
urlpatterns = [
|
|
102
|
+
# ... other URL patterns
|
|
103
|
+
path('search/', include('simplesitesearch.urls')),
|
|
104
|
+
# ... other URL patterns
|
|
105
|
+
]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Django CMS Integration
|
|
109
|
+
|
|
110
|
+
### 1. Create a Search Page
|
|
111
|
+
|
|
112
|
+
1. Log into your Django CMS admin
|
|
113
|
+
2. Go to **Django CMS** > **Pages**
|
|
114
|
+
3. Create a new page named "Search"
|
|
115
|
+
4. Translate the title and slug in all languages
|
|
116
|
+
5. Save and continue editing
|
|
117
|
+
|
|
118
|
+
### 2. Configure the Page
|
|
119
|
+
|
|
120
|
+
1. Go to **Advanced settings** of the search page
|
|
121
|
+
2. Set **APPLICATION** to "Site Search"
|
|
122
|
+
3. Set the **Application ID** to `'site_search'` (this is the default value)
|
|
123
|
+
4. Save the page
|
|
124
|
+
5. Remove the page from the menu (uncheck "menu" in the table)
|
|
125
|
+
6. Publish the page in all languages
|
|
126
|
+
|
|
127
|
+
### 3. Access the Search
|
|
128
|
+
|
|
129
|
+
Your search functionality will be available at the URL you configured for the search page.
|
|
130
|
+
|
|
131
|
+
## Usage
|
|
132
|
+
|
|
133
|
+
### Basic Search
|
|
134
|
+
|
|
135
|
+
The search form accepts a `q` parameter for the search term:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
/search/?q=your+search+term
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Pagination
|
|
142
|
+
|
|
143
|
+
The search results support pagination with a `page` parameter:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
/search/?q=your+search+term&page=2
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Honeypot Protection
|
|
150
|
+
|
|
151
|
+
The search includes basic honeypot protection. If a `message` parameter is present, the search will not execute.
|
|
152
|
+
|
|
153
|
+
## Customization
|
|
154
|
+
|
|
155
|
+
### Templates
|
|
156
|
+
|
|
157
|
+
The package includes two main templates:
|
|
158
|
+
|
|
159
|
+
- `simplesitesearch/search_results.html` - Main search results template
|
|
160
|
+
- `simplesitesearch/pagination.html` - Pagination template
|
|
161
|
+
|
|
162
|
+
#### Template Customization
|
|
163
|
+
|
|
164
|
+
You can override these templates in your project by creating templates with the same names in your template directory. The templates are designed to be easily customizable:
|
|
165
|
+
|
|
166
|
+
**Template Include Paths:**
|
|
167
|
+
- `simplesitesearch/search_results.html` - Main search results page
|
|
168
|
+
- `simplesitesearch/pagination.html` - Pagination component (included in search_results.html)
|
|
169
|
+
|
|
170
|
+
**To customize templates:**
|
|
171
|
+
1. Create a `templates/simplesitesearch/` directory in your Django project
|
|
172
|
+
2. Copy the template files from the package and modify them as needed
|
|
173
|
+
3. Your custom templates will override the package defaults
|
|
174
|
+
|
|
175
|
+
**Example template structure:**
|
|
176
|
+
```
|
|
177
|
+
your_project/
|
|
178
|
+
├── templates/
|
|
179
|
+
│ └── simplesitesearch/
|
|
180
|
+
│ ├── search_results.html # Your custom search results template
|
|
181
|
+
│ └── pagination.html # Your custom pagination template
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Styling
|
|
185
|
+
|
|
186
|
+
The templates use Bootstrap classes and can be easily customized with CSS. The main CSS classes used are:
|
|
187
|
+
|
|
188
|
+
- `.pagination` - Pagination container
|
|
189
|
+
- `.search_query` - Search query display
|
|
190
|
+
- `.search_results` - Results count display
|
|
191
|
+
- `.wrapper_single_result` - Individual result container
|
|
192
|
+
|
|
193
|
+
## API Response Format
|
|
194
|
+
|
|
195
|
+
The search expects the API to return JSON in the following format:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"total_hits": 42,
|
|
200
|
+
"hits": [
|
|
201
|
+
{
|
|
202
|
+
"title": "Page Title",
|
|
203
|
+
"url": "https://example.com/page/",
|
|
204
|
+
"highlight": "Search term highlighted content..."
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Requirements
|
|
211
|
+
|
|
212
|
+
- Python 3.6+
|
|
213
|
+
- Django 2.2+
|
|
214
|
+
- django-cms 3.2+
|
|
215
|
+
- requests 2.22.0+
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
### Local Development
|
|
220
|
+
|
|
221
|
+
1. Clone the repository
|
|
222
|
+
2. Install in development mode:
|
|
223
|
+
```bash
|
|
224
|
+
pip install -e .
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Testing
|
|
228
|
+
|
|
229
|
+
Run the tests with:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
python manage.py test simplesitesearch
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
238
|
+
|
|
239
|
+
## Support
|
|
240
|
+
|
|
241
|
+
For support and questions, please open an issue on the [GitHub repository](https://github.com/yourusername/simplesitesearch/issues).
|
|
242
|
+
|
|
243
|
+
## Changelog
|
|
244
|
+
|
|
245
|
+
### 0.0.1
|
|
246
|
+
- **First stable release**
|
|
247
|
+
- Django CMS integration with apphook support
|
|
248
|
+
- Pagination support for search results
|
|
249
|
+
- Multi-language support with Django i18n
|
|
250
|
+
- Basic search functionality with API integration
|
|
251
|
+
- Template customization support
|
|
252
|
+
- Support for Python 3.6+ and Django 2.2+
|
|
253
|
+
- Reptile Search API integration
|
|
254
|
+
- Comprehensive documentation and setup instructions
|
|
255
|
+
|
|
256
|
+
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Simple Site Search
|
|
2
|
+
|
|
3
|
+
A simple Django app for site search functionality with Django CMS integration. This package provides a clean, easy-to-use search interface that can be integrated into Django CMS projects.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **Django CMS Integration**: Seamlessly integrates with Django CMS as an apphook
|
|
9
|
+
- **Pagination Support**: Built-in pagination for search results
|
|
10
|
+
- **Multi-language Support**: Supports internationalization with Django's i18n framework
|
|
11
|
+
- **Customizable Templates**: Easy to customize search result templates
|
|
12
|
+
- **API Integration**: Connects to external search APIs (like AddSearch)
|
|
13
|
+
- **Responsive Design**: Bootstrap-compatible templates
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Install the package using pip:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install simplesitesearch
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
### 1. Add to INSTALLED_APPS
|
|
26
|
+
|
|
27
|
+
Add `simplesitesearch` to your Django project's `INSTALLED_APPS`:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
INSTALLED_APPS = [
|
|
31
|
+
# ... other apps
|
|
32
|
+
'simplesitesearch',
|
|
33
|
+
# ... other apps
|
|
34
|
+
]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Required Settings
|
|
38
|
+
|
|
39
|
+
Add the following settings to your Django settings file:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
# Search API Configuration
|
|
43
|
+
SITE_SEARCH_API_BASE_URL = "https://search.rt5.ca/reptile_search/api/search/"
|
|
44
|
+
SITE_SEARCH_SITE_KEY = "your-site-key-here"
|
|
45
|
+
SITE_SEARCH_API_KEY = "your-api-key-here" # Optional, if required by your API
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3. URL Configuration
|
|
49
|
+
|
|
50
|
+
Include the app's URLs in your main `urls.py`:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from django.urls import path, include
|
|
54
|
+
|
|
55
|
+
urlpatterns = [
|
|
56
|
+
# ... other URL patterns
|
|
57
|
+
path('search/', include('simplesitesearch.urls')),
|
|
58
|
+
# ... other URL patterns
|
|
59
|
+
]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Django CMS Integration
|
|
63
|
+
|
|
64
|
+
### 1. Create a Search Page
|
|
65
|
+
|
|
66
|
+
1. Log into your Django CMS admin
|
|
67
|
+
2. Go to **Django CMS** > **Pages**
|
|
68
|
+
3. Create a new page named "Search"
|
|
69
|
+
4. Translate the title and slug in all languages
|
|
70
|
+
5. Save and continue editing
|
|
71
|
+
|
|
72
|
+
### 2. Configure the Page
|
|
73
|
+
|
|
74
|
+
1. Go to **Advanced settings** of the search page
|
|
75
|
+
2. Set **APPLICATION** to "Site Search"
|
|
76
|
+
3. Set the **Application ID** to `'site_search'` (this is the default value)
|
|
77
|
+
4. Save the page
|
|
78
|
+
5. Remove the page from the menu (uncheck "menu" in the table)
|
|
79
|
+
6. Publish the page in all languages
|
|
80
|
+
|
|
81
|
+
### 3. Access the Search
|
|
82
|
+
|
|
83
|
+
Your search functionality will be available at the URL you configured for the search page.
|
|
84
|
+
|
|
85
|
+
## Usage
|
|
86
|
+
|
|
87
|
+
### Basic Search
|
|
88
|
+
|
|
89
|
+
The search form accepts a `q` parameter for the search term:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
/search/?q=your+search+term
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Pagination
|
|
96
|
+
|
|
97
|
+
The search results support pagination with a `page` parameter:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
/search/?q=your+search+term&page=2
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Honeypot Protection
|
|
104
|
+
|
|
105
|
+
The search includes basic honeypot protection. If a `message` parameter is present, the search will not execute.
|
|
106
|
+
|
|
107
|
+
## Customization
|
|
108
|
+
|
|
109
|
+
### Templates
|
|
110
|
+
|
|
111
|
+
The package includes two main templates:
|
|
112
|
+
|
|
113
|
+
- `simplesitesearch/search_results.html` - Main search results template
|
|
114
|
+
- `simplesitesearch/pagination.html` - Pagination template
|
|
115
|
+
|
|
116
|
+
#### Template Customization
|
|
117
|
+
|
|
118
|
+
You can override these templates in your project by creating templates with the same names in your template directory. The templates are designed to be easily customizable:
|
|
119
|
+
|
|
120
|
+
**Template Include Paths:**
|
|
121
|
+
- `simplesitesearch/search_results.html` - Main search results page
|
|
122
|
+
- `simplesitesearch/pagination.html` - Pagination component (included in search_results.html)
|
|
123
|
+
|
|
124
|
+
**To customize templates:**
|
|
125
|
+
1. Create a `templates/simplesitesearch/` directory in your Django project
|
|
126
|
+
2. Copy the template files from the package and modify them as needed
|
|
127
|
+
3. Your custom templates will override the package defaults
|
|
128
|
+
|
|
129
|
+
**Example template structure:**
|
|
130
|
+
```
|
|
131
|
+
your_project/
|
|
132
|
+
├── templates/
|
|
133
|
+
│ └── simplesitesearch/
|
|
134
|
+
│ ├── search_results.html # Your custom search results template
|
|
135
|
+
│ └── pagination.html # Your custom pagination template
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Styling
|
|
139
|
+
|
|
140
|
+
The templates use Bootstrap classes and can be easily customized with CSS. The main CSS classes used are:
|
|
141
|
+
|
|
142
|
+
- `.pagination` - Pagination container
|
|
143
|
+
- `.search_query` - Search query display
|
|
144
|
+
- `.search_results` - Results count display
|
|
145
|
+
- `.wrapper_single_result` - Individual result container
|
|
146
|
+
|
|
147
|
+
## API Response Format
|
|
148
|
+
|
|
149
|
+
The search expects the API to return JSON in the following format:
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"total_hits": 42,
|
|
154
|
+
"hits": [
|
|
155
|
+
{
|
|
156
|
+
"title": "Page Title",
|
|
157
|
+
"url": "https://example.com/page/",
|
|
158
|
+
"highlight": "Search term highlighted content..."
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Requirements
|
|
165
|
+
|
|
166
|
+
- Python 3.6+
|
|
167
|
+
- Django 2.2+
|
|
168
|
+
- django-cms 3.2+
|
|
169
|
+
- requests 2.22.0+
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
### Local Development
|
|
174
|
+
|
|
175
|
+
1. Clone the repository
|
|
176
|
+
2. Install in development mode:
|
|
177
|
+
```bash
|
|
178
|
+
pip install -e .
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Testing
|
|
182
|
+
|
|
183
|
+
Run the tests with:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
python manage.py test simplesitesearch
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
192
|
+
|
|
193
|
+
## Support
|
|
194
|
+
|
|
195
|
+
For support and questions, please open an issue on the [GitHub repository](https://github.com/yourusername/simplesitesearch/issues).
|
|
196
|
+
|
|
197
|
+
## Changelog
|
|
198
|
+
|
|
199
|
+
### 0.0.1
|
|
200
|
+
- **First stable release**
|
|
201
|
+
- Django CMS integration with apphook support
|
|
202
|
+
- Pagination support for search results
|
|
203
|
+
- Multi-language support with Django i18n
|
|
204
|
+
- Basic search functionality with API integration
|
|
205
|
+
- Template customization support
|
|
206
|
+
- Support for Python 3.6+ and Django 2.2+
|
|
207
|
+
- Reptile Search API integration
|
|
208
|
+
- Comprehensive documentation and setup instructions
|
|
209
|
+
|
|
210
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "simplesitesearch"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Reptile Simple Site Search django app"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Reptile Tech", email = "flouis@reptile.tech"},
|
|
13
|
+
]
|
|
14
|
+
maintainers = [
|
|
15
|
+
{name = "Reptile Tech", email = "flouis@reptile.tech"},
|
|
16
|
+
]
|
|
17
|
+
keywords = ["django", "search", "cms", "django-cms"]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 5 - Production/Stable",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.6",
|
|
25
|
+
"Programming Language :: Python :: 3.7",
|
|
26
|
+
"Programming Language :: Python :: 3.8",
|
|
27
|
+
"Programming Language :: Python :: 3.9",
|
|
28
|
+
"Programming Language :: Python :: 3.10",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Framework :: Django",
|
|
32
|
+
"Framework :: Django :: 2.2",
|
|
33
|
+
"Framework :: Django :: 3.2",
|
|
34
|
+
"Framework :: Django :: 4.0",
|
|
35
|
+
"Framework :: Django :: 4.1",
|
|
36
|
+
"Framework :: Django :: 4.2",
|
|
37
|
+
"Framework :: Django :: 5.0",
|
|
38
|
+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
|
|
39
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
40
|
+
]
|
|
41
|
+
requires-python = ">=3.6"
|
|
42
|
+
dependencies = [
|
|
43
|
+
"Django>=2.2",
|
|
44
|
+
"django-cms>=3.2",
|
|
45
|
+
"requests>=2.22.0",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://github.com/reptiletech/simplesitesearch"
|
|
50
|
+
Documentation = "https://github.com/reptiletech/simplesitesearch#readme"
|
|
51
|
+
Repository = "https://github.com/reptiletech/simplesitesearch.git"
|
|
52
|
+
"Bug Tracker" = "https://github.com/reptiletech/simplesitesearch/issues"
|
|
53
|
+
|
|
54
|
+
[tool.setuptools]
|
|
55
|
+
packages = ["simplesitesearch"]
|
|
56
|
+
include-package-data = true
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.package-data]
|
|
59
|
+
simplesitesearch = ["templates/simplesitesearch/*.html"]
|
|
60
|
+
|
|
61
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = simplesitesearch
|
|
3
|
+
version = 0.0.1
|
|
4
|
+
author = Reptile Tech
|
|
5
|
+
author_email = flouis@reptile.tech
|
|
6
|
+
description = Reptile Simple Site Search django app
|
|
7
|
+
long_description = file: README.md
|
|
8
|
+
long_description_content_type = text/markdown
|
|
9
|
+
url = https://github.com/reptiletech/simplesitesearch
|
|
10
|
+
license = MIT
|
|
11
|
+
license_files = LICENSE
|
|
12
|
+
classifiers =
|
|
13
|
+
Development Status :: 5 - Production/Stable
|
|
14
|
+
Intended Audience :: Developers
|
|
15
|
+
License :: OSI Approved :: MIT License
|
|
16
|
+
Operating System :: OS Independent
|
|
17
|
+
Programming Language :: Python :: 3
|
|
18
|
+
Programming Language :: Python :: 3.6
|
|
19
|
+
Programming Language :: Python :: 3.7
|
|
20
|
+
Programming Language :: Python :: 3.8
|
|
21
|
+
Programming Language :: Python :: 3.9
|
|
22
|
+
Programming Language :: Python :: 3.10
|
|
23
|
+
Programming Language :: Python :: 3.11
|
|
24
|
+
Programming Language :: Python :: 3.12
|
|
25
|
+
Framework :: Django
|
|
26
|
+
Framework :: Django :: 2.2
|
|
27
|
+
Framework :: Django :: 3.2
|
|
28
|
+
Framework :: Django :: 4.0
|
|
29
|
+
Framework :: Django :: 4.1
|
|
30
|
+
Framework :: Django :: 4.2
|
|
31
|
+
Framework :: Django :: 5.0
|
|
32
|
+
Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
33
|
+
Topic :: Software Development :: Libraries :: Python Modules
|
|
34
|
+
keywords = django search cms django-cms
|
|
35
|
+
project_urls =
|
|
36
|
+
Homepage = https://github.com/yourusername/simplesitesearch
|
|
37
|
+
Documentation = https://github.com/yourusername/simplesitesearch#readme
|
|
38
|
+
Repository = https://github.com/yourusername/simplesitesearch.git
|
|
39
|
+
Bug Tracker = https://github.com/yourusername/simplesitesearch/issues
|
|
40
|
+
|
|
41
|
+
[options]
|
|
42
|
+
packages = find:
|
|
43
|
+
python_requires = >=3.6
|
|
44
|
+
install_requires =
|
|
45
|
+
Django>=2.2
|
|
46
|
+
django-cms>=3.2
|
|
47
|
+
requests>=2.22.0
|
|
48
|
+
include_package_data = True
|
|
49
|
+
zip_safe = False
|
|
50
|
+
|
|
51
|
+
[options.packages.find]
|
|
52
|
+
exclude =
|
|
53
|
+
tests*
|
|
54
|
+
docs*
|
|
55
|
+
|
|
56
|
+
[options.package_data]
|
|
57
|
+
simplesitesearch = templates/simplesitesearch/*.html
|
|
58
|
+
|
|
59
|
+
[egg_info]
|
|
60
|
+
tag_build =
|
|
61
|
+
tag_date = 0
|
|
62
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
from setuptools import setup, find_packages
|
|
5
|
+
|
|
6
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
7
|
+
long_description = fh.read()
|
|
8
|
+
|
|
9
|
+
setup(
|
|
10
|
+
name="simplesitesearch",
|
|
11
|
+
version="0.0.1",
|
|
12
|
+
author="Reptile Tech",
|
|
13
|
+
author_email="flouis@reptile.tech",
|
|
14
|
+
description="Reptile Simple Site Search django app",
|
|
15
|
+
long_description=long_description,
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
url="https://github.com/reptiletech/simplesitesearch",
|
|
18
|
+
packages=find_packages(),
|
|
19
|
+
classifiers=[
|
|
20
|
+
"Development Status :: 5 - Production/Stable",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.6",
|
|
26
|
+
"Programming Language :: Python :: 3.7",
|
|
27
|
+
"Programming Language :: Python :: 3.8",
|
|
28
|
+
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Framework :: Django",
|
|
33
|
+
"Framework :: Django :: 2.2",
|
|
34
|
+
"Framework :: Django :: 3.2",
|
|
35
|
+
"Framework :: Django :: 4.0",
|
|
36
|
+
"Framework :: Django :: 4.1",
|
|
37
|
+
"Framework :: Django :: 4.2",
|
|
38
|
+
"Framework :: Django :: 5.0",
|
|
39
|
+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
|
|
40
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
41
|
+
],
|
|
42
|
+
python_requires=">=3.6",
|
|
43
|
+
install_requires=[
|
|
44
|
+
"Django>=2.2",
|
|
45
|
+
"django-cms>=3.2",
|
|
46
|
+
"requests>=2.22.0",
|
|
47
|
+
],
|
|
48
|
+
include_package_data=True,
|
|
49
|
+
package_data={
|
|
50
|
+
"simplesitesearch": [
|
|
51
|
+
"templates/simplesitesearch/*.html",
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
zip_safe=False,
|
|
55
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.0.1'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from cms.app_base import CMSApp
|
|
3
|
+
from cms.apphook_pool import apphook_pool
|
|
4
|
+
from django.utils.translation import gettext_lazy as _
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@apphook_pool.register
|
|
8
|
+
class SiteSearchApp(CMSApp):
|
|
9
|
+
app_name = "site_search"
|
|
10
|
+
name = _("Site Search")
|
|
11
|
+
|
|
12
|
+
def get_urls(self, page=None, language=None, **kwargs):
|
|
13
|
+
return ["simplesitesearch.urls"]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{% load i18n staticfiles cms_tags %}
|
|
2
|
+
|
|
3
|
+
<div class="search__pagination d-flex justify-content-between justify-sm-content-center align-items-center">
|
|
4
|
+
<div class="search__pagination__nav search__pagination__nav--prev">
|
|
5
|
+
{% if prev_link %}
|
|
6
|
+
<a class="search__pagination__nav__item" href="{% url 'site_search:search' %}{{prev_link}}"><i class="fal fa-chevron-left"></i></a>
|
|
7
|
+
{% endif %}
|
|
8
|
+
</div>
|
|
9
|
+
<div class="d-flex search__pagination__links">
|
|
10
|
+
{% for page_link in page_links %}
|
|
11
|
+
<div class="search__pagination__link-container{% ifequal page_link.page current_page %} active{% endifequal %}">
|
|
12
|
+
<a class="search__pagination__link" href="{{ page_link.url }}">{{ page_link.page }}</a>
|
|
13
|
+
</div>
|
|
14
|
+
{% endfor %}
|
|
15
|
+
</div>
|
|
16
|
+
<div class="search__pagination__nav search__pagination__nav--next">
|
|
17
|
+
{% if next_link %}
|
|
18
|
+
<a class="search__pagination__nav__item" href="{% url 'site_search:search' %}{{next_link}}"><i class="fal fa-chevron-right"></i></a>
|
|
19
|
+
{% endif %}
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
{% comment %}
|
|
24
|
+
<ul class="pagination">
|
|
25
|
+
{% if prev_link %}
|
|
26
|
+
<li>
|
|
27
|
+
<a href="{% url 'site_search:search' %}{{prev_link}}" class="term">«</a>
|
|
28
|
+
</li>
|
|
29
|
+
{% endif %}
|
|
30
|
+
|
|
31
|
+
{% for page_link in page_links %}
|
|
32
|
+
<li{% ifequal page_link.page current_page %} class="active"{% endifequal %}>
|
|
33
|
+
<a href="{{ page_link.url }}" class="page">{{ page_link.page }}</a>
|
|
34
|
+
</li>
|
|
35
|
+
{% endfor %}
|
|
36
|
+
|
|
37
|
+
{% if next_link %}
|
|
38
|
+
<li>
|
|
39
|
+
<a href="{% url 'site_search:search' %}{{next_link}}" class="term">»</a>
|
|
40
|
+
</li>
|
|
41
|
+
{% endif %}
|
|
42
|
+
</ul>
|
|
43
|
+
{% endcomment %}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
{% load i18n staticfiles cms_tags %}
|
|
3
|
+
|
|
4
|
+
{% block template_class %}template_search{% endblock %}
|
|
5
|
+
|
|
6
|
+
{% block content %}
|
|
7
|
+
<section id="search" class="section section--nopadding section--nomargin">
|
|
8
|
+
{% if results_count %}
|
|
9
|
+
<div class="search__about-container">
|
|
10
|
+
<div class="search__about d-sm-flex justify-content-between">
|
|
11
|
+
<div class="headings__third-container headings__third-container--noMargin">
|
|
12
|
+
<div class="headings headings__third headings--white">
|
|
13
|
+
<h3>{% trans "Search results for:" %} "{{ query }}"</h3>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="text-container">
|
|
17
|
+
<div class="text text--white">
|
|
18
|
+
<p>{{ results_count }} {% trans "result" %}{{ results_count|pluralize }}</p>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
{% endif %}
|
|
24
|
+
</section>
|
|
25
|
+
<section class="section">
|
|
26
|
+
<div class="search__content">
|
|
27
|
+
{% for result in results %}
|
|
28
|
+
<div class="search__content__result">
|
|
29
|
+
<div class="headings__third-container">
|
|
30
|
+
<a class="headings headings__third headings--blue" href="{{result.url}}">{{ result.title|safe }}</a>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="text-container">
|
|
33
|
+
<div class="text text--graydark">
|
|
34
|
+
<p>{{result.highlight|safe}}...</p>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
{% empty %}
|
|
39
|
+
<div class="search__content--empty">
|
|
40
|
+
<div class="headings__third-container">
|
|
41
|
+
<div class="headings headings__third">
|
|
42
|
+
<h3>{% trans "No results" %}</h3>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
{% endfor %}
|
|
47
|
+
</div>
|
|
48
|
+
</section>
|
|
49
|
+
{% if page_links|length > 1 %}
|
|
50
|
+
<section class="section section--nopadding section--nomargin">
|
|
51
|
+
{% include "pagination.html" %}
|
|
52
|
+
</section>
|
|
53
|
+
{% endif %}
|
|
54
|
+
|
|
55
|
+
{% endblock %}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
from math import floor
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.utils.translation import get_language
|
|
6
|
+
from django.views.generic import TemplateView
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_page_links(pages_count, current_page, term):
|
|
10
|
+
|
|
11
|
+
page_links = []
|
|
12
|
+
|
|
13
|
+
if pages_count > 1:
|
|
14
|
+
|
|
15
|
+
if current_page == 1:
|
|
16
|
+
from_page = 1
|
|
17
|
+
to_page = from_page + 7
|
|
18
|
+
if current_page == pages_count + 1:
|
|
19
|
+
pass
|
|
20
|
+
else:
|
|
21
|
+
from_page = current_page - 4
|
|
22
|
+
to_page = current_page + 5
|
|
23
|
+
|
|
24
|
+
if from_page < 1:
|
|
25
|
+
from_page = 1
|
|
26
|
+
|
|
27
|
+
if to_page > pages_count:
|
|
28
|
+
to_page = pages_count
|
|
29
|
+
|
|
30
|
+
for page in range(from_page, to_page + 1):
|
|
31
|
+
page_link = "?q=%s&page=%s" % (term, page)
|
|
32
|
+
|
|
33
|
+
page_links.append({
|
|
34
|
+
'page': page,
|
|
35
|
+
'url': page_link
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return page_links
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def get_prev_next_links(next_page_number, prev_page_number, term):
|
|
42
|
+
next_link = None
|
|
43
|
+
if next_page_number:
|
|
44
|
+
next_link = "?q=%s&page=%s" % (term, next_page_number)
|
|
45
|
+
|
|
46
|
+
prev_link = None
|
|
47
|
+
if prev_page_number:
|
|
48
|
+
prev_link = "?q=%s&page=%s" % (term, prev_page_number)
|
|
49
|
+
|
|
50
|
+
return [prev_link, next_link]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def get_prev_next_page_number(pages_count, current_page):
|
|
54
|
+
|
|
55
|
+
current_page = int(current_page)
|
|
56
|
+
pages_count - int(pages_count)
|
|
57
|
+
|
|
58
|
+
if current_page > 1:
|
|
59
|
+
prev_page_number = current_page - 1
|
|
60
|
+
else:
|
|
61
|
+
prev_page_number = None
|
|
62
|
+
|
|
63
|
+
if current_page < pages_count:
|
|
64
|
+
next_page_number = current_page + 1
|
|
65
|
+
else:
|
|
66
|
+
next_page_number = None
|
|
67
|
+
|
|
68
|
+
return [prev_page_number, next_page_number]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def get_total_pages(total_hits):
|
|
72
|
+
pages_count = floor(total_hits / 10)
|
|
73
|
+
|
|
74
|
+
modulo = total_hits % 10
|
|
75
|
+
if modulo > 0:
|
|
76
|
+
pages_count = pages_count + 1
|
|
77
|
+
|
|
78
|
+
return pages_count
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def get_api_re_path(term, current_page):
|
|
82
|
+
base_url = settings.SITE_SEARCH_API_BASE_URL
|
|
83
|
+
site_key = settings.SITE_SEARCH_SITE_KEY
|
|
84
|
+
lang = get_language()
|
|
85
|
+
|
|
86
|
+
return "%s%s?term=%s&lang=%s&page=%s" % (base_url, site_key, term, lang, current_page)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class SearchResult(TemplateView):
|
|
90
|
+
|
|
91
|
+
template_name = "simplesitesearch/search_results.html"
|
|
92
|
+
|
|
93
|
+
def get(self, request, *args, **kwargs):
|
|
94
|
+
context = self.get_context_data(**kwargs)
|
|
95
|
+
|
|
96
|
+
# get Term from url params
|
|
97
|
+
term = request.GET.get('q', None)
|
|
98
|
+
honeypot_message = request.GET.get('message', None)
|
|
99
|
+
|
|
100
|
+
# get current page from url params
|
|
101
|
+
current_page = int(request.GET.get('page', 1))
|
|
102
|
+
|
|
103
|
+
if term and not honeypot_message:
|
|
104
|
+
|
|
105
|
+
term = ' '.join(term.split()[:10])
|
|
106
|
+
|
|
107
|
+
# get api URl depending on current page
|
|
108
|
+
api_url = get_api_re_path(term, current_page)
|
|
109
|
+
|
|
110
|
+
# get results from api
|
|
111
|
+
response = requests.get(api_url, verify=False)
|
|
112
|
+
# convert results to usable json
|
|
113
|
+
try:
|
|
114
|
+
response_data = response.json()
|
|
115
|
+
except:
|
|
116
|
+
response_data = {
|
|
117
|
+
'total_hits': 0,
|
|
118
|
+
'hits': []
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# get pages count
|
|
122
|
+
pages_count = get_total_pages(response_data['total_hits'])
|
|
123
|
+
|
|
124
|
+
# get prev and next page numbers
|
|
125
|
+
prev_page_number, next_page_number = get_prev_next_page_number(pages_count, current_page)
|
|
126
|
+
|
|
127
|
+
# get prev and next btn links
|
|
128
|
+
prev_link, next_link = get_prev_next_links(next_page_number, prev_page_number, term)
|
|
129
|
+
|
|
130
|
+
# get pages links
|
|
131
|
+
page_links = get_page_links(pages_count, current_page, term)
|
|
132
|
+
|
|
133
|
+
context.update({
|
|
134
|
+
'pages_count': pages_count,
|
|
135
|
+
'current_page': current_page,
|
|
136
|
+
'results_count': response_data['total_hits'],
|
|
137
|
+
'prev_link': prev_link,
|
|
138
|
+
'next_link': next_link,
|
|
139
|
+
'page_links': page_links,
|
|
140
|
+
'results': response_data['hits']
|
|
141
|
+
})
|
|
142
|
+
else:
|
|
143
|
+
context.update({
|
|
144
|
+
'results': None
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
context.update({
|
|
148
|
+
'query': term
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
return self.render_to_response(context)
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: simplesitesearch
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Reptile Simple Site Search django app
|
|
5
|
+
Home-page: https://github.com/reptiletech/simplesitesearch
|
|
6
|
+
Author: Reptile Tech
|
|
7
|
+
Author-email: Reptile Tech <flouis@reptile.tech>
|
|
8
|
+
Maintainer-email: Reptile Tech <flouis@reptile.tech>
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Homepage, https://github.com/reptiletech/simplesitesearch
|
|
11
|
+
Project-URL: Documentation, https://github.com/reptiletech/simplesitesearch#readme
|
|
12
|
+
Project-URL: Repository, https://github.com/reptiletech/simplesitesearch.git
|
|
13
|
+
Project-URL: Bug Tracker, https://github.com/reptiletech/simplesitesearch/issues
|
|
14
|
+
Keywords: django,search,cms,django-cms
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Framework :: Django
|
|
28
|
+
Classifier: Framework :: Django :: 2.2
|
|
29
|
+
Classifier: Framework :: Django :: 3.2
|
|
30
|
+
Classifier: Framework :: Django :: 4.0
|
|
31
|
+
Classifier: Framework :: Django :: 4.1
|
|
32
|
+
Classifier: Framework :: Django :: 4.2
|
|
33
|
+
Classifier: Framework :: Django :: 5.0
|
|
34
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
35
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
36
|
+
Requires-Python: >=3.6
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
License-File: LICENSE
|
|
39
|
+
Requires-Dist: Django>=2.2
|
|
40
|
+
Requires-Dist: django-cms>=3.2
|
|
41
|
+
Requires-Dist: requests>=2.22.0
|
|
42
|
+
Dynamic: author
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
Dynamic: requires-python
|
|
46
|
+
|
|
47
|
+
# Simple Site Search
|
|
48
|
+
|
|
49
|
+
A simple Django app for site search functionality with Django CMS integration. This package provides a clean, easy-to-use search interface that can be integrated into Django CMS projects.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
- **Django CMS Integration**: Seamlessly integrates with Django CMS as an apphook
|
|
55
|
+
- **Pagination Support**: Built-in pagination for search results
|
|
56
|
+
- **Multi-language Support**: Supports internationalization with Django's i18n framework
|
|
57
|
+
- **Customizable Templates**: Easy to customize search result templates
|
|
58
|
+
- **API Integration**: Connects to external search APIs (like AddSearch)
|
|
59
|
+
- **Responsive Design**: Bootstrap-compatible templates
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
Install the package using pip:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install simplesitesearch
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
### 1. Add to INSTALLED_APPS
|
|
72
|
+
|
|
73
|
+
Add `simplesitesearch` to your Django project's `INSTALLED_APPS`:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
INSTALLED_APPS = [
|
|
77
|
+
# ... other apps
|
|
78
|
+
'simplesitesearch',
|
|
79
|
+
# ... other apps
|
|
80
|
+
]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. Required Settings
|
|
84
|
+
|
|
85
|
+
Add the following settings to your Django settings file:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
# Search API Configuration
|
|
89
|
+
SITE_SEARCH_API_BASE_URL = "https://search.rt5.ca/reptile_search/api/search/"
|
|
90
|
+
SITE_SEARCH_SITE_KEY = "your-site-key-here"
|
|
91
|
+
SITE_SEARCH_API_KEY = "your-api-key-here" # Optional, if required by your API
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 3. URL Configuration
|
|
95
|
+
|
|
96
|
+
Include the app's URLs in your main `urls.py`:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from django.urls import path, include
|
|
100
|
+
|
|
101
|
+
urlpatterns = [
|
|
102
|
+
# ... other URL patterns
|
|
103
|
+
path('search/', include('simplesitesearch.urls')),
|
|
104
|
+
# ... other URL patterns
|
|
105
|
+
]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Django CMS Integration
|
|
109
|
+
|
|
110
|
+
### 1. Create a Search Page
|
|
111
|
+
|
|
112
|
+
1. Log into your Django CMS admin
|
|
113
|
+
2. Go to **Django CMS** > **Pages**
|
|
114
|
+
3. Create a new page named "Search"
|
|
115
|
+
4. Translate the title and slug in all languages
|
|
116
|
+
5. Save and continue editing
|
|
117
|
+
|
|
118
|
+
### 2. Configure the Page
|
|
119
|
+
|
|
120
|
+
1. Go to **Advanced settings** of the search page
|
|
121
|
+
2. Set **APPLICATION** to "Site Search"
|
|
122
|
+
3. Set the **Application ID** to `'site_search'` (this is the default value)
|
|
123
|
+
4. Save the page
|
|
124
|
+
5. Remove the page from the menu (uncheck "menu" in the table)
|
|
125
|
+
6. Publish the page in all languages
|
|
126
|
+
|
|
127
|
+
### 3. Access the Search
|
|
128
|
+
|
|
129
|
+
Your search functionality will be available at the URL you configured for the search page.
|
|
130
|
+
|
|
131
|
+
## Usage
|
|
132
|
+
|
|
133
|
+
### Basic Search
|
|
134
|
+
|
|
135
|
+
The search form accepts a `q` parameter for the search term:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
/search/?q=your+search+term
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Pagination
|
|
142
|
+
|
|
143
|
+
The search results support pagination with a `page` parameter:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
/search/?q=your+search+term&page=2
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Honeypot Protection
|
|
150
|
+
|
|
151
|
+
The search includes basic honeypot protection. If a `message` parameter is present, the search will not execute.
|
|
152
|
+
|
|
153
|
+
## Customization
|
|
154
|
+
|
|
155
|
+
### Templates
|
|
156
|
+
|
|
157
|
+
The package includes two main templates:
|
|
158
|
+
|
|
159
|
+
- `simplesitesearch/search_results.html` - Main search results template
|
|
160
|
+
- `simplesitesearch/pagination.html` - Pagination template
|
|
161
|
+
|
|
162
|
+
#### Template Customization
|
|
163
|
+
|
|
164
|
+
You can override these templates in your project by creating templates with the same names in your template directory. The templates are designed to be easily customizable:
|
|
165
|
+
|
|
166
|
+
**Template Include Paths:**
|
|
167
|
+
- `simplesitesearch/search_results.html` - Main search results page
|
|
168
|
+
- `simplesitesearch/pagination.html` - Pagination component (included in search_results.html)
|
|
169
|
+
|
|
170
|
+
**To customize templates:**
|
|
171
|
+
1. Create a `templates/simplesitesearch/` directory in your Django project
|
|
172
|
+
2. Copy the template files from the package and modify them as needed
|
|
173
|
+
3. Your custom templates will override the package defaults
|
|
174
|
+
|
|
175
|
+
**Example template structure:**
|
|
176
|
+
```
|
|
177
|
+
your_project/
|
|
178
|
+
├── templates/
|
|
179
|
+
│ └── simplesitesearch/
|
|
180
|
+
│ ├── search_results.html # Your custom search results template
|
|
181
|
+
│ └── pagination.html # Your custom pagination template
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Styling
|
|
185
|
+
|
|
186
|
+
The templates use Bootstrap classes and can be easily customized with CSS. The main CSS classes used are:
|
|
187
|
+
|
|
188
|
+
- `.pagination` - Pagination container
|
|
189
|
+
- `.search_query` - Search query display
|
|
190
|
+
- `.search_results` - Results count display
|
|
191
|
+
- `.wrapper_single_result` - Individual result container
|
|
192
|
+
|
|
193
|
+
## API Response Format
|
|
194
|
+
|
|
195
|
+
The search expects the API to return JSON in the following format:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"total_hits": 42,
|
|
200
|
+
"hits": [
|
|
201
|
+
{
|
|
202
|
+
"title": "Page Title",
|
|
203
|
+
"url": "https://example.com/page/",
|
|
204
|
+
"highlight": "Search term highlighted content..."
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Requirements
|
|
211
|
+
|
|
212
|
+
- Python 3.6+
|
|
213
|
+
- Django 2.2+
|
|
214
|
+
- django-cms 3.2+
|
|
215
|
+
- requests 2.22.0+
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
### Local Development
|
|
220
|
+
|
|
221
|
+
1. Clone the repository
|
|
222
|
+
2. Install in development mode:
|
|
223
|
+
```bash
|
|
224
|
+
pip install -e .
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Testing
|
|
228
|
+
|
|
229
|
+
Run the tests with:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
python manage.py test simplesitesearch
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
238
|
+
|
|
239
|
+
## Support
|
|
240
|
+
|
|
241
|
+
For support and questions, please open an issue on the [GitHub repository](https://github.com/yourusername/simplesitesearch/issues).
|
|
242
|
+
|
|
243
|
+
## Changelog
|
|
244
|
+
|
|
245
|
+
### 0.0.1
|
|
246
|
+
- **First stable release**
|
|
247
|
+
- Django CMS integration with apphook support
|
|
248
|
+
- Pagination support for search results
|
|
249
|
+
- Multi-language support with Django i18n
|
|
250
|
+
- Basic search functionality with API integration
|
|
251
|
+
- Template customization support
|
|
252
|
+
- Support for Python 3.6+ and Django 2.2+
|
|
253
|
+
- Reptile Search API integration
|
|
254
|
+
- Comprehensive documentation and setup instructions
|
|
255
|
+
|
|
256
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.cfg
|
|
6
|
+
setup.py
|
|
7
|
+
simplesitesearch/__init__.py
|
|
8
|
+
simplesitesearch/cms_apps.py
|
|
9
|
+
simplesitesearch/urls.py
|
|
10
|
+
simplesitesearch/views.py
|
|
11
|
+
simplesitesearch.egg-info/PKG-INFO
|
|
12
|
+
simplesitesearch.egg-info/SOURCES.txt
|
|
13
|
+
simplesitesearch.egg-info/dependency_links.txt
|
|
14
|
+
simplesitesearch.egg-info/not-zip-safe
|
|
15
|
+
simplesitesearch.egg-info/requires.txt
|
|
16
|
+
simplesitesearch.egg-info/top_level.txt
|
|
17
|
+
simplesitesearch/templates/simplesitesearch/pagination.html
|
|
18
|
+
simplesitesearch/templates/simplesitesearch/search_results.html
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
simplesitesearch
|