Skip to content

Commit

Permalink
Merge branch 'release/0.1.2' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
straumat committed Jan 7, 2024
2 parents fff972f + eccdb2f commit 558c705
Show file tree
Hide file tree
Showing 20 changed files with 214 additions and 13 deletions.
2 changes: 1 addition & 1 deletion backend/explorer-core/autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
<parent>
<groupId>org.royllo.explorer</groupId>
<artifactId>explorer</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<!-- =========================================================================================================== -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.royllo.explorer.core.util.parameters.IncomingRateLimitsParameters;
import org.royllo.explorer.core.util.parameters.MempoolParameters;
import org.royllo.explorer.core.util.parameters.OutgoingRateLimitsParameters;
import org.royllo.explorer.core.util.parameters.RoylloExplorerAnalyticsParameters;
import org.royllo.explorer.core.util.parameters.RoylloExplorerParameters;
import org.royllo.explorer.core.util.parameters.S3Parameters;
import org.royllo.explorer.core.util.parameters.TAPDParameters;
Expand All @@ -19,6 +20,9 @@
RoylloExplorerParameters.Api.class,
RoylloExplorerParameters.Web.class,
RoylloExplorerParameters.Content.class,
// Royllo explorer analytics configuration.
RoylloExplorerAnalyticsParameters.class,
RoylloExplorerAnalyticsParameters.Piwik.class,
// S3 configuration.
S3Parameters.class,
// Mempool configuration.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.royllo.explorer.core.util.parameters;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

/**
* Royllo explorer analytics parameters.
*/
@Validated
@Getter
@Setter
@ToString
@ConfigurationProperties(prefix = "royllo.explorer.analytics")
public class RoylloExplorerAnalyticsParameters {

/** Piwik analytics. */
private Piwik piwik = new Piwik();

/** Piwik parameters. */
@Validated
@Getter
@Setter
@ToString
@ConfigurationProperties(prefix = "piwik")
public static class Piwik {

/** Piwik tracking id. */
private String trackingId;

}

}
2 changes: 1 addition & 1 deletion backend/explorer-core/starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<parent>
<groupId>org.royllo.explorer</groupId>
<artifactId>explorer</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<!-- =========================================================================================================== -->
Expand Down
2 changes: 1 addition & 1 deletion backend/servers/explorer-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
<parent>
<groupId>org.royllo.explorer</groupId>
<artifactId>explorer</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<!-- =========================================================================================================== -->
Expand Down
2 changes: 1 addition & 1 deletion backend/servers/explorer-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
<parent>
<groupId>org.royllo.explorer</groupId>
<artifactId>explorer</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<!-- =========================================================================================================== -->
Expand Down
2 changes: 1 addition & 1 deletion backend/servers/explorer-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
<parent>
<groupId>org.royllo.explorer</groupId>
<artifactId>explorer</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<!-- =========================================================================================================== -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.royllo.explorer.web.util.advice;

import lombok.RequiredArgsConstructor;
import org.royllo.explorer.core.util.parameters.RoylloExplorerAnalyticsParameters;
import org.royllo.explorer.core.util.parameters.RoylloExplorerParameters;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

import static org.royllo.explorer.web.util.constants.ModelAttributeConstants.API_BASE_URL_ATTRIBUTE;
import static org.royllo.explorer.web.util.constants.ModelAttributeConstants.CONTENT_BASE_URL_ATTRIBUTE;
import static org.royllo.explorer.web.util.constants.ModelAttributeConstants.PIWIK_ANALYTICS_TRACKING_ID_ATTRIBUTE;
import static org.royllo.explorer.web.util.constants.ModelAttributeConstants.WEB_BASE_URL_ATTRIBUTE;

/**
Expand All @@ -20,6 +22,9 @@ public class ConfigurationControllerAdvice {
/** Royllo explorer parameters. */
private final RoylloExplorerParameters roylloExplorerParameters;

/** Royllo explorer analytics parameters. */
private final RoylloExplorerAnalyticsParameters roylloExplorerAnalyticsParameters;

