Skip to content

Commit 2843133

Browse files
brunoborgesCopilot
andcommitted
Add Contribute dropdown to detail pages
- Add Contribute button on the title row of each slug detail page - Dropdown with 3 options: report code issue, report translation issue, suggest new pattern - Links open pre-filled GitHub issue templates - Add translation-issue.yml issue template - Add enterprise category to new-pattern.yml issue template - Add i18n strings for all 9 locales - Regenerate all site HTML Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 91e17e6 commit 2843133

File tree

15 files changed

+251
-1
lines changed

15 files changed

+251
-1
lines changed

.github/ISSUE_TEMPLATE/new-pattern.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ body:
2828
- datetime
2929
- security
3030
- tooling
31+
- enterprise
3132
validations:
3233
required: true
3334

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
name: Translation Issue
3+
description: Report a translation problem or suggest an improvement
4+
title: "[Translation] "
5+
labels: ["translation"]
6+
body:
7+
- type: markdown
8+
attributes:
9+
value: |
10+
## Report a translation issue
11+
12+
Found a mistranslation, awkward phrasing, or missing translation?
13+
Let us know and we'll fix it.
14+
15+
- type: dropdown
16+
id: locale
17+
attributes:
18+
label: Language
19+
description: "Which language has the issue?"
20+
options:
21+
- de — Deutsch
22+
- es — Español
23+
- pt-BR — Português (Brasil)
24+
- zh-CN — 中文 (简体)
25+
- ar — العربية
26+
- fr — Français
27+
- ja — 日本語
28+
- ko — 한국어
29+
validations:
30+
required: true
31+
32+
- type: dropdown
33+
id: area
34+
attributes:
35+
label: What is affected?
36+
description: "Is this about a pattern page or the site UI (nav, buttons, labels)?"
37+
options:
38+
- Pattern content (title, summary, explanation, etc.)
39+
- UI strings (navigation, buttons, labels, footer)
40+
validations:
41+
required: true
42+
43+
- type: input
44+
id: pattern
45+
attributes:
46+
label: Pattern slug (if applicable)
47+
description: "The pattern ID, e.g. `type-inference-with-var`. Leave blank for UI string issues."
48+
placeholder: "type-inference-with-var"
49+
50+
- type: textarea
51+
id: current-text
52+
attributes:
53+
label: Current text
54+
description: "Copy the text that is incorrect or needs improvement"
55+
validations:
56+
required: true
57+
58+
- type: textarea
59+
id: suggested-text
60+
attributes:
61+
label: Suggested text
62+
description: "What should it say instead?"
63+
validations:
64+
required: true
65+
66+
- type: textarea
67+
id: context
68+
attributes:
69+
label: Additional context
70+
description: "Any extra context about why the current translation is incorrect"

html-generators/generate.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,28 @@ String renderSocialShare(String tpl, String slug, String title, Map<String, Stri
416416
"share.label", strings.getOrDefault("share.label", "Share")));
417417
}
418418

