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 21, 2023
1 parent ed2d642 commit 8f5118a
Show file tree
Hide file tree
Showing 13 changed files with 656 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
.flattened-pom.xml
node_modules/

# Eclipse
.project
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
3 changes: 2 additions & 1 deletion src/main/java/io/quarkus/search/app/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.quarkus.search.app.entity.Guide;

@ApplicationScoped
@Path("/")
@Path("/api")
public class SearchService {

private static final Integer PAGE_SIZE = 50;
Expand All @@ -32,6 +32,7 @@ public class SearchService {
SearchSession session;

@GET
@Path("search")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Search for any resource")
@Transactional
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/io/quarkus/search/app/SearchWebComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.quarkus.search.app;

import io.quarkiverse.web.bundler.runtime.Bundle;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;
import org.jboss.resteasy.reactive.Cache;

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

@Path("/")
public class SearchWebComponent {

@Inject
Bundle bundle;

// This route allows to access the web-component js on a fixed path
// without affecting caching of the script
@Path("/quarkus-search.js")
@Cache(noCache = true)
@GET
public Response script() {
try {
return Response.seeOther(new URI(bundle.script("main"))).build();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/io/quarkus/search/app/dto/SearchHit.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ProjectionConstructor;

@ProjectionConstructor
public record SearchHit(@IdProjection String id, @FieldProjection String title) {
public record SearchHit(@IdProjection String id, @FieldProjection String title, @FieldProjection String summary,
@FieldProjection String keywords) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public String toIndexedValue(InputProvider provider, ValueBridgeToIndexedValueCo
try (var in = provider.open()) {
Element body = Jsoup.parse(in, StandardCharsets.UTF_8.name(), "/").body();
// Content div has two grid columns: actual content and TOC. There's not much use of the TOC, we want the content only:
Element content = body.selectFirst(".content .grid__item");
Element content = body.selectFirst(".content .grid_item");
if (content != null) {
// Means we've found a guide content column. hence let's use that to have only real content:
return content.text();
Expand Down
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="/quarkus-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

0 comments on commit 8f5118a

Please sign in to comment.