Spaces:
Running
Running
File size: 2,469 Bytes
1517f5f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# Hugging Face Space — Staticize Kit
This kit converts a PHP-based Space into a **static** Space (HTML/CSS/JS), ready to upload.
## What this does
- Converts every `*.html` into `*.html` (same relative paths)
- Strips PHP code blocks `<?php ... ?>`
- Rewrites internal links from `.html` → `.html` across HTML/CSS/JS/MD
- Ensures an `index.html` exists at repo root
- Provides a tiny JS include system to replace PHP includes
## Quick start
1. **Clone your Space locally**
```bash
git clone https://huggingface.co/spaces/oldmonk69/gemini-ui-redesign
cd gemini-ui-redesign
git checkout -b staticize
```
2. **Download and unpack this kit into the repo root**
- Place the contents of this folder into the repo root (you should see `convert.sh` at the same level as your existing files).
3. **Run the converter**
```bash
bash convert.sh
```
4. **Verify locally**
- Open the generated `.html` files in a browser (use a simple local server to avoid CORS issues):
```bash
python3 -m http.server 5173
# then visit http://localhost:5173/
```
5. **Commit and push**
```bash
git add -A
git commit -m "Staticize Space: convert PHP to HTML, update links"
git push -u origin staticize
```
6. **Switch Space runtime to Static** (if not already)
- In your Space: **Settings → Runtime → Static**
- Ensure the repo root has **index.html**
7. **Restart Space** to rebuild.
## Includes-based layout (optional)
This kit ships `asset/include.js` and two partials:
- `asset/partials/header.html`
- `asset/partials/footer.html`
To use them in your pages:
```html
<script src="/asset/include.js" defer></script>
<div id="site-header"></div>
<!-- page-specific content -->
<div id="site-footer"></div>
```
Edit the partials once and every page will pick them up at runtime.
## Notes & caveats
- If your PHP *echoed* dynamic HTML (templating), that content won’t exist after stripping. Copy the intended HTML into the new `.html` files manually (the script keeps a `_backup_php/` folder for reference).
- If you used server-side logic (forms, mailers, DB), you must replace it with client-side logic or move to a **Docker Space** running PHP.
- Relative paths: when in doubt, use root-relative paths like `/asset/...` so links behave on every page.
## Rollback
Everything original is backed up under `_backup_php/`. To undo, just reset your branch:
```bash
git reset --hard HEAD~1
git clean -fd
```
|