Skip to content

Commit

Permalink
🔧 Make social headline configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Fihlon <[email protected]>
  • Loading branch information
McPringle committed Aug 30, 2024
1 parent 5ba1735 commit 8420fea
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/main/java/swiss/fihlon/apus/configuration/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Configuration {
private AdminConfig admin;
private CustomConfig custom;
private EventConfig event;
private PostConfig post;
private SocialConfig social;
private FilterConfig filter;

// Event Plugin Configs
Expand Down Expand Up @@ -78,12 +78,12 @@ public void setAdmin(@NotNull final AdminConfig admin) {
this.admin = admin;
}

public PostConfig getPost() {
return post;
public SocialConfig getSocial() {
return social;
}

public void setPost(@NotNull final PostConfig post) {
this.post = post;
public void setSocial(@NotNull final SocialConfig social) {
this.social = social;
}

public FilterConfig getFilter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
*/
package swiss.fihlon.apus.configuration;

public record PostConfig(int numberOfColumns) { }
public record SocialConfig(String headline, int numberOfColumns) { }
8 changes: 6 additions & 2 deletions src/main/java/swiss/fihlon/apus/ui/view/SocialView.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ public SocialView(@NotNull final SocialService socialService,
this.configuration = configuration;

setId("social-view");
add(new H2(getTranslation("social.heading", configuration.getMastodon().hashtag())));
if (configuration.getSocial().headline().isBlank()) {
add(new H2(getTranslation("social.heading", configuration.getMastodon().hashtag())));
} else {
add(new H2(configuration.getSocial().headline()));
}
var postsColumnsDiv = new Div();
postsColumnsDiv.addClassName("posts");
add(postsColumnsDiv);

final int numberOfColumns = configuration.getPost().numberOfColumns();
final int numberOfColumns = configuration.getSocial().numberOfColumns();
postsColumns = new ArrayList<>(numberOfColumns);
for (int i = 0; i < numberOfColumns; i++) {
final var postsContainer = new Div();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@
"type": "java.lang.String",
"description": "The Mastodon instance used to read the posts from."
},
{
"name": "apus.post.numberOfColumns",
"type": "java.lang.String",
"description" : "How many columns to be used for social media posts."
},
{
"name": "apus.sessionize.eventId",
"type": "java.lang.String",
Expand All @@ -99,6 +94,16 @@
"name": "apus.sessionize.eventApi",
"type": "java.lang.String",
"description": "The URL of the Sessionize event API to read the conference agenda."
},
{
"name": "apus.social.headline",
"type": "java.lang.String",
"description" : "Overwrite the headline for social media posts."
},
{
"name": "apus.social.numberOfColumns",
"type": "java.lang.Integer",
"description" : "How many columns to be used for social media posts."
}
]
}
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ apus.mastodon.hashtag=${MASTODON_HASHTAG:}
apus.mastodon.imageLimit=${MASTODON_IMAGE_LIMIT:1}
apus.mastodon.imagesEnabled=${MASTODON_IMAGES_ENABLED:true}
apus.mastodon.instance=${MASTODON_INSTANCE:}
apus.post.numberOfColumns=${POST_COLUMNS:3}
apus.sessionize.eventApi=${SESSIONIZE_EVENT_API:https://sessionize.com/api/v2/%s/view/Sessions}
apus.sessionize.eventId=${SESSIONIZE_EVENT_ID:0}
apus.social.headline=${SOCIAL_HEADLINE:}
apus.social.numberOfColumns=${SOCIAL_COLUMNS:3}
3 changes: 2 additions & 1 deletion src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ apus.mastodon.hashtag=java
apus.mastodon.imageLimit=1
apus.mastodon.imagesEnabled=true
apus.mastodon.instance=ijug.social
apus.post.numberOfColumns=3
apus.sessionize.eventApi=https://sessionize.com/api/v2/%s/view/Sessions
apus.sessionize.eventId=0
apus.social.headline=
apus.social.numberOfColumns=3

0 comments on commit 8420fea

Please sign in to comment.