Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcruzdev committed Oct 9, 2024
1 parent 873e43c commit 3c0f5ba
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 66 deletions.
40 changes: 11 additions & 29 deletions blog/src/test/java/io/quarkiverse/roq/it/RoqTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,38 @@ public class RoqTest {

@Test
public void testIndex() {
given()
.when().get("/")
.then()
.statusCode(200)
.body(containsString("I provide you with all the tools to generate static websites out of your Quarkus web application."))
.body(containsString("Hello, world! I'm Roq"))
.body(containsString("minute read"))
.body(containsString("Page 1 of"))
.body(containsString("2024 © ROQ"));
given().when().get("/").then().statusCode(200).body(containsString(
"I provide you with all the tools to generate static websites out of your Quarkus web application."))
.body(containsString("Hello, world! I'm Roq")).body(containsString("minute read"))
.body(containsString("Page 1 of")).body(containsString("2024 © ROQ"));
}

@Test
public void testTag() {
given()
.when().get("/posts/tag/cool-stuff")
.then()
.statusCode(200)
.body(containsString("cool-stuff"));
given().when().get("/posts/tag/cool-stuff").then().statusCode(200).body(containsString("cool-stuff"));
}

@Test
public void testPosts() {
given()
.when().get("/posts/2024-08-29-welcome-to-roq")
.then()
.statusCode(200)
.body(containsString("I provide you with all the tools to generate static websites out of your Quarkus web application."))
given().when().get("/posts/2024-08-29-welcome-to-roq").then().statusCode(200).body(containsString(
"I provide you with all the tools to generate static websites out of your Quarkus web application."))
.body(containsString("<p>Hello folks,</p>"))
.body(containsString("<h1 class=\"page-title\">Welcome to Roq!</h1>"))
.body(containsString("2024 &copy; ROQ"));
}

@Test
public void testPage() {
given()
.when().get("/events")
.then()
.statusCode(200)
.body(containsString("I provide you with all the tools to generate static websites out of your Quarkus web application."))
given().when().get("/events").then().statusCode(200).body(containsString(
"I provide you with all the tools to generate static websites out of your Quarkus web application."))
.body(containsString("<h2 class=\"event-title\">Roq 1.0 Beta</h2>"))
.body(containsString("2024 &copy; ROQ"));
}

@Test
public void testAlias() {
given()
.when().get("/first-roq-article-ever")
.then()
.statusCode(200)
.body(containsString("I provide you with all the tools to generate static websites out of your Quarkus web application."))
given().when().get("/first-roq-article-ever").then().statusCode(200).body(containsString(
"I provide you with all the tools to generate static websites out of your Quarkus web application."))
.body(containsString("<p>Hello folks,</p>"))
.body(containsString("<h1 class=\"page-title\">Welcome to Roq!</h1>"))
.body(containsString("2024 &copy; ROQ"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.Set;

import io.quarkiverse.roq.frontmatter.deployment.data.RoqFrontMatterTemplateBuildItem;
import io.quarkiverse.roq.frontmatter.runtime.RoqSiteConfig;
import io.quarkiverse.roq.frontmatter.runtime.model.RoqUrl;
import io.quarkiverse.roq.generator.deployment.items.SelectedPathBuildItem;
import io.quarkiverse.roq.plugin.aliases.deployment.items.RoqFrontMatterAliasesBuildItem;
Expand All @@ -34,17 +33,21 @@ FeatureBuildItem feature() {
}

@BuildStep
public void consumeTemplates(RoqSiteConfig config, List<RoqFrontMatterTemplateBuildItem> rawTemplates,
public void consumeTemplates(List<RoqFrontMatterTemplateBuildItem> templates,
BuildProducer<RoqFrontMatterAliasesBuildItem> aliasesProducer,
BuildProducer<SelectedPathBuildItem> selectedPathsProducer,
BuildProducer<NotFoundPageDisplayableEndpointBuildItem> notFoundPageDisplayableEndpointProducer) {

if (rawTemplates.isEmpty()) {
if (templates.isEmpty()) {
return;
}

HashMap<String, String> aliasMap = new HashMap<>();
for (RoqFrontMatterTemplateBuildItem item : rawTemplates) {
for (RoqFrontMatterTemplateBuildItem item : templates) {

if (!item.published()) {
continue;
}

Set<String> aliasesName = getAliases(item.data());
if (aliasesName.isEmpty()) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package io.quarkiverse.roq.frontmatter.deployment.data;

import static io.quarkiverse.roq.frontmatter.deployment.FrontMatterJsonData.*;
import static io.quarkiverse.roq.frontmatter.deployment.Link.DEFAULT_PAGE_LINK_TEMPLATE;

import java.util.List;
import java.util.Map;
import java.util.Stack;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -75,4 +76,26 @@ void dispatchByType(BuildProducer<RoqFrontMatterPublishPageBuildItem> pagesProdu

}
}

public static JsonObject mergeParents(RoqFrontMatterRawTemplateBuildItem item,
Map<String, RoqFrontMatterRawTemplateBuildItem> byPath) {
Stack<JsonObject> fms = new Stack<>();
String parent = item.layout();
fms.add(item.data());
while (parent != null) {
if (byPath.containsKey(parent)) {
final RoqFrontMatterRawTemplateBuildItem parentItem = byPath.get(parent);
parent = parentItem.layout();
fms.push(parentItem.data());
} else {
parent = null;
}
}

JsonObject merged = new JsonObject();
while (!fms.empty()) {
merged.mergeIn(fms.pop());
}
return merged;
}
}

0 comments on commit 3c0f5ba

Please sign in to comment.