Skip to content

Commit

Permalink
Migrate to the new kobweb route generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellet committed Mar 12, 2024
1 parent 2ab003a commit 0be9318
Show file tree
Hide file tree
Showing 22 changed files with 71 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
jetbrains-compose = "1.5.11"
kobweb = "0.15.3"
kotlin = "1.9.21"
jetbrains-compose = "1.6.0"
kobweb = "0.17.0"
kotlin = "1.9.22"

[libraries]
kobweb-api = { module = "com.varabyte.kobweb:kobweb-api", version.ref = "kobweb" }
Expand Down
2 changes: 1 addition & 1 deletion site/.kobweb/site/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion site/.kobweb/site/app.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<link href="/favicon-32x32.png" rel="icon" sizes="32x32" type="image/png">
<link href="/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png">
<link href="/site.webmanifest" rel="manifest">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" referrerpolicy="no-referrer" rel="stylesheet">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" referrerpolicy="no-referrer" rel="stylesheet">
</head>
<body>
<div id="root" style="width: 100%; height: 100%;" class="silk-colors_light">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<link href="/favicon-32x32.png" rel="icon" sizes="32x32" type="image/png">
<link href="/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png">
<link href="/site.webmanifest" rel="manifest">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" referrerpolicy="no-referrer" rel="stylesheet">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" referrerpolicy="no-referrer" rel="stylesheet">
</head>
<body>
<div id="root" style="width: 100%; height: 100%;" class="silk-colors_light">
Expand Down
16 changes: 8 additions & 8 deletions site/.kobweb/site/ar/index.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<link href="/favicon-32x32.png" rel="icon" sizes="32x32" type="image/png">
<link href="/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png">
<link href="/site.webmanifest" rel="manifest">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" referrerpolicy="no-referrer" rel="stylesheet">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" referrerpolicy="no-referrer" rel="stylesheet">
</head>
<body>
<div id="root" style="width: 100%; height: 100%;" class="silk-colors_light">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<link href="/favicon-32x32.png" rel="icon" sizes="32x32" type="image/png">
<link href="/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png">
<link href="/site.webmanifest" rel="manifest">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" referrerpolicy="no-referrer" rel="stylesheet">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" referrerpolicy="no-referrer" rel="stylesheet">
</head>
<body>
<div id="root" style="width: 100%; height: 100%;" class="silk-colors_light">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<link href="/favicon-32x32.png" rel="icon" sizes="32x32" type="image/png">
<link href="/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png">
<link href="/site.webmanifest" rel="manifest">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" referrerpolicy="no-referrer" rel="stylesheet">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" referrerpolicy="no-referrer" rel="stylesheet">
</head>
<body>
<div id="root" style="width: 100%; height: 100%;" class="silk-colors_light">
Expand Down
14 changes: 7 additions & 7 deletions site/.kobweb/site/index.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<link href="/favicon-32x32.png" rel="icon" sizes="32x32" type="image/png">
<link href="/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png">
<link href="/site.webmanifest" rel="manifest">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" referrerpolicy="no-referrer" rel="stylesheet">
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" referrerpolicy="no-referrer" rel="stylesheet">
</head>
<body>
<div id="root" style="width: 100%; height: 100%;" class="silk-colors_light">
Expand Down
16 changes: 8 additions & 8 deletions site/.kobweb/site/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@
href="https://alrayada.net/ar/"/>
</url>
<url>
<loc>https://alrayada.net/privacy_policy</loc>
<loc>https://alrayada.net/privacy-policy</loc>
<lastmod>2023-10-15T12:57:20+00:00</lastmod>
<priority>0.80</priority>
<xhtml:link
rel="alternate"
hreflang="x-default"
href="https://alrayada.net/privacy_policy/"/>
href="https://alrayada.net/privacy-policy/"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://alrayada.net/privacy_policy/"/>
href="https://alrayada.net/privacy-policy/"/>
<xhtml:link
rel="alternate"
hreflang="ar"
href="https://alrayada.net/ar/privacy_policy/"/>
href="https://alrayada.net/ar/privacy-policy/"/>
</url>
<url>
<loc>https://alrayada.net/download_mobile_app</loc>
<loc>https://alrayada.net/download-mobile-app</loc>
<lastmod>2023-10-15T12:57:20+00:00</lastmod>
<priority>0.80</priority>
<xhtml:link
rel="alternate"
hreflang="x-default"
href="https://alrayada.net/download_mobile_app/"/>
href="https://alrayada.net/download-mobile-app/"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://alrayada.net/download_mobile_app/"/>
href="https://alrayada.net/download-mobile-app/"/>
<xhtml:link
rel="alternate"
hreflang="ar"
href="https://alrayada.net/ar/download_mobile_app/"/>
href="https://alrayada.net/ar/download-mobile-app/"/>
</url>
</urlset>
19 changes: 17 additions & 2 deletions site/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.varabyte.kobweb.gradle.application.extensions.AppBlock
import com.varabyte.kobweb.gradle.application.util.configAsKobwebApplication
import kotlinx.html.link
import kotlinx.html.meta
Expand Down Expand Up @@ -131,6 +132,10 @@ kobweb {
}
description.set(webDesc)
}

