diff --git a/.gitignore b/.gitignore
index bb91773..3cb2889 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,6 @@ __pycache__/
PDS
.DS_Store
+/styles/00 archive/
+00 archive/
+.idea/
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..bb133c6
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,190 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/ "null"), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html "null").
+
+## \[2.5.0\] - 2025-11-22
+
+Introduction of the "Architecture Sandbox" for offline restructuring.
+
+### Added
+
+- **Architecture Sandbox:** Introduced `create_editor.py` and `patch_sidebar.py`. Users can now generate a visual Drag & Drop editor (`editor_sidebar.html`) to restructure the exported documentation offline and apply changes massively using the patcher.
+
+- **Robust Editor Generation:** The editor generator now uses a safe string concatenation approach to avoid syntax errors and supports creating a working copy of the sidebar structure (`sidebar_edit.md`).
+
+
+### Changed
+
+- **CSS Strategy:** Refined the "Two-Layer" styling approach (Standard + Custom) to be more robust in the documentation and implementation.
+
+
+## \[2.4.1\] - 2025-11-21
+
+UI/UX Improvements and Bug Fixes.
+
+### Added
+
+- **Metadata Injection:** Page Title, Author, and Modification Date are now injected directly into the HTML Body (top of the page) for better readability.
+
+- **Automatic Time-stamping:** Output folders are now automatically named with `YYYY-MM-DD HHMM [Title]` to support clean versioned backups.
+
+- **Persistent Sidebar:** The sidebar width is now remembered across page loads using `localStorage`.
+
+- **Absolute Links in Markdown:** The generated `sidebar.md` uses absolute file URIs to support opening links in external editors like Logseq or WebStorm directly.
+
+
+### Fixed
+
+- **Empty Page Bug:** Fixed an issue where pages with empty bodies (folders) resulted in 0-byte HTML files. Now generates a proper HTML skeleton with title and sidebar.
+
+- **Markdown Patching:** Updated `patch_sidebar.py` to handle absolute file URIs correctly.
+
+- **UI Layout:** Optimized Sidebar/Content padding and Hamburger button alignment.
+
+
+## \[2.4.0\] - 2025-11-21
+
+Advanced Filtering and Tree Logic Update.
+
+### Added
+
+- **Label Forest Mode:** The `label` command now supports deep recursion ("Forest Export"). It finds all pages with the include-label and treats them as roots for full tree exports.
+
+- **Label Pruning:** Added `--exclude-label` to prune subtrees based on a specific label (e.g., 'archived') during recursion.
+
+
+## \[2.3.0\] - 2025-11-21
+
+Enterprise Performance & Usability Release.
+
+### Added
+
+- **Recursive Inventory:** Changed scanning logic to use `/child/page` API endpoints. This ensures the export respects the **manual sort order** of Confluence.
+
+- **Multithreading:** Added `-t/--threads` argument to parallelize page downloads (Phase 2), significantly improving performance on large spaces.
+
+- **Tree Pruning (ID):** Added `--exclude-page-id` to skip specific branches during recursion.
+
+- **JS Resizer:** The sidebar now has a robust JavaScript-based drag-handle for resizing.
+
+- **UX Improvements:**
+
+ - Fixed Hamburger position (top-left).
+
+ - Added "Heartbeat" visualization during inventory scan.
+
+ - Added VPN Reminder for Data Center profiles.
+
+
+### Changed
+
+- **Architecture:** Split process into a strict "Inventory Phase" (Serial, Recursive for sorting) and "Download Phase" (Parallel).
+
+
+## \[2.2.0\] - 2025-11-20
+
+Introduction of Static Sidebar Injection.
+
+### Added
+
+- **Static Sidebar Injection:** Automatically generates a hierarchical navigation tree and injects it into every HTML page.
+
+- **Inventory Phase:** Scans all pages/metadata _before_ downloading content to allow for accurate progress bars (`tqdm`) and global tree generation.
+
+- **Smart Linking:** Improved detection of dead/external links vs. local links based on the inventory.
+
+- **CSS Auto-Discovery:** The script automatically detects and applies `site.css` from the local `styles/` folder.
+
+- **Multi-CSS Support:** Allows layering multiple CSS files (Standard + Custom).
+
+- **`sidebar.html` Export:** Saves the generated sidebar tree as a separate file.
+
+
+### Changed
+
+- **HTML Layout:** Pages are now wrapped in a Flexbox layout container to support the sidebar.
+
+- **Logging:** Cleaned up library logging to support progress bars.
+
+
+## \[2.1.0\] - 2025-11-19
+
+Major functionality restore and improvement ("Visual Copy" release).
+
+### Added
+
+- **HTML Processing with BeautifulSoup:** Re-introduced intelligent HTML parsing.
+
+ - **Image Downloading:** Automatically detects embedded images/emoticons, downloads them, and rewrites HTML links to local paths (`../attachments/`).
+
+ - **Link Sanitizing:** Attempts to rewrite Confluence internal links to relative filenames.
+
+ - **Metadata Injection (Head):** Injects Title, Page ID, and Labels into the HTML `
`.
+
+- **Export View:** Switched API fetch from `storage` format to `export_view` (or `view`) to get rendered HTML (resolves macros like TOC).
+
+- **Attachment Downloading:** Downloads _all_ attachments of a page via API list, not just those embedded in the text.
+
+
+### Changed
+
+- **HTML First:** The primary output format is now processed HTML (`export_view`). RST export is optional via `-R`.
+
+- **Dependencies:** Added `beautifulsoup4` to requirements.
+
+- **CSS handling:** Improved relative pathing for robust offline viewing.
+
+
+## \[2.0.0\] - 2025-11-17
+
+This version introduces a major architectural refactoring to support both Confluence Cloud and Data Center.
+
+### Added
+
+- **Confluence Data Center Support:** The script now supports both Confluence Cloud (`--profile cloud`) and Data Center (`--profile dc`).
+
+- **Configuration File (`confluence_products.ini`):** All platform-specific values (API URL templates, auth methods, base paths) are now defined in this external INI file.
+
+- **Data Center Authentication:** Added support for Bearer Token (Personal Access Token) authentication.
+
+- **New `label` Command:** Added support for dumping all pages with a specific label.
+
+- **Troubleshooting Hints:** Added specific error messages for Data Center users when authentication fails (Intranet/VPN warning).
+
+- **Documentation:** Added `CONTRIBUTING.md` and `CHANGELOG.md`.
+
+
+### Changed
+
+- **\[BREAKING CHANGE\] CLI Architecture (Sub-Commands):** The script's interface has been completely modernized, replacing the `-m`/`--mode` flag with sub-commands (like `git`).
+
+ - **REMOVED:** The `-m`/`--mode` flag.
+
+ - **REMOVED:** The `-s`/`--site` argument.
+
+ - **ADDED:** Sub-commands: `single`, `tree`, `space`, `all-spaces`, `label`.
+
+ - **ADDED (Global):** `--base-url`, `--profile`, `--context-path`.
+
+- **Refactored `myModules.py`:** All API functions are now platform-agnostic. Hardcoded URLs removed.
+
+- **Internationalization:** All code comments translated to English.
+
+
+_History below this line is from the original author (jgoldin-skillz)._
+
+## \[1.0.2\] - 2022-03-03
+
+- Bugfixes
+
+
+## \[1.0.1\] - 2022-03-03
+
+- Added `confluenceDumpWithPython.py`
+
+
+## \[1.0.0\] - 2022-03-01
+
+- Initial version
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..c854a43
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,60 @@
+# Contributing Guide
+
+This document explains the internal architecture of this script, primarily for future contributors or the original author when reviewing pull requests.
+
+## Architectural Overview
+
+The codebase has been refactored from a simple linear scraper to a multi-phase, multithreaded export engine designed for enterprise stability.
+
+### Core Philosophy
+
+- **Inventory First:** We scan the entire structure _before_ downloading content. This allows for accurate progress bars (`tqdm`) and correct sorting.
+
+- **Static & Self-Contained:** The output HTML must work without a server, internet connection, or JavaScript dependencies (Zero-Dependency).
+
+- **Platform Agnostic:** `confluence_products.ini` abstracts the differences between Cloud and Data Center.
+
+
+### The Export Pipeline (`confluenceDumpWithPython.py`)
+
+1. **Inventory Phase (Serial):**
+
+ - Uses recursion (e.g., `recursive_scan`) to walk the Confluence tree using `child/page` endpoints.
+
+ - This guarantees the sidebar matches the _manual sort order_ of Confluence (unlike CQL search).
+
+ - Applies pruning (excludes) at this stage to save time.
+
+ - Generates `sidebar.md` (Markdown representation) and `sidebar.html` (HTML Tree).
+
+2. **Download Phase (Parallel):**
+
+ - Uses `ThreadPoolExecutor` to fetch `export_view` HTML and attachments in parallel.
+
+ - Calls `myModules.process_page_content` to sanitize HTML (BeautifulSoup).
+
+3. **Injection Phase:**
+
+ - Injects the pre-calculated Sidebar, Metadata, and CSS into every downloaded page.
+
+
+### The Editor Workflow (`create_editor.py` & `patch_sidebar.py`)
+
+We treat the exported structure as mutable.
+
+- **`create_editor.py`**: Parses the `sidebar.md` and generates a standalone HTML Single-Page-Application using vanilla JavaScript. It allows Drag & Drop reordering.
+
+- **`patch_sidebar.py`**: Parses the modified Markdown and re-injects the new navigation tree into all existing HTML files.
+
+
+## Key Files
+
+- **`confluenceDumpWithPython.py`**: Main entry point and orchestration.
+
+- **`myModules.py`**: API abstraction, BeautifulSoup logic, and HTML templating.
+
+- **`confluence_products.ini`**: URL templates for Cloud vs. DC.
+
+- **`create_editor.py`**: Tool to generate the visual sidebar editor.
+
+- **`patch_sidebar.py`**: Tool to apply structure changes.
\ No newline at end of file
diff --git a/README.md b/README.md
index 207040a..369ad17 100644
--- a/README.md
+++ b/README.md
@@ -1,142 +1,181 @@
-# Confluence Dump With Python
-
-Dump Confluence pages using Python (requests) in HTML and RST format, including embedded pictures and attachments.
-References to downloaded files will be updated to their local relative path.
-
-## Description
-
-Nonetheless, the refactoring will require only 2 files and accept command-line args:
-* `myModules.py`: Contains all the required functions.
-* `confluenceDumpWithPython.py`: Script to use with the following command line args:
- * `-m, --mode`: The export mode, `single`, `space`, `bylabel`, `pageprops` (required).
- * Note: Only `single`, `pageprops` and `space` have been implemented so far.
- * `-S, --site`: The Atlassian Site (required).
- * `-s, --space`: The Space Key (if needed).
- * `-p, --page`: The Page ID (if needed).
- * `-l, --label`: The Page label (if needed).
- * `-x, --sphinx`: The `_images` and `_static` folders are placed at the root of the export folder, instead of together with the exported HTML files.
- * `--notags`: Does not add the tags directives to the rst files (when the `sphinx-tags` addon is not used).
-* `updatePageLinks.py`: Update online confluence links to the local files that have been downloaded so far.
- * `--folder`: Folder containing the files to update.
- * `--test`: Instead of overwriting the original .rst files, it will create updated ones with `zout_` as a prefix.
-* `getPageEditorVersion.py`: Get the editor version from single pages or all pages in a space.
- * `--site`: The Atlassian Site (required).
- * `--page`: Page ID (either/or)
- * `--space`: Space Key (either/or)
-
-For CSS Styling, it uses the `confluence.css` from Confluence that can be obtained by using the Workaround described in: https://jira.atlassian.com/browse/CONFSERVER-40907.
-The `site.css` file included with Confluence UI HTML exports is not as complete as the one above.
-
-### Folder and file structure:
-
-* The default output folder is `output/` under the same path as the script.
-* A folder with the Space name, Page Properties report page, single page name or Page Label name will be created under the output folder.
-* By default, the `_images/` and `_static/` folders will be placed in the page|space|pageprops|label folder.
- * The `--sphinx` command line option will put those folder directly under the output folder
-* The file `styles/confluence.css` will be copied into the defined `_static/`
-
-## What it does
-
-* Leverages the Confluence Cloud API
-* Puts Confluence meta data like Page ID and Page Labels, in the HTML headers and RST fields.
-* beautifulsoup is used to parse HTML to get and update content, ie. change remote links to local links.
-* Download for every page, all attachments, emoticons and embedded files.
+# Confluence Dump with Python
-## Requirements
-
-* declare system variables:
- * `atlassianAPIToken`
- * `atlassianUserEmail`
-
-### Dependencies
-
-* python3
- * requests
- * beautifulsoup4
- * Pillow (handle images)
- * pandoc & pypandoc (convert to RST)
- * re
-
-### Installing
-
-* Clone repo.
-* Install dependencies.
-* Declare system variables for Atlassian API Token.
+This script exports content from a Confluence instance (Cloud or Data Center) using various modes.
-### Executing program
+**Key Features:**
+- **Visual Fidelity & Sidebar:** Creates a visually faithful copy of Confluence pages, including a **fully functional, static navigation sidebar** on the left—something even the standard Confluence export does not provide.
+
+- **Offline Browsing:** Localizes images and links, and downloads **all** attachments (PDFs, Office docs, etc.) for complete offline access.
+
+- **Recursive Inventory:** Scans the tree hierarchy to ensure the **correct sort order** (manual Confluence order) in the sidebar.
+
+- **Metadata Injection:** Automatically adds Page Title, Author, and Modification Date to the top of every page.
+
+- **Versioning:** Automatically creates timestamped output subfolders (e.g., `2025-11-21 1400 Space IT`) for clean history management. This allows you to run the script repeatedly (e.g., after changes in Confluence) and maintain a history of snapshots without overwriting previous exports.
+
+- **Performance:** Supports **Multithreaded** downloading (`--threads`) to speed up the export of large spaces.
+
+- **Tree Pruning:** Exclude specific branches with `--exclude-page-id` or `--exclude-label`.
+
+- **Index Sandbox:** Includes visual tools to manually restructure the navigation tree via Drag & Drop and apply it to the downloaded files without affecting Confluence.
+
-* How to download a single page based on its ID.
+## Platform Support
-```
-confluenceDumpWithPython.py -m single -S -p [