Skip to content

Commit ea702fb

Browse files
authored
Merge pull request #46 from javaevolved/copilot/fix-enterprise-category-slug
Fix enterprise category not generating HTML pages
2 parents 3fecbf6 + 7779949 commit ea702fb

File tree

8 files changed

+49
-1579
lines changed

8 files changed

+49
-1579
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ site/errors/*.html
99
site/datetime/*.html
1010
site/security/*.html
1111
site/tooling/*.html
12+
site/enterprise/*.html
1213

1314
# Generated aggregate file (built from individual JSON sources by html-generators/)
1415
site/data/snippets.json
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language=Language
2+
collections=Collections
3+
strings=Strings
4+
streams=Streams
5+
concurrency=Concurrency
6+
io=I/O
7+
errors=Errors
8+
datetime=Date/Time
9+
security=Security
10+
tooling=Tooling
11+
enterprise=Enterprise

html-generators/generate.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@
1616
static final Pattern TOKEN = Pattern.compile("\\{\\{(\\w+)}}");
1717
static final ObjectMapper MAPPER = new ObjectMapper();
1818

19-
static final SequencedMap<String, String> CATEGORY_DISPLAY = new LinkedHashMap<>() {{
20-
put("language", "Language"); put("collections", "Collections");
21-
put("strings", "Strings"); put("streams", "Streams");
22-
put("concurrency", "Concurrency"); put("io", "I/O");
23-
put("errors", "Errors"); put("datetime", "Date/Time");
24-
put("security", "Security"); put("tooling", "Tooling");
25-
}};
19+
static final String CATEGORIES_FILE = "html-generators/categories.properties";
20+
static final SequencedMap<String, String> CATEGORY_DISPLAY = loadCategoryDisplay();
21+
22+
static SequencedMap<String, String> loadCategoryDisplay() {
23+
try {
24+
var map = new LinkedHashMap<String, String>();
25+
for (var line : Files.readAllLines(Path.of(CATEGORIES_FILE))) {
26+
line = line.strip();
27+
if (line.isEmpty() || line.startsWith("#")) continue;
28+
var idx = line.indexOf('=');
29+
if (idx > 0) map.put(line.substring(0, idx).strip(), line.substring(idx + 1).strip());
30+
}
31+
return map;
32+
} catch (IOException e) {
33+
throw new UncheckedIOException(e);
34+
}
35+
}
2636

2737
static final Set<String> EXCLUDED_KEYS = Set.of("_path", "prev", "next", "related");
2838

html-generators/generate.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,25 @@
1919
CONTENT_DIR = "content"
2020
SITE_DIR = "site"
2121

22-
CATEGORY_DISPLAY = {
23-
"language": "Language",
24-
"collections": "Collections",
25-
"strings": "Strings",
26-
"streams": "Streams",
27-
"concurrency": "Concurrency",
28-
"io": "I/O",
29-
"errors": "Errors",
30-
"datetime": "Date/Time",
31-
"security": "Security",
32-
"tooling": "Tooling",
33-
"enterprise": "Enterprise",
34-
}
22+
CATEGORIES_FILE = "html-generators/categories.properties"
23+
24+
25+
def load_category_display():
26+
"""Load category display names from the properties file."""
27+
categories = {}
28+
with open(CATEGORIES_FILE) as f:
29+
for line in f:
30+
line = line.strip()
31+
if not line or line.startswith('#'):
32+
continue
33+
key, sep, value = line.partition('=')
34+
key, value = key.strip(), value.strip()
35+
if sep and key:
36+
categories[key] = value
37+
return categories
38+
39+
40+
CATEGORY_DISPLAY = load_category_display()
3541

3642

3743
def escape(text):
@@ -65,12 +71,8 @@ def load_template():
6571
def load_all_snippets():
6672
"""Load all JSON snippet files, keyed by category/slug."""
6773
snippets = {}
68-
categories = [
69-
"language", "collections", "strings", "streams", "concurrency",
70-
"io", "errors", "datetime", "security", "tooling", "enterprise",
71-
]
7274
json_files = []
73-
for cat in categories:
75+
for cat in CATEGORY_DISPLAY:
7476
json_files.extend(sorted(glob.glob(f"{CONTENT_DIR}/{cat}/*.json")))
7577
for path in json_files:
7678
with open(path) as f:

0 commit comments

Comments
 (0)