| author | Tomas Zeman <tzeman@volny.cz> |
| Tue, 11 Dec 2018 15:03:57 +0100 | |
| changeset 15 | 1e1b0a1a4d63 |
| child 16 | 4556852613a9 |
| permissions | -rw-r--r-- |
|
15
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
1 |
package sqwl.cms |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
2 |
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
3 |
import java.nio.file.Path |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
4 |
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
5 |
import scala.io.Source |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
6 |
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
7 |
trait FsArticle extends iArticle {
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
8 |
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
9 |
protected def contentPath: Path |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
10 |
protected def encoding: String = "UTF-8" |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
11 |
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
12 |
override def htmlContent: String = {
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
13 |
val src = Source.fromFile(contentPath.toFile, encoding) |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
14 |
try {
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
15 |
src.getLines.mkString |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
16 |
} catch {
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
17 |
case _: Throwable => "" |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
18 |
} finally {
|
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
19 |
src.close() |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
20 |
} |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
21 |
} |
|
1e1b0a1a4d63
Filesystem based article implementation
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
22 |
} |