Skip to content
Merged
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
1 change: 1 addition & 0 deletions cms-api/src/main/java/com/condation/cms/api/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public static class CacheNames {
public static final String TEMPLATE = "template";
public static final String CONTENT = "content";
public static final String MEDIA = "media";
public static final String MENU = "menu";
public static final String RESPONSE = "response";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.condation.cms.api.eventbus.events;

/*-
* #%L
* CMS Api
* %%
* Copyright (C) 2023 - 2026 CondationCMS
* %%
* 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 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/>.
* #L%
*/

import com.condation.cms.api.eventbus.Event;

/**
* Signals that the persisted representation of a site menu has changed.
*/
public record MenuChangedEvent(String menuId) implements Event {
}
2 changes: 2 additions & 0 deletions cms-api/src/main/java/com/condation/cms/api/hooks/Hooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public enum Hooks {
/* navigation */
NAVIGATION_PATH("system/navigation/%s/path"),
NAVIGATION_LIST("system/navigation/%s/list"),
/* menu */
MENU_FILTER("system/menu/%s/items"),
/* content */
CONTENT_SHORTCODES("system/content/shortcode"),
CONTENT_FILTER("system/content/filter"),
Expand Down
34 changes: 34 additions & 0 deletions cms-api/src/main/java/com/condation/cms/api/menu/Menu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.condation.cms.api.menu;

/*-
* #%L
* CMS Api
* %%
* Copyright (C) 2023 - 2026 CondationCMS
* %%
* 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 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/>.
* #L%
*/

import java.util.List;

/**
* A named navigation menu. The id is also used as the YAML file name.
*/
public record Menu(String id, String name, List<MenuItem> items) {

public Menu {
items = items == null ? List.of() : List.copyOf(items);
}
}
54 changes: 54 additions & 0 deletions cms-api/src/main/java/com/condation/cms/api/menu/MenuItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.condation.cms.api.menu;

/*-
* #%L
* CMS Api
* %%
* Copyright (C) 2023 - 2026 CondationCMS
* %%
* 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 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/>.
* #L%
*/

import java.util.ArrayList;
import java.util.List;

/**
* A single, potentially nested entry in a navigation menu.
*/
public record MenuItem(
String id,
String type,
String label,
String url,
String target,
boolean enabled,
List<MenuItem> children,
boolean current) {

public MenuItem {
children = children == null ? new ArrayList<>() : new ArrayList<>(children);
}

public MenuItem(
String id,
String type,
String label,
String url,
String target,
boolean enabled,
List<MenuItem> children) {
this(id, type, label, url, target, enabled, children, false);
}
}
42 changes: 42 additions & 0 deletions cms-api/src/main/java/com/condation/cms/api/menu/MenuService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.condation.cms.api.menu;

/*-
* #%L
* CMS Api
* %%
* Copyright (C) 2023 - 2026 CondationCMS
* %%
* 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 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/>.
* #L%
*/

import java.io.IOException;
import java.util.List;
import java.util.Optional;

/**
* Storage abstraction for site navigation menus.
*/
public interface MenuService {

List<Menu> list() throws IOException;

Optional<Menu> get(String id) throws IOException;

Menu create(Menu menu) throws IOException;

Menu update(Menu menu) throws IOException;

boolean delete(String id) throws IOException;
}
62 changes: 62 additions & 0 deletions cms-api/src/main/java/com/condation/cms/api/ui/apps/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.condation.cms.api.ui.apps;

/*-
* #%L
* CMS Api
* %%
* Copyright (C) 2023 - 2026 CondationCMS
* %%
* 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 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/>.
* #L%
*/

import com.condation.cms.api.ui.action.UIAction;
import java.util.List;
import java.util.Objects;

/**
* An application available from the manager app launcher.
*
* @param id stable app identifier
* @param title title displayed in the app launcher
* @param icon URL of the app icon
* @param action action executed when the app is opened
* @param permissions permissions required to see the app
*/
public record App(
String id,
String title,
String icon,
UIAction action,
List<String> permissions) {

public App {
id = requireText(id, "App id");
title = requireText(title, "App title");
icon = requireText(icon, "App icon");
action = Objects.requireNonNull(action, "App action is required");
permissions = permissions == null ? List.of() : List.copyOf(permissions);
}

public App(String id, String title, String icon, UIAction action) {
this(id, title, icon, action, List.of());
}

private static String requireText(String value, String name) {
if (value == null || value.isBlank()) {
throw new IllegalArgumentException(name + " is required");
}
return value.trim();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.condation.cms.api.ui.apps;

/*-
* #%L
* CMS Api
* %%
* Copyright (C) 2023 - 2026 CondationCMS
* %%
* 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 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/>.
* #L%
*/

import com.condation.cms.api.ui.extensions.UIExtensionPoint;
import java.util.List;

/**
* Extension point for contributing applications to the manager app launcher.
*/
public interface AppExtensionPoint extends UIExtensionPoint {

List<App> getApps();
}
Loading
Loading