<artifactId>sonar-channel</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-markdown</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-check-api</artifactId>
@SuppressWarnings("rawtypes")
public ChannelDispatcher(List<Channel> channels, boolean failIfNoChannelToConsumeOneCharacter) {
- this.channels = channels.toArray(new Channel[0]); // NOSONAR, lack of performance is not an issue here
+ this.channels = channels.toArray(new Channel[channels.size()]);
this.failIfNoChannelToConsumeOneCharacter = failIfNoChannelToConsumeOneCharacter;
}
public final String toString() {
StringBuilder result = new StringBuilder();
result.append("CodeReader(");
- result.append("line:" + cursor.line);
- result.append("|column:" + cursor.column);
- result.append("|cursor value:'" + (char) peek() + "'");
+ result.append("line:").append(cursor.line);
+ result.append("|column:").append(cursor.column);
+ result.append("|cursor value:'").append((char) peek()).append("'");
result.append(")");
return result.toString();
}
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-java-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-markdown</artifactId>
+ </dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
import org.sonar.jpa.dao.AsyncMeasuresService;
import org.sonar.jpa.dialect.Dialect;
import org.sonar.jpa.session.DatabaseConnector;
+import org.sonar.markdown.MarkdownEngine;
import org.sonar.server.configuration.Backup;
import org.sonar.server.configuration.CoreConfiguration;
import org.sonar.server.configuration.ProfilesManager;
return getContainer().getComponent(FilterExecutor.class).execute(filter);
}
- /* UPDATE CENTER */
+ // UPDATE CENTER ------------------------------------------------------------
public void downloadPlugin(String pluginKey, String pluginVersion) {
getContainer().getComponent(PluginDownloader.class).download(pluginKey, Version.create(pluginVersion));
return getContainer().getComponent(UpdateCenterMatrixFactory.class).getMatrix(forceReload);
}
- /* PLUGINS */
+ // PLUGINS ------------------------------------------------------------------
public Property[] getPluginProperties(PluginMetadata metadata) {
Plugins plugins = getContainer().getComponent(Plugins.class);
return getContainer().getComponent(PluginDeployer.class).getPluginsMetadata();
}
+
+ // SYNTAX HIGHLIGHTING ------------------------------------------------------
+
public String colorizeCode(String code, String language) {
try {
return getContainer().getComponent(CodeColorizers.class).toHtml(code, language);
}
}
+ public static String markdownToHtml(String input) {
+ return MarkdownEngine.convertToHtml(input);
+ }
+
+
+
+
+
public List<ViewProxy<Widget>> getWidgets(String resourceScope, String resourceQualifier, String resourceLanguage) {
return getContainer().getComponent(Views.class).getWidgets(resourceScope, resourceQualifier, resourceLanguage);
}
class ResourceController < ApplicationController
SECTION=Navigation::SECTION_RESOURCE
- helper DashboardHelper
+ helper :dashboard, :markdown
def index
@resource = Project.by_key(params[:id])
verify :method => :post, :only => [ :create, :create_comment ], :redirect_to => { :action => :error_not_post }
+ helper(:reviews, :markdown)
+
def index
init_params
search_reviews
--- /dev/null
+ #
+ # Sonar, entreprise quality control tool.
+ # Copyright (C) 2008-2011 SonarSource
+ # mailto:contact AT sonarsource DOT com
+ #
+ # Sonar is free software; you can redistribute it and/or
+ # modify it under the terms of the GNU Lesser General Public
+ # License as published by the Free Software Foundation; either
+ # version 3 of the License, or (at your option) any later version.
+ #
+ # Sonar is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ # Lesser General Public License for more details.
+ #
+ # You should have received a copy of the GNU Lesser General Public
+ # License along with Sonar; if not, write to the Free Software
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ #
+module MarkdownHelper
+
+ def markdown_to_html(input)
+ input ? Java::OrgSonarServerUi::JRubyFacade.markdownToHtml(h(input)) : ''
+ end
+
+end
\ No newline at end of file
validates_presence_of :user => "can't be empty"
validate :comment_should_not_be_empty
+ alias_attribute :text, :review_text
+
+ private
+
def comment_should_not_be_empty
errors.add("Comment", " cannot be empty") if review_text.strip.blank?
end
</h4>
<% if review_comment == last_comment %>
<div id="lastComment<%= violation.id -%>">
- <%= h(review_comment.review_text) -%>
+ <%= markdown_to_html(review_comment.text) -%>
</div>
<% else %>
- <%= h(review_comment.review_text) -%>
+ <%= markdown_to_html(review_comment.text) -%>
<% end %>
</div>
<%
</div>
<% end %>
-<div>
\ No newline at end of file
+</div>
\ No newline at end of file
<%= review.assignee ? h(review.assignee.name) : '-'-%>
</td>
<td class="key">
- Created:
+ Created by:
</td>
<td class="val">
- by <%= h(review.user.name) -%> at <%= l(review.created_at) -%>
+ <%= h(review.user.name) -%> at <%= l(review.created_at) -%>
</td>
</tr>
<% if review.rule %>
<% review.comments.each do |comment| %>
<div class="discussionComment">
<h4><%= image_tag("reviews/comment.png") -%> <b><%= comment.user.name -%></b> (<%= distance_of_time_in_words_to_now(comment.created_at) -%>)</h4>
- <%= h(comment.review_text) -%>
+ <%= markdown_to_html(comment.text) -%>
</div>
<% end %>
</div>
-<div>
\ No newline at end of file
+</div>
\ No newline at end of file
.small {
font-size: 85%;
}
-em {
+small {
color: #AAA;
font-size: 85%;
font-style: normal;
}
+em {
+ font-weight: bold;
+}
a.external {
background: url('../images/links/external.png') no-repeat 100% 0;