@@ -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 { | |||
} |
@@ -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); |
@@ -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<PageDecoration> decorations) { | |||
this.decorations = decorations.toArray(new PageDecoration[decorations.size()]); | |||
} | |||
public PageDecorations() { | |||
this(Collections.<PageDecoration>emptyList()); | |||
} | |||
public PageDecoration[] get() { | |||
return decorations; | |||
} | |||
} |
@@ -7,6 +7,7 @@ | |||
period_param = "period=#{params[:period]}" if params[:period] | |||
%> | |||
<div id="container"> | |||
<%= yield :header -%> | |||
<div id="hd"> | |||
<div id="nav-left"> | |||
<ul> | |||
@@ -180,6 +181,7 @@ | |||
<% end %> | |||
</ul> | |||
<%= yield :sidebar %> | |||
<div id="logo"> | |||
<center><a href="http://www.sonarsource.org/" target="SonarSource"><%= image_tag('sonar.png', :alt => message('layout.sonar.slogan'), :class => 'png') -%></a></center> | |||
</div> | |||
@@ -211,6 +213,7 @@ | |||
</div> | |||
<% unless params[:hd]=='false' %> | |||
<%= yield :footer %> | |||
<div id="footer"> | |||
<% controller.java_facade.getWebFooters().each do |footer| %> | |||
<% if footer.getHtml() %> |
@@ -1,3 +1,14 @@ | |||
<% | |||
controller.java_facade.getCoreComponentByClassname('org.sonar.server.ui.PageDecorations').get().each do |decoration| | |||
begin | |||
%> | |||
<%= render :inline => decoration.getTemplate() -%> | |||
<% | |||
rescue => error | |||
logger.error(error) | |||
end | |||
end | |||
%> | |||
<%= render :partial => 'layouts/head' unless params[:hd]=='false' %> | |||
<% if params[:layout]=='false' %> | |||
<%= render :partial => 'layouts/nolayout' %> |
@@ -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.junit.Test; | |||
import org.sonar.api.web.PageDecoration; | |||
import java.util.Arrays; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
public class PageDecorationsTest { | |||
@Test | |||
public void should_not_fail_if_no_decorations() { | |||
assertThat(new PageDecorations().get()).isEmpty(); | |||
} | |||
@Test | |||
public void should_register_decorations() { | |||
PageDecoration deco1 = mock(PageDecoration.class); | |||
PageDecoration deco2 = mock(PageDecoration.class); | |||
PageDecorations decorations = new PageDecorations(Arrays.asList(deco1, deco2)); | |||
assertThat(decorations.get()).hasSize(2); | |||
} | |||
} |