Skip to content

Commit

Permalink
Merge pull request #63 from seowings/main
Browse files Browse the repository at this point in the history
Project Management & Git Support
  • Loading branch information
seowings authored Jan 7, 2024
2 parents 17dfc94 + 4e668a1 commit a6e86ff
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/staticwordpress/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_:
Expand Down
5 changes: 4 additions & 1 deletion src/staticwordpress/gui/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion src/staticwordpress/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion src/staticwordpress/gui/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion src/staticwordpress/gui/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/staticwordpress/share/_ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
._data/
_data

0 comments on commit a6e86ff

Please sign in to comment.