Skip to content

Commit 750fb33

Browse files
committed
Simplify data file processing
1 parent 7f8efaa commit 750fb33

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

.github/workflows/site.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
with:
1515
token: ${{ secrets.GIT_ACCESS_TOKEN }}
1616

1717
- name: Setup Java
18-
uses: actions/setup-java@v3
18+
uses: actions/setup-java@v4
1919
with:
2020
java-version: 17
2121
distribution: zulu
2222

2323
- name: Cache Jbang
24-
uses: actions/cache@v3
24+
uses: actions/cache@v4
2525
with:
2626
path: ~/.jbang/cache/
2727
key: ${{ runner.os }}-jbang-cache-${{ hashFiles('**/*.java') }}
@@ -31,7 +31,7 @@ jobs:
3131
- name: Parse data
3232
run: |
3333
cd resources
34-
./jbang site.java ../java-champions.yml ../podcasts.yml ../site/content/
34+
./jbang site.java .. ../site/content/
3535
3636
- name: Generate site
3737
run: |

CONTRIBUTING.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ You may install of these prerequisites with link:https://sdkman.io[Sdkman].
1414

1515
1. `git clone https://github.com/aalmiray/java-champions.git`
1616
2. `cd java-champions/resources`
17-
3. `jbang site.java ../java-champions.yml ../podcasts.yml ../site/content/`
17+
3. `jbang site.java .. ../site/content/`
1818
4. `cd ../site`
1919
5. `jbake -b`
2020
6. `jbake -s`

resources/site.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,25 @@ public class site {
4949
);
5050

5151
public static void main(String... args) throws Exception {
52-
if (null == args || args.length != 3) {
53-
System.out.println("❌ Usage: java site.java [YAML members] [YAML podcasts] [DIRECTORY]");
52+
if (null == args || args.length != 2) {
53+
System.out.println("❌ Usage: java site.java [YAML DIRECTORY] [OUTPUT DIRECTORY]");
5454
System.exit(1);
5555
}
5656

57-
var fileMembers = Path.of(args[0]);
58-
var filePodcasts = Path.of(args[1]);
59-
var directory = Path.of(args[2]);
57+
var inputDirectory = Path.of(args[0]);
58+
var outputDirectory = Path.of(args[1]);
59+
var fileMembers = inputDirectory.resolve("java-champions.yml");
60+
var filePodcasts = inputDirectory.resolve("podcasts.yml");
61+
62+
if (!Files.exists(fileMembers)) {
63+
System.out.printf("❌ %s/java-champions.yml does not exist%n", inputDirectory.toAbsolutePath());
64+
System.exit(1);
65+
}
66+
67+
if (!Files.exists(filePodcasts)) {
68+
System.out.printf("❌ %s/podcasts.yml does not exist%n", inputDirectory.toAbsolutePath());
69+
System.exit(1);
70+
}
6071

6172
var mapper = YAMLMapper.builder().build();
6273
var members = new Members();
@@ -77,7 +88,7 @@ public static void main(String... args) throws Exception {
7788
membersDoc.append(member.formatted());
7889
}
7990

80-
var outputMembers = directory.resolve("members.adoc");
91+
var outputMembers = outputDirectory.resolve("members.adoc");
8192
Files.write(outputMembers, membersDoc.toString().getBytes());
8293

8394
// generate stats.adoc
@@ -113,11 +124,11 @@ public static void main(String... args) throws Exception {
113124
.replace("@COUNTRIES_HEIGHT@", String.valueOf(countries.size() * 30))
114125
.replace("@YEARS@", yearsSb.toString())
115126
.replace("@YEARS_HEIGHT@", String.valueOf(years.size() * 30));
116-
var outputStats = directory.resolve("stats.adoc");
127+
var outputStats = outputDirectory.resolve("stats.adoc");
117128
Files.write(outputStats, statsDoc.getBytes());
118129

119130
// generate fediverse CSV file
120-
var mastodonCsv = new PrintWriter(Files.newOutputStream(directory.resolve("resources").resolve("mastodon.csv")));
131+
var mastodonCsv = new PrintWriter(Files.newOutputStream(outputDirectory.resolve("resources").resolve("mastodon.csv")));
121132
mastodonCsv.println("Account address,Show boosts,Notify on new posts,Languages");
122133
members.members.stream()
123134
.filter(JavaChampion::hasMastodon)
@@ -141,7 +152,7 @@ public static void main(String... args) throws Exception {
141152
podcastsDoc.append(podcast.formatted());
142153
}
143154

144-
var outputPodcasts = directory.resolve("podcasts.adoc");
155+
var outputPodcasts = outputDirectory.resolve("podcasts.adoc");
145156
Files.write(outputPodcasts, podcastsDoc.toString().getBytes());
146157
}
147158

site/templates/menu.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>index.html">Home</a></li>
1616
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>bylaws.html">Bylaws</a></li>
1717
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>members.html">Members</a></li>
18-
<!--<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>podcasts.html">Podcasts</a></li>-->
18+
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>podcasts.html">Podcasts</a></li>
1919
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>stats.html">Stats</a></li>
2020
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>about.html">About</a></li>
2121
</ul>

0 commit comments

Comments
 (0)