com.mchange.feedletter.default.email.item-html-untemplate.scala Maven / Gradle / Ivy
// DO NOT HAND EDIT -- Autogenerated from 'item.html.untemplate' at 2024-01-22T21:31:23.510821Z
package com.mchange.feedletter.default.email
import java.io.{Writer,StringWriter}
import scala.collection.{immutable,mutable}
import com.mchange.feedletter.*
import com.mchange.feedletter.style.*
import java.time.ZoneId
import java.time.format.{DateTimeFormatter,FormatStyle}
val Untemplate_item_html = new untemplate.Untemplate[(ComposeInfo.Universal, ItemContent),Nothing]:
val UntemplateFunction : untemplate.Untemplate[(ComposeInfo.Universal, ItemContent),Nothing] = this
val UntemplateName : String = "item_html"
val UntemplatePackage : String = "com.mchange.feedletter.default.email"
val UntemplateInputName : String = "tup"
val UntemplateInputTypeDeclared : String = "(ComposeInfo.Universal, ItemContent)"
val UntemplateInputTypeCanonical : Option[String] = untemplate.Macro.nonEmptyStringOption( untemplate.Macro.recursiveCanonicalName[(ComposeInfo.Universal, ItemContent)] )
val UntemplateInputDefaultArgument : Option[(ComposeInfo.Universal, ItemContent)] = (None : Option[(ComposeInfo.Universal, ItemContent)])
val UntemplateOutputMetadataTypeDeclared : String = "Nothing"
val UntemplateOutputMetadataTypeCanonical : Option[String] = untemplate.Macro.nonEmptyStringOption( untemplate.Macro.recursiveCanonicalName[Nothing] )
val UntemplateHeaderNote : String = ""
val UntemplateAttributes : immutable.Map[String,Any] = immutable.Map.empty
def apply(tup : (ComposeInfo.Universal, ItemContent)) : untemplate.Result[Nothing] =
val writer : StringWriter = new StringWriter(14960)
val attrs : immutable.Map[String,Any] = UntemplateAttributes
var mbMetadata : Option[Nothing] = None
var outputTransformer : Function1[untemplate.Result[Nothing],untemplate.Result[Nothing]] = identity
val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.LONG)
val (info, contents) = tup
val images = contents.media.filter( _.mimeType.map( _.startsWith("image") ).getOrElse(false) )
val (topImageUrl, bottomImageUrls) =
images.size match
case 0 => (None, None)
case 1 => (Some(images.head.url), None)
case n => (None, Some(images.map(_.url)))
end val
val block0 = new Function0[String]:
def apply() : String =
"\n \n"
writer.write(block0())
contents.title.foreach { title =>
val block1 = new Function0[String]:
def apply() : String =
" \n " + ( ifLink( contents.link, title ) ) +
"\n \n"
writer.write(block1())
}
contents.author.foreach { author =>
val block2 = new Function0[String]:
def apply() : String =
" \n"
writer.write(block2())
}
topImageUrl.foreach { url =>
val block3 = new Function0[String]:
def apply() : String =
" \n
\n \n"
writer.write(block3())
}
contents.article.foreach { article =>
val block4 = new Function0[String]:
def apply() : String =
" \n " + ( article ) +
"\n \n"
writer.write(block4())
}
contents.pubDate.foreach { pubDate =>
val block5 = new Function0[String]:
def apply() : String =
" \n Published " + ( formatter.format( pubDate.atZone(info.timeZone) ) ) +
"\n \n"
writer.write(block5())
}
if bottomImageUrls.nonEmpty then {
val block6 = new Function0[String]:
def apply() : String =
" \n"
writer.write(block6())
bottomImageUrls.foreach { url =>
val block7 = new Function0[String]:
def apply() : String =
" \n
\n \n"
writer.write(block7())
}
val block8 = new Function0[String]:
def apply() : String =
" \n"
writer.write(block8())
}
val block9 = new Function0[String]:
def apply() : String =
" \n"
writer.write(block9())
outputTransformer( untemplate.Result( mbMetadata, writer.toString ) )
end apply
end Untemplate_item_html
def item_html(tup : (ComposeInfo.Universal, ItemContent)) : untemplate.Result[Nothing] = Untemplate_item_html( tup )
© 2015 - 2025 Weber Informatics LLC | Privacy Policy