Skip to content

Commit

Permalink
Merge pull request #42 from seowings/project
Browse files Browse the repository at this point in the history
Updated Project Settings via dialogs.
  • Loading branch information
seowings authored Oct 14, 2023
2 parents c8134ea + 4432bf9 commit ed47100
Show file tree
Hide file tree
Showing 17 changed files with 895 additions and 547 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
.vscode

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
10 changes: 6 additions & 4 deletions src/staticwordpress/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, path_: str = None) -> None:

self["wordpress"] = {"user": "", "api-token": ""}
self["github"] = {"token": "", "repository": ""}
self["redirects"] = REDIRECTS.REDIRECTION
self["redirects"] = REDIRECTS.NONE
self["sitemap"] = "sitemap_index.xml"
self["search"] = "search"
self["404"] = "404-error"
Expand Down Expand Up @@ -135,15 +135,17 @@ def is_valid(self) -> bool:
)

def has_github(self) -> bool:
return self["github"]["token"] != "" or self["github"]["repository"] != ""
return self["github"]["token"] != "" and self["github"]["repository"] != ""

def has_wordpress(self) -> bool:
return self["wordpress"]["api-token"] != "" or self["wordpress"]["user"] != ""
return self["source"]["type"] == SOURCE.CRAWL or (
self["wordpress"]["api-token"] != "" and self["wordpress"]["user"] != ""
)

def can_crawl(self) -> bool:
return all(
[
self["source"]["type"] != SOURCE.CRAWL,
self["source"]["type"] == SOURCE.CRAWL,
self["source"]["url"] != "",
self["destination"]["output"] != "",
]
Expand Down
13 changes: 11 additions & 2 deletions src/staticwordpress/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def rm_dir_tree(dir_path: str = None, delete_root: bool = False) -> None:
return

for _path in dir_path.glob("**/*"):
if _path.is_file():
if _path.is_file() and _path.stem not in [".gitignore", ".project"]:
_path.unlink()
elif _path.is_dir():
elif _path.is_dir() and _path.stem != "._data":
shutil.rmtree(_path, onerror=rmtree_permission_error)

if delete_root:
Expand Down Expand Up @@ -222,3 +222,12 @@ def extract_zip_file(zip_file_path: Path, output_location: Path) -> None:
if output_location.is_dir() and zip_file_path.exists():
with ZipFile(zip_file_path, "r") as zf:
zf.extractall(output_location)


def is_url_valid(url_: str) -> bool:
url_parsed_ = parse.urlparse(url_)

if all([url_parsed_.scheme, url_parsed_.netloc]):
return get_remote_content(url_parsed_, max_retires=1).status_code < 399

return False
6 changes: 5 additions & 1 deletion src/staticwordpress/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ def create_project(
output_folder_: str = "",
custom_404_: str = "",
custom_search_: str = "",
src_type_: SOURCE = SOURCE.CRAWL,
src_type_: SOURCE = SOURCE.ZIP,
host_type_: HOST = HOST.NETLIFY,
) -> None:
self._project.status = PROJECT.NEW

if src_type_ == SOURCE.ZIP:
self._project.redirects = REDIRECTS.REDIRECTION

self._project.name = project_name_
self._project.path = project_path_
self._project._404 = custom_404_
Expand Down
6 changes: 3 additions & 3 deletions src/staticwordpress/gui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def paintEvent(self, event: QPaintEvent) -> None:
return


class ConfigWidget(QDialog):
def __init__(self):
super(ConfigWidget, self).__init__()
class ConfigDialog(QDialog):
def __init__(self, parent=None):
super(ConfigDialog, self).__init__(parent=parent)
self.appConfigurations = QSettings(
CONFIGS["APPLICATION_NAME"], CONFIGS["APPLICATION_NAME"]
)
Expand Down
Loading

0 comments on commit ed47100

Please sign in to comment.