From 186c158abed49d4413673332cd1892e296eabe2e Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 24 Sep 2012 14:47:58 +0200 Subject: [PATCH] SONAR-2376 Add an extension point to define a HTML banner --- .../org/sonar/api/web/PageDecoration.java | 29 ++++++++++++ .../org/sonar/server/platform/Platform.java | 6 +-- .../org/sonar/server/ui/PageDecorations.java | 46 +++++++++++++++++++ .../app/views/layouts/_layout.html.erb | 3 ++ .../app/views/layouts/application.html.erb | 11 +++++ .../sonar/server/ui/PageDecorationsTest.java | 46 +++++++++++++++++++ 6 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/web/PageDecoration.java create mode 100644 sonar-server/src/main/java/org/sonar/server/ui/PageDecorations.java create mode 100644 sonar-server/src/test/java/org/sonar/server/ui/PageDecorationsTest.java diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/PageDecoration.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/PageDecoration.java new file mode 100644 index 00000000000..3c89d1aa238 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/PageDecoration.java @@ -0,0 +1,29 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 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 + */ +package org.sonar.api.web; + +import org.sonar.api.ServerExtension; + +/** + * @since 3.3 + */ +public abstract class PageDecoration extends AbstractRubyTemplate implements ServerExtension { + +} diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index 5f369ba3454..3c39a3d7a89 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -69,10 +69,7 @@ import org.sonar.server.qualitymodel.DefaultModelManager; import org.sonar.server.rules.ProfilesConsole; import org.sonar.server.rules.RulesConsole; import org.sonar.server.startup.*; -import org.sonar.server.ui.CodeColorizers; -import org.sonar.server.ui.JRubyI18n; -import org.sonar.server.ui.SecurityRealmFactory; -import org.sonar.server.ui.Views; +import org.sonar.server.ui.*; import javax.servlet.ServletContext; @@ -221,6 +218,7 @@ public final class Platform { servicesContainer.addSingleton(ResourceTypes.class); servicesContainer.addSingleton(NewUserNotifier.class); servicesContainer.addSingleton(SettingsChangeNotifier.class); + servicesContainer.addSingleton(PageDecorations.class); // Notifications servicesContainer.addSingleton(EmailSettings.class); diff --git a/sonar-server/src/main/java/org/sonar/server/ui/PageDecorations.java b/sonar-server/src/main/java/org/sonar/server/ui/PageDecorations.java new file mode 100644 index 00000000000..2c0dde37be2 --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/ui/PageDecorations.java @@ -0,0 +1,46 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 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 + */ +package org.sonar.server.ui; + +import org.sonar.api.ServerComponent; +import org.sonar.api.web.PageDecoration; + +import java.util.Collections; +import java.util.List; + +/** + * @since 3.3 + */ +public final class PageDecorations implements ServerComponent { + + private final PageDecoration[] decorations; + + public PageDecorations(List decorations) { + this.decorations = decorations.toArray(new PageDecoration[decorations.size()]); + } + + public PageDecorations() { + this(Collections.emptyList()); + } + + public PageDecoration[] get() { + return decorations; + } +} diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index 01afcdae95e..0bf5418a25b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -7,6 +7,7 @@ period_param = "period=#{params[:period]}" if params[:period] %>
+<%= yield :header -%>
<% unless params[:hd]=='false' %> + <%= yield :footer %>