Fix escape sequence usage in strings. Remove unneeded import of os

Rename /config API method to config to match it's purpose. UI is
anyway too generic, and not what it is doing
This commit is contained in:
Debanjum Singh Solanky 2022-08-03 14:00:30 +03:00
parent a4eb55dd00
commit 38df727ef4
3 changed files with 6 additions and 4 deletions

View file

@ -1,5 +1,5 @@
# Standard Packages # Standard Packages
import sys, json, yaml, os import sys, json, yaml
import time import time
from typing import Optional from typing import Optional
from pathlib import Path from pathlib import Path
@ -38,12 +38,14 @@ web_directory = this_directory / 'interface/web/'
app.mount("/static", StaticFiles(directory=web_directory), name="static") app.mount("/static", StaticFiles(directory=web_directory), name="static")
templates = Jinja2Templates(directory=web_directory) templates = Jinja2Templates(directory=web_directory)
# Controllers
@app.get("/", response_class=FileResponse) @app.get("/", response_class=FileResponse)
def index(): def index():
return FileResponse(web_directory / "index.html") return FileResponse(web_directory / "index.html")
@app.get('/config', response_class=HTMLResponse) @app.get('/config', response_class=HTMLResponse)
def ui(request: Request): def config(request: Request):
return templates.TemplateResponse("config.html", context={'request': request}) return templates.TemplateResponse("config.html", context={'request': request})
@app.get('/config/data', response_model=FullConfig) @app.get('/config/data', response_model=FullConfig)

View file

@ -194,7 +194,7 @@ def makelist(filename):
n.setHeading(prtysrch.group(2)) n.setHeading(prtysrch.group(2))
# Set SOURCE property to a file+heading based org-mode link to the entry # Set SOURCE property to a file+heading based org-mode link to the entry
escaped_heading = n.Heading().replace("[","\[").replace("]","\]") escaped_heading = n.Heading().replace("[","\\[").replace("]","\\]")
n.properties['SOURCE'] = f'[[file:{normalize_filename(filename)}::*{escaped_heading}]]' n.properties['SOURCE'] = f'[[file:{normalize_filename(filename)}::*{escaped_heading}]]'
return nodelist return nodelist

View file

@ -32,7 +32,7 @@ class DateFilter:
return query, entries, embeddings return query, entries, embeddings
# remove date range filter from query # remove date range filter from query
query = re.sub(f'\s+{self.date_regex}', ' ', query) query = re.sub(rf'\s+{self.date_regex}', ' ', query)
query = re.sub(r'\s{2,}', ' ', query).strip() # remove multiple spaces query = re.sub(r'\s{2,}', ' ', query).strip() # remove multiple spaces
# find entries containing any dates that fall with date range specified in query # find entries containing any dates that fall with date range specified in query