forked from akiko-pusu/redmine_banner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 72a2669
Showing
17 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
= Redmine Banner Plugin | ||
|
||
Plugin to show site-wide message, such as maintenacne informations or notifications. | ||
|
||
=== Plugin installation | ||
|
||
1. Copy the plugin directory into the vendor/plugins directory. | ||
2. Go to plugin's page and click "Settings" link of Redmine Banner Plugin. | ||
You can edit banner message. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class BannerController < ApplicationController | ||
unloadable | ||
|
||
def preview | ||
@text = params[:settings][:banner_description] | ||
render :partial => 'common/preview' | ||
end | ||
|
||
def show | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module BannerHelper | ||
def escape_single_quote(data) | ||
return data.gsub("'","’") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<p> | ||
<%=content_tag(:label, "プラグインを有効にする")%> | ||
<%=check_box_tag 'settings[enable]', true, @settings['enable'] == "true" %> | ||
</p> | ||
|
||
<p> | ||
<%=content_tag(:label, "メッセージのタイプ")%> | ||
<%= radio_button_tag 'settings[type]', "info", @settings['type'] == "info" %> <span class="banner_info">Info</span><br> | ||
<%= radio_button_tag 'settings[type]', "warn", @settings['type'] == "warn" %> <span class="banner_warn">Warn</span><br> | ||
<%= radio_button_tag 'settings[type]', "alert", @settings['type'] == "alert" %> <span class="banner_alert">Alert </span> | ||
</p> | ||
|
||
<p> | ||
<%=content_tag(:label, "バナーメッセージ") %> | ||
<%=text_area_tag 'settings[banner_description]', @settings['banner_description'], :size =>"40x3", | ||
:class => 'wiki-edit' ,:required => true %><br/> | ||
<%= wikitoolbar_for "settings_banner_description" %> | ||
<%= link_to_remote l(:label_preview), | ||
{ :url => { :controller => 'banner', :action => 'preview'}, | ||
:method => 'post', | ||
:id => 'banner_preview', | ||
:update => 'banner_description_preview', | ||
:with => "Form.serialize('plugin')", | ||
:complete => "Element.scrollTo('banner_description_preview')" | ||
}, :accesskey => accesskey(:preview) %> | ||
<div id="banner_description_preview" class="wiki"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h2><%= l(:label_settings) %>: <%=h @plugin.name %></h2> | ||
|
||
<div id="settings"> | ||
<% form_tag({:action => 'plugin'},{:id => :plugin }) do %> | ||
<div class="box tabular"> | ||
<%= render :partial => @partial, :locals => {:settings => @settings}%> | ||
</div> | ||
<%= submit_tag l(:button_apply) %> | ||
<% end %> | ||
</div> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.banner { | ||
border-style: solid; | ||
border-width: 1px; | ||
/* | ||
background-image: url(/plugin_assets/redmine_banner/images/info.png); | ||
background-repeat: no-repeat; | ||
background-position: left; | ||
*/ | ||
margin: 5px 10px; | ||
padding-left: 34px; | ||
padding: 5px 20px; | ||
} | ||
|
||
div.banner_info { | ||
border-color: #b0c4de; | ||
background: #f0f8ff url(/plugin_assets/redmine_banner/images/info.png) no-repeat left center; | ||
} | ||
|
||
div.banner_warn { | ||
border-color: #f3d51a; | ||
background: #f9f99e url(/plugin_assets/redmine_banner/images/warn.png) no-repeat left center; | ||
} | ||
|
||
div.banner_alert { | ||
background-color: #ffe3e3; | ||
border-color: #dd0000; | ||
background: #ffe3e3 url(/plugin_assets/redmine_banner/images/alert.png) no-repeat left center; | ||
} | ||
|
||
span.banner_info { | ||
background-image: url(/plugin_assets/redmine_banner/images/info.png); | ||
background-repeat: no-repeat; | ||
background-position: left center; | ||
padding-left: 26px; | ||
} | ||
|
||
span.banner_warn { | ||
background-image: url(/plugin_assets/redmine_banner/images/warn.png); | ||
background-repeat: no-repeat; | ||
background-position: left center; | ||
padding-left: 26px; | ||
} | ||
|
||
span.banner_alert { | ||
background-image: url(/plugin_assets/redmine_banner/images/alert.png); | ||
background-repeat: no-repeat; | ||
background-position: left center; | ||
padding-left: 26px; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# English strings go here for Rails i18n | ||
en: | ||
banner: "Banner" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# English strings go here for Rails i18n | ||
ja: | ||
banner: "バナー" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'redmine' | ||
require 'banner_application_hooks' | ||
|
||
Redmine::Plugin.register :redmine_banner do | ||
name 'Redmine Banner plugin' | ||
author 'Akiko Takano' | ||
description 'Plugin to show site-wide message, such as maintenacne informations or notifications.' | ||
version '0.0.1' | ||
requires_redmine :version_or_higher => '1.2.0' | ||
|
||
settings :partial => 'settings/redmine_banner', | ||
:default => { | ||
'enable' => 'false', | ||
'banner_description' => 'exp. Information about upcoming Service Interruption.', | ||
'type' => 'info' | ||
} | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# English strings go here | ||
banner: "Banner" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class BannerApplicationHooks < Redmine::Hook::ViewListener | ||
def view_layouts_base_html_head(context = {}) | ||
return '' unless Setting.plugin_redmine_banner['enable'] == "true" | ||
o = '' | ||
o << stylesheet_link_tag('banner', :plugin => 'redmine_banner') | ||
o << '<script type="text/javascript">' | ||
o << 'Event.observe(window, \'load\', window_onload);' | ||
o << ' function window_onload(evt){' | ||
o << " $( \'top-menu\' ).insert({after:\'" | ||
o << textilize_banner(Setting.plugin_redmine_banner['banner_description']) | ||
o << '\'});' | ||
o << '}' | ||
o << '</script>' | ||
|
||
return o | ||
end | ||
|
||
def view_layouts_base_body_bottom(context = {}) | ||
return '' unless Setting.plugin_redmine_banner['enable'] == "true" | ||
o = '' | ||
o << textilize_banner(Setting.plugin_redmine_banner['banner_description']) | ||
return o | ||
end | ||
|
||
private | ||
def escape_single_quote(data) | ||
return data.gsub("'","’") | ||
end | ||
|
||
def textilize_banner(data) | ||
o = '' | ||
o << '<div class="banner banner_' | ||
o << Setting.plugin_redmine_banner['type'] | ||
o << '">' | ||
o << escape_single_quote(textilizable(data)) | ||
o << '</div>' | ||
return o | ||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class BannerControllerTest < ActionController::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Load the normal Rails helper | ||
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper') | ||
|
||
# Ensure that we are using the temporary fixture path | ||
Engines::Testing.set_fixture_path |