webdav_prefix setting
This commit is contained in:
parent
8eeb3a61a7
commit
c074bac3c8
5 changed files with 13 additions and 8 deletions
|
@ -48,7 +48,7 @@ class Config(BaseModel):
|
|||
Load the configuration instance from the server using `TOML`.
|
||||
"""
|
||||
|
||||
dav_file = DavFile("ovdashboard/config.txt")
|
||||
dav_file = DavFile("config.txt")
|
||||
|
||||
try:
|
||||
return cls.parse_obj(
|
||||
|
|
|
@ -26,7 +26,9 @@ def webdav_resource(remote_path: Any) -> WebDAVResource:
|
|||
Gets a resource using the main WebDAV client.
|
||||
"""
|
||||
|
||||
return _WEBDAV_CLIENT.resource(remote_path)
|
||||
return _WEBDAV_CLIENT.resource(
|
||||
f"{SETTINGS.webdav_prefix}/{remote_path}"
|
||||
)
|
||||
|
||||
|
||||
@run_in_executor
|
||||
|
@ -35,7 +37,9 @@ def webdav_list(remote_path: str) -> list[str]:
|
|||
Asynchroneously lists a WebDAV path using the main WebDAV client.
|
||||
"""
|
||||
|
||||
return _WEBDAV_CLIENT.list(remote_path)
|
||||
return _WEBDAV_CLIENT.list(
|
||||
f"{SETTINGS.webdav_prefix}/{remote_path}"
|
||||
)
|
||||
|
||||
|
||||
_CALDAV_CLIENT = CalDAVclient(
|
||||
|
|
|
@ -62,11 +62,11 @@ async def get_image(
|
|||
prefix: str,
|
||||
name: str = Depends(_unique),
|
||||
) -> str:
|
||||
dav_file = DavFile(f"ovdashboard/{_lister.remote_path}/{name}")
|
||||
dav_file = DavFile(f"{_lister.remote_path}/{name}")
|
||||
img = Image.open(BytesIO(await dav_file.bytes)).convert("RGB")
|
||||
|
||||
img_buffer = BytesIO()
|
||||
img.save(img_buffer, format='JPEG', quality=85)
|
||||
img.save(img_buffer, format="JPEG", quality=85)
|
||||
img_buffer.seek(0)
|
||||
|
||||
return StreamingResponse(
|
||||
|
|
|
@ -22,7 +22,7 @@ from ._common import FileNameLister, PrefixFinder, PrefixUnique
|
|||
router = APIRouter(prefix="/text", tags=["text"])
|
||||
|
||||
_lister = FileNameLister(
|
||||
remote_path="ovdashboard/text",
|
||||
remote_path="text",
|
||||
re=re.compile(
|
||||
r"\.(txt|md)$",
|
||||
flags=re.IGNORECASE,
|
||||
|
@ -34,7 +34,7 @@ _unique = PrefixUnique(_finder)
|
|||
|
||||
|
||||
async def get_ticker_lines() -> Iterator[str]:
|
||||
ticker = await DavFile("ovdashboard/text/ticker.txt").string
|
||||
ticker = await DavFile("text/ticker.txt").string
|
||||
|
||||
return (
|
||||
line.strip()
|
||||
|
@ -104,7 +104,7 @@ async def find_texts(
|
|||
async def get_text_content(
|
||||
name: str = Depends(_unique),
|
||||
) -> str:
|
||||
return await DavFile(f"ovdashboard/{_lister.remote_path}/{name}").string
|
||||
return await DavFile(f"{_lister.remote_path}/{name}").string
|
||||
|
||||
|
||||
@router.get(
|
||||
|
|
|
@ -54,6 +54,7 @@ class Settings(BaseSettings):
|
|||
redoc_url: Optional[str] = "/redoc"
|
||||
|
||||
webdav: DavSettings = DavSettings()
|
||||
webdav_prefix: str = "/ovdashboard"
|
||||
caldav: DavSettings = DavSettings()
|
||||
|
||||
cache_seconds: int = 30
|
||||
|
|
Loading…
Reference in a new issue