Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept #154

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion blog/src/test/java/io/quarkiverse/roq/it/RoqTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

import io.quarkus.test.junit.QuarkusTest;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

@QuarkusTest
public class RoqTest {

Expand Down Expand Up @@ -45,7 +52,8 @@ public void testPosts() {
}

@Test
public void testPage() {
public void testPage() throws IOException, URISyntaxException {

given()
.when().get("/events")
.then()
Expand Down
4 changes: 4 additions & 0 deletions common/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-deployment</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import io.quarkiverse.roq.deployment.items.RoqProjectBuildItem;
import io.quarkiverse.roq.frontmatter.deployment.RoqFrontMatterConfig;
import io.quarkiverse.roq.frontmatter.runtime.model.PageInfo;
import io.quarkiverse.roq.util.PathUtils;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem;
import io.quarkus.vertx.http.deployment.spi.GeneratedStaticResourceBuildItem;
import io.vertx.core.json.JsonObject;

public class RoqFrontMatterScanProcessor {
Expand Down Expand Up @@ -75,13 +77,16 @@ void scan(RoqProjectBuildItem roqProject,
RoqJacksonBuildItem jackson,
BuildProducer<RoqFrontMatterRawTemplateBuildItem> dataProducer,
RoqFrontMatterConfig roqDataConfig,
BuildProducer<HotDeploymentWatchedFileBuildItem> watch) {
BuildProducer<HotDeploymentWatchedFileBuildItem> watch,
BuildProducer<GeneratedStaticResourceBuildItem> resources) {
try {
Set<RoqFrontMatterRawTemplateBuildItem> items = resolveItems(roqProject, jackson.getYamlMapper(), roqDataConfig,
watch);

for (RoqFrontMatterRawTemplateBuildItem item : items) {
dataProducer.produce(item);
resources.produce(new GeneratedStaticResourceBuildItem(
PathUtils.prefixWithSlash(item.id()), item.generatedContent().getBytes(StandardCharsets.UTF_8)));
}

} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.quarkiverse.roq.generator.runtime;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Path;
import java.time.Duration;
import java.util.*;
Expand Down Expand Up @@ -57,6 +60,19 @@ public RoqGenerator(final Instance<Vertx> vertx, final RoqGeneratorConfig config
}

void onStart(@Observes StartupEvent ev) {
URL url = Thread.currentThread().getContextClassLoader()
.getResource("META-INF/resources/pages/about");
Copy link
Member Author

@mcruzdev mcruzdev Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ia3andy, About the issue #145, here, we have the following output:

{#include page}

<h1>About Roq</h1>

<p>Roq stands out in the Java development community as a powerful static site generator, bridging the gap between the
  likes of Gatsby, Hugo, and the broader backend community.
  As Andy Damevin explains, while tools like Jekyll once filled this space, they’ve become outdated and cumbersome,
  especially with Ruby’s limitations.
  Roq offers a modern solution, leveraging Quarkus with no configuration needed, allowing developers to start quickly
  using Codestart and simply editing their site directory.
</p>
<p>With GitHub Actions support out-of-the-box, Roq is easy to use for beginners, but also flexible enough to provide
  Java hooks for advanced users.
</p>

  <p><b>This tool is a testament to how extensible and powerful Quarkus is, offering a low-risk
    yet highly capable platform that will evolve as demand grows.</b></p>


<h2>Credits</h2>

<code>Those are generated as a json by all-contributors then we leverage roq-data to print them... slick �!</code>

<p>Thanks goes to these wonderful people:</p>

<div class="contributors">
  {#for contributor in cdi:contributors.contributors}
  <article class="contributor">
    <div class="avatar">
      <img src="{contributor.avatar_url}" alt="{contributor.name}'s Avatar"/>
    </div>
    <div class="details">
      <h2 class="name">{contributor.name}</h2>
      <a href="{contributor.profile}" target="_blank" class="login">@{contributor.login}</a>
    </div>
  </article>
  {/for}
</div>

{/include}


if (url != null) {
try (InputStream inputStream = url
.openStream()) {
byte[] bytes = inputStream.readAllBytes();
String result = new String(bytes);
System.out.println(result);
} catch (IOException e) {
}
}

if (config.batch()) {
generate().subscribe().with(t -> {
LOGGER.info("Roq generation succeeded in directory: " + outputDir());
Expand Down
Loading