// Only legacy sites need this set. Sites built after 0.16.0 should default to DISALLOW.
// See https://github.com/varabyte/kobweb#legacy-routes for more information.
legacyRouteRedirectStrategy.set(AppBlock.LegacyRouteRedirectStrategy.DISALLOW)
}
}

Expand Down Expand Up @@ -159,11 +164,21 @@ kotlin {
// Here we will use code generator to generate unique pages that redirect to the original pages

val languages = listOf("ar") // other than English
val pages = listOf("download_mobile_app", "privacy_policy", "delete_account_instructions") // all the pages in the `page` package
val pages = listOf("downloadMobileApp", "privacyPolicy", "deleteAccountInstructions") // all the pages in the `page` package

val generateLanguagesPagesTask = tasks.register("generateLanguagesPages") {
group = "net.freshplatform.alrayada_web"

fun toKebabCase(input: String): String {
var result = input.replace(Regex("([a-z])([A-Z])")) {
"${it.groupValues[1]}-${it.groupValues[2]}"
}

result = result.replace("_", "-")

return result.lowercase()
}

doLast {
val pagesDirectory = project.file("src/jsMain/kotlin/net/freshplatform/alrayada_web")
languages.forEach { lang ->
Expand All @@ -181,7 +196,7 @@ val generateLanguagesPagesTask = tasks.register("generateLanguagesPages") {
@Composable
@Page
fun PrivacyPolicyPage_${lang}() {
rememberPageContext().router.navigateTo("/${page}/?lang=${lang}")
rememberPageContext().router.navigateTo("/${toKebabCase(page)}/?lang=${lang}")
}
""".trimIndent())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package net.freshplatform.alrayada_web.core.router

object AppRouter {
// Unfortunately, we can't use those in the pages routeOverride, even though it's a constant in compile time
const val PRIVACY_POLICY = "/privacy_policy"
const val DOWNLOAD_MOBILE_APP = "/download_mobile_app"
const val PRIVACY_POLICY = "/privacy-policy"
const val DOWNLOAD_MOBILE_APP = "/download-mobile-app"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.freshplatform.alrayada_web.pages.ar.delete_account_instructions
package net.freshplatform.alrayada_web.pages.ar.deleteAccountInstructions

import androidx.compose.runtime.Composable
import com.varabyte.kobweb.core.Page
Expand All @@ -7,5 +7,5 @@ import com.varabyte.kobweb.core.rememberPageContext
@Composable
@Page
fun PrivacyPolicyPage_ar() {
rememberPageContext().router.navigateTo("/delete_account_instructions/?lang=ar")
rememberPageContext().router.navigateTo("/delete-account-instructions/?lang=ar")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.freshplatform.alrayada_web.pages.ar.download_mobile_app
package net.freshplatform.alrayada_web.pages.ar.downloadMobileApp

import androidx.compose.runtime.Composable
import com.varabyte.kobweb.core.Page
Expand All @@ -7,5 +7,5 @@ import com.varabyte.kobweb.core.rememberPageContext
@Composable
@Page
fun PrivacyPolicyPage_ar() {
rememberPageContext().router.navigateTo("/download_mobile_app/?lang=ar")
rememberPageContext().router.navigateTo("/download-mobile-app/?lang=ar")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.freshplatform.alrayada_web.pages.ar.privacy_policy
package net.freshplatform.alrayada_web.pages.ar.privacyPolicy

import androidx.compose.runtime.Composable
import com.varabyte.kobweb.core.Page
Expand All @@ -7,5 +7,5 @@ import com.varabyte.kobweb.core.rememberPageContext
@Composable
@Page
fun PrivacyPolicyPage_ar() {
rememberPageContext().router.navigateTo("/privacy_policy/?lang=ar")
rememberPageContext().router.navigateTo("/privacy-policy/?lang=ar")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.freshplatform.alrayada_web.pages.delete_account_instructions
package net.freshplatform.alrayada_web.pages.deleteAccountInstructions

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -13,7 +13,6 @@ import com.varabyte.kobweb.silk.components.style.toModifier
import net.freshplatform.alrayada_web.components.core.Center
import net.freshplatform.alrayada_web.core.data.StringRes
import net.freshplatform.alrayada_web.core.services.localization.getStringResource
import net.freshplatform.alrayada_web.core.services.localization.stringResource
import net.freshplatform.alrayada_web.styles.ReadableTextStyleOnWhiteBackground
import net.freshplatform.alrayada_web.utils.updateDocument
import org.jetbrains.compose.web.css.Color
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.freshplatform.alrayada_web.pages.download_mobile_app
package net.freshplatform.alrayada_web.pages.downloadMobileApp

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.freshplatform.alrayada_web.pages.privacy_policy
package net.freshplatform.alrayada_web.pages.privacyPolicy

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down
16 changes: 8 additions & 8 deletions site/src/jsMain/resources/public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@
href="https://alrayada.net/ar/"/>
</url>
<url>
<loc>https://alrayada.net/privacy_policy</loc>
<loc>https://alrayada.net/privacy-policy</loc>
<lastmod>2023-10-15T12:57:20+00:00</lastmod>
<priority>0.80</priority>
<xhtml:link
rel="alternate"
hreflang="x-default"
href="https://alrayada.net/privacy_policy/"/>
href="https://alrayada.net/privacy-policy/"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://alrayada.net/privacy_policy/"/>
href="https://alrayada.net/privacy-policy/"/>
<xhtml:link
rel="alternate"
hreflang="ar"
href="https://alrayada.net/ar/privacy_policy/"/>
href="https://alrayada.net/ar/privacy-policy/"/>
</url>
<url>
<loc>https://alrayada.net/download_mobile_app</loc>
<loc>https://alrayada.net/download-mobile-app</loc>
<lastmod>2023-10-15T12:57:20+00:00</lastmod>
<priority>0.80</priority>
<xhtml:link
rel="alternate"
hreflang="x-default"
href="https://alrayada.net/download_mobile_app/"/>
href="https://alrayada.net/download-mobile-app/"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://alrayada.net/download_mobile_app/"/>
href="https://alrayada.net/download-mobile-app/"/>
<xhtml:link
rel="alternate"
hreflang="ar"
href="https://alrayada.net/ar/download_mobile_app/"/>
href="https://alrayada.net/ar/download-mobile-app/"/>
</url>
</urlset>

0 comments on commit 0be9318

Please sign in to comment.