base/src/sqwl/cms/FsArticle.scala
author Tomas Zeman <tzeman@volny.cz>
Tue, 11 Dec 2018 15:03:57 +0100
changeset 15 1e1b0a1a4d63
child 16 4556852613a9
permissions -rw-r--r--
Filesystem based article implementation

package sqwl.cms

import java.nio.file.Path

import scala.io.Source

trait FsArticle extends iArticle {

  protected def contentPath: Path
  protected def encoding: String = "UTF-8"

  override def htmlContent: String = {
    val src = Source.fromFile(contentPath.toFile, encoding)
    try {
      src.getLines.mkString
    } catch {
      case _: Throwable => ""
    } finally {
      src.close()
    }
  }
}