Compare commits
No commits in common. "abedef158397e48d07422ad8982d036870c91f84" and "445abccd736780f4c1cd266985b313f3545f6c11" have entirely different histories.
abedef1583
...
445abccd73
18 changed files with 15 additions and 109 deletions
|
|
@ -11,7 +11,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
from .dav_common import webdav_check
|
from .dav_common import webdav_check
|
||||||
from .routers import v1_router
|
from .routers.v1 import router as v1_router
|
||||||
from .settings import SETTINGS
|
from .settings import SETTINGS
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ Definition of WebDAV and CalDAV clients.
|
||||||
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from os import path
|
|
||||||
from pathlib import Path
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import Any, Iterator
|
from typing import Any, Iterator
|
||||||
|
|
||||||
|
|
@ -14,7 +12,6 @@ from caldav import Principal as CalDAVPrincipal
|
||||||
from webdav3.client import Client as WebDAVclient
|
from webdav3.client import Client as WebDAVclient
|
||||||
from webdav3.client import Resource as WebDAVResource
|
from webdav3.client import Resource as WebDAVResource
|
||||||
|
|
||||||
from . import __file__ as OVD_INIT
|
|
||||||
from .async_helpers import run_in_executor
|
from .async_helpers import run_in_executor
|
||||||
from .settings import SETTINGS
|
from .settings import SETTINGS
|
||||||
|
|
||||||
|
|
@ -70,7 +67,7 @@ def webdav_check() -> None:
|
||||||
_logger.debug("WebDAV prefix directory found.")
|
_logger.debug("WebDAV prefix directory found.")
|
||||||
|
|
||||||
|
|
||||||
def webdav_ensure_path(remote_path: str) -> bool:
|
def webdav_ensure_path(remote_path: str) -> None:
|
||||||
remote_path = f"{SETTINGS.webdav_prefix}/{remote_path}"
|
remote_path = f"{SETTINGS.webdav_prefix}/{remote_path}"
|
||||||
|
|
||||||
if _WEBDAV_CLIENT.check(remote_path):
|
if _WEBDAV_CLIENT.check(remote_path):
|
||||||
|
|
@ -78,7 +75,7 @@ def webdav_ensure_path(remote_path: str) -> bool:
|
||||||
"WebDAV path %s found.",
|
"WebDAV path %s found.",
|
||||||
repr(remote_path),
|
repr(remote_path),
|
||||||
)
|
)
|
||||||
return True
|
return
|
||||||
|
|
||||||
_logger.info(
|
_logger.info(
|
||||||
"WebDAV path %s not found, creating ...",
|
"WebDAV path %s not found, creating ...",
|
||||||
|
|
@ -86,45 +83,6 @@ def webdav_ensure_path(remote_path: str) -> bool:
|
||||||
)
|
)
|
||||||
_WEBDAV_CLIENT.mkdir(remote_path)
|
_WEBDAV_CLIENT.mkdir(remote_path)
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def get_skel_path(skel_file: str) -> Path:
|
|
||||||
skel_path = path.dirname(Path(OVD_INIT).absolute())
|
|
||||||
return Path(skel_path).joinpath("skel", skel_file)
|
|
||||||
|
|
||||||
|
|
||||||
def webdav_upload_skel(remote_path: str, *skel_files: str) -> None:
|
|
||||||
remote_path = f"{SETTINGS.webdav_prefix}/{remote_path}"
|
|
||||||
|
|
||||||
for skel_file in skel_files:
|
|
||||||
_logger.debug(
|
|
||||||
"Creating WebDAV file %s ...",
|
|
||||||
repr(skel_file),
|
|
||||||
)
|
|
||||||
|
|
||||||
_WEBDAV_CLIENT.upload_file(
|
|
||||||
f"{remote_path}/{skel_file}",
|
|
||||||
get_skel_path(skel_file),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def webdav_ensure_files(remote_path: str, *file_names: str) -> None:
|
|
||||||
missing_files = (
|
|
||||||
file_name
|
|
||||||
for file_name in file_names
|
|
||||||
if not _WEBDAV_CLIENT.check(path.join(
|
|
||||||
SETTINGS.webdav_prefix,
|
|
||||||
remote_path,
|
|
||||||
file_name,
|
|
||||||
))
|
|
||||||
)
|
|
||||||
|
|
||||||
webdav_upload_skel(
|
|
||||||
remote_path,
|
|
||||||
*missing_files,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=SETTINGS.cache_size)
|
@lru_cache(maxsize=SETTINGS.cache_size)
|
||||||
def webdav_resource(remote_path: Any) -> WebDAVResource:
|
def webdav_resource(remote_path: Any) -> WebDAVResource:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
from .v1 import router as v1_router
|
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
"v1_router",
|
|
||||||
]
|
|
||||||
|
|
@ -19,3 +19,7 @@ router.include_router(file.router)
|
||||||
|
|
||||||
router.include_router(calendar.router)
|
router.include_router(calendar.router)
|
||||||
router.include_router(aggregate.router)
|
router.include_router(aggregate.router)
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"router",
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ from fastapi import APIRouter, Depends
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
from magic import Magic
|
from magic import Magic
|
||||||
|
|
||||||
from ...dav_common import webdav_ensure_files, webdav_ensure_path
|
from ...dav_common import webdav_ensure_path
|
||||||
from ...dav_file import DavFile
|
from ...dav_file import DavFile
|
||||||
from ._common import FileNameLister, PrefixFinder, PrefixUnique
|
from ._common import FileNameLister, PrefixFinder, PrefixUnique
|
||||||
|
|
||||||
|
|
@ -40,11 +40,7 @@ file_unique = PrefixUnique(file_finder)
|
||||||
async def start_router() -> None:
|
async def start_router() -> None:
|
||||||
_logger.debug(f"{router.prefix} router starting.")
|
_logger.debug(f"{router.prefix} router starting.")
|
||||||
|
|
||||||
if not webdav_ensure_path(await file_lister.remote_path):
|
webdav_ensure_path(await file_lister.remote_path)
|
||||||
webdav_ensure_files(
|
|
||||||
await file_lister.remote_path,
|
|
||||||
"logo.svg",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ from fastapi.responses import StreamingResponse
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from ...config import Config, ImageUIConfig
|
from ...config import Config, ImageUIConfig
|
||||||
from ...dav_common import webdav_ensure_files, webdav_ensure_path
|
from ...dav_common import webdav_ensure_path
|
||||||
from ...dav_file import DavFile
|
from ...dav_file import DavFile
|
||||||
from ._common import FileNameLister, PrefixFinder, PrefixUnique
|
from ._common import FileNameLister, PrefixFinder, PrefixUnique
|
||||||
|
|
||||||
|
|
@ -40,13 +40,7 @@ image_unique = PrefixUnique(image_finder)
|
||||||
async def start_router() -> None:
|
async def start_router() -> None:
|
||||||
_logger.debug(f"{router.prefix} router starting.")
|
_logger.debug(f"{router.prefix} router starting.")
|
||||||
|
|
||||||
if not webdav_ensure_path(await image_lister.remote_path):
|
webdav_ensure_path(await image_lister.remote_path)
|
||||||
webdav_ensure_files(
|
|
||||||
await image_lister.remote_path,
|
|
||||||
"img1.jpg",
|
|
||||||
"img2.jpg",
|
|
||||||
"img3.jpg",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ from typing import Iterator
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
from markdown import markdown
|
from markdown import markdown
|
||||||
|
|
||||||
from ...dav_common import webdav_ensure_files, webdav_ensure_path
|
from ...dav_common import webdav_ensure_path
|
||||||
from ...dav_file import DavFile
|
from ...dav_file import DavFile
|
||||||
from ._common import FileNameLister, PrefixFinder, PrefixUnique
|
from ._common import FileNameLister, PrefixFinder, PrefixUnique
|
||||||
|
|
||||||
|
|
@ -40,13 +40,6 @@ async def start_router() -> None:
|
||||||
|
|
||||||
webdav_ensure_path(await text_lister.remote_path)
|
webdav_ensure_path(await text_lister.remote_path)
|
||||||
|
|
||||||
webdav_ensure_files(
|
|
||||||
await text_lister.remote_path,
|
|
||||||
"message.txt",
|
|
||||||
"title.txt",
|
|
||||||
"ticker.txt",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/list",
|
"/list",
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ from fastapi import APIRouter, Depends
|
||||||
from markdown import markdown
|
from markdown import markdown
|
||||||
|
|
||||||
from ...config import Config, TickerUIConfig
|
from ...config import Config, TickerUIConfig
|
||||||
from ...dav_common import webdav_ensure_files, webdav_ensure_path
|
from ...dav_common import webdav_ensure_path
|
||||||
from ...dav_file import DavFile
|
from ...dav_file import DavFile
|
||||||
from .text import text_lister, text_unique
|
from .text import text_lister, text_unique
|
||||||
|
|
||||||
|
|
@ -28,11 +28,6 @@ async def start_router() -> None:
|
||||||
|
|
||||||
webdav_ensure_path(await text_lister.remote_path)
|
webdav_ensure_path(await text_lister.remote_path)
|
||||||
|
|
||||||
webdav_ensure_files(
|
|
||||||
await text_lister.remote_path,
|
|
||||||
"ticker.txt",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def get_ticker_lines() -> Iterator[str]:
|
async def get_ticker_lines() -> Iterator[str]:
|
||||||
cfg = await Config.get()
|
cfg = await Config.get()
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 57 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB |
|
|
@ -1,10 +0,0 @@
|
||||||
# The API is working!
|
|
||||||
|
|
||||||
## Everything seems to be set up correctly
|
|
||||||
|
|
||||||
If you're reading this text in the dashboard, your OVDashboard is set up correctly.
|
|
||||||
|
|
||||||
A few files, including message.txt have been uploaded to your WebDAV server, and this
|
|
||||||
message is already being served from there.
|
|
||||||
|
|
||||||
> Congratulations!
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
######################################################################
|
|
||||||
# OVDashboard Ticker #
|
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
|
||||||
# This is the news ticker on the dashboard's bottom. #
|
|
||||||
# #
|
|
||||||
# Format: #
|
|
||||||
# - Every line corresponds to one item in the ticker #
|
|
||||||
# - Empty lines are ignored #
|
|
||||||
# - Lines beginning with the "Comment Marker" (default: "#") are #
|
|
||||||
# ignored #
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
This is the first ticker item
|
|
||||||
|
|
||||||
This is the second ticker item, the empty line does not count
|
|
||||||
Another ticker item
|
|
||||||
# This also used to be a ticker item, but now it is inactive
|
|
||||||
And another ticker item
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
# OVDashboard Title
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
authors = ["Jörn-Michael Miehe <jmm@yavook.de>"]
|
authors = ["Jörn-Michael Miehe <jmm@yavook.de>"]
|
||||||
description = ""
|
description = ""
|
||||||
include = ["ovdashboard_api/skel/*"]
|
include = ["skel/*"]
|
||||||
name = "ovdashboard-api"
|
name = "ovdashboard-api"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
|
@ -76,7 +76,7 @@ export default class App extends Vue {
|
||||||
private image_height = 300;
|
private image_height = 300;
|
||||||
private image_contain = false;
|
private image_contain = false;
|
||||||
private image_speed = 10000;
|
private image_speed = 10000;
|
||||||
private message_html = require("@/assets/message_testdata.json");
|
private message_html = require("@/assets/lipsum.json");
|
||||||
|
|
||||||
private calendar_data: CalendarData[] = require("@/assets/calendar_testdata.json");
|
private calendar_data: CalendarData[] = require("@/assets/calendar_testdata.json");
|
||||||
private calendar_speed = 10000;
|
private calendar_speed = 10000;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue