Skip to content

Commit

Permalink
Simplify data file processing
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Jan 31, 2025
1 parent 7f8efaa commit 750fb33
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_ACCESS_TOKEN }}

- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: zulu

- name: Cache Jbang
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.jbang/cache/
key: ${{ runner.os }}-jbang-cache-${{ hashFiles('**/*.java') }}
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Parse data
run: |
cd resources
./jbang site.java ../java-champions.yml ../podcasts.yml ../site/content/
./jbang site.java .. ../site/content/
- name: Generate site
run: |
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You may install of these prerequisites with link:https://sdkman.io[Sdkman].

1. `git clone https://github.com/aalmiray/java-champions.git`
2. `cd java-champions/resources`
3. `jbang site.java ../java-champions.yml ../podcasts.yml ../site/content/`
3. `jbang site.java .. ../site/content/`
4. `cd ../site`
5. `jbake -b`
6. `jbake -s`
Expand Down
29 changes: 20 additions & 9 deletions resources/site.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,25 @@ public class site {
);

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

var fileMembers = Path.of(args[0]);
var filePodcasts = Path.of(args[1]);
var directory = Path.of(args[2]);
var inputDirectory = Path.of(args[0]);
var outputDirectory = Path.of(args[1]);
var fileMembers = inputDirectory.resolve("java-champions.yml");
var filePodcasts = inputDirectory.resolve("podcasts.yml");

if (!Files.exists(fileMembers)) {
System.out.printf("❌ %s/java-champions.yml does not exist%n", inputDirectory.toAbsolutePath());
System.exit(1);
}

if (!Files.exists(filePodcasts)) {
System.out.printf("❌ %s/podcasts.yml does not exist%n", inputDirectory.toAbsolutePath());
System.exit(1);
}

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

var outputMembers = directory.resolve("members.adoc");
var outputMembers = outputDirectory.resolve("members.adoc");
Files.write(outputMembers, membersDoc.toString().getBytes());

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

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

var outputPodcasts = directory.resolve("podcasts.adoc");
var outputPodcasts = outputDirectory.resolve("podcasts.adoc");
Files.write(outputPodcasts, podcastsDoc.toString().getBytes());
}

Expand Down
2 changes: 1 addition & 1 deletion site/templates/menu.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>index.html">Home</a></li>
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>bylaws.html">Bylaws</a></li>
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>members.html">Members</a></li>
<!--<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>podcasts.html">Podcasts</a></li>-->
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>podcasts.html">Podcasts</a></li>
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>stats.html">Stats</a></li>
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>about.html">About</a></li>
</ul>
Expand Down

0 comments on commit 750fb33

Please sign in to comment.