mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
* Add Bootstrap Extension * Rename main.yml * Artifact Upload * Fix Bootstrap Reference Error * BootstrapTreeProcessor * getiterator removed * keys function * Style Images * Update docs_build.yml * Added Meta Files * Template Get * Fix Page Ref * Update BASE_URL * Sort Schemas * Add Sitemaps * Add favicons, open-graph, and setup guide * Update Setup.md * Update .gitignore * Update Setup.md * Use _blank on external links * Restructured Docs * Fix Links * Added XML Schemas * Name XML Schemas * Improved Best Practices * Add Logs For Static Files * Make docs build happen on PR
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from abc import ABC
|
|
from pathlib import Path
|
|
|
|
|
|
class StaticItem:
|
|
|
|
extensions = ('',)
|
|
|
|
def __init__(self, path: Path):
|
|
self.in_path = path
|
|
self.out_path = Path('out/', path.relative_to('content/static/'))
|
|
self.out_path.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
def generate(self, **kwargs):
|
|
print("Building:", str(self.in_path), "->", str(self.out_path))
|
|
with self.in_path.open(mode='rb') as file:
|
|
content = file.read()
|
|
with self.out_path.open(mode='wb+') as file:
|
|
file.write(content)
|
|
|
|
|
|
class MinifiedStaticItem(StaticItem, ABC):
|
|
|
|
def __init__(self, path: Path):
|
|
super().__init__(path)
|
|
self.out_path = self.out_path.with_stem(self.out_path.stem + '.min')
|
|
|
|
def minify(self, content):
|
|
raise NotImplementedError()
|
|
|
|
def generate(self, **kwargs):
|
|
print("Building:", str(self.in_path), "->", str(self.out_path))
|
|
with self.in_path.open(mode='r') as file:
|
|
content = file.read()
|
|
with self.out_path.open(mode='w+') as file:
|
|
file.write(self.minify(content))
|