Skip to content

Commit

Permalink
#93 closed: "Show number of comments in each category"
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatov committed Jul 29, 2011
1 parent c90a3c2 commit 2195bc8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import java.text.SimpleDateFormat
* @author Sergey Ignatov
*/
object DateUtils {
def dateFormatter(d: Date) = new SimpleDateFormat("HH:mm:ss dd MMMM yyyy").format(d)
def dateFormatter(d: Date) = new SimpleDateFormat("HH:mm dd MMMM yyyy").format(d)

def atomDateFormatter(d: Date) = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(d)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,20 @@ object Discussion extends Discussion with LongKeyedMetaMapper[Discussion] {
By(Discussion.valid, true))

/** Get replies for discussion current comment. */
def replies(category: Category, d: Discussion) = Discussion.findAll(
def replies(category: Category, d: Discussion) = findAll(
By(Discussion.category, category),
By(Discussion.qualifiedName, d.qualifiedName.is),
NotNullRef(Discussion.parent),
By(Discussion.parent, d),
OrderBy(Discussion.dateTime, Ascending))

/** Get the latest valid comment for entity and category. */
def latest(category: Category, qualifiedName: String) = findAll(
By(Discussion.category, category),
By(Discussion.qualifiedName, qualifiedName),
By(Discussion.valid, true),
OrderBy(Discussion.dateTime, Descending), MaxRows(1)) match {
case List(d: Discussion, _*) => Some(d)
case _ => None
}
}
14 changes: 13 additions & 1 deletion src/main/scala/scala/tools/colladoc/page/Template.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,19 @@ class Template(tpl: DocTemplateEntity) extends tools.nsc.doc.html.page.Template(

private def categoryToHtml(c: Category) =
<div id={ id(c.name.is) } class="category">
<h3 id={ id(c.name.is + "header") } class="header">{ c.name }</h3>
<div id={ id(c.name.is + "header") } class="header">
<h3>{ c.name } ({ Discussion.count(c, tpl.qualifiedName) })</h3>
{
Discussion.latest(c, tpl.qualifiedName) match {
case Some(d) =>
<xml:group>
<span>updated</span>
<span class="datetime" title={d.atomDateTime}>{d.humanDateTime}</span>
</xml:group>
case _ => NodeSeq.Empty
}
}
</div>
<div id={ id(c.name.is + "wrapper") } class="wrapper">
<ul class="discussion_thread">
{
Expand Down
9 changes: 6 additions & 3 deletions src/main/webapp/cotemplate.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,17 @@ background-color: #E5E5E5;
display: none;
}

.category h3 {
.header {
color: black;
padding: 4px 4px 4px 16px;
border-top: 1px dotted #555;
background-color: #E5E5E5;
cursor: pointer;
}

.category h3 {
font-size: 12pt;
font-weight: bold;
cursor: pointer;
display: inline;
}

.wrapper {
Expand Down

0 comments on commit 2195bc8

Please sign in to comment.