gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: inject demo sites URLs into the SPA


From: gnunet
Subject: [libeufin] branch master updated: inject demo sites URLs into the SPA
Date: Mon, 18 Apr 2022 22:50:08 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new bc67ee57 inject demo sites URLs into the SPA
bc67ee57 is described below

commit bc67ee57b2c0dcd65c8bf0b21b9db280d2c2156a
Author: ms <ms@taler.net>
AuthorDate: Mon Apr 18 22:49:57 2022 +0200

    inject demo sites URLs into the SPA
---
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  | 40 ++++++++++++++++------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index caf8167a..e1a981a6 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -64,6 +64,7 @@ import io.ktor.server.netty.*
 import io.ktor.util.*
 import io.ktor.util.date.*
 import kotlinx.coroutines.newSingleThreadContext
+import org.apache.commons.compress.utils.IOUtils
 import org.jetbrains.exposed.sql.*
 import org.jetbrains.exposed.sql.statements.api.ExposedBlob
 import 
org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
@@ -73,7 +74,11 @@ import org.slf4j.LoggerFactory
 import org.w3c.dom.Document
 import startServer
 import tech.libeufin.util.*
+import java.io.ByteArrayInputStream
+import java.io.ByteArrayOutputStream
 import java.io.IOException
+import java.io.StringWriter
+import java.lang.StringBuilder
 import java.math.BigDecimal
 import java.net.BindException
 import java.net.URL
@@ -965,18 +970,31 @@ val sandboxApp: Application.() -> Unit = {
             if (call.request.headers["Content-Type"] != "application/json") {
                 val spa = 
ClassLoader.getSystemClassLoader().getResourceAsStream("static/spa.html")
                 if (spa == null) throw internalServerError("SPA not found!")
-                call.respondBytesWriter(contentType = ContentType.Text.Html) {
-                    writeWhile {
-                        val content = try {
-                            spa.read()
-                        } catch (e: IOException) {
-                            throw internalServerError("Could not load the SPA")
-                        }
-                        if (content == -1) return@writeWhile false
-                        it.put(content.toByte())
-                        true
-                    }
+
+                // load whole SPA from disk.  Now <200KB, so fine to 
block-reading it.
+                val builder = StringBuilder()
+                var buf: Int = spa.read();
+                while (buf != -1) {
+                    builder.append(buf)
+                    buf = spa.read()
                 }
+                val content = builder.toString()
+                val landingUrl = System.getenv(
+                    "TALER_ENV_URL_INTRO") ?: "https://demo.taler.net/";
+                content.replace("%DEMO_SITE_LANDING_URL%", landingUrl)
+                val bankUrl = System.getenv(
+                    "TALER_ENV_URL_BANK") ?: 
"https://demo.taler.net/sandbox/demobanks/default/";
+                content.replace("%DEMO_SITE_BANK_URL%", bankUrl)
+                val blogUrl = System.getenv(
+                    "TALER_ENV_URL_MERCHANT_BLOG") ?: 
"https://demo.taler.net/blog/";
+                content.replace("%DEMO_SITE_BLOG_URL%", blogUrl)
+                val donationsUrl = System.getenv(
+                    "TALER_ENV_URL_MERCHANT_DONATIONS") ?: 
"https://demo.taler.net/donations/";
+                content.replace("%DEMO_SITE_MERCHANT_DONATIONS%", donationsUrl)
+                val surveyUrl = System.getenv(
+                    "TALER_ENV_URL_MERCHANT_SURVEY") ?: 
"https://demo.taler.net/survey/";
+                content.replace("%DEMO_SITE_MERCHANT_SURVEY%", surveyUrl)
+                call.respondText(content)
                 return@get
             }
             expectAdmin(call.request.basicAuth())

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]