diff --git a/pkgs/clan-app/clan_app/__init__.py b/pkgs/clan-app/clan_app/__init__.py index a0dd3c33e..457e151c8 100644 --- a/pkgs/clan-app/clan_app/__init__.py +++ b/pkgs/clan-app/clan_app/__init__.py @@ -3,17 +3,39 @@ import sys from clan_cli.profiler import profile -from clan_app.app import MainApplication - log = logging.getLogger(__name__) -from urllib.parse import quote - +from clan_cli.custom_logger import setup_logging from clan_app.deps.webview.webview import Webview - +from pathlib import Path +import os +import argparse +from urllib.parse import quote @profile def main(argv: list[str] = sys.argv) -> int: + parser = argparse.ArgumentParser(description="Clan App") + parser.add_argument("--content-uri", type=str, help="The URI of the content to display") + parser.add_argument("--debug", action="store_true", help="Enable debug mode") + args = parser.parse_args(argv[1:]) + + if args.debug: + setup_logging(logging.DEBUG, root_log_name=__name__.split(".")[0]) + setup_logging(logging.DEBUG, root_log_name="clan_cli") + else: + setup_logging(logging.INFO, root_log_name=__name__.split(".")[0]) + + log.debug("Debug mode enabled") + + if args.content_uri: + content_uri = args.content_uri + else: + site_index: Path = Path(os.getenv("WEBUI_PATH", ".")).resolve() / "index.html" + content_uri = f"file://{site_index}" + + site_index: Path = Path(os.getenv("WEBUI_PATH", ".")).resolve() / "index.html" + content_uri = f"file://{site_index}" + html = """ @@ -21,8 +43,9 @@ def main(argv: list[str] = sys.argv) -> int: """ + webview = Webview() webview.navigate(f"data:text/html,{quote(html)}") + #webview.navigate(content_uri) webview.run() - app = MainApplication() - return app.run(argv) + diff --git a/pkgs/clan-app/clan_app/deps/webview/_webview_ffi.py b/pkgs/clan-app/clan_app/deps/webview/_webview_ffi.py index 3101b38ca..529ff1686 100644 --- a/pkgs/clan-app/clan_app/deps/webview/_webview_ffi.py +++ b/pkgs/clan-app/clan_app/deps/webview/_webview_ffi.py @@ -34,14 +34,6 @@ def _get_lib_names(): def _be_sure_libraries(): """Ensure libraries exist and return paths.""" - if getattr(sys, 'frozen', False): - if hasattr(sys, '_MEIPASS'): - base_dir = Path(sys._MEIPASS) - else: - base_dir = Path(sys.executable).parent / '_internal' - else: - base_dir = Path(__file__).parent - from ctypes.util import find_library lib_dir = os.environ.get("WEBVIEW_LIB_DIR") if not lib_dir: diff --git a/pkgs/clan-app/shell.nix b/pkgs/clan-app/shell.nix index 9f3bed655..9d91c7a3a 100644 --- a/pkgs/clan-app/shell.nix +++ b/pkgs/clan-app/shell.nix @@ -39,6 +39,7 @@ mkShell { ruff gtk4 clang + webview-wrapper.dev webview-wrapper gtk4.dev # has the demo called 'gtk4-widget-factory' libadwaita.devdoc # has the demo called 'adwaita-1-demo' diff --git a/pkgs/webview-wrapper/default.nix b/pkgs/webview-wrapper/default.nix index 3951ebf45..96d8fd2d9 100644 --- a/pkgs/webview-wrapper/default.nix +++ b/pkgs/webview-wrapper/default.nix @@ -1,4 +1,4 @@ -{ pkgs }: +{ pkgs, ... }: pkgs.stdenv.mkDerivation { pname = "webview"; @@ -22,7 +22,6 @@ pkgs.stdenv.mkDerivation { gtk4 ]; - meta = with pkgs.lib; { description = "Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows)"; homepage = "https://github.com/webview/webview";