Skip to content

Commit

Permalink
added preview for discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatov committed Jul 19, 2011
1 parent d546fd7 commit dc7d047
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/main/scala/scala/tools/colladoc/page/Template.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import net.liftweb.util.Helpers._
import tools.nsc.doc.model._
import xml.{NodeSeq, Text}
import lib.DependencyFactory._
import tools.nsc.util.NoPosition

/**
* Page containing template entity documentation and user controls.
Expand Down Expand Up @@ -177,7 +178,7 @@ class Template(tpl: DocTemplateEntity) extends tools.nsc.doc.html.page.Template(
/** Render discussion comment. */
private def discussionToHtml(d: Discussion) =
<li class="discussion_comment">
<span class="comment">{d.comment.is}</span>
<span class="comment">{bodyToHtml(parseWiki(d.comment.is, NoPosition))}</span>
<span class="info">{d.userNameDate}</span>
</li>

Expand All @@ -188,7 +189,7 @@ class Template(tpl: DocTemplateEntity) extends tools.nsc.doc.html.page.Template(

/** Render editor. */
private def discussionEditor: JsCmd = {
Editor.editorObj("", text => NodeSeq.Empty, saveDiscussionComment _) match {
Editor.editorObj("", preview _, saveDiscussionComment _) match {
case (n, j) =>
Replace("add_discussion_button",
<form id="discussion_form" class="edit" method="GET">
Expand All @@ -214,6 +215,21 @@ class Template(tpl: DocTemplateEntity) extends tools.nsc.doc.html.page.Template(
Discussion.create.qualifiedName(tpl.qualifiedName).comment(text).dateTime(now).user(User.currentUser.open_!).valid(true).save
}

/** Parse input string to show comment preview. */
private def preview(text: String) = {
<html>
<head>
<link href="/lib/template.css" media="screen" type="text/css" rel="stylesheet" />
<link href="/copreview.css" media="screen" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="preview">
{ bodyToHtml(parseWiki(text, NoPosition)) }
</div>
</body>
</html>
}

override def memberToHtml(mbr: MemberEntity): NodeSeq =
super.memberToHtml(mbr) \% Map("data-istype" -> (mbr.isAbstractType || mbr.isAliasType).toString)

Expand Down

0 comments on commit dc7d047

Please sign in to comment.