Simplify www setup: symlink instead of two copies
/home/claude/www is now a symlink to the repo's www/ directory. update-costs.sh writes to a single path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
728f7784d1
commit
1c35751095
1 changed files with 9 additions and 11 deletions
|
|
@ -23,7 +23,7 @@ python3 << 'PYEOF'
|
||||||
import json, re, sys
|
import json, re, sys
|
||||||
|
|
||||||
IMPACT_LOG = "/home/claude/claude-dir/.claude/impact/impact-log.jsonl"
|
IMPACT_LOG = "/home/claude/claude-dir/.claude/impact/impact-log.jsonl"
|
||||||
PAGES = ["/home/claude/www/index.html", "/home/claude/claude-dir/www/index.html"]
|
LANDING_PAGE = "/home/claude/claude-dir/www/index.html"
|
||||||
|
|
||||||
# Read all entries, keep latest per session
|
# Read all entries, keep latest per session
|
||||||
sessions = {}
|
sessions = {}
|
||||||
|
|
@ -73,17 +73,15 @@ new_para = (
|
||||||
f" </div>"
|
f" </div>"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Read and replace in all landing page copies
|
# Read and replace
|
||||||
pattern = r"How this was made:</strong>.*?</div>"
|
with open(LANDING_PAGE) as f:
|
||||||
for page in PAGES:
|
|
||||||
try:
|
|
||||||
with open(page) as f:
|
|
||||||
html = f.read()
|
html = f.read()
|
||||||
new_html = re.sub(pattern, new_para, html, flags=re.DOTALL)
|
|
||||||
with open(page, "w") as f:
|
pattern = r"How this was made:</strong>.*?</div>"
|
||||||
|
new_html = re.sub(pattern, new_para, html, flags=re.DOTALL)
|
||||||
|
|
||||||
|
with open(LANDING_PAGE, "w") as f:
|
||||||
f.write(new_html)
|
f.write(new_html)
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
print(f"Updated: {n} {session_word}, {total_energy} Wh, {total_co2}g CO2, {cost_display}")
|
print(f"Updated: {n} {session_word}, {total_energy} Wh, {total_co2}g CO2, {cost_display}")
|
||||||
PYEOF
|
PYEOF
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue