1
0

Basic implementation for files app

This commit is contained in:
2022-05-06 23:01:23 +02:00
parent 4e12f4805e
commit 7d6c6c6321
54 changed files with 2381 additions and 94 deletions

View File

@@ -21,21 +21,44 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- nbs-cloud modules -->
<!-- optional nbs-cloud modules -->
<!-- comment the ones you don't need -->
<dependency>
<groupId>de.77zzc7.nbs-cloud</groupId>
<groupId>de.77zzcx7.nbs-cloud</groupId>
<artifactId>notes</artifactId>
</dependency>
<dependency>
<groupId>de.77zzcx7.nbs-cloud</groupId>
<artifactId>pastebin</artifactId>
</dependency>
<dependency>
<groupId>de.77zzcx7.nbs-cloud</groupId>
<artifactId>bookmarks</artifactId>
</dependency>
<dependency>
<groupId>de.77zzcx7.nbs-cloud</groupId>
<artifactId>todo</artifactId>
</dependency>
<!-- required nbs-cloud modules -->
<dependency>
<groupId>de.77zzcx7.nbs-cloud</groupId>
<artifactId>web-container-registry</artifactId>
</dependency>
<dependency>
<groupId>de.77zzcx7.nbs-cloud</groupId>
<artifactId>web-container-config</artifactId>
</dependency>
<dependency>
<groupId>de.77zzcx7.nbs-cloud</groupId>
<artifactId>dashboard</artifactId>
</dependency>
<dependency>
<groupId>de.77zzcx7.nbs-cloud</groupId>
<artifactId>files</artifactId>
</dependency>
@@ -44,6 +67,25 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- Misc -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -6,6 +6,12 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "nbs-cloud.web-container")
@ComponentScan("de.nbscloud.webcontainer.shared")
@ComponentScan("de.nbscloud.files")
@ComponentScan("de.nbscloud.notes")
@ComponentScan("de.nbscloud.pastebin")
@ComponentScan("de.nbscloud.bookmarks")
@ComponentScan("de.nbscloud.todo")
@ComponentScan("de.nbscloud.dashboard")
public class WebContainerConfig {
}

View File

@@ -0,0 +1,58 @@
package de.nbscloud.webcontainer.controller;
import de.nbscloud.webcontainer.registry.App;
import de.nbscloud.webcontainer.registry.AppRegistry;
import de.nbscloud.webcontainer.shared.config.WebContainerSharedConfig;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import javax.servlet.http.HttpServletRequest;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.stream.Collectors;
@Controller
public class WebContainerController {
private static final Logger logger = LoggerFactory.getLogger(WebContainerController.class);
@Autowired
private WebContainerSharedConfig webContainerSharedConfig;
@Autowired
private AppRegistry appRegistry;
@GetMapping("/")
public String landing(Model model) {
logger.info("NBSCloud started - apps available: {}", this.appRegistry.getAll().stream().map(App::getId)
.collect(Collectors.joining(", ")));
return "redirect:dashboard";
}
@GetMapping("/toggleDarkMode")
public String toggleDarkMode(Model model, HttpServletRequest httpServletRequest) {
String navigateTo = "/";
try {
final String fullPath = new URL(httpServletRequest.getHeader("referer")).toURI().getPath();
// FIXME - will break if the app is deployed on http://host/a/b/financer instead of http://host/financer
final String tmpPath = StringUtils.removeStart(fullPath, "/");
navigateTo = tmpPath.substring(tmpPath.indexOf("/"));
} catch (MalformedURLException | URISyntaxException | StringIndexOutOfBoundsException e) {
// TODO
e.printStackTrace();
}
this.webContainerSharedConfig.setDarkMode(!this.webContainerSharedConfig.isDarkMode());
return "redirect:" + navigateTo;
}
}

View File

