foreman_custom_banner 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ /.bundle
2
+ /pkg
3
+ /Gemfile.lock
4
+ *.gem
5
+ *.sw*
data/CHANGES.md ADDED
@@ -0,0 +1,7 @@
1
+ # Version 0.0.1a
2
+
3
+ * Fixed a broken SCL macro in the RPM spec file.
4
+
5
+ # Version 0.0.1
6
+
7
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # foreman_custom_banner
2
+
3
+ A Foreman plugin which provides a configurable, custom banner for the Foreman UI.
4
+
5
+ The purpose of this plugin is to provide a simple way to distinguish multiple
6
+ installations of Foreman, e.g. a production vs. a development installation.
7
+
8
+ This looks something like:
9
+
10
+ ![foreman_custom_banner_preview](foreman_custom_banner.png)
11
+
12
+ Customize the banner by altering the plugin settings within Foreman and refreshing your browser.
13
+
14
+ ## Installation
15
+
16
+ * Build and install the rubygem.
17
+ * Add ``install/foreman_custom_banner.rb`` into Foreman's ``bundler.d`` directory.
18
+ E.g. in the packaged Foreman installation, ``/usr/share/foreman/bundler.d``.
19
+ * Restart the webserver hosting the Foreman application.
@@ -0,0 +1,15 @@
1
+ ApplicationController.class_eval do
2
+ helper_method :custom_banner_text, :custom_banner_enabled, :custom_banner_style
3
+
4
+ def custom_banner_text
5
+ Setting.custom_banner_text
6
+ end
7
+
8
+ def custom_banner_enabled
9
+ !!Setting.custom_banner_enabled
10
+ end
11
+
12
+ def custom_banner_style
13
+ Setting.custom_banner_style
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ class Setting::CustomBanner < ::Setting
2
+ def self.load_defaults
3
+ return unless ActiveRecord::Base.connection.table_exists?('settings')
4
+ return unless super
5
+
6
+ Setting.transaction do
7
+ [
8
+ self.set('custom_banner_text', N_('Text to set on the custom banner'),
9
+ 'Configure the custom banner in your Foreman settings!'),
10
+ self.set('custom_banner_enabled', N_('Whether to enable the custom banner'), true),
11
+ self.set('custom_banner_style', N_('CSS styling for the custom banner'),
12
+ 'text-align:center;background-color:green;color:white;font-weight:bold;'),
13
+ ].compact.each { |s| self.create! s.update(:category => "Setting::CustomBanner") }
14
+ end
15
+
16
+ true
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => 'home/_topbar',
2
+ :name => 'add_custom_banner',
3
+ :insert_before => 'div.navbar.navbar-default.navbar-outer',
4
+ :template => 'home/_foreman_custom_header')
@@ -0,0 +1,5 @@
1
+ <% if custom_banner_enabled -%>
2
+ <div style="<%= h(custom_banner_style) %>">
3
+ <%= h(custom_banner_text) %>
4
+ </div>
5
+ <% end -%>
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/foreman_custom_banner/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jon McKenzie"]
6
+ gem.email = ["jcmcken@gmail.com"]
7
+ gem.description = %q{Plugin for Foreman that adds a custom banner}
8
+ gem.summary = %q{Plugin for Foreman that adds a custom banner}
9
+ gem.homepage = "https://github.com/jcmcken/foreman_custom_banner"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "foreman_custom_banner"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = ForemanCustomBanner::VERSION
17
+
18
+ gem.add_runtime_dependency "deface"
19
+ end
Binary file
@@ -0,0 +1,85 @@
1
+ %global gem_name foreman_custom_banner
2
+ %global rubyabi 1.9.1
3
+
4
+ %{?scl:%scl_package rubygem-%{gem_name}}
5
+ %{?scl:%global pkg_name %{name}}
6
+
7
+ Summary: Plugin for Foreman that adds a custom banner
8
+ Name: %{?scl_prefix}rubygem-%{gem_name}
9
+ Version: 0.0.1
10
+ Release: 1%{?dist}
11
+ Group: Development/Languages
12
+ License: Apache License 2.0
13
+ URL: https://github.com/jcmcken/foreman_custom_banner
14
+ Source0: %{gem_name}-%{version}.gem
15
+ Requires: %{?scl_prefix}ruby(abi) = %{rubyabi}
16
+ Requires: %{?scl_prefix}ruby(rubygems)
17
+ Requires: %{?scl_prefix}rubygem(deface)
18
+ %{?scl:BuildRequires: scl-utils-build}
19
+ BuildRequires: %{?scl_prefix}ruby(abi) = %{rubyabi}
20
+ BuildRequires: %{?scl_prefix}ruby(rubygems)
21
+ BuildRequires: %{?scl_prefix}rubygems-devel
22
+ BuildArch: noarch
23
+ Provides: %{?scl_prefix}rubygem(%{gem_name}) = %{version}
24
+
25
+ %description
26
+ Plugin for Foreman that adds a custom banner.
27
+
28
+ %package doc
29
+ Summary: Documentation for %{name}
30
+ Group: Documentation
31
+ Requires: %{name} = %{version}-%{release}
32
+ BuildArch: noarch
33
+
34
+ %description doc
35
+ Documentation for %{name}
36
+
37
+
38
+ %prep
39
+ %setup -q -c -T
40
+ mkdir -p .%{gem_dir}
41
+
42
+ %{?scl:scl enable %{scl} "}
43
+ gem install --local --install-dir .%{gem_dir} \
44
+ --force %{SOURCE0}
45
+ %{?scl:"}
46
+
47
+ %build
48
+
49
+ %install
50
+ mkdir -p %{buildroot}%{gem_dir}
51
+ cp -pa .%{gem_dir}/* \
52
+ %{buildroot}%{gem_dir}/
53
+
54
+ find %{buildroot}%{gem_instdir} -type f | xargs chmod ugo+r
55
+
56
+ %if %{?scl:1}%{!?scl:0}
57
+ mkdir -p %{buildroot}%{_root_datadir}/foreman/bundler.d
58
+ ln -s %{gem_instdir}/install/foreman_custom_banner.rb \
59
+ %{buildroot}%{_root_datadir}/foreman/bundler.d
60
+ %endif
61
+
62
+ rm %{buildroot}/%{gem_instdir}/.gitignore
63
+
64
+ %files
65
+ %dir %{gem_instdir}
66
+ %{gem_instdir}/lib
67
+ %{gem_instdir}/install
68
+ %{gem_instdir}/app
69
+ %{gem_instdir}/Gemfile
70
+ %{gem_instdir}/foreman_custom_banner.png
71
+ %exclude %{gem_dir}/cache/%{gem_name}-%{version}.gem
72
+ %exclude %{gem_instdir}/%{gem_name}.gemspec
73
+ %{gem_dir}/specifications/%{gem_name}-%{version}.gemspec
74
+ %{_root_datadir}/foreman/bundler.d
75
+ %doc %{gem_instdir}/README.md
76
+ %doc %{gem_instdir}/CHANGES.md
77
+ %doc %{gem_instdir}/LICENSE
78
+
79
+ %files doc
80
+ %doc %{gem_dir}/doc/%{gem_name}-%{version}
81
+
82
+
83
+ %changelog
84
+ * Sat Oct 11 2014 Jon McKenzie - 0.0.1-1
85
+ - Initial release.
@@ -0,0 +1,2 @@
1
+ # To enable the plugin, copy this file into /usr/share/foreman/bundler.d
2
+ gem 'foreman_custom_banner'
@@ -0,0 +1,22 @@
1
+ module ForemanCustomBanner
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace ForemanCustomBanner
4
+
5
+ config.to_prepare do
6
+ Dir.glob(Rails.root + 'app/decorators/**/*_decorator*.rb').each do |c|
7
+ require_dependency(c)
8
+ end
9
+ end
10
+
11
+ initializer 'foreman_custom_banner.load_default_settings', :before => :load_config_initializers do |app|
12
+ require_dependency File.expand_path('../../../app/models/settings/custom_banner.rb', __FILE__) if \
13
+ (Setting.table_exists? rescue(false))
14
+ end
15
+
16
+ initializer 'foreman_custom_banner.register_plugin', :after => :finisher_hook do |app|
17
+ Foreman::Plugin.register :foreman_custom_banner do
18
+ requires_foreman '>= 1.5'
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module ForemanCustomBanner
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "deface"
2
+ require "foreman_custom_banner/version"
3
+ require "foreman_custom_banner/engine"
4
+
5
+ module ForemanCustomBanner
6
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foreman_custom_banner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jon McKenzie
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-10-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: deface
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Plugin for Foreman that adds a custom banner
31
+ email:
32
+ - jcmcken@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - CHANGES.md
39
+ - Gemfile
40
+ - LICENSE
41
+ - README.md
42
+ - app/decorators/controllers/application_controller_decorator.rb
43
+ - app/models/settings/custom_banner.rb
44
+ - app/overrides/add_banner.rb
45
+ - app/views/home/_foreman_custom_header.html.erb
46
+ - foreman_custom_banner.gemspec
47
+ - foreman_custom_banner.png
48
+ - foreman_custom_banner.spec
49
+ - install/foreman_custom_banner.rb
50
+ - lib/foreman_custom_banner.rb
51
+ - lib/foreman_custom_banner/engine.rb
52
+ - lib/foreman_custom_banner/version.rb
53
+ homepage: https://github.com/jcmcken/foreman_custom_banner
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.23
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Plugin for Foreman that adds a custom banner
77
+ test_files: []