Skip to content

Commit

Permalink
114 closed: "Use section headers on discussions tabs in profiles"
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatov committed Aug 3, 2011
1 parent a09e337 commit b4f5e9f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
43 changes: 37 additions & 6 deletions src/main/scala/scala/tools/colladoc/snippet/ProfileOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import lib.widgets.Editor
import net.liftweb.http.js.jquery.JqJE.Jq
import lib.js.JqUI.Button
import net.liftweb.http.js.JsCmds._
import tools.nsc.doc.model.{DocTemplateEntity, MemberEntity}
import lib.util.PathUtils._

/**
* User profile snippet.
Expand Down Expand Up @@ -306,6 +308,21 @@ class ProfileOps {
</div>
}

private def tmpl(member: MemberEntity) = member match {
case tpl: DocTemplateEntity => tpl
case _ => member.inTemplate
}

def path(qualifiedName: String) = qualifiedName.split('.').toList

def fixedPath(qualifiedName: String) = {
val p = path(qualifiedName)
if (p.length == 1)
p ::: List("package")
else
p
}

def body(xhtml: NodeSeq): NodeSeq = {
val user = getUser

Expand All @@ -319,14 +336,28 @@ class ProfileOps {

val entities = dscs.map(d => (d.qualifiedName.is, d)).groupBy(p => p._1)

lazy val x = entities map { case (qualifiedName, value) =>
<xml:group>
<h3><a href={abs(qualifiedName)}>{qualifiedName}</a></h3>
<ul>{value map { case (q, d) => dToHtml(d) } }</ul>
</xml:group>
lazy val x = entities map { case (qualifiedName, value) => {
val m = pathToTemplate(model.vend.rootPackage, fixedPath(qualifiedName))

val containingType = tmpl(m);

<div class={if (containingType.isTrait || containingType.isClass) " type" else " value"}>
<h4 class="definition">
<a href={ abs(qualifiedName) }>
<img src={ profile.relativeLinkTo{List(profile.kindToString(containingType) + ".png", "lib")} }/>
</a>
<span>{ qualifiedName }</span>
</h4>
<div class="discussion_wrapper">
<ul>
{value map { case (q, d) => dToHtml(d) } }
</ul>
</div>
</div>
}
}

def abs(qualifiedName: String) = "/" + qualifiedName.replace(".", "/").replace("#", "$") + ".html"
def abs(qualifiedName: String) = "/" + fixedPath(qualifiedName).mkString("/") + ".html"

def dToHtml(d: Discussion) = {
bind("discussion_comment", template.discussionToHtml(d))
Expand Down
13 changes: 13 additions & 0 deletions src/main/webapp/coprofile.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,17 @@

#edit_info_button {
margin-top: 8px;
}

#discussion_comments_tab {
padding-left: 0;
padding-right: 0;
}

.definition > a {
text-decoration: none;
}

.discussion_wrapper {
margin-left: 20px;
}

0 comments on commit b4f5e9f

Please sign in to comment.