A little bit of progress on search

* Created a README
* Included instructions on how to apply the Inkscape patch, so that we can actually handle Thoughts of length
* Restyled the search results page
This commit is contained in:
MatthiasSaihttam 2021-12-15 09:29:30 -05:00
parent d67ea3f498
commit 13dd18b28a
7 changed files with 79 additions and 13 deletions

5
.gitignore vendored
View File

@ -1,3 +1,4 @@
.env
/venv
/.idea
/*.sqlite3
@ -5,8 +6,8 @@
/media
/log
/xapian_index
/xapian-haystack
stale_outputs_checked
__pycache__
Thoughts.iml
.env
*.iml
*.pages

43
README Normal file
View File

@ -0,0 +1,43 @@
# WhisperMaPhone
## Installing
```sh
# Clone
git clone https://tildegit.org/Matthias/WhisperMaPhone
cd WhisperMaPhone
# Create a virtual environment
# Python 3 should go without saying in 2021
python -m venv venv
# Activate
. ./venv/bin/activate
# Install Requirements
pip install -r requirements.txt
# To install xapian to power /search:
git clone https://github.com/notanumber/xapian-haystack.git
cd xapian-haystack
git remote add inscape https://github.com/inkscape/xapian-haystack.git
git fetch inscape
git cherry-pick d1346dc53f35b0960badf6435cff468c648de694
pip install ./xapian-haystack
# Check the latest version of xapian from https://github.com/xapian/xapian/tags
. install_xapain <version>
./manage.py rebuild_index
# Otherwise, disable xapian by patching settings.py like so
patch whispermaphone/settings.py <<EOF
54,55c54
< "ENGINE": "xapian_backend.XapianEngine",
< "PATH": str(BASE_DIR / "xapian_index")
---
> "ENGINE": "haystack.backends.simple_backend.SimpleEngine"
EOF
```

View File

@ -38,7 +38,7 @@ body {
}
/* Standard button styles, most prominently used on the show-more buttons */
button, input[type="button"], input[type="submit"] {
button, input[type="button"], input[type="submit"], .button {
background: none;
border: none;
border-radius: 0;
@ -52,7 +52,8 @@ button, input[type="button"], input[type="submit"] {
}
button:hover, button:focus,
input[type="button"]:hover, input[type="button"]:focus,
input[type="submit"]:hover, input[type="submit"]:focus {
input[type="submit"]:hover, input[type="submit"]:focus,
.button:hover, .button:focus {
/* border-bottom-color: var(--accent-color); */
text-decoration: underline;
}

View File

@ -32,8 +32,6 @@
{{ form.submit }}
</form>
<!-- {{ form }} -->
{% endblock %}
{% block scripts %}

View File

@ -1,3 +1,3 @@
{{ object.text }}
{{ object.extended_text|truncatechars:238 }}
{{ object.media_alt|truncatechars:238 }}
{{ object.extended_text }}
{{ object.media_alt }}

View File

@ -20,12 +20,32 @@
</table>
{% if query %}
{% load tz %}
<h3>Results</h3>
{% for result in page.object_list %}
<p>
<a href="/?show={{ result.object.uuid }}">{{ result.object.text }}</a>
</p>
{% for thought in page.object_list %}
<div class="thought" id="{{ thought.uuid }}">
<div class="main">
<span class="main-text text">{{ thought.object.text|urlize }}</span>
<a href="/?show={{thought.uuid}}" class="button show-more">Show</a>
</div>
<div class="thought-end">
<span class="timestamp">
{% timezone thought.object.get_timezone %}
{{ thought.object.posted|time:"g:i a" }}
{{ thought.object.posted|date:"M d, Y" }},
UTC{{ thought.object.get_offset_hours }}
{{ thought.object.get_season }}
{% endtimezone %}
</span>
</div>
<hr>
</div>
{% empty %}
<p>No results found.</p>
{% endfor %}

View File

@ -5,10 +5,13 @@ from main import views
from main.feed import MainFeed
from whispermaphone import settings
from haystack.views import SearchView
from haystack.forms import SearchForm
urlpatterns = [
path("", views.index, name="index"),
path("about", views.about, name="about"),
path("post", views.post, name="post"),
path("feed", MainFeed()),
path("search", include('haystack.urls')),
path("search", SearchView(form_class=SearchForm), name="thoughts_search")
] + (static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG else [])