Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Feature/spring boot #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ java/bin
java/build
go/servepkx.exe
go/servepkx_linux
go/servepkx_mac
go/servepkx_mac
servepkx-spring-boot/target
.idea
*.iml
9 changes: 9 additions & 0 deletions servepkx-spring-boot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Self-hosted servepkx

__Requires Java 8__

To start run the following command

`java -jar servepkx.jar`

The jar can also be run by double-clicking it, but you will need to kill the process manually.
73 changes: 73 additions & 0 deletions servepkx-spring-boot/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.github.flagbrew</groupId>
<artifactId>servepkx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>servepkx</name>
<description>Self hosted servepkx browser version</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>servepkx</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/static</outputDirectory>
<resources>
<resource>
<directory>../browser</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package io.github.flagbrew.servepkx;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;

import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**
* @author rproud
* @since 2018-10-07
*/
@SpringBootApplication
public class Application {

private static final Logger logger = LoggerFactory.getLogger(Application.class);

@Value("${local.server.port:8080}")
private Integer serverPort;

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

@EventListener(ApplicationReadyEvent.class)
public void applicationReadyEvent() {
System.out.println("Application started ... launching browser now");
Browse("http://localhost:" + serverPort);
}

public static void Browse(String url) {
if(Desktop.isDesktopSupported()){
final Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI(url));
} catch (IOException | URISyntaxException e) {
logger.error("Failed to open browser with Desktop support", e);
}
}else{
final Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("rundll32 url.dll,FileProtocolHandler " + url);
} catch (IOException e) {
logger.error("Failed to open url with FileProtocolHandler", e);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.flagbrew.servepkx.web;

import org.springframework.stereotype.Controller;

/**
* @author rproud
* @since 2018-10-07
*/
@Controller
public class ServePkxController {
}