From d9d33a877abdde1522aa3528b4be5fbdf3a2e886 Mon Sep 17 00:00:00 2001 From: crunk Date: Sat, 29 Jun 2024 15:25:28 +0200 Subject: [PATCH] ruff formatting --- .gitignore | 1 + verse/app.py | 2 -- verse/search/forms/searchform.py | 1 + verse/search/search.py | 2 +- verse/search/search_index.py | 7 ++++++- verse/start.py | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e7045b6..f273bbd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ pip-wheel-metadata/ verse/tmpupload/* verse/stash/* +verse/search/searchdata/* *.db diff --git a/verse/app.py b/verse/app.py index 8c9c355..ff47f2b 100644 --- a/verse/app.py +++ b/verse/app.py @@ -9,7 +9,6 @@ from flask_sqlalchemy import SQLAlchemy from flask_wtf.csrf import CSRFProtect - APP = Flask(__name__, static_folder="static") db = SQLAlchemy() migrate = Migrate() @@ -48,7 +47,6 @@ def create_app(): migrate.init_app(APP, db, render_as_batch=True) bcrypt.init_app(APP) - @APP.context_processor def inject_title(): return dict(title=APP.config["title"]) diff --git a/verse/search/forms/searchform.py b/verse/search/forms/searchform.py index d32296a..707c9b7 100644 --- a/verse/search/forms/searchform.py +++ b/verse/search/forms/searchform.py @@ -5,6 +5,7 @@ from wtforms import StringField, SubmitField, validators from wtforms.validators import Length from wtforms.widgets import TextArea + class SearchForm(FlaskForm): searchfield = StringField("Search distribusi-verse archive") submit = SubmitField("Search") diff --git a/verse/search/search.py b/verse/search/search.py index 8129d08..8628da2 100644 --- a/verse/search/search.py +++ b/verse/search/search.py @@ -31,7 +31,7 @@ def searchpage(): def search(searchinput): """search and get search result titles and return them as distribusi ids""" - ix = open_dir(SEARCH_DATA_DIR) + ix = open_dir(SEARCH_DATA_DIRgi) with ix.searcher() as searcher: query = QueryParser("content", ix.schema).parse(searchinput) search_results = searcher.search(query) diff --git a/verse/search/search_index.py b/verse/search/search_index.py index 11d75d4..88c9dd0 100644 --- a/verse/search/search_index.py +++ b/verse/search/search_index.py @@ -9,6 +9,7 @@ import flask_apscheduler SCRIPT_DIR = os.path.dirname(__file__) SEARCH_DATA_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "searchdata")) + def init_search_index(APP): scheduler = flask_apscheduler.APScheduler() scheduler.api_enabled = False @@ -31,7 +32,11 @@ def index_distribusis(APP): writer = ix.writer() distribusis = _visible_distribusis(APP) for distribusi in distribusis: - writer.add_document(title=distribusi.distribusiname, path="/a", content=distribusi.description) + writer.add_document( + title=distribusi.distribusiname, + path="/a", + content=distribusi.description, + ) writer.commit() diff --git a/verse/start.py b/verse/start.py index f5bf472..368a594 100644 --- a/verse/start.py +++ b/verse/start.py @@ -41,6 +41,7 @@ APP.register_blueprint(distribusikan, url_prefix="/distribusikan") APP.register_blueprint(searchpages, url_prefix="/search") init_search_index(APP) + @APP.before_request def session_handler(): session.permanent = True