Hide raw path filenames from user-visible text
authorLanius Trolling <lanius@laniustrolling.dev>
Wed, 3 Apr 2024 22:47:45 +0000 (18:47 -0400)
committerLanius Trolling <lanius@laniustrolling.dev>
Wed, 3 Apr 2024 22:47:45 +0000 (18:47 -0400)
src/jvmMain/kotlin/info/mechyrdia/data/view_comments.kt
src/jvmMain/kotlin/info/mechyrdia/lore/article_listing.kt
src/jvmMain/kotlin/info/mechyrdia/lore/view_nav.kt
src/jvmMain/kotlin/info/mechyrdia/lore/views_robots.kt

index 631706bc15888b06f9c5df78a3051b14ec85db16..67036733a93e5bacdc67fb56155b30119f12ab08 100644 (file)
@@ -4,6 +4,7 @@ import info.mechyrdia.OwnerNationId
 import info.mechyrdia.lore.TextParserCommentTags
 import info.mechyrdia.lore.TextParserState
 import info.mechyrdia.lore.dateTime
+import info.mechyrdia.lore.toFriendlyIndexTitle
 import info.mechyrdia.route.Root
 import info.mechyrdia.route.href
 import info.mechyrdia.route.installCsrfToken
@@ -65,7 +66,7 @@ fun FlowContent.commentBox(comment: CommentRenderData, loggedInAs: Id<NationData
                        style = "font-size:1.5em;margin-top:2.5em"
                        +"On factbook "
                        a(href = href(Root.LorePage(comment.submittedIn))) {
-                               +comment.submittedIn.joinToString(separator = "/")
+                               +comment.submittedIn.toFriendlyIndexTitle()
                        }
                }
        
index 77e77d3a3de36e6addb7745193960a81a9634516..7fdca1c73dcd141afc27bf09ca8f41ea63c2cd74 100644 (file)
@@ -39,20 +39,22 @@ fun List<ArticleNode>.renderInto(list: UL, base: List<String> = emptyList(), for
        for (node in this) {
                if (node.isViewable)
                        list.li {
-                               a(href = href(Root.LorePage(base + node.name, format))) { +node.name }
+                               val nodePath = base + node.name
+                               a(href = href(Root.LorePage(nodePath, format))) { +node.name.toFriendlyPageTitle() }
                                if (node.subNodes.isNotEmpty())
                                        ul {
-                                               node.subNodes.renderInto(this, base + node.name, format)
+                                               node.subNodes.renderInto(this, nodePath, format)
                                        }
                        }
        }
 }
 
-fun String.toFriendlyIndexTitle() = split('/').joinToString(separator = " - ") { part ->
+fun List<String>.toFriendlyIndexTitle() = joinToString(separator = " - ") { part ->
        part.toFriendlyPageTitle()
 }
 
-fun String.toFriendlyPageTitle() = split('-')
-       .joinToString(separator = " ") { word ->
-               word.lowercase().replaceFirstChar { it.titlecase() }
-       }
+fun String.toFriendlyIndexTitle() = split('/').toFriendlyIndexTitle()
+
+fun String.toFriendlyPageTitle() = split('-').joinToString(separator = " ") { word ->
+       word.lowercase().replaceFirstChar { it.titlecase() }
+}
index f4eac83b44c130cbbfea8fcfc470a2ebb4206616..c5eac0961c1a00c0917d90e8e3a0673f38137dd9 100644 (file)
@@ -36,7 +36,7 @@ suspend fun ApplicationCall.standardNavBar(path: List<String>? = null) = listOf(
 ) + path?.let { pathParts ->
        pathParts.dropLast(1).mapIndexed { i, part ->
                val subPath = pathParts.take(i + 1)
-               NavLink(href(Root.LorePage(subPath)), part)
+               NavLink(href(Root.LorePage(subPath)), part.toFriendlyPageTitle())
        }
 }.orEmpty() + (currentNation()?.let { data ->
        listOf(
index 0d2e7e15b5f36757a97a95a7d7a870634c1a7e26..82d023e4a35d104009d3b900fe91d6f15b22eff8 100644 (file)
@@ -28,7 +28,7 @@ context(Appendable)
 private fun List<ArticleNode>.renderIntoSitemap(base: String? = null) {
        val prefix by lazy(LazyThreadSafetyMode.NONE) { base?.let { "$it/" }.orEmpty() }
        for (node in this) {
-               if (Configuration.CurrentConfiguration.isDevMode || !(node.name.endsWith(".wip") || node.name.endsWith(".old"))) {
+               if (node.isViewable) {
                        val path = "$prefix${node.name}"
                        
                        val file = File(Configuration.CurrentConfiguration.articleDir).combineSafe(path)