Compare commits

..

No commits in common. "6a11f7ec6ccf6b5b4175ff6d867d24edaa576a66" and "5c965eb61d6e392eb87f69f7df61dff7386e6d91" have entirely different histories.

8 changed files with 4 additions and 80 deletions

View file

@ -2,28 +2,20 @@ package eu.m724.talkpages;
import io.quarkus.qute.CheckedTemplate;
import io.quarkus.qute.TemplateInstance;
import io.vertx.core.http.Cookie;
import io.vertx.core.http.HttpServerRequest;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.NewCookie;
import jakarta.ws.rs.core.Response;
import org.jboss.resteasy.reactive.RestResponse.Status;
import java.net.URI;
@Path("/")
public class IndexResource {
@Inject
RedirectService redirectService;
@Inject
HttpServerRequest request;
@CheckedTemplate
public static class Templates {
public static native TemplateInstance index();
@ -35,29 +27,6 @@ public class IndexResource {
return Templates.index();
}
@GET
@Path("/theme")
public Response toggleDark() {
Cookie cookie = request.getCookie("dark");
NewCookie newCookie;
if (cookie == null) {
newCookie = new NewCookie.Builder("dark")
.path("/")
.value("1")
.maxAge(31560000)
.build();
} else {
newCookie = new NewCookie.Builder("dark")
.path("/")
.value("0")
.maxAge(0)
.build();
}
return Response.temporaryRedirect(URI.create("/")).cookie(newCookie).build();
}
@GET
@Path("/search")
public Response search(@QueryParam("query") String query) {

View file

@ -5,8 +5,6 @@ import eu.m724.talkpages.orm.entity.content.Page;
import eu.m724.talkpages.orm.entity.content.PageRevision;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.StartupEvent;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.handler.StaticHandler;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
@ -25,12 +23,6 @@ public class Startup {
@ConfigProperty(name = "talkpages.createExamplePage")
private boolean createExamplePage;
void installStaticRoute(@Observes StartupEvent startupEvent, Router router) {
router.route()
.path("/static/*")
.handler(StaticHandler.create("static/"));
}
@Transactional
public void examplePage(@Observes StartupEvent ignoredEvent) {
if (Account.findById(1) != null) {

View file

@ -1,10 +1,7 @@
package eu.m724.talkpages.template;
import io.quarkus.qute.TemplateExtension;
import io.vertx.core.http.Cookie;
import io.vertx.core.http.HttpServerRequest;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jsoup.Jsoup;
import org.jsoup.safety.Safelist;

View file

@ -1,21 +0,0 @@
package eu.m724.talkpages.template;
import eu.m724.talkpages.RedirectService;
import io.quarkus.arc.Arc;
import io.quarkus.qute.TemplateExtension;
import io.vertx.core.Vertx;
import io.vertx.core.http.Cookie;
import io.vertx.core.http.HttpServerRequest;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Request;
@TemplateExtension(namespace = "theme")
public class ThemeExtension {
public static boolean darkTheme() {
// this is bad
HttpServerRequest request = Arc.container().instance(HttpServerRequest.class).get();
Cookie cookie = request.getCookie("dark");
return cookie == null || cookie.getValue().equals("0");
}
}

View file

@ -1,9 +0,0 @@
body {
background: #202020;
color: white;
}
a:link { color: #e0d0ff; }
a:visited { color: #d0c0ff; }
a:hover { color: #e0e0ff; }
a:active { color: #e0d0ff; }

View file

@ -7,10 +7,10 @@
<form method="post" action="/auth/action/register">
<label for="username">Username</label>
<input type="text" id="username" name="username" value="{username}" title="Go back to change" readonly>
<input type="text" id="username" name="username" disabled value="{username}">
<br>
<label for="password">Confirm password</label>
<input type="password" id="password" name="password" title="Copy the password you submitted in the last step">
<input type="password" id="password" name="password">
<br>
<input type="submit" value="Register">
</form>

View file

@ -9,11 +9,10 @@
<ul>
<li><a href="/edit">Create a page</a></li>
{#if !user:loggedIn}
<li><a href="/auth">Login or register</a></li>
<li><a href="/auth">Login or register</a></li>
{#else}
<li><a href="/auth/logout">Logout ({user:name})</a></li>
<li><a href="/auth/logout">Logout ({user:name})</a></li>
{/if}
<li><a href="/theme">{#if theme:darkTheme}Light mode{#else}Dark mode{/if}</a></li>
</ul>
<small>Running <a href="/page/TalkPages">TalkPages</a> version {config:["quarkus.application.version"]}</small>

View file

@ -4,9 +4,6 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- TODO opengraph tags and maybe some nice css. also add errors and stuff here -->
{#if theme:darkTheme}
<link rel="stylesheet" href="/static/dark.css">
{/if}
<title>{#insert pageTitle /}{#if !customTitle??} - TalkPages{/if}</title> <!-- I give up -->
</head>
<body>