@ModelAttribute
public final void handleRequest(final Model model) {

Expand All @@ -28,6 +33,8 @@ public final void handleRequest(final Model model) {
model.addAttribute(WEB_BASE_URL_ATTRIBUTE, roylloExplorerParameters.getWeb().getBaseUrl());
model.addAttribute(CONTENT_BASE_URL_ATTRIBUTE, roylloExplorerParameters.getContent().getBaseUrl());

// Set the analytics parameters.
model.addAttribute(PIWIK_ANALYTICS_TRACKING_ID_ATTRIBUTE, roylloExplorerAnalyticsParameters.getPiwik().getTrackingId());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class ModelAttributeConstants {
/** Content base url. */
public static final String CONTENT_BASE_URL_ATTRIBUTE = "contentBaseUrl";

/** Piwik analytics tracking id. */
public static final String PIWIK_ANALYTICS_TRACKING_ID_ATTRIBUTE = "piwikAnalyticsTrackingId";

/** Query attribute. */
public static final String QUERY_ATTRIBUTE = "query";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
royllo.explorer.api.base-url=http://localhost:9090/api
royllo.explorer.web.base-url=http://localhost:3000
royllo.explorer.content.base-url=http://localhost:9093
#
# ======================================================================================================================
# Royllo explorer analytics configuration.
royllo.explorer.analytics.piwik.trackingId=00000000-0000-0000-0000-000000000000
#
# ======================================================================================================================
# Using Liquibase to import test data
spring.liquibase.enabled=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
# Royllo explorer configuration.
royllo.explorer.api.base-url=https://api.explorer.royllo.org
royllo.explorer.web.base-url=https://explorer.royllo.org
royllo.explorer.content.base-url=https://assets.royllo.org
royllo.explorer.content.base-url=http://localhost:9093
#
# ======================================================================================================================
# Royllo explorer analytics configuration.
royllo.explorer.analytics.piwik.trackingId=00000000-0000-0000-0000-000000000000
#
# ======================================================================================================================
# Database access configuration.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script type="text/javascript">
/*<![CDATA[*/
(function (window, document, dataLayerName, id) {
window[dataLayerName] = window[dataLayerName] || [], window[dataLayerName].push({
start: (new Date).getTime(),
event: "stg.start"
});
var scripts = document.getElementsByTagName('script')[0], tags = document.createElement('script');

function stgCreateCookie(a, b, c) {
var d = "";
if (c) {
var e = new Date;
e.setTime(e.getTime() + 24 * c * 60 * 60 * 1e3), d = "; expires=" + e.toUTCString();
f = "; SameSite=Strict"
}
document.cookie = a + "=" + b + d + f + "; path=/"
}

var isStgDebug = (window.location.href.match("stg_debug") || document.cookie.match("stg_debug")) && !window.location.href.match("stg_disable_debug");
stgCreateCookie("stg_debug", isStgDebug ? 1 : "", isStgDebug ? 14 : -1);
var qP = [];
dataLayerName !== "dataLayer" && qP.push("data_layer_name=" + dataLayerName), isStgDebug && qP.push("stg_debug");
var qPString = qP.length > 0 ? ("?" + qP.join("&")) : "";
tags.async = !0, tags.src = "https://royllo.containers.piwik.pro/" + id + ".js" + qPString, scripts.parentNode.insertBefore(tags, scripts);
!function (a, n, i) {
a[n] = a[n] || {};
for (var c = 0; c < i.length; c++) !function (i) {
a[n][i] = a[n][i] || {}, a[n][i].api = a[n][i].api || function () {
var a = [].slice.call(arguments, 0);
"string" == typeof a[0] && window[dataLayerName].push({
event: n + "." + i + ":" + a[0],
parameters: [].slice.call(arguments, 1)
})
}
}(i[c])
}(window, "ppms", ["tm", "cm"]);
})(window, document, 'dataLayer', '[[${piwikAnalyticsTrackingId}]]');
/*]]>*/
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<!--/* Body */-->
<body>

<!--/* Analytics */-->
<th:block th:if="${!#strings.isEmpty(piwikAnalyticsTrackingId)}">
<script th:replace="~{util/fragments/components/analytics_piwik :: script}"></script>
</th:block>

<!--/* Header */-->
<header th:replace="~{util/fragments/layouts/asset/header :: header}"></header>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<!--/* Body */-->
<body>

<!--/* Analytics */-->
<th:block th:if="${!#strings.isEmpty(piwikAnalyticsTrackingId)}">
<script th:replace="~{util/fragments/components/analytics_piwik :: script}"></script>
</th:block>

<!--/* Header */-->
<header th:replace="~{util/fragments/layouts/default/header :: header}"></header>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ void assetPageGenesis(final HttpHeaders headers) throws Exception {
.andExpect(content().string(containsString(">" + assetIdAlias + "<")))
.andExpect(content().string(containsString(">" + getMessage(messages, "asset.data.assetType.normal") + "<")))
.andExpect(content().string(containsString(">" + assetFromTest.getAsset().getAmount() + "<")))
.andExpect(content().string(not(containsString("src=" + "\"" + "null/" + assetFromTest.getAsset().getAssetGenesis().getAssetId() + ".txt"))))
.andExpect(content().string(containsString("href=" + "\"" + "null/" + assetFromTest.getAsset().getAssetGenesis().getAssetId() + ".txt")))
.andExpect(content().string(not(containsString("src=" + "\"" + "https://assets.royllo.org/" + assetFromTest.getAsset().getAssetGenesis().getAssetId() + ".txt"))))
.andExpect(content().string(containsString("href=" + "\"" + "https://assets.royllo.org/" + assetFromTest.getAsset().getAssetGenesis().getAssetId() + ".txt")))
.andExpect(content().string(containsString(">" + assetFromTest.getAsset().getAssetGenesis().getMetaDataHash() + "<")))
.andExpect(content().string(containsString(">" + assetFromTest.getAsset().getAssetGenesis().getVersion() + "<")))
.andExpect(content().string(containsString(">" + assetFromTest.getAsset().getAssetGenesis().getGenesisPoint() + "<")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ void assetPageGenesis(final HttpHeaders headers) throws Exception {
.andExpect(content().string(containsString(">" + assetIdAlias + "<")))
.andExpect(content().string(containsString(">" + getMessage(messages, "asset.data.assetType.collectible") + "<")))
.andExpect(content().string(not(containsString(">" + assetFromTest.getAsset().getAmount() + "<"))))
.andExpect(content().string(containsString("src=" + "\"" + "null/" + assetFromTest.getAsset().getAssetGenesis().getAssetId() + ".png")))
.andExpect(content().string(containsString("href=" + "\"" + "null/" + assetFromTest.getAsset().getAssetGenesis().getAssetId() + ".png")))
.andExpect(content().string(containsString("src=" + "\"" + "https://assets.royllo.org/" + assetFromTest.getAsset().getAssetGenesis().getAssetId() + ".png")))
.andExpect(content().string(containsString("href=" + "\"" + "https://assets.royllo.org/" + assetFromTest.getAsset().getAssetGenesis().getAssetId() + ".png")))
.andExpect(content().string(containsString(">" + assetFromTest.getAsset().getAssetGenesis().getMetaDataHash() + "<")))
.andExpect(content().string(containsString(">" + assetFromTest.getAsset().getAssetGenesis().getVersion() + "<")))
.andExpect(content().string(containsString(">" + assetFromTest.getAsset().getAssetGenesis().getGenesisPoint() + "<")))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.royllo.explorer.web.test.controllers.util;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;

import static org.hamcrest.Matchers.containsString;
import static org.royllo.test.TapdData.ROYLLO_COIN_ASSET_ID;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@SpringBootTest
@DirtiesContext
@DisplayName("Analytics - Piwik tests")
@AutoConfigureMockMvc
@TestPropertySource(properties = {"royllo.explorer.analytics.piwik.trackingId=00000000-0000-0000-0000-000000000001"})
public class AnalyticsPiwikTest {

@Autowired
MockMvc mockMvc;

@Test
@DisplayName("Piwik configured")
void piwikConfigured() throws Exception {

// We test on each layout (home, asset).
mockMvc.perform(get("/"))
.andExpect(status().isOk())
.andExpect(content().string(containsString("(window, document, 'dataLayer', '00000000-0000-0000-0000-000000000001');")));

mockMvc.perform(get("/asset/" + ROYLLO_COIN_ASSET_ID))
.andExpect(status().isOk())
.andExpect(content().string(containsString("(window, document, 'dataLayer', '00000000-0000-0000-0000-000000000001');")));

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.royllo.explorer.web.test.controllers.util;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.royllo.test.TapdData.ROYLLO_COIN_ASSET_ID;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@SpringBootTest
@DirtiesContext
@DisplayName("Analytics - no analytics tests")
@AutoConfigureMockMvc
@TestPropertySource(properties = {"royllo.explorer.analytics.piwik.trackingId="})
public class NoAnalyticsTest {

@Autowired
MockMvc mockMvc;

@Test
@DisplayName("No analytics configured")
void noAnalyticsConfigured() throws Exception {

// We test on each layout (home, asset).
mockMvc.perform(get("/"))
.andExpect(status().isOk())
.andExpect(content().string(not(containsString("(window, document, 'dataLayer'"))));

mockMvc.perform(get("/asset/" + ROYLLO_COIN_ASSET_ID))
.andExpect(status().isOk())
.andExpect(content().string(not(containsString("(window, document, 'dataLayer'"))));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
# Royllo explorer configuration.
royllo.explorer.api.base-url=http://localhost:9090/api
royllo.explorer.web.base-url=http://localhost:8080
royllo.explorer.content.base-url=https://assets.royllo.org
#
# ======================================================================================================================
# Royllo explorer analytics configuration.
royllo.explorer.analytics.piwik.trackingId=
#
#
# ======================================================================================================================
# Database access configuration.
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Project information -->
<groupId>org.royllo.explorer</groupId>
<artifactId>explorer</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<name>Royllo - A Taproot asset explorer</name>
<description>Royllo explorer allows you to search for Taproot assets created on the Bitcoin blockchain</description>
<packaging>pom</packaging>
Expand Down Expand Up @@ -64,7 +64,7 @@

<!-- ======================================================================================================= -->
<!-- Project libraries -->
<spring.version>3.1.5</spring.version>
<spring.version>3.1.7</spring.version>
<reactor-core.version>3.6.1</reactor-core.version>
<reactor-netty.version>1.1.14</reactor-netty.version>

Expand Down Expand Up @@ -179,7 +179,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.5</version>
<version>3.1.7</version>
<relativePath/>
</parent>
<!-- =========================================================================================================== -->
Expand Down

0 comments on commit 558c705

Please sign in to comment.