419+
static final String GITHUB_ISSUES_URL = "https://github.com/javaevolved/javaevolved.github.io/issues/new";
420+
421+
Map<String, String> buildContributeUrls(Snippet s, String locale, String localeName) {
422+
var pageUrl = locale.equals("en")
423+
? "%s/%s/%s.html".formatted(BASE_URL, s.category(), s.slug())
424+
: "%s/%s/%s/%s.html".formatted(BASE_URL, locale, s.category(), s.slug());
425+
426+
var codeTitle = urlEncode("[Code Issue] %s".formatted(s.title()));
427+
var codeBody = urlEncode("**Pattern:** %s\n**URL:** %s\n\nDescribe the issue:\n".formatted(s.slug(), pageUrl));
428+
var codeUrl = "%s?title=%s&labels=%s&body=%s".formatted(GITHUB_ISSUES_URL, codeTitle, "bug", codeBody);
429+
430+
var transUrl = "%s?template=translation-issue.yml&title=%s".formatted(
431+
GITHUB_ISSUES_URL, urlEncode("[Translation] %s (%s)".formatted(s.title(), localeName)));
432+
433+
var suggestUrl = "%s?template=new-pattern.yml".formatted(GITHUB_ISSUES_URL);
434+
435+
return Map.of(
436+
"contributeCodeIssueUrl", codeUrl,
437+
"contributeTranslationIssueUrl", transUrl,
438+
"contributeSuggestUrl", suggestUrl);
439+
}
440+
419441
String generateHtml(Templates tpl, Snippet s, Map<String, Snippet> all, Map<String, String> extraTokens, String locale) throws IOException {
420442
var isEnglish = locale.equals("en");
421443
var canonicalUrl = isEnglish
@@ -445,6 +467,8 @@ String generateHtml(Templates tpl, Snippet s, Map<String, Snippet> all, Map<Stri
445467
Map.entry("docLinks", renderDocLinks(tpl.docLink(), s.node().withArray("docs"))),
446468
Map.entry("relatedCards", renderRelatedSection(tpl.relatedCard(), s, all, locale, extraTokens)),
447469
Map.entry("socialShare", renderSocialShare(tpl.socialShare(), s.slug(), s.title(), extraTokens))));
470+
var localeName = LOCALES.getOrDefault(locale, locale);
471+
tokens.putAll(buildContributeUrls(s, locale, localeName));
448472
return replaceTokens(tpl.page(), tokens);
449473
}
450474

site/app.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,37 @@
698698
});
699699
};
700700

701+
/* ==========================================================
702+
9. Contribute Dropdown
703+
========================================================== */
704+
const initContributeDropdown = () => {
705+
const dropdown = document.getElementById('contributeDropdown');
706+
if (!dropdown) return;
707+
708+
const toggleBtn = dropdown.querySelector('.contribute-toggle');
709+
const list = dropdown.querySelector('ul');
710+
711+
const open = () => {
712+
list.style.display = 'block';
713+
toggleBtn.setAttribute('aria-expanded', 'true');
714+
};
715+
716+
const close = () => {
717+
list.style.display = 'none';
718+
toggleBtn.setAttribute('aria-expanded', 'false');
719+
};
720+
721+
toggleBtn.addEventListener('click', (e) => {
722+
e.stopPropagation();
723+
list.style.display === 'block' ? close() : open();
724+
});
725+
726+
document.addEventListener('click', close);
727+
document.addEventListener('keydown', (e) => {
728+
if (e.key === 'Escape') close();
729+
});
730+
};
731+
701732
/* ==========================================================
702733
Utilities
703734
========================================================== */
@@ -722,5 +753,6 @@
722753
initNewsletter();
723754
initThemeToggle();
724755
initLocalePicker();
756+
initContributeDropdown();
725757
});
726758
})();

site/styles.css

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,12 @@ nav {
869869
margin-bottom: 40px;
870870
}
871871

