| author | Tomas Zeman <tomas@functionals.cz> |
| Tue, 29 Dec 2020 16:46:47 +0100 | |
| changeset 33 | fa0f19a74283 |
| parent 27 | 8529ce302f7c |
| permissions | -rw-r--r-- |
| 33 | 1 |
/* |
2 |
* Copyright 2018-2020 Tomas Zeman <tomas@functionals.cz> |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
|
18
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
16 |
package sqwl.cms |
|
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
17 |
|
| 33 | 18 |
import scalatags.Text.all._ |
19 |
||
|
18
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
20 |
import scala.collection.mutable |
|
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
21 |
|
|
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
22 |
object Articles {
|
| 21 | 23 |
case class Id(v: String) |
|
18
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
24 |
case class Article( |
| 21 | 25 |
id: Id, |
26 |
title: String, |
|
27 |
category: Option[iCategory], |
|
28 |
tags: Seq[iTag] = Seq(), |
|
| 33 | 29 |
htmlContent: SeqFrag[Frag], |
|
27
8529ce302f7c
Article.rank: sort articles by category/tag w.r.t. rank
Tomas Zeman <tzeman@volny.cz>
parents:
21
diff
changeset
|
30 |
rank: Int = 0 |
|
18
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
31 |
) extends iArticle {
|
|
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
32 |
override def pathSegment: String = id.v |
|
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
33 |
} |
|
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
34 |
private val all = mutable.ArrayBuffer[iArticle]() |
|
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
35 |
|
| 21 | 36 |
def values: Seq[iArticle] = all.toIndexedSeq |
|
18
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
37 |
|
|
27
8529ce302f7c
Article.rank: sort articles by category/tag w.r.t. rank
Tomas Zeman <tzeman@volny.cz>
parents:
21
diff
changeset
|
38 |
def article(title: String, cat: iCategory, tags: Seq[iTag] = Seq(), |
|
8529ce302f7c
Article.rank: sort articles by category/tag w.r.t. rank
Tomas Zeman <tzeman@volny.cz>
parents:
21
diff
changeset
|
39 |
rank: Int = 0)(body: Frag*)(implicit articleId: Id): SeqFrag[Frag] = {
|
|
18
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
40 |
|
| 33 | 41 |
all += Article(articleId, title, Option(cat), tags, body, rank) |
|
18
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
42 |
body |
|
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
43 |
} |
|
8cfd67425811
Scalatex article as primary format
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
44 |
} |