Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a podcasts page to the website #259

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Parse data
run: |
cd resources
./jbang site.java ../java-champions.yml ../site/content/
./jbang site.java ../java-champions.yml ../podcasts.yml ../site/content/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podcasts have yet to be integrated into the site.
This step is not needed at the moment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the script expects this extra value, we need to keep it here to avoid the workflow to break. The new webpage is already created by the script, but I commented the link to it in the menu so you can first validate the new page before making it public.


- name: Generate site
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ output/

# VS Code project files
.vscode/
/out/
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 ../site/content/`
3. `jbang site.java ../java-champions.yml ../podcasts.yml ../site/content/`
4. `cd ../site`
5. `jbake -b`
6. `jbake -s`
Expand Down
2 changes: 2 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

image:site/assets/img/duke_champion.png[align="center"]

The data collected in this repository is used to update link:javachampions.org[javachampions.org].

== What is a Java Champion?

One of the best descriptions was given in the 2009 JavaOne
Expand Down
2 changes: 1 addition & 1 deletion java-champions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ members:
social:
twitter: https://twitter.com/FrankDelporte
mastodon: https://foojay.social/@frankdelporte
bluesky: https://bsky.app/profile/frankdelporte.bsky.social
bluesky: https://bsky.app/profile/frankdelporte.be
youtube: https://www.youtube.com/@FrankDelporte
linkedin: https://www.linkedin.com/in/frankdelporte/
github: https://github.com/FDelporte
Expand Down
10 changes: 10 additions & 0 deletions resources/podcasts.adoc.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
= Podcasts
Frank Delporte
:jbake-type: page
:jbake-status: published
:linkattrs:

[cols="^,^,<2,<2,<2,<2"]
[subs="attributes"]
|===
| | |Title |Language |Host(s) |Social
103 changes: 92 additions & 11 deletions resources/site.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,25 @@ public class site {
);

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

var file = Path.of(args[0]);
var directory = Path.of(args[1]);
var fileMembers = Path.of(args[0]);
var filePodcasts = Path.of(args[1]);
var directory = Path.of(args[2]);

var mapper = YAMLMapper.builder().build();
var members = new Members();
var podcasts = new Podcasts();

// parse input data
try (InputStream in = Files.newInputStream(file)) {
// parse members input data
try (InputStream in = Files.newInputStream(fileMembers)) {
members = mapper.readValue(in, Members.class);
} catch (IOException e) {
e.printStackTrace();
System.out.printf("❌ Unexpected error reading %s%n", file);
System.out.printf("❌ Unexpected error reading %s%n", fileMembers);
System.exit(1);
}

Expand All @@ -75,8 +77,8 @@ public static void main(String... args) throws Exception {
membersDoc.append(member.formatted());
}

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

// generate stats.adoc
var countries = members.members.stream()
Expand Down Expand Up @@ -111,8 +113,8 @@ 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));
output = directory.resolve("stats.adoc");
Files.write(output, statsDoc.getBytes());
var outputStats = directory.resolve("stats.adoc");
Files.write(outputStats, statsDoc.getBytes());

// generate fediverse CSV file
var mastodonCsv = new PrintWriter(Files.newOutputStream(directory.resolve("resources").resolve("mastodon.csv")));
Expand All @@ -123,6 +125,24 @@ public static void main(String... args) throws Exception {
.forEach(mastodonCsv::println);
mastodonCsv.flush();
mastodonCsv.close();

// parse podcasts input data
try (InputStream in = Files.newInputStream(filePodcasts)) {
podcasts = mapper.readValue(in, Podcasts.class);
} catch (IOException e) {
e.printStackTrace();
System.out.printf("❌ Unexpected error reading %s%n", filePodcasts);
System.exit(1);
}

// generate podcasts.adoc
var podcastsDoc = new StringBuilder(Files.readString(Path.of("podcasts.adoc.tpl")));
for (Podcast podcast : podcasts.podcasts) {
podcastsDoc.append(podcast.formatted());
}

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

static class Members {
Expand Down Expand Up @@ -331,4 +351,65 @@ String getMastodonAccount() {
return "@" + n + "@" + s;
}
}

static class Podcasts {
public List<Podcast> podcasts = new ArrayList<>();
}

static class Host {
public String name;

String formatted() {
var b = new StringBuilder()
.append(name);

return b.append("\n")
.toString();
}
}

static class Podcast {
public String title;
public String url;
public String language;
public String logo;
public Social social;
public List<Host> hosts = new ArrayList<>();

String formatted() {
var b = new StringBuilder("|{counter:idx}\n")
.append("|image:")
.append(logo)
.append("[]");

b.append("|")
.append("link:")
.append(url)
.append("[")
.append(title)
.append("]")
.append("\n");

b.append("|")
.append(language)
.append("\n");

if (hosts != null && !hosts.isEmpty()) {
b.append("a|");
hosts.forEach(h -> b.append("* ").append(h.formatted()).append("\n"));
b.append("\n");
} else {
b.append("|\n");
}

if (social != null) {
b.append(social.formatted());
} else {
b.append("|\n");
}

return b.append("\n\n")
.toString();
}
}
}
1 change: 1 addition & 0 deletions site/templates/menu.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +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>stats.html">Stats</a></li>
<li><a href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>about.html">About</a></li>
</ul>
Expand Down