872+
.tip-title-row {
873+
display: flex;
874+
align-items: baseline;
875+
gap: 16px;
876+
}
877+
872878
.tip-header h1 {
873879
font-size: clamp(1.6rem, 4vw, 2.4rem);
874880
font-weight: 800;
@@ -1573,6 +1579,68 @@ footer a:hover {
15731579
.share-li { font-family: Georgia, serif; font-weight: 800; font-size: 0.85rem; }
15741580
.share-reddit { font-size: 1.1rem; }
15751581

1582+
/* ============================
1583+
Contribute Dropdown
1584+
============================ */
1585+
.contribute-dropdown {
1586+
position: relative;
1587+
display: inline-flex;
1588+
margin-inline-start: auto;
1589+
}
1590+
.contribute-toggle {
1591+
display: flex;
1592+
align-items: center;
1593+
gap: 6px;
1594+
padding: 5px 14px;
1595+
border-radius: var(--radius-sm);
1596+
border: 1px solid var(--border);
1597+
background: var(--surface);
1598+
color: var(--text-muted);
1599+
font-size: 0.82rem;
1600+
font-weight: 500;
1601+
line-height: 1;
1602+
transition: all 0.2s;
1603+
cursor: pointer;
1604+
white-space: nowrap;
1605+
}
1606+
.contribute-toggle:hover {
1607+
background: var(--accent);
1608+
color: #fff;
1609+
border-color: var(--accent);
1610+
}
1611+
.contribute-dropdown ul {
1612+
display: none;
1613+
position: absolute;
1614+
top: 100%;
1615+
right: 0;
1616+
margin: 4px 0 0;
1617+
padding: 4px 0;
1618+
list-style: none;
1619+
background: var(--surface);
1620+
border: 1px solid var(--border);
1621+
border-radius: var(--radius-sm);
1622+
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1623+
z-index: 100;
1624+
min-width: 220px;
1625+
}
1626+
[dir="rtl"] .contribute-dropdown ul {
1627+
right: auto;
1628+
left: 0;
1629+
}
1630+
.contribute-dropdown li a {
1631+
display: block;
1632+
padding: 8px 16px;
1633+
font-size: 0.9rem;
1634+
color: var(--text);
1635+
white-space: nowrap;
1636+
text-decoration: none;
1637+
transition: background 0.15s;
1638+
}
1639+
.contribute-dropdown li a:hover {
1640+
background: var(--accent);
1641+
color: #fff;
1642+
}
1643+
15761644
/* ============================
15771645
Locale Picker
15781646
============================ */

templates/slug-template.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,17 @@
125125
<span class="badge {{category}}">{{categoryDisplay}}</span>
126126
<span class="badge {{difficulty}}">{{difficultyDisplay}}</span>
127127
</div>
128-
<h1>{{title}}</h1>
128+
<div class="tip-title-row">
129+
<h1>{{title}}</h1>
130+
<div class="contribute-dropdown" id="contributeDropdown">
131+
<button type="button" class="contribute-toggle" aria-haspopup="true" aria-expanded="false">{{contribute.button}}</button>
132+
<ul>
133+
<li><a href="{{contributeCodeIssueUrl}}" target="_blank" rel="noopener">🐛 {{contribute.codeIssue}}</a></li>
134+
<li><a href="{{contributeTranslationIssueUrl}}" target="_blank" rel="noopener">🌐 {{contribute.translationIssue}}</a></li>
135+
<li><a href="{{contributeSuggestUrl}}" target="_blank" rel="noopener">💡 {{contribute.suggestPattern}}</a></li>
136+
</ul>
137+
</div>
138+
</div>
129139
<p>{{summary}}</p>
130140
</div>
131141

translations/strings/ar.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ support:
7575
available: متاح
7676
preview: معاينة
7777
experimental: تجريبي
78+
contribute:
79+
button: المساهمة
80+
codeIssue: الإبلاغ عن مشكلة في الكود
81+
translationIssue: الإبلاغ عن مشكلة في الترجمة
82+
suggestPattern: اقتراح نمط جديد
7883
untranslated:
7984
notice: "هذه الصفحة لم تُترجم بعد إلى {{localeName}}."
8085
viewInEnglish: عرض بالإنجليزية

translations/strings/de.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ support:
7777
available: Verfügbar
7878
preview: Vorschau
7979
experimental: Experimentell
80+
contribute:
81+
button: Beitragen
82+
codeIssue: Code-Problem melden
83+
translationIssue: Übersetzungsproblem melden
84+
suggestPattern: Neues Muster vorschlagen
8085
untranslated:
8186
notice: Diese Seite wurde noch nicht ins {{localeName}} übersetzt.
8287
viewInEnglish: Auf Englisch ansehen

translations/strings/en.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ support:
7777
available: Available
7878
preview: Preview
7979
experimental: Experimental
80+
contribute:
81+
button: Contribute
82+
codeIssue: Report a code issue
83+
translationIssue: Report a translation issue
84+
suggestPattern: Suggest a new pattern
8085
untranslated:
8186
notice: This page has not yet been translated into {{localeName}}.
8287
viewInEnglish: View in English

translations/strings/es.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ support:
7777
available: Disponible
7878
preview: Preview
7979
experimental: Experimental
80+
contribute:
81+
button: Contribuir
82+
codeIssue: Reportar un problema de código
83+
translationIssue: Reportar un problema de traducción
84+
suggestPattern: Sugerir un nuevo patrón
8085
untranslated:
8186
notice: Esta página aún no ha sido traducida al {{localeName}}.
8287
viewInEnglish: Ver en Inglés

0 commit comments

Comments
 (0)