mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-24 10:46:19 +01:00
feat: minified index html to below 14kB
This commit is contained in:
parent
386ccbd0bb
commit
80d7fee6f9
@ -7,6 +7,15 @@ all: server_c
|
|||||||
server_c: server_c.c
|
server_c: server_c.c
|
||||||
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
|
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
|
||||||
|
|
||||||
|
build: minify
|
||||||
|
|
||||||
|
minify:
|
||||||
|
npx -y html-minifier-terser \
|
||||||
|
--collapse-whitespace --remove-comments --remove-attribute-quotes \
|
||||||
|
--remove-redundant-attributes --minify-css true --minify-js true \
|
||||||
|
-o index.min.html index.html
|
||||||
|
npx -y terser sw.js -o sw.min.js -c -m
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f server_c
|
rm -f server_c
|
||||||
|
|
||||||
|
|||||||
@ -40,35 +40,29 @@ article h1{margin:.25rem 0 .5rem;font-size:1.6rem}
|
|||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<!-- Loading indicator -->
|
<section id="loading" class="hidden">
|
||||||
<section id="loading" class="hidden" aria-live="polite">
|
|
||||||
<div class="small"><span class="spinner"></span><span class="msg">Loading…</span></div>
|
<div class="small"><span class="spinner"></span><span class="msg">Loading…</span></div>
|
||||||
</section>
|
</section>
|
||||||
<!-- List View -->
|
|
||||||
<section id="listV" class="grid"></section>
|
<section id="listV" class="grid"></section>
|
||||||
|
|
||||||
<!-- Read View -->
|
|
||||||
<section id="readV" class="hidden">
|
<section id="readV" class="hidden">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button id="backBtn">← Back</button>
|
<button id="backBtn">← Back</button>
|
||||||
<button id="delBtn" title="Delete">Delete</button>
|
<button id="delBtn">Delete</button>
|
||||||
<span class="small" id="dateInfo"></span>
|
<span class="small" id="dateInfo"></span>
|
||||||
</div>
|
</div>
|
||||||
<article id="readA">
|
<article id="readA">
|
||||||
<img id="readThumb" alt="thumbnail"/>
|
<img id="readThumb"/>
|
||||||
<h1 id="readTitle"></h1>
|
<h1 id="readTitle"></h1>
|
||||||
<div id="readBody"></div>
|
<div id="readBody"></div>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- Editor View -->
|
|
||||||
<section id="editor" class="hidden">
|
<section id="editor" class="hidden">
|
||||||
<label>Title</label>
|
<label>Title</label>
|
||||||
<input id="title" type="text" maxlength="200" placeholder="Article title"/>
|
<input id="title" type="text" placeholder="Article title"/>
|
||||||
|
|
||||||
<label>Thumbnail</label>
|
<label>Thumbnail</label>
|
||||||
<div id="thumbDrop" class="drop" tabindex="0">Drop image here or choose…<br><img id="thumbPrev" alt="thumbnail preview"/></div>
|
<div id="thumbDrop" class="drop">Drop image here or choose…<br><img id="thumbPrev"/></div>
|
||||||
<input id="thumbFile" type="file" accept="image/*"/>
|
<input id="thumbFile" type="file"/>
|
||||||
|
|
||||||
<label>Body</label>
|
<label>Body</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
@ -82,13 +76,12 @@ article h1{margin:.25rem 0 .5rem;font-size:1.6rem}
|
|||||||
<button id="cancelBtn">Cancel</button>
|
<button id="cancelBtn">Cancel</button>
|
||||||
<span class="small">Stored locally or on server if available.</span>
|
<span class="small">Stored locally or on server if available.</span>
|
||||||
</div>
|
</div>
|
||||||
<input id="imgFile" type="file" accept="image/*" hidden>
|
<input id="imgFile" type="file" hidden>
|
||||||
<input id="vidFile" type="file" accept="video/*" hidden>
|
<input id="vidFile" type="file" hidden>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Tiny SPA with optional backend. Falls back to localStorage.
|
|
||||||
(function(){
|
(function(){
|
||||||
const $=s=>document.querySelector(s);
|
const $=s=>document.querySelector(s);
|
||||||
const listV=$('#listV'), readV=$('#readV'), editor=$('#editor');
|
const listV=$('#listV'), readV=$('#readV'), editor=$('#editor');
|
||||||
@ -101,9 +94,8 @@ article h1{margin:.25rem 0 .5rem;font-size:1.6rem}
|
|||||||
const saveBtn=$('#saveBtn'), cancelBtn=$('#cancelBtn');
|
const saveBtn=$('#saveBtn'), cancelBtn=$('#cancelBtn');
|
||||||
const KEY='articles14k';
|
const KEY='articles14k';
|
||||||
let selId=null; let API=null; let preList; // cache first list to avoid duplicate initial fetches
|
let selId=null; let API=null; let preList; // cache first list to avoid duplicate initial fetches
|
||||||
const AC={}; // per-article cache by id
|
const AC={};
|
||||||
function setLoading(on,msg){ if(!loading) return; if(msg) loading.querySelector('.msg').textContent=msg; loading.classList.toggle('hidden',!on); }
|
function setLoading(on,msg){ if(!loading) return; if(msg) loading.querySelector('.msg').textContent=msg; loading.classList.toggle('hidden',!on); }
|
||||||
const supportsUpload = true; // try server upload; fallback uses data URLs
|
|
||||||
|
|
||||||
async function uploadBlobAndGetURL(blob){
|
async function uploadBlobAndGetURL(blob){
|
||||||
try{
|
try{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user