Skip to content

Commit

Permalink
✨ Add a full-screen social media post view without conference agenda c…
Browse files Browse the repository at this point in the history
…loses #44

Signed-off-by: Marcus Fihlon <[email protected]>
  • Loading branch information
McPringle committed Aug 30, 2024
1 parent 9967f90 commit 5ba1735
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ For questions and support requests, please use

### New Features

* Add a full-screen social media post view without conference agenda

### Fixed Bugs

### Maintenance Work
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ To modify the default configuration values, just specify environment variables w
| MASTODON_IMAGE_LIMIT | 1 | Limit number of images per post (0 = no limit). |
| MASTODON_IMAGES_ENABLED | true | Enable or disable images in mastodon posts. |
| MASTODON_INSTANCE | | The Mastodon instance used to read the posts from (empty = disabled). |
| POST_COLUMNS | 3 | How many columns to be used for social media posts. |
| SESSIONIZE_EVENT_API | [2] | The URL of the Sessionize event API to read the conference agenda. |
| SESSIONIZE_EVENT_ID | 0 | The ID of the Sessionize event to read the conference agenda (0 = disabled). |
| TZ | UTC | The timezone used for date and time calculations. |
Expand Down
11 changes: 10 additions & 1 deletion frontend/themes/apus/views/social-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
flex-direction: column;
}

.fullscreen-posts > #social-view {
left: 0;
width: 1900px;
}

#social-view * {
color: var(--social-text-color);
}
Expand All @@ -51,5 +56,9 @@
flex-direction: column;
row-gap: var(--lumo-space-s);
justify-content: safe flex-start;
width: 33%;
width: calc(100% / 3);
}

.fullscreen-posts > #social-view .column {
width: calc(100% / 6);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Configuration {
private AdminConfig admin;
private CustomConfig custom;
private EventConfig event;
private PostConfig post;
private FilterConfig filter;

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

public PostConfig getPost() {
return post;
}

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

public FilterConfig getFilter() {
return filter;
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/swiss/fihlon/apus/configuration/PostConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Apus - A social wall for conferences with additional features.
* Copyright (C) Marcus Fihlon and the individual contributors to Apus.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package swiss.fihlon.apus.configuration;

public record PostConfig(int numberOfColumns) { }
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public EventService(@NotNull final TaskScheduler taskScheduler,
@NotNull final Configuration configuration,
@NotNull final List<EventPlugin> eventPlugins) {
this.eventPlugins = eventPlugins;
if (eventPlugins.stream().anyMatch(EventPlugin::isEnabled)) {
if (isEnabled()) {
updateSessions();
final var updateFrequency = Duration.ofMinutes(configuration.getEvent().updateFrequency());
if (updateFrequency.isPositive()) {
Expand Down Expand Up @@ -109,4 +109,8 @@ public Map<Room, List<Session>> getRoomsWithSessions() {
return new TreeMap<>(roomsWithSessions);
}
}

public boolean isEnabled() {
return eventPlugins.stream().anyMatch(EventPlugin::isEnabled);
}
}
14 changes: 10 additions & 4 deletions src/main/java/swiss/fihlon/apus/ui/view/SocialView.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;

Expand All @@ -48,7 +49,7 @@ public final class SocialView extends Div {

private final transient SocialService socialService;
private final transient Configuration configuration;
private final List<Div> postsColumns = List.of(new Div(), new Div(), new Div());
private final List<Div> postsColumns;
private final ContextMenu contextMenu;
private boolean adminModeEnabled = false;

Expand All @@ -63,10 +64,15 @@ public SocialView(@NotNull final SocialService socialService,
var postsColumnsDiv = new Div();
postsColumnsDiv.addClassName("posts");
add(postsColumnsDiv);
postsColumns.forEach(postsContainer -> {
postsColumnsDiv.add(postsContainer);

final int numberOfColumns = configuration.getPost().numberOfColumns();
postsColumns = new ArrayList<>(numberOfColumns);
for (int i = 0; i < numberOfColumns; i++) {
final var postsContainer = new Div();
postsColumns.add(postsContainer);
postsContainer.addClassName("column");
});
postsColumnsDiv.add(postsContainer);
}

if (adminModeEnabled || configuration.getAdmin().password().isBlank()) {
contextMenu = null;
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/swiss/fihlon/apus/ui/view/SocialWallView.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ public SocialWallView(@NotNull final EventService eventService,
});
}
setId("social-wall-view");
add(new EventView(eventService, taskScheduler, configuration));
if (eventService.isEnabled()) {
add(new EventView(eventService, taskScheduler, configuration));
} else {
addClassName("fullscreen-posts");
}
add(new SocialView(socialService, taskScheduler, configuration));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
"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 Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ 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}
1 change: 1 addition & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ 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

0 comments on commit 5ba1735

Please sign in to comment.