@@ -0,0 +1,20 @@
### This is the main configuration file of the application.
### Filtering of the @...@ values happens via the maven-resource-plugin. The execution of the plugin is configured in
### the Spring Boot parent POM.
spring.profiles.active=@activeProfiles@
info.app.name=NoBullShit Cloud - web container
info.app.description=Aggregator for web projects
info.build.group=@project.groupId@
info.build.artifact=@project.artifactId@
info.build.version=@project.version@
spring.messages.basename=i18n/container_messages,i18n/files_messages
spring.servlet.multipart.max-file-size=-1
spring.servlet.multipart.max-request-size=-1
logging.level.de.nbscloud=DEBUG
logging.file=nbscloud.log
logging.file.max-history=7
logging.file.max-size=50MB

View File

@@ -0,0 +1,3 @@
nbscloud.show-actions=...
nbscloud.footer.changelog=Changelog
nbscloud.footer.toggleDarkMode=Toggle dark mode

View File

@@ -0,0 +1,3 @@
nbscloud.show-actions=...
nbscloud.footer.changelog=\u00C4nderungshistorie
nbscloud.footer.toggleDarkMode=Dark Mode umschalten

View File

@@ -0,0 +1,2 @@
v1:
- Initial

View File

@@ -0,0 +1,12 @@
/* Color definitions for dark mode */
:root {
--error-color: #D30000;
--text-color: #7f7f7f;
--background-color: #1d1f21;
--link-color: #87ab63;
--hover-color: #1f1f2f;
--border-color: #7f7f7f;
--background-brightness: 1.5;
--good-color: #479A37;
}
/* --------------------- */

View File

@@ -0,0 +1,12 @@
/* Color definitions for light mode */
:root {
--error-color: #D30000;
--text-color: #000000;
--background-color: #FFFFFF;
--link-color: #0000EE;
--hover-color: lightgrey;
--border-color: #ddd;
--background-brightness: 0.5;
--good-color: #479A37;
}
/* --------------------- */

View File

@@ -0,0 +1,95 @@
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(../font/SourceCodePro_Regular_400.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url(../font/SourceCodePro_Bold_600.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(../font/Material_Icons.woff2) format('woff2');
}
.icon {
font-family: 'Material Icons';
vertical-align: middle;
}
body {
color: var(--text-color);
background-color: var(--background-color);
font-family: 'Source Code Pro', monospace;
}
* {
font-family: 'Source Code Pro', monospace;
}
a {
color: var(--link-color);
}
tr:hover {
background-color: var(--hover-color);
}
#footer-container {
margin-top: 1em;
}
#footer-container > hr,
#footer-container > div {
display: block;
}
#footer-container > hr {
width: 100%;
}
#footer-container > div {
text-align: center;
font-size: 0.9em;
}
.errorMessage {
color: var(--error-color);
}
.menu-entry {
display: inline;
padding-right: 6em;
}
#main-container {
display: flex;
flex-direction: column;
padding-left: 3em;
padding-right: 3em;
padding-top: 3em;
padding-bottom: 3em;
}
@media only screen and (max-width: 450px) {
.no-mobile {
display: none;
}
#main-container {
padding-left: 1em;
padding-right: 1em;
padding-top: 1em;
padding-bottom: 1em;
}
.menu-entry {
display: inline;
padding-right: 1em;
}
}

View File

@@ -0,0 +1,8 @@
<div id="footer-container" th:fragment="footer">
<hr>
<div>
<span th:text="'nbs-cloud v' + ${nbsVersion}"/>
&nbsp;(<a th:href="@{/changelog.txt}" th:text="#{nbscloud.footer.changelog}" />,
<a th:href="@{/toggleDarkMode}" th:text="#{nbscloud.footer.toggleDarkMode}" />)
</div>
</div>

View File

@@ -0,0 +1,5 @@
<div id="header-container" th:fragment="header">
<div th:each="app : ${apps}" class="menu-entry">
<a th:href="@{/} + ${app.startPath}" th:text="${app.id}"/>
</div>
</div>