example/src/sqwl/cms/Articles.scala
changeset 27 8529ce302f7c
parent 21 1fa630ed9b8a
child 33 fa0f19a74283
equal deleted inserted replaced
26:4978df5ebf0a 27:8529ce302f7c
     9   case class Article(
     9   case class Article(
    10     id: Id,
    10     id: Id,
    11     title: String,
    11     title: String,
    12     category: Option[iCategory],
    12     category: Option[iCategory],
    13     tags: Seq[iTag] = Seq(),
    13     tags: Seq[iTag] = Seq(),
    14     htmlContent: String
    14     htmlContent: String,
       
    15     rank: Int = 0
    15   ) extends iArticle {
    16   ) extends iArticle {
    16     override def assets: Path = Paths.get(s"example/content/${id.v}")
    17     override def assets: Path = Paths.get(s"example/content/${id.v}")
    17     override def pathSegment: String = id.v
    18     override def pathSegment: String = id.v
    18   }
    19   }
    19   private val all = mutable.ArrayBuffer[iArticle]()
    20   private val all = mutable.ArrayBuffer[iArticle]()
    20 
    21 
    21   def values: Seq[iArticle] = all.toIndexedSeq
    22   def values: Seq[iArticle] = all.toIndexedSeq
    22 
    23 
    23   def article(title: String, cat: iCategory, tags: Seq[iTag] = Seq())(
    24   def article(title: String, cat: iCategory, tags: Seq[iTag] = Seq(),
    24     body: Frag*)(implicit articleId: Id): SeqFrag[Frag] = {
    25     rank: Int = 0)(body: Frag*)(implicit articleId: Id): SeqFrag[Frag] = {
    25 
    26 
    26     all += Article(articleId, title, Option(cat), tags, body.render)
    27     all += Article(articleId, title, Option(cat), tags, body.render, rank)
    27     body
    28     body
    28   }
    29   }
    29 }
    30 }