Skip to content

Commit

Permalink
♻️ refactor Conference to Agenda closes #94
Browse files Browse the repository at this point in the history
  • Loading branch information
McPringle committed Apr 18, 2024
1 parent bdef585 commit 3532d4d
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 95 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Modify this command according your needs and consult the [configuration section]

## Plugin Support

### Conference Plugins
### Agenda Plugins

*Apus* uses a simple plugin technology to import the agenda of various events. Plugins are currently available for the following events:

Expand All @@ -202,7 +202,7 @@ Plugins for other social media services are planned.

### Plugin Development

Everyone is welcome to contribute a plugin themselves. The implementation is very simple. There are two types of plugins: `ConferencePlugin` and `SocialPlugin`. For a new plugin, a new package is created under `swiss.fihlon.apus.plugin.conference` or `swiss.fihlon.apus.plugin.social`, based on the plugin type. The implementation is carried out in this new package. Implement one of these two interfaces depending on the plugin type you want to contribute.
Everyone is welcome to contribute a plugin themselves. The implementation is very simple. There are two types of plugins: `AgendaPlugin` and `SocialPlugin`. For a new plugin, a new package is created under `swiss.fihlon.apus.plugin.agenda` or `swiss.fihlon.apus.plugin.social`, based on the plugin type. The implementation is carried out in this new package. Implement one of these two interfaces depending on the plugin type you want to contribute.

If your implementation requires a configuration, the `Configuration` class must be extended accordingly. Add a property and corresponding setters and getters in the marked sections. Implement the settings object as a `record` in your new plugin package. Take one of the existing plugins as a template. Default settings belong in the file `application.properties` and the corresponding schema is stored in `additional-spring-configuration-metadata.json`. Of course, this `README.md` must also be adapted.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#conference-view {
#agenda-view {
background-color: #007e89;
position: absolute;
top: 0;
Expand All @@ -26,18 +26,18 @@
overflow: clip;
}

#conference-view h2 {
#agenda-view h2 {
float: left;
font-size: 30px;
margin: 10px;
}

#conference-view .legend {
#agenda-view .legend {
float: right;
padding: 13px 10px 0 0;
}

#conference-view .legend > span {
#agenda-view .legend > span {
color: #003861;
margin-left: var(--lumo-space-s);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,6 @@
"workbox-core": "7.0.0",
"workbox-precaching": "7.0.0"
},
"hash": "8023d3b7b5d639047c5ab43eb5c1312a8fbbb60e1e6ce1130741ac4296ad6f5d"
"hash": "1d21881e8ebfe05d70574f3d5e5566c7c252fa9ae84068b3f09d53fd47ed661a"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* 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.conference;
package swiss.fihlon.apus.agenda;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* 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.conference;
package swiss.fihlon.apus.agenda;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* 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.conference;
package swiss.fihlon.apus.agenda;

import org.jetbrains.annotations.NotNull;

