Skip to content

Commit 58f5fb1

Browse files
committed
f
1 parent ab41eee commit 58f5fb1

File tree

3 files changed

+22
-29
lines changed

3 files changed

+22
-29
lines changed

.github/workflows/build_master.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ jobs:
8888
RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
8989
echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
9090
91-
# Copy both versions to the searchindex repo
91+
# Copy ONLY the .gz version to the searchindex repo (no uncompressed .js)
9292
cd /tmp/searchindex-repo
93-
cp "${GITHUB_WORKSPACE}/${ASSET}" "${FILENAME}"
9493
cp "${GITHUB_WORKSPACE}/${ASSET}.gz" "${FILENAME}.gz"
9594
9695
# Stage all files

.github/workflows/translate_all.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,23 @@ jobs:
175175
# Clone the searchindex repo
176176
git clone https://x-access-token:${TOKEN}@github.com/${TARGET_REPO}.git /tmp/searchindex-repo
177177
178-
# Copy and compress the searchindex file
179-
cp "$ASSET" "/tmp/searchindex-repo/${FILENAME}"
178+
# Compress the searchindex file
180179
gzip -9 -k -f "$ASSET"
181-
cp "${ASSET}.gz" "/tmp/searchindex-repo/${FILENAME}.gz"
182180
183181
# Show compression stats
184182
ORIGINAL_SIZE=$(wc -c < "$ASSET")
185183
COMPRESSED_SIZE=$(wc -c < "${ASSET}.gz")
186184
RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
187185
echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
188186
187+
# Copy ONLY the .gz version to the searchindex repo (no uncompressed .js)
188+
cp "${ASSET}.gz" "/tmp/searchindex-repo/${FILENAME}.gz"
189+
189190
# Commit and push with retry logic
190191
cd /tmp/searchindex-repo
191192
git config user.name "GitHub Actions"
192193
git config user.email "[email protected]"
193-
git add "${FILENAME}" "${FILENAME}.gz"
194+
git add "${FILENAME}.gz"
194195
195196
if git diff --staged --quiet; then
196197
echo "No changes to commit"
@@ -223,12 +224,11 @@ jobs:
223224
git config user.name "GitHub Actions"
224225
git config user.email "[email protected]"
225226
226-
# Re-copy and compress the searchindex file
227-
cp "$ASSET" "${FILENAME}"
227+
# Re-copy ONLY the .gz version (no uncompressed .js)
228228
cp "${ASSET}.gz" "${FILENAME}.gz"
229229
230-
git add "${FILENAME}" "${FILENAME}.gz"
231-
git commit -m "Update ${FILENAME} from hacktricks-cloud build"
230+
git add "${FILENAME}.gz"
231+
git commit -m "Update ${FILENAME}.gz from hacktricks-cloud build"
232232
echo "Re-cloned and re-committed, will retry push..."
233233
else
234234
echo "Rebase failed for unknown reason, retrying anyway..."

theme/ht_searcher.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,25 @@
4444
async function loadIndex(remote, local, isCloud=false){
4545
let rawLoaded = false;
4646
if(remote){
47-
/* Try compressed version first */
47+
/* Try ONLY compressed version from GitHub (remote already includes .js.gz) */
4848
try {
49-
const gzUrl = remote + '.gz';
50-
const r = await fetch(gzUrl,{mode:'cors'});
49+
const r = await fetch(remote,{mode:'cors'});
5150
if (r.ok) {
5251
const compressed = await r.arrayBuffer();
5352
const text = await decompressGzip(compressed);
5453
importScripts(URL.createObjectURL(new Blob([text],{type:'application/javascript'})));
5554
rawLoaded = true;
56-
console.log('Loaded compressed',gzUrl);
55+
console.log('Loaded compressed from GitHub:',remote);
5756
}
58-
} catch(e){ console.warn('compressed',remote+'.gz','failed →',e); }
59-
60-
/* Fall back to uncompressed if compressed failed */
61-
if(!rawLoaded){
62-
try {
63-
const r = await fetch(remote,{mode:'cors'});
64-
if (!r.ok) throw new Error('HTTP '+r.status);
65-
importScripts(URL.createObjectURL(new Blob([await r.text()],{type:'application/javascript'})));
66-
rawLoaded = true;
67-
console.log('Loaded uncompressed',remote);
68-
} catch(e){ console.warn('remote',remote,'failed →',e); }
69-
}
57+
} catch(e){ console.warn('compressed GitHub',remote,'failed →',e); }
7058
}
59+
/* If remote (GitHub) failed, fall back to local uncompressed file */
7160
if(!rawLoaded && local){
72-
try { importScripts(abs(local)); rawLoaded = true; }
61+
try {
62+
importScripts(abs(local));
63+
rawLoaded = true;
64+
console.log('Loaded local fallback:',local);
65+
}
7366
catch(e){ console.error('local',local,'failed →',e); }
7467
}
7568
if(!rawLoaded) return null; /* give up on this index */
@@ -106,8 +99,9 @@
10699
const lang = data.lang || 'en';
107100
const searchindexBase = 'https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-searchindex/main';
108101
109-
const mainFilenames = Array.from(new Set(['searchindex-' + lang + '.js', 'searchindex-en.js']));
110-
const cloudFilenames = Array.from(new Set(['searchindex-cloud-' + lang + '.js', 'searchindex-cloud-en.js']));
102+
/* Remote sources are .js.gz (compressed), local fallback is .js (uncompressed) */
103+
const mainFilenames = Array.from(new Set(['searchindex-' + lang + '.js.gz', 'searchindex-en.js.gz']));
104+
const cloudFilenames = Array.from(new Set(['searchindex-cloud-' + lang + '.js.gz', 'searchindex-cloud-en.js.gz']));
111105
112106
const MAIN_REMOTE_SOURCES = mainFilenames.map(function(filename) { return searchindexBase + '/' + filename; });
113107
const CLOUD_REMOTE_SOURCES = cloudFilenames.map(function(filename) { return searchindexBase + '/' + filename; });

0 commit comments

Comments
 (0)