html redirect
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<version>3.0.11</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.flagnote</groupId>
|
||||
@@ -19,7 +19,7 @@
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
|
||||
<spring-cloud.version>2022.0.2</spring-cloud.version>
|
||||
<spring-cloud.version>2022.0.4</spring-cloud.version>
|
||||
<docker.repostory>registry.openif.com:5000</docker.repostory>
|
||||
<docker.registry.name>flagnote</docker.registry.name>
|
||||
</properties>
|
||||
@@ -52,6 +52,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
FROM openjdk:17-slim
|
||||
FROM registry.openif.com:5000/flagnote/flagnote-docker-image:0.0.1
|
||||
VOLUME /tmp
|
||||
ADD flagnote-service-0.0.1.jar app.jar
|
||||
RUN sh -c 'touch /app.jar'
|
||||
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
|
||||
RUN apt-get update && apt-get install -y curl
|
||||
ENV JAVA_OPTS=""
|
||||
ENTRYPOINT [ "sh", "-c", "exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.flagnote.note.controller;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.flagnote.note.entity.KeyMeta;
|
||||
import com.flagnote.note.utils.BizKeyUtils;
|
||||
import com.flagnote.note.utils.JsonUtils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/html")
|
||||
public class HtmlController {
|
||||
|
||||
@RequestMapping(value = "/redirect", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
||||
public String redirect(Map<String, Object> map) {
|
||||
KeyMeta c = new KeyMeta();
|
||||
String key = BizKeyUtils.getKey();
|
||||
c.setKey(key);
|
||||
c.setServerTime(new Date().getTime());
|
||||
c.setCipher(BizKeyUtils.getCipher(key, c.getServerTime().toString()));
|
||||
c.setSecretKey(BizKeyUtils.getSecretKey(key));
|
||||
|
||||
map.put("keyMeta", JsonUtils.toJson(c));
|
||||
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
}
|
||||
35
src/main/resources/templates/redirect.ftl
Normal file
35
src/main/resources/templates/redirect.ftl
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="renderer" content="webkit" />
|
||||
<meta name="force-rendering" content="webkit" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="theme-color" content="#ed4014" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Cache-control" content="no-cache" />
|
||||
<meta http-equiv="Cache" content="no-cache" />
|
||||
<title>flagnote.com</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #dddddd
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
let keyMeta = ${keyMeta};
|
||||
|
||||
if (keyMeta && keyMeta.key) {
|
||||
sessionStorage.setItem(keyMeta.key + ".keyMeta", JSON.stringify(keyMeta));
|
||||
location.href = "/" + keyMeta.key;
|
||||
} else {
|
||||
location.href = "/100006";
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body><noscript><strong>Please enable JavaScript to continue.</strong></noscript>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user