From 7512bff46a525bd857b4d128d584e7b5b628cf96 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 20 Apr 2015 12:04:43 +0200 Subject: [PATCH] SONAR-6005 Migrate markdown help window from ruby --- server/sonar-web/Gruntfile.coffee | 7 ++ .../src/main/hbs/markdown/markdown-help.hbs | 100 ++++++++++++++++ server/sonar-web/src/main/js/markdown/app.js | 30 +++++ .../main/js/markdown/markdown-help-view.js | 26 +++++ server/sonar-web/src/main/less/style.less | 3 +- .../WEB-INF/app/views/markdown/help.html.erb | 107 +----------------- 6 files changed, 171 insertions(+), 102 deletions(-) create mode 100644 server/sonar-web/src/main/hbs/markdown/markdown-help.hbs create mode 100644 server/sonar-web/src/main/js/markdown/app.js create mode 100644 server/sonar-web/src/main/js/markdown/markdown-help-view.js diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee index 9bc045a6f52..2c631a6b01a 100644 --- a/server/sonar-web/Gruntfile.coffee +++ b/server/sonar-web/Gruntfile.coffee @@ -248,6 +248,10 @@ module.exports = (grunt) -> name: 'widgets/issue-filter' out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/widgets/issue-filter.js' + markdown: options: + name: 'markdown/app' + out: '<%= grunt.option("assetsDir") || pkg.assets %>build/js/markdown/app.js' + handlebars: options: @@ -307,6 +311,9 @@ module.exports = (grunt) -> '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/workspace.js': [ '<%= pkg.sources %>hbs/workspace/**/*.hbs' ] + '<%= grunt.option("assetsDir") || pkg.assets %>js/templates/markdown.js': [ + '<%= pkg.sources %>hbs/markdown/**/*.hbs' + ] clean: diff --git a/server/sonar-web/src/main/hbs/markdown/markdown-help.hbs b/server/sonar-web/src/main/hbs/markdown/markdown-help.hbs new file mode 100644 index 00000000000..9524f7bb12a --- /dev/null +++ b/server/sonar-web/src/main/hbs/markdown/markdown-help.hbs @@ -0,0 +1,100 @@ +

Markdown Syntax

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Write:To display:
*this text is bold*this text is bold
http://sonarqube.orghttp://sonarqube.org
+ [SonarQube™ Home Page](http://www.sonarqube.org) + + SonarQube™ Home Page +
* first item
+ * second item +
+
    +
  • first item
  • +
  • second item
  • +
+
1. first item
+ 1. second item +
+
    +
  1. first item
  2. +
  3. second item
  4. +
+
+ = Heading Level 1
+ == Heading Level 2
+ === Heading Level 3
+ ==== Heading Level 4
+ ===== Heading Level 5
+ ====== Heading Level 6
+
+

Heading Level 1

+

Heading Level 2

+

Heading Level 3

+

Heading Level 4

+
Heading Level 5
+
Heading Level 6
+
``Lists#newArrayList()``Lists#newArrayList()
+ ``
+ // code on multiple lines
+ public void foo() {
+   // do some logic here
+ }
+ `` +
+
+  // code on multiple lines
+  public void foo() {
+  // do some logic here
+  }
+
+
+ Standard text
+ > Blockquoted text
+ > that spans multiple lines
+
+

Standard text

+
Blockquoted text
+ that spans multiple lines
+
diff --git a/server/sonar-web/src/main/js/markdown/app.js b/server/sonar-web/src/main/js/markdown/app.js new file mode 100644 index 00000000000..8446405c15c --- /dev/null +++ b/server/sonar-web/src/main/js/markdown/app.js @@ -0,0 +1,30 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +define(['markdown/markdown-help-view'], function (MarkdownView) { + + var App = new Marionette.Application(); + + App.on('start', function (options) { + new MarkdownView({ el: options.el }).render(); + }); + + return App; + +}); diff --git a/server/sonar-web/src/main/js/markdown/markdown-help-view.js b/server/sonar-web/src/main/js/markdown/markdown-help-view.js new file mode 100644 index 00000000000..8c2c10dee66 --- /dev/null +++ b/server/sonar-web/src/main/js/markdown/markdown-help-view.js @@ -0,0 +1,26 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +define(['templates/markdown'], function () { + + return Marionette.ItemView.extend({ + template: Templates['markdown-help'] + }); + +}); diff --git a/server/sonar-web/src/main/less/style.less b/server/sonar-web/src/main/less/style.less index 46c7ee988e7..7114b2e2314 100644 --- a/server/sonar-web/src/main/less/style.less +++ b/server/sonar-web/src/main/less/style.less @@ -462,7 +462,8 @@ ul.bullet li { /* API for Rule and Property Descriptions */ -.rule-desc { +.rule-desc, +.markdown { .formatted; } diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/markdown/help.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/markdown/help.html.erb index fe0b4702f53..7c85dbec572 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/markdown/help.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/markdown/help.html.erb @@ -1,101 +1,6 @@ -
-

Markdown Syntax

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Write :To display :
*this text is bold*this text is bold
http://sonarqube.orghttp://sonarqube.org
* first item
- * second item
-
    -
  • first item
  • -
  • second item
  • -
-
1. first item
- 1. second item
-
    -
  1. first item
  2. -
  3. second item
  4. -
-
- = Heading Level 1
- == Heading Level 2
- === Heading Level 3
- ==== Heading Level 4
- ===== Heading Level 5
- ====== Heading Level 6
-
-

Heading Level 1

-

Heading Level 2

-

Heading Level 3

-

Heading Level 4

-
Heading Level 5
-
Heading Level 6
-
``Lists#newArrayList()``Lists#newArrayList()
- ``
- // code on multiple lines
- public void foo() {
-   // do some logic here
- }
- `` -
-
-  // code on multiple lines
-  public void foo() {
-    // do some logic here
-  }
-
-      
-
- Standard text
- > Blockquoted text
- > that spans multiple lines
-
-

Standard text

-
Blockquoted text
- that spans multiple lines
-
- [SonarQube™ Home Page](http://www.sonarqube.org) - - SonarQube™ Home Page -
-
+
+ -- 2.39.5