Wrap articles in some HTML gravy on load

pull/1/head
Grégory Oestreicher 2016-12-16 15:01:28 +01:00
parent 34b92ac82c
commit 3a61c6c040
1 changed files with 22 additions and 1 deletions

View File

@ -26,6 +26,7 @@ Page {
id: articlePage
allowedOrientations: Orientation.All
property string title
property string content
SilicaWebView {
@ -33,7 +34,27 @@ Page {
anchors.fill: parent
Component.onCompleted: {
loadHtml( articlePage.content )
loadHtml( wrapArticleContent() )
}
}
function wrapArticleContent() {
var html =
"<html>" +
"<head>" +
"<style type=\"text/css\">" +
"article { font-family: sans-serif; font-size: 12px; }" +
"article h1 { font-size: 24px; }" +
"</style>" +
"</head>" +
"<body>" +
"<article>" +
"<h1>" + articlePage.title + "</h1>" +
articlePage.content +
"</article>" +
"</body>" +
"</html>"
return html
}
}