Skip to content

Commit

Permalink
Vorbereitung für die Suche
Browse files Browse the repository at this point in the history
  • Loading branch information
commel committed Oct 1, 2023
1 parent eaa3e42 commit cdb6e44
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 52 deletions.
52 changes: 2 additions & 50 deletions doc/tomcat/conf/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,58 +85,10 @@
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
redirectPort="8443"
URIEncoding="UTF-8" />

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->

<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public SecurityFilterChain webFormSecurityFilterChain(final HttpSecurity http, f

// Normale Webseite, auch als Gast nutzbar
.authorizeHttpRequests((requests) -> requests.requestMatchers(antMatcher("/"),
antMatcher("/search/**"),
antMatcher("/wiki/**"),
antMatcher("/datenschutz"),
antMatcher("/privacy"),
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/de/holarse/web/controller/SearchController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.holarse.web.controller;

import de.holarse.web.defines.WebDefines;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value = "/search")
public class SearchController {

@PostMapping
public ModelAndView searchForm(@RequestParam("q") final String q) throws UnsupportedEncodingException {
return new ModelAndView(String.format("redirect:/search?q=%s", q)); //URLEncoder.encode(q, StandardCharsets.UTF_8.toString())));
}

@GetMapping
public ModelAndView search(@RequestParam("q") final String q, final ModelAndView mv) throws UnsupportedEncodingException {
mv.setViewName("layouts/bare");
mv.addObject(WebDefines.DEFAULT_VIEW_ATTRIBUTE_NAME, "sites/search/results");

mv.addObject("q", q); //URLDecoder.decode(q, StandardCharsets.UTF_8.toString()));

return mv;
}

}
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/templates/fragments/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
</ul>

<!-- Search Form -->
<form id="searchform-1" class="u-searchform-v1" method="POST" action="/search">
<form id="searchform-1" class="u-searchform-v1" method="POST" data-th-action="@{/search}" encoding="UTF-8">
<input type="hidden" data-th-name="${_csrf.parameterName}" data-th-value="${_csrf.token}" />
<div class="input-group g-brd-primary--focus">
<input class="form-control rounded-0 u-form-control" type="search" placeholder="Linuxspiele finden..." id="query" name="term" data-th-value="${term}">
<input class="form-control rounded-0 u-form-control" type="search" placeholder="Linuxspiele finden..." id="query" name="q" data-th-value="${q}">
<div class="input-group-addon p-0">
<button class="btn rounded-0 btn-primary btn-md g-font-size-14 g-px-18" type="submit">
<i class="fa fa-search"></i>
Expand Down
5 changes: 5 additions & 0 deletions src/main/webapp/WEB-INF/templates/sites/search/results.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="container">
<div class="row">
Suchergebnisse für '<span data-th-text="${q}"></span>'
</div>
</div>

0 comments on commit cdb6e44

Please sign in to comment.