Skip to content

Commit 46bceed

Browse files
committed
Add footer sync helper script
1 parent 28739a5 commit 46bceed

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from pathlib import Path
2+
3+
index = Path('index.html')
4+
text = index.read_text(encoding='utf-8')
5+
6+
nav_github = ' <a href="https://github.com/CaseyCZ/Scriptable" target="_blank" rel="noopener">GitHub</a>\n'
7+
if nav_github not in text:
8+
raise SystemExit('Header GitHub link not found')
9+
text = text.replace(nav_github, '', 1)
10+
11+
old_footer = ''' <footer><span data-cs="Komunitní katalog čerpá z veřejných Scriptable projektů a doporučení komunity." data-en="The community catalog is curated from public Scriptable projects and community recommendations.">Komunitní katalog čerpá z veřejných Scriptable projektů a doporučení komunity.</span> · <a class="mutedLink" href="https://github.com/dersvenhesse/awesome-scriptable" target="_blank" rel="noopener">Awesome Scriptable</a> · <a class="mutedLink" href="https://www.scriptables.net/" target="_blank" rel="noopener">Scriptables.net</a> · <a class="mutedLink" href="https://www.reddit.com/r/Scriptable/" target="_blank" rel="noopener">r/Scriptable</a></footer>'''
12+
new_footer = ''' <footer class="footer">
13+
<div class="wrap footer-inner">
14+
<span>© <span id="year"></span> Scriptable Apps</span>
15+
<div class="footer-links">
16+
<a href="https://caseycz.github.io/" target="_blank" rel="noopener">Website</a>
17+
<a href="https://github.com/CaseyCZ/Scriptable" target="_blank" rel="noopener">GitHub · Scriptable</a>
18+
<a href="https://github.com/dersvenhesse/awesome-scriptable" target="_blank" rel="noopener">Awesome Scriptable</a>
19+
<a href="https://www.scriptables.net/" target="_blank" rel="noopener">Scriptables.net</a>
20+
<a href="https://www.reddit.com/r/Scriptable/" target="_blank" rel="noopener">r/Scriptable</a>
21+
<button class="footer-link-button" type="button" data-cookie-settings>Cookie settings</button>
22+
</div>
23+
</div>
24+
</footer>'''
25+
if old_footer not in text:
26+
raise SystemExit('Original footer not found')
27+
text = text.replace(old_footer, new_footer, 1)
28+
29+
year_hook = " applyTheme(theme);applyLayout(layout);setLanguage(lang);\n"
30+
if year_hook not in text:
31+
raise SystemExit('Year hook insertion point not found')
32+
text = text.replace(year_hook, " document.getElementById('year').textContent=new Date().getFullYear();\n" + year_hook, 1)
33+
index.write_text(text, encoding='utf-8')
34+
35+
css = Path('ios-hub-visual.css')
36+
styles = css.read_text(encoding='utf-8')
37+
marker = '/* iOS Hub footer 1:1 */'
38+
if marker not in styles:
39+
styles += '''
40+
41+
/* iOS Hub footer 1:1 */
42+
.footer{margin-top:38px;border-top:1px solid var(--border);padding:24px 0 36px;color:var(--muted);font-size:10px;text-align:center}
43+
.footer .wrap{width:min(1380px,calc(100% - 32px));margin:auto}
44+
.footer-inner{display:flex;align-items:center;justify-content:center;gap:14px;text-align:center;flex-direction:column}
45+
.footer-links{display:flex;gap:12px;flex-wrap:wrap;justify-content:center;align-items:center}
46+
.footer a:hover{color:var(--accent)}
47+
.footer-link-button{padding:0;border:0;background:transparent;color:var(--muted);font:inherit;cursor:pointer}
48+
.footer-link-button:hover{color:var(--accent)}
49+
.footer .caseycz-cookie-settings-wrap{display:contents;margin:0}
50+
.footer .caseycz-cookie-settings{min-height:0;padding:0;border:0;background:transparent;color:var(--muted);font:inherit;text-decoration:none;opacity:1}
51+
.footer .caseycz-cookie-settings:hover{color:var(--accent)}
52+
@media(max-width:640px){.footer-inner{align-items:center}.footer-links{justify-content:center}}
53+
'''
54+
css.write_text(styles, encoding='utf-8')

0 commit comments

Comments
 (0)