diff --git a/src/staticwordpress/core/utils.py b/src/staticwordpress/core/utils.py index 53960e5..7d9dc9e 100644 --- a/src/staticwordpress/core/utils.py +++ b/src/staticwordpress/core/utils.py @@ -128,7 +128,7 @@ def rm_dir_tree(dir_path_: str = None, delete_root_: bool = False) -> None: for _path in dir_path_.glob("**/*"): if _path.is_file() and _path.stem not in [".gitignore", ".project"]: _path.unlink() - elif _path.is_dir() and _path.stem != "._data": + elif _path.is_dir() and _path.stem != "_data": shutil.rmtree(_path, onerror=rmtree_permission_error) if delete_root_: diff --git a/src/staticwordpress/gui/logger.py b/src/staticwordpress/gui/logger.py index 94b510f..aaaaecd 100644 --- a/src/staticwordpress/gui/logger.py +++ b/src/staticwordpress/gui/logger.py @@ -57,4 +57,7 @@ def __init__(self, parent): self.append_text_message.connect(self.plaintext_edit.appendPlainText) def emit(self, msg): - self.append_text_message.emit(self.format(msg)) + try: + self.append_text_message.emit(self.format(msg)) + except: + pass # TODO: raise exception if append_text_message is not available diff --git a/src/staticwordpress/gui/main.py b/src/staticwordpress/gui/main.py index 068eb06..8e26ac7 100644 --- a/src/staticwordpress/gui/main.py +++ b/src/staticwordpress/gui/main.py @@ -478,10 +478,17 @@ def open_project(self): QFileDialog.ShowDirsOnly, ) - project_path = Path(f"{project_folder}/._data/.project.json") + project_path = Path(f"{project_folder}/_data/.project.json") if project_path.exists(): self._project.open(project_path) + + if Path(self._project.output).is_dir(): + src = Path(f"{SHARE_FOLDER_PATH}/_ignore") + dst = Path(f"{self._project.output}/.gitignore") + if src.exists(): + shutil.copyfile(src, dst) + if self._project.is_open(): project_dialog = SWProjectDialog( parent=self, project_=self._project, title_="Project Properties" diff --git a/src/staticwordpress/gui/project.py b/src/staticwordpress/gui/project.py index 533ef8c..993ee4f 100644 --- a/src/staticwordpress/gui/project.py +++ b/src/staticwordpress/gui/project.py @@ -490,7 +490,7 @@ def accept(self) -> None: self._project.create() self._project.output = Path(self.lineedit_output.text()) - self._project.path = Path(f"{self._project.output}/._data/.project.json") + self._project.path = Path(f"{self._project.output}/_data/.project.json") self._project.name = self.lineedit_project_name.text() self._project.src_url = self.lineedit_src_url.text() self._project.sitemap = self.lineedit_sitemap.text() @@ -514,6 +514,13 @@ def accept(self) -> None: self._project.exclude = self.textedit_exclude_patterns.toPlainText().split( "\n" ) + + # Create _data folder + import os + + os.makedirs(Path(f"{self._project.output}/_data/"), exist_ok=True) + + self._project.save() return super().accept() else: logging.info(f"Current Project Settings are not valid.") diff --git a/src/staticwordpress/gui/workflow.py b/src/staticwordpress/gui/workflow.py index 12dcbf8..4fe0327 100644 --- a/src/staticwordpress/gui/workflow.py +++ b/src/staticwordpress/gui/workflow.py @@ -214,7 +214,7 @@ def delete_github_repositoy(self): @logging_decorator def init_git_repositoy(self): self._work_flow.init_git_repositoy() - self.emit_sitemap_location.emit("Initalized Static Website", 100) + self.emit_progress.emit("Initalized Static Website", 100) @logging_decorator def commit_git_repositoy(self): diff --git a/src/staticwordpress/share/_ignore b/src/staticwordpress/share/_ignore index e0b03fb..c419d97 100644 --- a/src/staticwordpress/share/_ignore +++ b/src/staticwordpress/share/_ignore @@ -1 +1 @@ -._data/ \ No newline at end of file +_data \ No newline at end of file