ruff formatting
This commit is contained in:
parent
0ac59269e7
commit
d9d33a877a
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,4 +10,5 @@ pip-wheel-metadata/
|
|||||||
|
|
||||||
verse/tmpupload/*
|
verse/tmpupload/*
|
||||||
verse/stash/*
|
verse/stash/*
|
||||||
|
verse/search/searchdata/*
|
||||||
*.db
|
*.db
|
||||||
|
@ -9,7 +9,6 @@ from flask_sqlalchemy import SQLAlchemy
|
|||||||
from flask_wtf.csrf import CSRFProtect
|
from flask_wtf.csrf import CSRFProtect
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
APP = Flask(__name__, static_folder="static")
|
APP = Flask(__name__, static_folder="static")
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
migrate = Migrate()
|
migrate = Migrate()
|
||||||
@ -48,7 +47,6 @@ def create_app():
|
|||||||
migrate.init_app(APP, db, render_as_batch=True)
|
migrate.init_app(APP, db, render_as_batch=True)
|
||||||
bcrypt.init_app(APP)
|
bcrypt.init_app(APP)
|
||||||
|
|
||||||
|
|
||||||
@APP.context_processor
|
@APP.context_processor
|
||||||
def inject_title():
|
def inject_title():
|
||||||
return dict(title=APP.config["title"])
|
return dict(title=APP.config["title"])
|
||||||
|
@ -5,6 +5,7 @@ from wtforms import StringField, SubmitField, validators
|
|||||||
from wtforms.validators import Length
|
from wtforms.validators import Length
|
||||||
from wtforms.widgets import TextArea
|
from wtforms.widgets import TextArea
|
||||||
|
|
||||||
|
|
||||||
class SearchForm(FlaskForm):
|
class SearchForm(FlaskForm):
|
||||||
searchfield = StringField("Search distribusi-verse archive")
|
searchfield = StringField("Search distribusi-verse archive")
|
||||||
submit = SubmitField("Search")
|
submit = SubmitField("Search")
|
||||||
|
@ -31,7 +31,7 @@ def searchpage():
|
|||||||
|
|
||||||
def search(searchinput):
|
def search(searchinput):
|
||||||
"""search and get search result titles and return them as distribusi ids"""
|
"""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:
|
with ix.searcher() as searcher:
|
||||||
query = QueryParser("content", ix.schema).parse(searchinput)
|
query = QueryParser("content", ix.schema).parse(searchinput)
|
||||||
search_results = searcher.search(query)
|
search_results = searcher.search(query)
|
||||||
|
@ -9,6 +9,7 @@ import flask_apscheduler
|
|||||||
SCRIPT_DIR = os.path.dirname(__file__)
|
SCRIPT_DIR = os.path.dirname(__file__)
|
||||||
SEARCH_DATA_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "searchdata"))
|
SEARCH_DATA_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "searchdata"))
|
||||||
|
|
||||||
|
|
||||||
def init_search_index(APP):
|
def init_search_index(APP):
|
||||||
scheduler = flask_apscheduler.APScheduler()
|
scheduler = flask_apscheduler.APScheduler()
|
||||||
scheduler.api_enabled = False
|
scheduler.api_enabled = False
|
||||||
@ -31,7 +32,11 @@ def index_distribusis(APP):
|
|||||||
writer = ix.writer()
|
writer = ix.writer()
|
||||||
distribusis = _visible_distribusis(APP)
|
distribusis = _visible_distribusis(APP)
|
||||||
for distribusi in distribusis:
|
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()
|
writer.commit()
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ APP.register_blueprint(distribusikan, url_prefix="/distribusikan")
|
|||||||
APP.register_blueprint(searchpages, url_prefix="/search")
|
APP.register_blueprint(searchpages, url_prefix="/search")
|
||||||
init_search_index(APP)
|
init_search_index(APP)
|
||||||
|
|
||||||
|
|
||||||
@APP.before_request
|
@APP.before_request
|
||||||
def session_handler():
|
def session_handler():
|
||||||
session.permanent = True
|
session.permanent = True
|
||||||
|
Loading…
Reference in New Issue
Block a user