From daa127905fddcad42689d88e7d1bab7ef9dc48d0 Mon Sep 17 00:00:00 2001 From: Faisal Shahzad <84210709+seowings@users.noreply.github.com> Date: Sun, 22 Oct 2023 22:24:41 +0200 Subject: [PATCH] update project documentation --- docs/core-project.md | 3 ++ docs/index.md | 53 +++++++++++++-------------- mkdocs.yml | 2 + src/staticwordpress/gui/mainwindow.py | 18 +++++++-- src/staticwordpress/gui/project.py | 18 +++++++-- 5 files changed, 61 insertions(+), 33 deletions(-) create mode 100644 docs/core-project.md diff --git a/docs/core-project.md b/docs/core-project.md new file mode 100644 index 0000000..f17105f --- /dev/null +++ b/docs/core-project.md @@ -0,0 +1,3 @@ +# Project Class + +::: staticwordpress.core.project.Project \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index abf3c8f..2278269 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,14 +1,20 @@ -# staticwordpress +# static-wordpress Python Package for Converting WordPress Installation to a Static Website. +[![build_Tests](https://github.com/serpwings/static-wordpress/actions/workflows/tests.yml/badge.svg)](https://github.com/serpwings/static-wordpress/actions/workflows/tests.yml) +[![license](https://img.shields.io/pypi/l/staticwordpress.svg?style=flat-square "Project License: GPLv3+")](https://github.com/pleiszenburg/staticwordpress/blob/master/LICENSE) +[![status](https://img.shields.io/pypi/status/staticwordpress.svg?style=flat-square "Project Development Status")](https://github.com/pleiszenburg/staticwordpress/milestone/1) +[![pypi_version](https://img.shields.io/pypi/v/staticwordpress.svg?style=flat-square "Available on PyPi - the Python Package Index")](https://pypi.python.org/pypi/staticwordpress) +[![supported_python_versions](https://img.shields.io/pypi/pyversions/staticwordpress.svg?style=flat-square "Supported Python Version")](https://pypi.python.org/pypi/staticwordpress) -## How to Install staticwordpress? +## How to Install static-wordpress? ### Windows Installer We provide an ``exe`` file of ``staticwordpress`` for the convenice of users. Please download the latest version from [release section](https://github.com/serpwings/static-wordpress/releases). + ### Source Code - Clone or download this repository to your computer. @@ -23,9 +29,18 @@ This package is available at ``pypi`` and you can install it with ``pip install Once installed, you can implement customized workflows. Here is an example of post processing simply-static-zip file. ```python +import logging + from staticwordpress.core.workflow import Workflow from staticwordpress.core.constants import SOURCE, HOST +# enable logging for all functions. +logging.basicConfig( + format="%(asctime)s - %(levelname)s - %(message)s", + level=logging.DEBUG, + stream=sys.stdout, +) + swp = Workflow() swp.create_project( project_name_="simply-static-zip-deploy", @@ -33,8 +48,8 @@ swp.create_project( wp_api_token_=env_wp_api_token, # wordpress xml api token src_url_=env_src_url, # source url where WordPress is hosted dst_url_=env_dst_url, # destination url where you want to host Static version - output_folder_=env_output, # Output folder location, where all post processed files will be saved - src_type_=SOURCE.ZIP, # Data Source, ZIP works perfectly right with Simply Static WordPress Plugin + output_folder_=env_output, # Output folder location, where processed files will be saved + src_type_=SOURCE.ZIP, # Data Source e.g. ZIP file from Simply Static WordPress Plugin host_type_=HOST.NETLIFY, # Host, where you want to deplyo your website. ) @@ -48,32 +63,16 @@ swp.add_search() ## Documentation -Detailed documentation of all features is available at [staticwordpress documentation](https://serpwings.com/static-wordpress/). - -## TODO: - -Following tasks need attention. This list is without any priority. - -- Base Package - - Translations - - Redirects - - Vercel - - Cloudflare Pages - - others. - - 3rd Party Crawlers - - Process Folder data e.g. Simply Static - - Search - - Use Builint Interace - - Results for paramterized urls -- Dcoumentation -- GUI - - Recent Projects - - Improve Progressbar - +Detailed documentation of all features is available at [staticwordpress documentation](https://static-wordpress-docs.netlify.app/). + ## Contribute Pull Requests, Feature Suggestions, and collaborations are welcome. +## ICONS + +Icons used in this project are obtained from Google [Fonts Material Symbols](https://fonts.google.com/icons?selected=Material+Symbols+Outlined:search:FILL@0;wght@400;GRAD@0;opsz@24) + ## About Us -This work is a collaborative effort of [seowings](https://www.seowings.org/), and [serpwings](https://serpwings.com/). \ No newline at end of file +This work is a collaborative effort of [seowings](https://www.seowings.org/), and [serpwings](https://serpwings.com/). diff --git a/mkdocs.yml b/mkdocs.yml index 52c5b40..1a46866 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,6 +10,8 @@ edit_uri: blob/main/docs/ nav: - Home: index.md - Tutorial: tutorial.md + - Core: + - Project Class: core-project.md plugins: - search diff --git a/src/staticwordpress/gui/mainwindow.py b/src/staticwordpress/gui/mainwindow.py index 499900b..db733f0 100644 --- a/src/staticwordpress/gui/mainwindow.py +++ b/src/staticwordpress/gui/mainwindow.py @@ -422,9 +422,21 @@ def show_project(self): pdialog = ProjectDialog(self, self._project, title_="Current Project") if pdialog.exec_(): self._project = pdialog._project - - self._project.save() - self.update_widgets() + self._project.save() + self.update_widgets() + else: + msgBox = QMessageBox(parent=self) + msgBox.setText(f"No Project Available.") + msgBox.addButton(QMessageBox.Ok).setIcon( + QIcon(f"{SHARE_FOLDER_PATH}/icons/ok.svg") + ) + msgBox.setWindowIcon( + QIcon(f"{SHARE_FOLDER_PATH}/icons/static-wordpress.svg") + ) + msgBox.setTextFormat(Qt.RichText) + msgBox.setWindowTitle("Project Settings") + msgBox.exec() + logging.info("No New Project found.") @is_project_open @logging_decorator diff --git a/src/staticwordpress/gui/project.py b/src/staticwordpress/gui/project.py index 5afdffe..958238e 100644 --- a/src/staticwordpress/gui/project.py +++ b/src/staticwordpress/gui/project.py @@ -22,6 +22,7 @@ specific language governing rights and limitations under the License. """ + # +++++++++++++++++++++++++++++++++++++++++++++++++++++ # STANDARD LIBARY IMPORTS # +++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -52,7 +53,6 @@ QMessageBox, QFileDialog, QPushButton, - QAction, ) from PyQt5.QtCore import Qt, QSettings, QSize, QThread from PyQt5.QtGui import QIcon @@ -70,6 +70,7 @@ HOST, ) +from ..core.project import Project from ..core.utils import is_url_valid from ..gui.workflow import WorkflowGUI @@ -85,10 +86,10 @@ def __init__(self, parent, project_, title_="Project Settings"): CONFIGS["APPLICATION_NAME"], CONFIGS["APPLICATION_NAME"] ) + self._project = project_ self._bg_thread = QThread(parent=self) self._bg_worker = WorkflowGUI() - self._project = project_ vertical_layout_project = QVBoxLayout() groupbox_general_settings = QGroupBox("General Settings") form_layout_general_settings = QFormLayout() @@ -458,7 +459,16 @@ def accept(self) -> None: Path(self.lineedit_output.text()).is_dir(), ] ): - self._project.create() + logging.info(f"Current Project: {self.lineedit_output.text()} is valid") + logging.info(f"Current Url: {self.lineedit_src_url.text()} is valid") + logging.info( + f"Current Project Path: {self.lineedit_output.text()} is valid" + ) + + if not self._project.is_open(): + self._project = Project() + self._project.create() + self._project.output = Path(self.lineedit_output.text()) self._project.path = Path(f"{self._project.output}/._data/.project.json") self._project.name = self.lineedit_project_name.text() @@ -486,6 +496,8 @@ def accept(self) -> None: ) return super().accept() else: + logging.info(f"Current Project Settings are not valid.") + msgBox = QMessageBox(parent=self) msgBox.setText( "Cannot start this project.
Please check project settings."