diff --git a/api/ovdashboard_api/routers/text.py b/api/ovdashboard_api/routers/text.py index 58c92c3..9cddbb8 100644 --- a/api/ovdashboard_api/routers/text.py +++ b/api/ovdashboard_api/routers/text.py @@ -3,7 +3,10 @@ Router "text" provides: - listing text files - finding text files by name prefix -- getting image file content as converted Markdown by name prefix +- getting text file raw content by name prefix +- getting text file HTML content by name prefix (using Markdown) +- getting the "ticker" raw content +- getting the "ticker" HTML content (using Markdown) """ import re @@ -50,7 +53,6 @@ async def get_ticker_content_lines( ) -@router.get("/get/ticker") async def get_ticker_content( ticker_content_lines: Iterator[str] = Depends(get_ticker_content_lines), ) -> str: @@ -58,9 +60,21 @@ async def get_ticker_content( ticker_content_lines = ["", *ticker_content_lines, ""] ticker_content = cfg.ticker_separator.join(ticker_content_lines) - return markdown( - ticker_content.strip() - ) + return ticker_content.strip() + + +@ router.get("/get/html/ticker") +async def get_ticker( + ticker_content: str = Depends(get_ticker_content), +) -> str: + return markdown(ticker_content) + + +@ router.get("/get/raw/ticker") +async def get_raw_ticker( + ticker_content: str = Depends(get_ticker_content), +) -> str: + return ticker_content @router.get( @@ -85,16 +99,29 @@ async def find_texts( return list(names) +async def get_text_content( + name: str = Depends(_unique), +) -> str: + return await DavFile(f"{_lister.remote_path}/{name}").string + + @router.get( - "/get/{prefix}", + "/get/html/{prefix}", response_model=str, responses=_unique.responses, ) async def get_text( - name: str = Depends(_unique), + text: str = Depends(get_text_content), ) -> str: - text = await DavFile(f"{_lister.remote_path}/{name}").string + return markdown(text) - return markdown( - text - ) + +@router.get( + "/get/raw/{prefix}", + response_model=str, + responses=_unique.responses, +) +async def get_raw_text( + text: str = Depends(get_text_content), +) -> str: + return text