Skip to content

Commit

Permalink
Merge pull request #34 from Viva-con-Agua/feature/31
Browse files Browse the repository at this point in the history
Feature/31
  • Loading branch information
deinelieblings authored Jun 25, 2018
2 parents 3c4d200 + 1406ccb commit 9d2f3a4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Dispenser can render HTML-Files with custom Context. For this you can simply sen
},
templateData: {
title: "",
content:""
content:"",
head: Option String
}
}
```
Expand All @@ -49,7 +50,9 @@ simpleTemplate: header, body:
ChangeLog
=========

## Version 0.2.6 (2018-06-19)
## Version 0.2.8 (2018-06-25)
* [[B] #25- Navigation not Found](https://github.com/Viva-con-Agua/dispenser/issues/25)
* [[F] #31 - Templates: add option for handling javascript](https://github.com/Viva-con-Agua/dispenser/issues/31)
* [[F] #28 - Impressum: template logic for handling imprints](https://github.com/Viva-con-Agua/dispenser/issues/28)
* [[F] #26 - Switch the host](https://github.com/Viva-con-Agua/dispenser/issues/26)
* [[F] #21 - add init for navigation](https://github.com/Viva-con-Agua/dispenser/issues/23)
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/TemplateController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ class TemplateController @Inject() (
Logger.debug(path)
navigationDAO.findByPath(path).flatMap {
case Some(navigation) => Future.successful(Ok(render.buildSimpleHtml(navigation, template.templateData, template.navigationData.active)))
case _ => Future.successful(BadRequest("Navigation not found"))
case _ =>
navigationDAO.find("GlobalNav").flatMap {
case Some(navigation) => Future.successful(Ok(render.buildSimpleHtml(navigation, template.templateData, template.navigationData.active)))
case _ => Future.successful(BadRequest("Navigation not found"))
}

}
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/models/Template.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ case class MetaData (
)
case class TemplateData (
title: String,
content: String
content: String,
head: Option[String]
)

case class NavigationData (
Expand Down
8 changes: 7 additions & 1 deletion app/services/RenderService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ class RenderService @Inject() (

def buildSimpleHtml (navigation: Navigation, templateData: TemplateData, active: String): String = {
val navbarContent:String = build_navigation(navigation, active)

val host = templateData.head match {
case Some(head) =>
new String(java.util.Base64.getDecoder.decode(head), "UTF-8")
case None =>
""
}
scalate.render("mustache/simple/main.mustache", Map(
"title" -> templateData.title,
"hostURL" -> hostURL,
"navbarContent" -> navbarContent,
"host" -> host,
"imprintURL" -> imprintURL,
"content" -> new String(java.util.Base64.getDecoder.decode(templateData.content), "UTF-8")
)).toString
Expand Down
1 change: 1 addition & 0 deletions app/views/mustache/simple/main.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="{{hostURL}}/javascript/dropzone.js"></script>
<script src="{{hostURL}}/javascript/config.js"></script>
{{head}}
</head>
<body>
<div class="navbar navbar-vca navbar-default navbar-fixed-top"> <!-- navbar-default -->
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name := """dispenser"""
organization := "com.example"

version := Option(System.getProperty("version")).getOrElse("0.2.6")
version := Option(System.getProperty("version")).getOrElse("0.2.8")
//version := "0.2.3"

lazy val root = (project in file(".")).enablePlugins(PlayScala).enablePlugins(SbtWeb)
Expand Down

0 comments on commit 9d2f3a4

Please sign in to comment.