Skip to content

Commit caf65b8

Browse files
committed
- add python script to semi-automatically update the new "Newest Additions" section
- update faulty screenshot
1 parent 4d1073a commit caf65b8

File tree

3 files changed

+100
-4
lines changed

3 files changed

+100
-4
lines changed

index.html

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
margin: 50px 0;
152152
}
153153

154-
.game-list.top .game-card {
154+
.game-list.top .game-card, .game-list.newest .game-card {
155155
height: 260px;
156156
}
157157

@@ -294,14 +294,62 @@
294294

295295
</head>
296296
<body class="dark">
297+
297298
<div class="header">
298-
<h1>Top Games and Tools</h1>
299+
<h2>Newest Additions</h2>
299300
</div>
300301
<div class="search-container">
301302
<label>
302303
<input type="search" class="search-input" placeholder="🔍 Search for a game or tool" aria-label="Search input">
303304
</label>
304305
</div>
306+
<div class="game-list newest">
307+
<div class="game-card">
308+
<a href="tools/reading_time_estimator.html">
309+
<img src="screenshots/screenshot_145.png" alt="Reading Time Estimator" loading="lazy">
310+
<h2>Reading Time Estimator</h2>
311+
</a>
312+
</div>
313+
<div class="game-card">
314+
<a href="tools/daily_quote_generator.html">
315+
<img src="screenshots/screenshot_146.png" alt="Daily Quote Generator" loading="lazy">
316+
<h2>Daily Quote Generator</h2>
317+
</a>
318+
</div>
319+
<div class="game-card">
320+
<a href="games/death_by_ai.html">
321+
<img src="screenshots/screenshot_144.png" alt="Death by AI" loading="lazy">
322+
<h2>Death by AI</h2>
323+
</a>
324+
</div>
325+
<div class="game-card">
326+
<a href="tools/sql_minifier.html">
327+
<img src="screenshots/screenshot_142.png" alt="SQL Minifier & Formatter" loading="lazy">
328+
<h2>SQL Minifier & Formatter</h2>
329+
</a>
330+
</div>
331+
<div class="game-card">
332+
<a href="tools/php_code_minifier.html">
333+
<img src="screenshots/screenshot_141.png" alt="PHP Code Minifier" loading="lazy">
334+
<h2>PHP Code Minifier</h2>
335+
</a>
336+
</div>
337+
<div class="game-card">
338+
<a href="tools/pomodoro_timer.html">
339+
<img src="screenshots/screenshot_140.png" alt="Pomodoro Timer" loading="lazy">
340+
<h2>Pomodoro Timer</h2>
341+
</a>
342+
</div>
343+
<div class="game-card">
344+
<a href="tools/morse_code_translator.html">
345+
<img src="screenshots/screenshot_139.png" alt="Morse Code Translator" loading="lazy">
346+
<h2>Morse Code Translator</h2>
347+
</a>
348+
</div>
349+
</div>
350+
<div class="header">
351+
<h1>Top Games and Tools</h1>
352+
</div>
305353
<div class="game-list top">
306354
<div class="game-card">
307355
<a href="games/family_feud.html">
@@ -1459,14 +1507,14 @@ <h2>SQL Minifier & Formatter</h2>
14591507
</div>
14601508
<div class="game-card">
14611509
<a href="tools/daily_quote_generator.html">
1462-
<img src="screenshots/screenshot_145.png" alt="Daily Quote Generator" loading="lazy">
1510+
<img src="screenshots/screenshot_146.png" alt="Daily Quote Generator" loading="lazy">
14631511
<h2>Daily Quote Generator</h2>
14641512
<p>Generate, customize, and share inspirational daily quotes with our Daily Quote Generator. Features include automatic category randomization, author selection, and quote saving.</p>
14651513
</a>
14661514
</div>
14671515
<div class="game-card">
14681516
<a href="tools/reading_time_estimator.html">
1469-
<img src="screenshots/screenshot_146.png" alt="Reading Time Estimator" loading="lazy">
1517+
<img src="screenshots/screenshot_145.png" alt="Reading Time Estimator" loading="lazy">
14701518
<h2>Reading Time Estimator</h2>
14711519
<p>Estimate reading time for your text with our Reading Time Estimator tool. Adjust words per minute, analyze readability, and get detailed text statistics.</p>
14721520
</a>

screenshots/screenshot_146.png

-16.6 KB
Loading

util/update_newest.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import os
2+
import re
3+
4+
def extract_entries_from_index(index_content):
5+
pattern = r'<div class="game-card">\s*<a href="([^"]+)">\s*<img src="screenshots/screenshot_(\d+).png"[^>]*>\s*<h2>([^<]+)</h2>'
6+
matches = re.findall(pattern, index_content, re.DOTALL)
7+
return [{'href': m[0], 'number': int(m[1]), 'title': m[2]} for m in matches]
8+
9+
def update_index_html(root_dir):
10+
index_path = os.path.join(root_dir, 'index.html')
11+
with open(index_path, 'r', encoding='utf-8') as f:
12+
content = f.read()
13+
14+
entries = extract_entries_from_index(content)
15+
entries.sort(key=lambda x: x['number'], reverse=True)
16+
17+
newest_div_match = re.search(r'(<div class="game-list newest">)(.*?)(</div>)', content, re.DOTALL)
18+
if not newest_div_match:
19+
print("Couldn't find the 'Newest Additions' section. Make sure you've added it to your index.html file.")
20+
return
21+
22+
start, _, end = newest_div_match.groups()
23+
new_content = start + '\n'
24+
25+
added_entries = 0
26+
for entry in entries:
27+
if added_entries >= 7:
28+
break
29+
30+
new_content += f' <div class="game-card">\n'
31+
new_content += f' <a href="{entry["href"]}">\n'
32+
new_content += f' <img src="screenshots/screenshot_{entry["number"]}.png" alt="{entry["title"]}" loading="lazy">\n'
33+
new_content += f' <h2>{entry["title"]}</h2>\n'
34+
new_content += f' </a>\n'
35+
new_content += f' </div>\n'
36+
added_entries += 1
37+
38+
new_content += end
39+
40+
updated_content = content[:newest_div_match.start()] + new_content + content[newest_div_match.end():]
41+
42+
with open(index_path, 'w', encoding='utf-8') as f:
43+
f.write(updated_content)
44+
45+
if __name__ == "__main__":
46+
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
47+
update_index_html(root_dir)
48+
print("Index.html has been updated with the 7 newest additions.")

0 commit comments

Comments
 (0)