public enum RoomStyle {

NONE("", ""),
RUNNING("running-session", "conference.legend.running-session"),
NEXT("next-session", "conference.legend.next-session"),
EMPTY("empty-room", "conference.legend.empty-room");
RUNNING("running-session", "agenda.legend.running-session"),
NEXT("next-session", "agenda.legend.next-session"),
EMPTY("empty-room", "agenda.legend.empty-room");

private final String cssStyle;
private final String translationKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* 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.conference;
package swiss.fihlon.apus.agenda;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* 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.conference;
package swiss.fihlon.apus.agenda;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* 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.conference;
package swiss.fihlon.apus.agenda;

import org.jetbrains.annotations.NotNull;

Expand Down
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 @@ -20,7 +20,7 @@
import org.jetbrains.annotations.NotNull;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import swiss.fihlon.apus.plugin.conference.doag.DoagConfig;
import swiss.fihlon.apus.plugin.agenda.doag.DoagConfig;
import swiss.fihlon.apus.plugin.social.mastodon.MastodonConfig;

@org.springframework.context.annotation.Configuration
Expand All @@ -33,7 +33,7 @@ public class Configuration {
private AdminConfig admin;
private FilterConfig filter;

// Conference Plugin Configs
// Agenda Plugin Configs
private DoagConfig doag;

// Social Plugin Configs
Expand Down Expand Up @@ -63,9 +63,9 @@ public void setFilter(@NotNull final FilterConfig filter) {
this.filter = filter;
}

///////////////////////////////
// Conference Plugin Configs //
///////////////////////////////
///////////////////////////
// Agenda Plugin Configs //
///////////////////////////

public DoagConfig getDoag() {
return doag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* 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.plugin.conference;
package swiss.fihlon.apus.plugin.agenda;

import org.jetbrains.annotations.NotNull;
import swiss.fihlon.apus.conference.Session;
import swiss.fihlon.apus.agenda.Session;

import java.util.List;

public interface ConferencePlugin {
public interface AgendaPlugin {

boolean isEnabled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
* 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.plugin.conference;
package swiss.fihlon.apus.plugin.agenda;

import jakarta.annotation.PreDestroy;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Service;
import swiss.fihlon.apus.conference.Room;
import swiss.fihlon.apus.conference.Session;
import swiss.fihlon.apus.conference.SessionImportException;
import swiss.fihlon.apus.plugin.conference.doag.DoagPlugin;
import swiss.fihlon.apus.agenda.Room;
import swiss.fihlon.apus.agenda.Session;
import swiss.fihlon.apus.agenda.SessionImportException;
import swiss.fihlon.apus.plugin.agenda.doag.DoagPlugin;
import swiss.fihlon.apus.configuration.Configuration;

import java.time.Duration;
Expand All @@ -38,23 +38,23 @@
import java.util.concurrent.ScheduledFuture;

@Service
public final class ConferenceService {
public final class AgendaService {

private static final Duration UPDATE_FREQUENCY = Duration.ofMinutes(5);
private static final Logger LOGGER = LoggerFactory.getLogger(ConferenceService.class);
private static final Logger LOGGER = LoggerFactory.getLogger(AgendaService.class);

private final ConferencePlugin conferencePlugin;
private final AgendaPlugin agendaPlugin;
private final ScheduledFuture<?> updateScheduler;
private Map<Room, List<Session>> roomsWithSessions = new TreeMap<>();

public ConferenceService(@NotNull final TaskScheduler taskScheduler,
@NotNull final Configuration configuration) {
conferencePlugin = new DoagPlugin(configuration);
if (conferencePlugin.isEnabled()) {
public AgendaService(@NotNull final TaskScheduler taskScheduler,
@NotNull final Configuration configuration) {
agendaPlugin = new DoagPlugin(configuration);
if (agendaPlugin.isEnabled()) {
updateSessions();
updateScheduler = taskScheduler.scheduleAtFixedRate(this::updateSessions, UPDATE_FREQUENCY);
} else {
LOGGER.warn("No conference plugin is enabled. No agenda will be displayed.");
LOGGER.warn("No event plugin is enabled. No agenda will be displayed.");
updateScheduler = null;
}
}
Expand All @@ -66,7 +66,7 @@ public void stopUpdateScheduler() {

private void updateSessions() {
try {
final var sessions = conferencePlugin.getSessions().stream()
final var sessions = agendaPlugin.getSessions().stream()
.sorted()
.toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
* 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.plugin.conference.doag;
package swiss.fihlon.apus.plugin.agenda.doag;

public record DoagConfig(int eventId) { }
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
* 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.plugin.conference.doag;
package swiss.fihlon.apus.plugin.agenda.doag;

import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import swiss.fihlon.apus.conference.Language;
import swiss.fihlon.apus.conference.Room;
import swiss.fihlon.apus.conference.Session;
import swiss.fihlon.apus.conference.SessionImportException;
import swiss.fihlon.apus.conference.Speaker;
import swiss.fihlon.apus.agenda.Language;
import swiss.fihlon.apus.agenda.Room;
import swiss.fihlon.apus.agenda.Session;
import swiss.fihlon.apus.agenda.SessionImportException;
import swiss.fihlon.apus.agenda.Speaker;
import swiss.fihlon.apus.configuration.Configuration;
import swiss.fihlon.apus.plugin.conference.ConferencePlugin;
import swiss.fihlon.apus.plugin.agenda.AgendaPlugin;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -44,7 +44,7 @@
import java.util.Iterator;
import java.util.List;

public final class DoagPlugin implements ConferencePlugin {
public final class DoagPlugin implements AgendaPlugin {

public static final Logger LOGGER = LoggerFactory.getLogger(DoagPlugin.class);
public static final String CONFERENCE_API_LOCATION = "https://meine.doag.org/api/event/action.getCPEventAgenda/eventId.%d/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import com.vaadin.flow.component.notification.Notification;
import org.jetbrains.annotations.NotNull;
import org.springframework.scheduling.TaskScheduler;
import swiss.fihlon.apus.conference.Room;
import swiss.fihlon.apus.conference.RoomStyle;
import swiss.fihlon.apus.conference.Session;
import swiss.fihlon.apus.plugin.conference.ConferenceService;
import swiss.fihlon.apus.agenda.Room;
import swiss.fihlon.apus.agenda.RoomStyle;
import swiss.fihlon.apus.agenda.Session;
import swiss.fihlon.apus.plugin.agenda.AgendaService;

import java.time.Duration;
import java.time.Instant;
Expand All @@ -43,23 +43,23 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicInteger;

@CssImport(value = "./themes/apus/views/conference-view.css")
public final class ConferenceView extends Div {
@CssImport(value = "./themes/apus/views/agenda-view.css")
public final class AgendaView extends Div {

public static final String LABEL_THEME = "badge";
private static final int MAX_ROOMS_IN_VIEW = 12;
private static final Duration UPDATE_FREQUENCY = Duration.ofMinutes(1);
private static final Duration TIME_LIMIT_NEXT_SESSION = Duration.ofHours(1);

private final transient ConferenceService conferenceService;
private final transient AgendaService agendaService;
private final H2 title = createTitle();
private final Div roomContainer = new Div();
private final Span legend = new Span();

public ConferenceView(@NotNull final ConferenceService conferenceService,
@NotNull final TaskScheduler taskScheduler) {
this.conferenceService = conferenceService;
setId("conference-view");
public AgendaView(@NotNull final AgendaService agendaService,
@NotNull final TaskScheduler taskScheduler) {
this.agendaService = agendaService;
setId("agenda-view");
add(title);
add(createLegend());
add(roomContainer);
Expand All @@ -76,14 +76,14 @@ private void updateConferenceSessions() {
roomContainer.removeAll();
final var today = LocalDate.now();
final var roomCounter = new AtomicInteger(0);
final var roomsWithSessions = conferenceService.getRoomsWithSessions().entrySet();
final var roomsWithSessions = agendaService.getRoomsWithSessions().entrySet();
if (roomsWithSessions.isEmpty()) {
Notification.show(getTranslation("conference.error.nosessions"));
Notification.show(getTranslation("agenda.error.nosessions"));
}
final var roomStylesInUse = new HashSet<RoomStyle>();
for (final Map.Entry<Room, List<Session>> roomWithSession : roomsWithSessions) {
if (roomCounter.get() >= MAX_ROOMS_IN_VIEW) {
Notification.show(String.format(getTranslation("conference.error.rooms"), roomsWithSessions.size()));
Notification.show(String.format(getTranslation("agenda.error.rooms"), roomsWithSessions.size()));
break;
}
final RoomView roomView = createRoomView(roomWithSession, today, roomCounter);
Expand All @@ -96,12 +96,12 @@ private void updateConferenceSessions() {

@NotNull
private H2 createTitle() {
return new H2(getTranslation("conference.heading",
return new H2(getTranslation("agenda.heading",
LocalDate.now().getDayOfWeek().getDisplayName(TextStyle.FULL, UI.getCurrent().getLocale())));
}

private void updateTitle() {
title.setText(getTranslation("conference.heading",
title.setText(getTranslation("agenda.heading",
LocalDate.now().getDayOfWeek().getDisplayName(TextStyle.FULL, UI.getCurrent().getLocale())));

}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/swiss/fihlon/apus/ui/view/RoomView.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import com.vaadin.flow.component.html.Span;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import swiss.fihlon.apus.conference.Language;
import swiss.fihlon.apus.conference.Room;
import swiss.fihlon.apus.conference.RoomStyle;
import swiss.fihlon.apus.conference.Session;
import swiss.fihlon.apus.conference.Speaker;
import swiss.fihlon.apus.agenda.Language;
import swiss.fihlon.apus.agenda.Room;
import swiss.fihlon.apus.agenda.RoomStyle;
import swiss.fihlon.apus.agenda.Session;
import swiss.fihlon.apus.agenda.Speaker;

import java.time.Duration;
import java.time.LocalTime;
Expand Down Expand Up @@ -134,7 +134,7 @@ private Component createTimeComponent() {
final Duration duration = Duration.between(now, endTime);
final long timeLeft = Math.round(duration.getSeconds() / 60f);
timeComponent.add(new Text("⌛ " + getTranslation(timeLeft == 1
? "conference.session.countdown.singular" : "conference.session.countdown.plural",
? "agenda.session.countdown.singular" : "agenda.session.countdown.plural",
timeLeft)));
roomStyle = RoomStyle.RUNNING;
} else { // next session
Expand Down
Loading

0 comments on commit 3532d4d

Please sign in to comment.