RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color
For nginx:
Example nginx snippet:
location ~* \.xzmhtml$
default_type application/octet-stream;
add_header Content-Disposition 'attachment; filename=$uri';
For Apache:
json, gzip, tempfile, datetime.@dataclass class TopicNode: """ Represents a single node in the topic index tree. """ id: str title: str slug: str children: List['TopicNode'] = None index download xzmhtml fixed
def __post_init__(self):
if self.children is None:
self.children = []
class TopicIndexGenerator: """ Core logic for generating the fixed index. """
def __init__(self):
self._mock_database = self._seed_mock_data()
def _seed_mock_data(self) -> List[TopicNode]:
"""
Simulates fetching data from a database.
In a real scenario, this would query SQL or a NoSQL store.
"""
# Creating a nested hierarchy
root = TopicNode(
id="1",
title="Documentation Root",
slug="docs",
children=[
TopicNode(id="2", title="Getting Started", slug="getting-started"),
TopicNode(
id="3",
title="API Reference",
slug="api",
children=[
TopicNode(id="4", title="Authentication", slug="api-auth"),
TopicNode(id="5", title="Endpoints", slug="api-endpoints"),
]
),
TopicNode(id="6", title="FAQ", slug="faq"),
]
)
return [root]
def fetch_topics(self) -> List[Dict[str, Any]]:
"""
Converts the internal data structure to a JSON-serializable dictionary.
"""
return [asdict(node) for node in self._mock_database]
def generate_xzmhtml_payload(self) -> bytes:
"""
Creates the raw content for the .xzmhtml file.
Format Specification:
- Header: Metadata (Timestamp, Version)
- Body: Gzipped JSON of the topic tree
- Footer: Integrity Hash (simplified)
"""
print("[INFO] Fetching topic index data...")
topics_data = self.fetch_topics()
# Metadata
metadata =
"generated_at": datetime.utcnow().isoformat(),
"version": "1.0.0-fixed",
"type": "xzmhtml-index"
# Combine metadata and data
full_payload =
"meta": metadata,
"index": topics_data
# Convert to JSON string
json_str = json.dumps(full_payload, indent=2)
# 'Fixed' logic: Gzip compression to ensure portability
print("[INFO] Compressing payload...")
return gzip.compress(json_str.encode('utf-8'))
def save_to_disk(self, filename: str = "index.xzmhtml") -> str:
"""
Generates the file and saves it to a temporary location.
Returns the file path.
"""
payload = self.generate_xzmhtml_payload()
# Create a temp file that persists long enough for download
temp_dir = tempfile.gettempdir()
file_path = os.path.join(temp_dir, filename)
with open(file_path, 'wb') as f:
f.write(payload)
print(f"[SUCCESS] Fixed index generated at: file_path")
return file_path
Chrome ignores MIME fixes easily. Use "Simple Modify Headers" or "Header Editor": The Ultimate Guide: How to Get "Index Download
Content-Typetext/html to application/octet-stream only for URLs matching *.xzm.This intercepts the server’s mistake and fixes it locally.
Add --no-check-certificate to wget or -k to curl only for trusted internal repos. Correct MIME type and force download
If the issue is with a specific package: