This document provides instructions for contributing to the Scala Vienna webapp project on GitHub. It explains how to add blog feeds and talks by forking the repository, modifying the configuration files, and submitting a pull request. Technical details are also presented on validating JSON responses using case classes and formatting, and converting Markdown files to HTML for display on the site. The document encourages collaboration by noting ways the project could be improved with additional contributors.
6. Blogs: how to add your own
Go to Scala Vienna Web repository (https://github.com/
scala-vienna/scala-vienna-web)
Fork it and checkout
Find /conf/application.conf file and add your blog record to
“blogs.list” section at the bottom
Fix some bugs :)
Ensure that everything works
Commit changes and make pull request
Enjoy and relax!!!
7. Blogs: using Play config
Add new section
to config
Read it
blogs.default.categories = ["scala", "akka", "play", "reactive"]
blogs.list = [
{url: "http://blog.papauschek.com/feed/", categories: []},
{url: "http://manuel.bernhardt.io/feed/", categories: []}
]
val blogs = Play.configuration.getObjectList("blogs.list") match {
case Some(list) => {
list.flatMap(b => {
try {
val url = b.get("url").unwrapped().asInstanceOf[String]
val cats = b.get("categories").unwrapped().asInstanceOf[util.ArrayList[String]].toSet
Seq(Blog(url, if (cats.isEmpty) defaultCategories else cats))
} catch { case e: Throwable => { Logger.warn(e.getMessage); Nil } }
})
}…
8. API: JSON validation
Use case
classes
case class Contributor(
login: String,
id: Long,
avatar_url: String,
…
Add implicit Format
to the scope
implicit val contributorFormat =
Json.format[Contributor]
Validate JSON
def getContributors: Future[List[Contributor]] = {
WS.url("https://api.github.com/repos/rafacm/scala-vienna-web/contributors")
.withAuth(apiKey, "x-oauth-basic", Realm.AuthScheme.BASIC)
.get().map(response =>
if (response.status == 200) {
response.json.validate[List[Contributor]]
.recoverTotal(e => { Logger.warn(s"getContributors: ${e.toString}"); Nil })
} else { Logger.warn(s"getUser: ${response.statusText}"); Nil }
)
}
9. Talks: how to add your own
Go to Scala Vienna Web repository (https://github.com/
scala-vienna/scala-vienna-web)
Fork it and checkout
Add new talk /conf/<yyyymmdd-slug>.md
That’s too complicated - I skip it
Ensure that everything works
Commit changes and make pull request
Enjoy and relax!!!
10. Talks: file contents example
--title = Integration testing with MongoDB and ScalaTest
speaker = Michal Bigos
meetupEventId = 106481582
meetupMemberId = 21178561
twitter = teliatko
tags = "Scala,ScalaTest,MongoDB"
slides = "http://teliatko.github.io/talks/vsug-2013-03_it-with-mongodb.html#/"
--* Strategy for testing on our last Play! project
* Why we have done integration testing at all
* Using ScalaTest for integration testing with MongoDB
* Possibilities of integration testing frameworks
* Custom DSL for seeding the MongoDB
* Small extensions to Casbah for better query syntax
11. Talks: using markdown
Add dependency
libraryDependencies ++= Seq(
"org.pegdown" % "pegdown" % "1.4.2"
)
Read markdown files
val dir = Play.getFile(talksDirectory)
Convert to HTML
private def markdown(markdown: String): Html =
Html(pegDownProcessor.markdownToHtml(markdown))