Loading Makefile +2 −1 Changes for Makefile: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,11 +13,12 @@ clean: .PHONY:clean build:locales ## construire le paquet rye run pyinstaller src/climax.py --strip --noconfirm --collect-submodules shellingham rye run pyinstaller src/climax.py --strip --noconfirm --collect-submodules shellingham --collect-submodules urllib mkdir dist/climax/_internal/climax mkdir dist/climax/_internal/climax/locales cp -r src/climax/locales/* dist/climax/_internal/climax/locales/ cp src/env dist/climax/env cp -r dist/climax/* "${HOME}/.climax/" .PHONY:build format: ## Formatage des sources avec Black Loading pyproject.toml +2 Changes for pyproject.toml: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ dependencies = [ "basexclient>=8.4.4", "beautifulsoup4>=4.12.3", "lxml>=5.3.0", "pywebcopy>=7.0.2", "lxml-html-clean>=0.2.2", ] readme = "README.md" requires-python = ">= 3.12" Loading src/climax/__main__.py +102 −26 Changes for src/climax/__main__.py: 102 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ from typing import Optional, Union from typing_extensions import Annotated import gettext from bs4 import BeautifulSoup from pywebcopy import save_website from pywebcopy.configs import default_config as pywebcopy_config locales_dir = Path(__file__).parent / "locales" gettext.bindtextdomain("messages", str(locales_dir)) Loading @@ -12,7 +14,6 @@ _ = gettext.gettext import requests import os import stat import hashlib import platform import typer Loading Loading @@ -276,7 +277,7 @@ def ensure_max_distro() -> Path: return destination_folder def ensure_new_max_directory(directory: Optional[Path]) -> Path: def ensure_available_max_directory(directory: Optional[Path]) -> tuple[Path, bool]: if not directory: directory = os.getcwd() directory = Path(directory) Loading @@ -284,12 +285,13 @@ def ensure_new_max_directory(directory: Optional[Path]) -> Path: directory.mkdir(parents=True, exist_ok=False) directory = directory.resolve() is_empty = not any(directory.iterdir()) if not is_empty: is_max = dir_is_max(directory) if not is_empty and not is_max: print( f"[red]{_("Le dossier n'est pas vide, veuillez en choisir un autre.")}[/red]" f"[red]{_("Le dossier n'est pas vide et n'est pas un projet MaX valide, veuillez en choisir un autre.")}[/red]" ) raise typer.Exit(code=1) return directory return directory, is_max app = typer.Typer( Loading @@ -297,19 +299,12 @@ app = typer.Typer( ) @app.command(help=_("Initialisation d'une instance de MaX")) def init( directory: Annotated[ Optional[Path], typer.Argument(help=_("chemin vers un dossier")) ] = os.getcwd() ): root_directory = ensure_new_max_directory(directory) ensure_java() ensure_max_distro() def _install_new_max_instance(root_directory: Path): print( "[bold]" + _("Initialisation d'une instance de MaX dans {}").format(root_directory) + _("Initialisation d'une nouvelle instance de MaX dans {}").format( root_directory ) + "[/bold]" ) config_file_path = Path(root_directory, "config.xml") Loading @@ -319,9 +314,6 @@ def init( basex_zip_destination = Path(dot_max_dir, "BaseX.zip") cached_download(BASEX_DISTRO, basex_zip_destination) unzip(basex_zip_destination, dot_max_dir) os.chmod( Path(dot_max_dir, "basex", "bin", "basexhttp"), stat.S_IEXEC | stat.S_IREAD ) saxon_zip_destination = Path( dot_max_dir, "basex", "lib", "custom", "Saxon-HE-10.8.jar" ) Loading Loading @@ -351,12 +343,65 @@ def init( Path(USER_DIR, "max", "src", "main", "bundles", "max-autoroute-bundle"), Path(dot_max_dir, "basex", "repo", "max-autoroute-bundle"), ) # TODO: assuming TEI, but shouldn't we ask first ? Or make this a mandatory argument ? shutil.copytree( Path(USER_DIR, "max", "src", "main", "bundles", "max-tei-bundle"), Path(dot_max_dir, "basex", "repo", "max-tei-bundle"), ) config = MaXProjectConfig(config_file_path) config.write() new_max_config = MaXProjectConfig(config_file_path) new_max_config.vocabulary_bundle = "max-tei-bundle" new_max_config.write() print( "[bold]" + _("La nouvelle instance de MaX est prête dans {}").format(root_directory) + "[/bold]" ) print( _( 'Vous pouvez éventuellement installer un projet de démonstration avec "climax demo".' ) ) def _sync_max_instance(root_directory: Path): print( "[bold]" + _("Initialisation de l'instance de MaX existant dans {}").format( root_directory ) + "[/bold]" ) existing_max_config = MaXProjectConfig(Path(root_directory, "config.xml")) dot_max_dir = Path(root_directory, ".max") dot_max_dir.mkdir(parents=True, exist_ok=True) basex_zip_destination = Path(dot_max_dir, "BaseX.zip") cached_download(BASEX_DISTRO, basex_zip_destination) unzip(basex_zip_destination, dot_max_dir) saxon_zip_destination = Path( dot_max_dir, "basex", "lib", "custom", "Saxon-HE-10.8.jar" ) cached_download(SAXON_DISTRO, saxon_zip_destination) os.makedirs(Path(dot_max_dir, "basex", "repo", "max"), exist_ok=True) shutil.copytree( Path(USER_DIR, "max", "src", "main"), Path(dot_max_dir, "basex", "webapp", "max"), dirs_exist_ok=True, ) shutil.copy( Path(USER_DIR, "max", "expath-pkg.xml"), Path(dot_max_dir, "basex", "repo", "max", "expath-pkg.xml"), ) shutil.copytree( Path(USER_DIR, "max", "src", "main", "core"), Path(dot_max_dir, "basex", "repo", "max", "max"), dirs_exist_ok=True, ) # # TODO: read vocabulary and bundles list in existing_max_config and install # print( "[bold]" + _("L'instance de MaX est prête dans {}").format(root_directory) Loading @@ -364,6 +409,22 @@ def init( ) @app.command(help=_("Initialisation d'une instance de MaX")) def init( directory: Annotated[ Optional[Path], typer.Argument(help=_("chemin vers un dossier")) ] = os.getcwd() ): ensure_java() ensure_max_distro() root_directory, is_max = ensure_available_max_directory(directory) if is_max: _sync_max_instance(root_directory) else: _install_new_max_instance(root_directory) @app.command( help=_("Installe une édition de démonstration dans l'instance de MaX en cours") ) Loading @@ -387,11 +448,11 @@ def demo(): shutil.copytree( Path(USER_DIR, "max", "fixtures", "autoroute"), Path(cur_dir, "autoroute") ) shutil.copy( Path(USER_DIR, "max", "fixtures", "config.xml"), Path(cur_dir, "config.xml") ) # shutil.copy( # Path(USER_DIR, "max", "fixtures", "config.xml"), Path(cur_dir, "config.xml") # ) print("[green]" + _("édition de démonstration installée") + "[/green]") print(_("Vous pouvez démarrer MaX avec la commande [bold]climax run[/bold]")) print(_("Vous pouvez démarrer MaX avec la commande [bold]climax start[/bold]")) @app.command(help=_("Arrête l'instance de MaX du dossier en cours")) Loading Loading @@ -420,7 +481,7 @@ def start( bool, typer.Option( help=_( 'Démarrer MaX en tant que service. Utiliser "climax stop" pour arrêter le service.' 'Démarrer MaX en tant que service. Utilisez "climax stop" pour arrêter le service.' ) ), ] = False, Loading Loading @@ -461,5 +522,20 @@ def config(): print(max_config()) @app.command(help=_("Fait une copie HTML statique du projet dans le dossier")) def mirror( directory: Annotated[ Optional[Path], typer.Argument(help=_("chemin vers un dossier")) ] = Path(os.getcwd(), "output") ): # start server on specific port # copy website pywebcopy_config["encoding"] = "utf-8" # save_website(url="https://www.website.tld/", project_folder="/my/folder/", project_name="project name") # stop server pass if __name__ == "__main__": app() src/env −2 Changes for src/env: 0 added lines, 2 removed lines. Original line number Diff line number Diff line #!/bin/sh # climax shell setup case ":${PATH}:" in *:"$HOME/.climax":*) ;; Loading src/server_scripts/linux_x86_install.sh +19 Changes for src/server_scripts/linux_x86_install.sh: 19 added lines, 0 removed lines. Original line number Diff line number Diff line #!/bin/sh echo "installation de climax..." echo "" installation_path="$HOME/.climax" destination_archive="$installation_path/climax.tar.gz" mkdir -p $installation_path curl -o $destination_archive https://acme.tld/climax-linux-x86.tar.gz tar -xzf $destination_archive --directory=$installation_path rm $destination_archive chmod 750 "$installation_path/climax" grep -qF ".climax/env" ~/.zprofile || echo 'source "$HOME/.climax/env"' >> ~/.zprofile grep -qF ".climax/env" ~/.profile || echo '. "$HOME/.climax/env"' >> ~/.profile echo "" echo "Installation ok." echo "" echo "Pour tester votre installation:" echo " - relancez votre shell" echo " - lancez climax --help" echo "" Loading
Makefile +2 −1 Changes for Makefile: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,11 +13,12 @@ clean: .PHONY:clean build:locales ## construire le paquet rye run pyinstaller src/climax.py --strip --noconfirm --collect-submodules shellingham rye run pyinstaller src/climax.py --strip --noconfirm --collect-submodules shellingham --collect-submodules urllib mkdir dist/climax/_internal/climax mkdir dist/climax/_internal/climax/locales cp -r src/climax/locales/* dist/climax/_internal/climax/locales/ cp src/env dist/climax/env cp -r dist/climax/* "${HOME}/.climax/" .PHONY:build format: ## Formatage des sources avec Black Loading
pyproject.toml +2 Changes for pyproject.toml: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,8 @@ dependencies = [ "basexclient>=8.4.4", "beautifulsoup4>=4.12.3", "lxml>=5.3.0", "pywebcopy>=7.0.2", "lxml-html-clean>=0.2.2", ] readme = "README.md" requires-python = ">= 3.12" Loading
src/climax/__main__.py +102 −26 Changes for src/climax/__main__.py: 102 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ from typing import Optional, Union from typing_extensions import Annotated import gettext from bs4 import BeautifulSoup from pywebcopy import save_website from pywebcopy.configs import default_config as pywebcopy_config locales_dir = Path(__file__).parent / "locales" gettext.bindtextdomain("messages", str(locales_dir)) Loading @@ -12,7 +14,6 @@ _ = gettext.gettext import requests import os import stat import hashlib import platform import typer Loading Loading @@ -276,7 +277,7 @@ def ensure_max_distro() -> Path: return destination_folder def ensure_new_max_directory(directory: Optional[Path]) -> Path: def ensure_available_max_directory(directory: Optional[Path]) -> tuple[Path, bool]: if not directory: directory = os.getcwd() directory = Path(directory) Loading @@ -284,12 +285,13 @@ def ensure_new_max_directory(directory: Optional[Path]) -> Path: directory.mkdir(parents=True, exist_ok=False) directory = directory.resolve() is_empty = not any(directory.iterdir()) if not is_empty: is_max = dir_is_max(directory) if not is_empty and not is_max: print( f"[red]{_("Le dossier n'est pas vide, veuillez en choisir un autre.")}[/red]" f"[red]{_("Le dossier n'est pas vide et n'est pas un projet MaX valide, veuillez en choisir un autre.")}[/red]" ) raise typer.Exit(code=1) return directory return directory, is_max app = typer.Typer( Loading @@ -297,19 +299,12 @@ app = typer.Typer( ) @app.command(help=_("Initialisation d'une instance de MaX")) def init( directory: Annotated[ Optional[Path], typer.Argument(help=_("chemin vers un dossier")) ] = os.getcwd() ): root_directory = ensure_new_max_directory(directory) ensure_java() ensure_max_distro() def _install_new_max_instance(root_directory: Path): print( "[bold]" + _("Initialisation d'une instance de MaX dans {}").format(root_directory) + _("Initialisation d'une nouvelle instance de MaX dans {}").format( root_directory ) + "[/bold]" ) config_file_path = Path(root_directory, "config.xml") Loading @@ -319,9 +314,6 @@ def init( basex_zip_destination = Path(dot_max_dir, "BaseX.zip") cached_download(BASEX_DISTRO, basex_zip_destination) unzip(basex_zip_destination, dot_max_dir) os.chmod( Path(dot_max_dir, "basex", "bin", "basexhttp"), stat.S_IEXEC | stat.S_IREAD ) saxon_zip_destination = Path( dot_max_dir, "basex", "lib", "custom", "Saxon-HE-10.8.jar" ) Loading Loading @@ -351,12 +343,65 @@ def init( Path(USER_DIR, "max", "src", "main", "bundles", "max-autoroute-bundle"), Path(dot_max_dir, "basex", "repo", "max-autoroute-bundle"), ) # TODO: assuming TEI, but shouldn't we ask first ? Or make this a mandatory argument ? shutil.copytree( Path(USER_DIR, "max", "src", "main", "bundles", "max-tei-bundle"), Path(dot_max_dir, "basex", "repo", "max-tei-bundle"), ) config = MaXProjectConfig(config_file_path) config.write() new_max_config = MaXProjectConfig(config_file_path) new_max_config.vocabulary_bundle = "max-tei-bundle" new_max_config.write() print( "[bold]" + _("La nouvelle instance de MaX est prête dans {}").format(root_directory) + "[/bold]" ) print( _( 'Vous pouvez éventuellement installer un projet de démonstration avec "climax demo".' ) ) def _sync_max_instance(root_directory: Path): print( "[bold]" + _("Initialisation de l'instance de MaX existant dans {}").format( root_directory ) + "[/bold]" ) existing_max_config = MaXProjectConfig(Path(root_directory, "config.xml")) dot_max_dir = Path(root_directory, ".max") dot_max_dir.mkdir(parents=True, exist_ok=True) basex_zip_destination = Path(dot_max_dir, "BaseX.zip") cached_download(BASEX_DISTRO, basex_zip_destination) unzip(basex_zip_destination, dot_max_dir) saxon_zip_destination = Path( dot_max_dir, "basex", "lib", "custom", "Saxon-HE-10.8.jar" ) cached_download(SAXON_DISTRO, saxon_zip_destination) os.makedirs(Path(dot_max_dir, "basex", "repo", "max"), exist_ok=True) shutil.copytree( Path(USER_DIR, "max", "src", "main"), Path(dot_max_dir, "basex", "webapp", "max"), dirs_exist_ok=True, ) shutil.copy( Path(USER_DIR, "max", "expath-pkg.xml"), Path(dot_max_dir, "basex", "repo", "max", "expath-pkg.xml"), ) shutil.copytree( Path(USER_DIR, "max", "src", "main", "core"), Path(dot_max_dir, "basex", "repo", "max", "max"), dirs_exist_ok=True, ) # # TODO: read vocabulary and bundles list in existing_max_config and install # print( "[bold]" + _("L'instance de MaX est prête dans {}").format(root_directory) Loading @@ -364,6 +409,22 @@ def init( ) @app.command(help=_("Initialisation d'une instance de MaX")) def init( directory: Annotated[ Optional[Path], typer.Argument(help=_("chemin vers un dossier")) ] = os.getcwd() ): ensure_java() ensure_max_distro() root_directory, is_max = ensure_available_max_directory(directory) if is_max: _sync_max_instance(root_directory) else: _install_new_max_instance(root_directory) @app.command( help=_("Installe une édition de démonstration dans l'instance de MaX en cours") ) Loading @@ -387,11 +448,11 @@ def demo(): shutil.copytree( Path(USER_DIR, "max", "fixtures", "autoroute"), Path(cur_dir, "autoroute") ) shutil.copy( Path(USER_DIR, "max", "fixtures", "config.xml"), Path(cur_dir, "config.xml") ) # shutil.copy( # Path(USER_DIR, "max", "fixtures", "config.xml"), Path(cur_dir, "config.xml") # ) print("[green]" + _("édition de démonstration installée") + "[/green]") print(_("Vous pouvez démarrer MaX avec la commande [bold]climax run[/bold]")) print(_("Vous pouvez démarrer MaX avec la commande [bold]climax start[/bold]")) @app.command(help=_("Arrête l'instance de MaX du dossier en cours")) Loading Loading @@ -420,7 +481,7 @@ def start( bool, typer.Option( help=_( 'Démarrer MaX en tant que service. Utiliser "climax stop" pour arrêter le service.' 'Démarrer MaX en tant que service. Utilisez "climax stop" pour arrêter le service.' ) ), ] = False, Loading Loading @@ -461,5 +522,20 @@ def config(): print(max_config()) @app.command(help=_("Fait une copie HTML statique du projet dans le dossier")) def mirror( directory: Annotated[ Optional[Path], typer.Argument(help=_("chemin vers un dossier")) ] = Path(os.getcwd(), "output") ): # start server on specific port # copy website pywebcopy_config["encoding"] = "utf-8" # save_website(url="https://www.website.tld/", project_folder="/my/folder/", project_name="project name") # stop server pass if __name__ == "__main__": app()
src/env −2 Changes for src/env: 0 added lines, 2 removed lines. Original line number Diff line number Diff line #!/bin/sh # climax shell setup case ":${PATH}:" in *:"$HOME/.climax":*) ;; Loading
src/server_scripts/linux_x86_install.sh +19 Changes for src/server_scripts/linux_x86_install.sh: 19 added lines, 0 removed lines. Original line number Diff line number Diff line #!/bin/sh echo "installation de climax..." echo "" installation_path="$HOME/.climax" destination_archive="$installation_path/climax.tar.gz" mkdir -p $installation_path curl -o $destination_archive https://acme.tld/climax-linux-x86.tar.gz tar -xzf $destination_archive --directory=$installation_path rm $destination_archive chmod 750 "$installation_path/climax" grep -qF ".climax/env" ~/.zprofile || echo 'source "$HOME/.climax/env"' >> ~/.zprofile grep -qF ".climax/env" ~/.profile || echo '. "$HOME/.climax/env"' >> ~/.profile echo "" echo "Installation ok." echo "" echo "Pour tester votre installation:" echo " - relancez votre shell" echo " - lancez climax --help" echo ""