Add cp page
This commit is contained in:
parent
aea5600d8e
commit
41bb8be727
31
src/main/java/ru/redguy/webinfomod/pages/cp/Index.java
Normal file
31
src/main/java/ru/redguy/webinfomod/pages/cp/Index.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package ru.redguy.webinfomod.pages.cp;
|
||||||
|
|
||||||
|
import fi.iki.elonen.NanoHTTPD;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import ru.redguy.webinfomod.Config;
|
||||||
|
import ru.redguy.webinfomod.IWebPage;
|
||||||
|
import ru.redguy.webinfomod.WebPage;
|
||||||
|
import ru.redguy.webinfomod.WebServer;
|
||||||
|
import ru.redguy.webinfomod.langs.LangFile;
|
||||||
|
import ru.redguy.webinfomod.langs.enums.Links;
|
||||||
|
import ru.redguy.webinfomod.langs.enums.RootCategories;
|
||||||
|
import ru.redguy.webinfomod.utils.WebUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
@WebPage(url = "/cp/")
|
||||||
|
public class Index implements IWebPage {
|
||||||
|
public NanoHTTPD.Response getPage(Config config, LangFile langFile, NanoHTTPD.IHTTPSession session) throws IOException {
|
||||||
|
String path = "/resources/web/pages/cp/index.html";
|
||||||
|
String page = IOUtils.toString(WebServer.class.getResourceAsStream(path), StandardCharsets.UTF_8);
|
||||||
|
WebUtils.CookieHandler ch = new WebUtils.CookieHandler(session.getHeaders());
|
||||||
|
if(ch.read("session") == null) {
|
||||||
|
page = page.replace("<replace id=\"1\"/>","<a href=\"auth/\" class=\"authLink\">"+langFile.getCategory(RootCategories.Links).getString(Links.login)+"</a>");
|
||||||
|
} else {
|
||||||
|
page = page.replace("<replace id=\"1\"/>","<a href=\"logout/\" class=\"authLink\">"+langFile.getCategory(RootCategories.Links).getString(Links.logout)+"</a><br>" +
|
||||||
|
"<a href=\"cp/\" class=\"authLink\">"+langFile.getCategory(RootCategories.Links).getString(Links.controlPanel)+"</a>");
|
||||||
|
}
|
||||||
|
return NanoHTTPD.newFixedLengthResponse(page);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
.authLink {
|
||||||
|
float: right;
|
||||||
|
}
|
16
src/main/resources/resources/web/pages/cp/index.html
Normal file
16
src/main/resources/resources/web/pages/cp/index.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>WebInfo</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/css/index.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header" id="header">
|
||||||
|
Идёт загрузка...
|
||||||
|
</div>
|
||||||
|
<main>
|
||||||
|
<replace id="1"/>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user