Skip to content

Commit

Permalink
qs web-components
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Nov 22, 2023
1 parent 3c16eaa commit 9437a69
Show file tree
Hide file tree
Showing 20 changed files with 842 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ pom.xml.versionsBackup
release.properties
.flattened-pom.xml

# web-bundler uses it for IDE support
node_modules/

# Eclipse
.project
.classpath
Expand Down
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.web-bundler</groupId>
<artifactId>quarkus-web-bundler</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>lit</artifactId>
<version>2.7.6</version>
</dependency>
<dependency>
<groupId>org.mvnpm</groupId>
<artifactId>lodash</artifactId>
<version>4.17.21</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.qute.web</groupId>
<artifactId>quarkus-qute-web</artifactId>
<version>3.0.0.CR2</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
Expand Down Expand Up @@ -133,6 +153,13 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkiverse.playwright</groupId>
<artifactId>quarkus-playwright</artifactId>
<version>0.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/quarkus/search/app/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SearchService {
public SearchResult<GuideSearchHit> search(@RestQuery @DefaultValue(QuarkusVersions.LATEST) String version,
@RestQuery List<String> categories,
@RestQuery String q,
@RestQuery @DefaultValue("highlighted") String highlightCssClass,
@RestQuery @DefaultValue("___") String highlightTag,
@RestQuery @DefaultValue("0") int page,
@RestQuery @DefaultValue("1") int contentSnippets,
@RestQuery @DefaultValue("100") int contentSnippetsLength) {
Expand Down Expand Up @@ -74,7 +74,7 @@ public SearchResult<GuideSearchHit> search(@RestQuery @DefaultValue(QuarkusVersi
.boost(50.0f)));
}
})
// * Highlighters are going to use spans-with-classes so that we will have more control over styling the visual on the search results screen.
// * Highlighters are going to use tags so that we will have more control over the search results.
// * We give control to the caller on the content snippet length and the number of these fragments
// * No match size is there to make sure that we are still going to get the text even if the field didn't have a match in it.
// * The title in the Guide entity is `Length.LONG` long, so we use that as a max value for no-match size, but hopefully nobody writes a title that long...
Expand All @@ -84,7 +84,7 @@ public SearchResult<GuideSearchHit> search(@RestQuery @DefaultValue(QuarkusVersi
// just in case we have any "unsafe" content:
.encoder(HighlighterEncoder.HTML)
.numberOfFragments(1)
.tag("<span class=\"" + highlightCssClass + "\">", "</span>")
.tag(highlightTag, highlightTag)
.boundaryScanner().sentence().end())
// * If there's no match in the full content we don't want to return anything.
// * Also content is really huge, so we want to only get small parts of the sentences. We are allowing caller to pick the number of sentences and their length:
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/io/quarkus/search/app/WebComponents.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.quarkus.search.app;

import io.quarkiverse.web.bundler.runtime.Bundle;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder;
import jakarta.ws.rs.core.UriInfo;
import org.jboss.resteasy.reactive.Cache;

import java.net.URI;
import java.net.URISyntaxException;

@Path("/web-components")
public class WebComponents {

@Inject
Bundle bundle;

@Context
UriInfo uriInfo;

// This route allows to access the web-component js on a fixed path
// without affecting caching of the script
@Path("/search.js")
@Cache(noCache = true)
@GET
public Response script() {
URI baseUri = uriInfo.getBaseUri();
URI redirectUri = baseUri.resolve(bundle.script("main"));
return Response.temporaryRedirect(redirectUri).build();
}
}
5 changes: 4 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,7 @@ quarkus.openshift.startup-probe.period=10S
quarkus.openshift.startup-probe.failure-threshold=15
# Declare the management port on the service
quarkus.openshift.ports."management".container-port=9000
quarkus.openshift.ports."management".host-port=90
quarkus.openshift.ports."management".host-port=90

quarkus.web-bundler.loaders.data-url=svg
quarkus.web-bundler.loaders.file=
201 changes: 201 additions & 0 deletions src/main/resources/templates/pub/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
<!DOCTYPE html>
<html>
<head>
<title>Quarkus Search Web-Component test</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://quarkus.io/assets/css/main.css?2021-07-29" rel="stylesheet" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css"
integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<script type="module" src="/api/web-components/search.js"></script>
{#bundle tag="style"/}
</head>

<body>
<div class="content">
<qs-form>
<section class="full-width-version-bg flexfilterbar">
<div class="flexcontainer">
<div class="flexlabel">
<label>By Version</label>
</div>
<div class="pulldown version">
<select id="guidesindex-version-dropdown" name="version">
<option value="main">Main - SNAPSHOT</option>
<option value="latest" selected="">3.5.1 - Latest</option>
<option value="3.2">3.2</option>
<option value="2.16">2.16</option>
<option value="2.13">2.13</option>
<option value="2.7">2.7</option>
</select>
</div>
<div class="flexlabel">
<label>By Category</label>
</div>
<div class="pulldown category">
<select id="guidesindex-category-dropdown" name="categories">
<option value="">All categories</option>
<option value="alt-languages">Alternative languages</option>
<option value="architecture">Architecture</option>
<option value="business-automation">Business Automation</option>
<option value="cloud">Cloud</option>
<option value="command-line">Command Line Applications</option>
<option value="compatibility">Compatibility</option>
<option value="contributing">Contributing</option>
<option value="core">Core</option>
<option value="data">Data</option>
<option value="getting-started">Getting Started</option>
<option value="integration">Integration</option>
<option value="messaging">Messaging</option>
<option value="miscellaneous">Miscellaneous</option>
<option value="native">Native</option>
<option value="observability">Observability</option>
<option value="security">Security</option>
<option value="serialization">Serialization</option>
<option value="tooling">Tooling</option>
<option value="web">Web</option>
<option value="writing-extensions">Writing Extensions</option>
</select>
</div>
<div class="search">
<input name="q" type="text" placeholder="Filter by keyword"/>
</div>
</div>
</section>
</qs-form>
<div><h1 class="title">Guides - Latest</h1></div>

<qs-target type="guide">
<div class="grid-wrapper guides">
<div class="grid__item width-12-12 docslist">
<div class="doclist-header">
<h3 id="tutorial">Tutorials</h3>
<p>Short and focused exercises to get you going quickly.</p>
</div>
<div class="grid-wrapper">
<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/building-native-image">Building a Native Executable</a></h4>
<div class="description"><p>Build native executables with GraalVM or Mandrel.</p>
</div>
<div class="keywords"></div>
<div class="categories">getting-started, native</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/telemetry-micrometer-tutorial">Collect metrics using Micrometer</a></h4>
<div class="description"><p>Create an application that uses the Micrometer metrics library to collect runtime,
extension and application metrics and expose them as a Prometheus (OpenMetrics) endpoint.</p>
</div>
<div class="keywords"></div>
<div class="categories">observability</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/getting-started">Creating Your First Application</a></h4>
<div class="description"><p>Discover how to create your first Quarkus application.</p>
</div>
<div class="keywords"></div>
<div class="categories">getting-started</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/doc-create-tutorial">Creating a tutorial</a></h4>
<div class="description"><p>Create a new tutorial that guides users through creating, running, and testing a Quarkus
application that uses annotations from an imaginary extension.</p>
</div>
<div class="keywords"></div>
<div class="categories">contributing</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/getting-started-reactive">Getting Started With Reactive</a></h4>
<div class="description"><p>Learn more about developing reactive applications with Quarkus.</p>
</div>
<div class="keywords"></div>
<div class="categories">getting-started</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/security-oidc-auth0-tutorial">Protect Quarkus web application by using an Auth0 OpenID Connect
provider</a></h4>
<div class="description"><p>Quarkus Security provides comprehensive OpenId Connect (OIDC) and OAuth2 support with
its quarkus-oidc extension, supporting both Authorization code flow and Bearer token authentication
mechanisms.</p>
</div>
<div class="keywords">oidc, sso, auth0</div>
<div class="categories">security, web</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/security-oidc-bearer-token-authentication-tutorial">Protect a service application by using
OpenID Connect (OIDC) Bearer token authentication</a></h4>
<div class="description"><p>Use the Quarkus OpenID Connect (OIDC) extension to secure a Jakarta REST application
with Bearer token authentication.</p>
</div>
<div class="keywords"></div>
<div class="categories">security</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/security-oidc-code-flow-authentication-tutorial">Protect a web application by using OpenID
Connect (OIDC) authorization code flow</a></h4>
<div class="description"><p>With the Quarkus OpenID Connect (OIDC) extension, you can protect application HTTP
endpoints by using the OIDC Authorization Code Flow mechanism.</p>
</div>
<div class="keywords"></div>
<div class="categories">security, web</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/ide-tooling">Quarkus Tools in your favorite IDE</a></h4>
<div class="description"><p>Learn more about Quarkus integrations in IDEs.</p>
</div>
<div class="keywords"></div>
<div class="categories">getting-started</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/security-basic-authentication-tutorial">Secure a Quarkus application with Basic authentication
and Jakarta Persistence</a></h4>
<div class="description"><p>Secure your Quarkus application endpoints by combining the built-in Quarkus Basic
authentication with the Jakarta Persistence identity provider to enable role-based access control (RBAC).</p>
</div>
<div class="keywords"></div>
<div class="categories">getting-started, security</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/tooling">Using our Tooling</a></h4>
<div class="description"><p>Explore the Quarkus developer toolchain which makes Quarkus development so fast and
enjoyable.</p>
</div>
<div class="keywords"></div>
<div class="categories">getting-started</div>
</div>


<div class="grid__item docs-card tutorialbkg">
<h4><a href="/guides/getting-started-dev-services">Your second Quarkus application</a></h4>
<div class="description"><p>Discover some of the features that make developing with Quarkus a joyful experience.</p>
</div>
<div class="keywords"></div>
<div class="categories">core, data, getting-started</div>
</div>


</div>
</div>
</qs-target>
</div>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9437a69

Please sign in to comment.