X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpage%2FPageMakerInteraction.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpage%2FPageMakerInteraction.kt;h=8d6884cef767773ad05c290166b690dd77684033;hp=0000000000000000000000000000000000000000;hb=03cec6a6772c2d836d94864adddaf544cbe9d72f;hpb=6f1f26e3998cfef155b0cf59152827accea70d30 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/page/PageMakerInteraction.kt b/src/main/kotlin/net/pterodactylus/sone/web/page/PageMakerInteraction.kt new file mode 100644 index 0000000..8d6884c --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/web/page/PageMakerInteraction.kt @@ -0,0 +1,31 @@ +package net.pterodactylus.sone.web.page + +import freenet.clients.http.* + +class PageMakerInteraction(toadletContext: ToadletContext, pageTitle: String) { + + private val pageMaker: PageMaker = toadletContext.pageMaker + private val pageNode: PageNode = pageMaker.getPageNode(pageTitle, toadletContext) + + fun addStyleSheet(styleSheet: String) { + pageNode.addCustomStyleSheet(styleSheet) + } + + fun addLinkNode(linkAttributes: Map) { + pageNode.headNode.addChild("link").let { + linkAttributes.forEach(it::addAttribute) + } + } + + fun addShortcutIcon(shortcutIcon: String) { + pageNode.addForwardLink("icon", shortcutIcon) + } + + fun setContent(content: String) { + pageNode.content.addChild("%", content) + } + + fun renderPage(): String = + pageNode.outer.generate() + +}