CachingOptions(CacheControl.MaxAge(maxAgeSeconds = 3600))
else if (call.attributes.getOrNull(PageDoNotCacheAttributeKey) == true)
CachingOptions(CacheControl.NoStore(null))
- else null
+ else
+ null
}
}
version { call, outgoingContent ->
if (outgoingContent is LocalFileContent)
listOf(LastModifiedVersion(outgoingContent.file.lastModified()))
- else call.attributes.getOrNull(FactbookLastModifiedAttributeKey)?.let { lastModified ->
- listOf(LastModifiedVersion(lastModified.toEpochMilli()))
- } ?: emptyList()
+ else
+ emptyList()
}
}
get() = OpenGraphData(desc, image)
}
-val FactbookLastModifiedAttributeKey = AttributeKey<Instant>("Mechyrdia.FactbookLastModified")
-
-private val File.lastSubFilesModified: Instant?
- get() = if (isDirectory)
- (listFiles()!!.mapNotNull {
- it.lastSubFilesModified
- } + Instant.ofEpochMilli(lastModified())!!).max()
- else null
-
-private val File.lastContentModified: Instant
- get() = lastSubFilesModified ?: Instant.ofEpochMilli(lastModified())!!
-
suspend fun ApplicationCall.loreIntroPage(): HTML.() -> Unit {
val metaJsonFile = File(Configuration.CurrentConfiguration.articleDir).parentFile.combineSafe("introMeta.json")
val metaData = JsonFileCodec.decodeFromString(IntroMetaData.serializer(), metaJsonFile.readText())
val htmlFile = File(Configuration.CurrentConfiguration.articleDir).parentFile.combineSafe("intro.html")
val fileHtml = htmlFile.readText()
- attributes.put(
- FactbookLastModifiedAttributeKey,
- maxOf(
- Instant.ofEpochMilli(htmlFile.lastModified()),
- Instant.ofEpochMilli(metaJsonFile.lastModified())
- )
- )
-
return page(metaData.title, standardNavBar(), null, metaData.ogData) {
section {
a { id = "page-top" }
canCommentAs.await() to comments.await()
}
- if (pageFile.exists())
- attributes.put(FactbookLastModifiedAttributeKey,
- (comments.map { comment ->
- comment.lastEdit ?: comment.submittedAt
- } + pageFile.lastContentModified).max()
- )
-
if (pageFile.isDirectory) {
val navbar = standardNavBar(pagePathParts.takeIf { it.isNotEmpty() })