foreman_simplify 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ /.bundle
2
+ /pkg
3
+ /Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in foreman_simplify.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2013 Red Hat, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,17 @@
1
+ ## Installation
2
+
3
+ Do these steps on the node where you have installed Foreman:
4
+
5
+ 1. `yum install rubygem-nokogiri`
6
+
7
+ 1. `gem install deface -v 0.7.2 --ignore-dependencies`
8
+
9
+ 1. `git clone git://github.com/theforeman/foreman_simplify.git /usr/local/foreman_simplify`
10
+
11
+ 1. Put this into `/usr/share/foreman/bundler.d/foreman_simplify.rb`:
12
+
13
+ ```
14
+ gem 'deface', '0.7.2'
15
+ gem 'foreman_simplify', :path => '/usr/local/foreman_simplify'
16
+ ```
17
+ 1. Run `bundle` as user `foreman` in the `/usr/share/foreman` directory.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ Deface::Override.new(:virtual_path => 'home/_topbar',
2
+ :name => 'disable_audits',
3
+ :remove => %q{code[erb-loud]:contains("menu 'audits'")})
4
+
5
+ Deface::Override.new(:virtual_path => 'hosts/_overview',
6
+ :name => 'disable_host_audits_button',
7
+ :remove => %q{code[erb-loud]:contains('hash_for_host_audits_path')})
@@ -0,0 +1,20 @@
1
+ Deface::Override.new(:virtual_path => 'home/_settings',
2
+ :name => 'disable_compute_resources',
3
+ :replace => "code[erb-silent]:contains('choices = setting_options')") do
4
+ <<-END
5
+ <%
6
+ previous_item_is_divider = false
7
+ choices = setting_options.map do |item|
8
+ if item[0] == :group && item[1] == "Provisioning"
9
+ item.dup.tap { |i| i[2] = i[2].reject { |subitem| subitem[1] == :compute_resources } }
10
+ else
11
+ item
12
+ end
13
+ end.reject do |item| # remove double dividers
14
+ result = previous_item_is_divider && item[0] == :divider
15
+ previous_item_is_divider = item[0] == :divider
16
+ result
17
+ end
18
+ %>
19
+ END
20
+ end
@@ -0,0 +1,3 @@
1
+ Deface::Override.new(:virtual_path => 'home/_topbar',
2
+ :name => 'disable_statistics',
3
+ :remove => %q{code[erb-loud]:contains("menu 'statistics'")})
@@ -0,0 +1,3 @@
1
+ Deface::Override.new(:virtual_path => 'home/_topbar',
2
+ :name => 'disable_trends',
3
+ :remove => %q{code[erb-loud]:contains("menu 'trends'")})
@@ -0,0 +1,6 @@
1
+ ForemanSimplify::ControllerPatches.tap do |cp|
2
+ cp.not_implemented(AuditsController, [:index, :show])
3
+
4
+ cp.not_implemented(Api::V1::AuditsController, [:index, :show], :json)
5
+ Api::V1::AuditsController.skip_filter :find_resource
6
+ end
@@ -0,0 +1,7 @@
1
+ ForemanSimplify::ControllerPatches.tap do |cp|
2
+ cp.not_implemented_ui_crud(ComputeResourcesController)
3
+ ComputeResourcesController.skip_filter :find_by_id
4
+
5
+ cp.not_implemented_api_crud(Api::V1::ComputeResourcesController)
6
+ cp.not_implemented_api_crud(Api::V2::ComputeResourcesController)
7
+ end
@@ -0,0 +1,5 @@
1
+ ForemanSimplify::ControllerPatches.tap do |cp|
2
+ cp.not_implemented(ComputeResourcesVmsController,
3
+ [:index, :new, :create, :show, :power, :destroy, :console])
4
+ ComputeResourcesVmsController.skip_filter :find_compute_resource, :find_vm
5
+ end
@@ -0,0 +1,7 @@
1
+ ForemanSimplify::ControllerPatches.tap do |cp|
2
+ cp.not_implemented_ui_crud(ImagesController)
3
+ ImagesController.skip_filter :find_compute_resource, :find_by_name
4
+
5
+ cp.not_implemented_api_crud(Api::V1::ImagesController)
6
+ Api::V1::ImagesController.skip_filter :find_compute_resource
7
+ end
@@ -0,0 +1,3 @@
1
+ ForemanSimplify::ControllerPatches.tap do |cp|
2
+ cp.not_implemented(StatisticsController, [:index])
3
+ end
@@ -0,0 +1,4 @@
1
+ ForemanSimplify::ControllerPatches.tap do |cp|
2
+ cp.not_implemented_ui_crud(TrendsController)
3
+ TrendsController.skip_filter :find_trend
4
+ end
@@ -0,0 +1,9 @@
1
+ # Runs before each request in development (controllers reload each request),
2
+ # before first request in production (controllers don't reload).
3
+ # http://apidock.com/rails/ActionDispatch/Callbacks/to_prepare/class
4
+ ActionDispatch::Callbacks.to_prepare do
5
+ patch_dir = File.expand_path("#{File.dirname(__FILE__)}/../../app/patches")
6
+ Dir["#{patch_dir}/**/*.rb"].each do |file_name|
7
+ load file_name
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/foreman_simplify/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jiri Stransky"]
6
+ gem.email = ["jistr@redhat.com"]
7
+ gem.description = %q{Plugin for Foreman that simplifies the UI}
8
+ gem.summary = %q{Plugin for Foreman that simplifies the UI}
9
+ gem.homepage = "https://github.com/theforeman/foreman_simplify"
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_simplify"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = ForemanSimplify::VERSION
17
+
18
+ gem.add_runtime_dependency "deface"
19
+ end
@@ -0,0 +1,2 @@
1
+ # To enable the plugin, copy this file into /usr/share/foreman/bundler.d
2
+ gem 'foreman_simplify'
@@ -0,0 +1,7 @@
1
+ require "deface"
2
+ require "foreman_simplify/version"
3
+ require "foreman_simplify/engine"
4
+ require "foreman_simplify/controller_patches"
5
+
6
+ module ForemanSimplify
7
+ end
@@ -0,0 +1,35 @@
1
+ module ForemanSimplify::ControllerPatches
2
+ class << self
3
+
4
+ def not_implemented(controller_class, method_names, type = :text)
5
+ controller_class.class_eval do
6
+ method_names.each do |method_name|
7
+ case type
8
+ when :text
9
+ define_method(method_name) do
10
+ render :text => "Not Implemented", :status => :not_implemented
11
+ end
12
+ when :json
13
+ define_method(method_name) do
14
+ render :json => '{"error":{"message":"Not Implemented"}}', :status => :not_implemented
15
+ end
16
+ else
17
+ raise ArgumentError, "Wrong response type '#{type.to_s}'"
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ def not_implemented_ui_crud(controller_class)
24
+ not_implemented(controller_class,
25
+ [:index, :show, :new, :create, :edit, :update, :destroy])
26
+ end
27
+
28
+ def not_implemented_api_crud(controller_class, skip_find_resource = true)
29
+ not_implemented(controller_class,
30
+ [:index, :show, :create, :update, :destroy], :json)
31
+ controller_class.skip_filter :find_resource if skip_find_resource
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,4 @@
1
+ module ForemanSimplify
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,5 @@
1
+ module ForemanSimplify
2
+ unless defined? ::ForemanSimplify::VERSION
3
+ VERSION = "0.0.5"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foreman_simplify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jiri Stransky
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-29 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 simplifies the UI
31
+ email:
32
+ - jistr@redhat.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - app/overrides/disable_audits.rb
43
+ - app/overrides/disable_compute_resources.rb
44
+ - app/overrides/disable_statistics.rb
45
+ - app/overrides/disable_trends.rb
46
+ - app/patches/audits_controller_patch.rb
47
+ - app/patches/compute_resources_controller_patch.rb
48
+ - app/patches/compute_resources_vms_controller_patch.rb
49
+ - app/patches/images_controller_patch.rb
50
+ - app/patches/statistics_controller_patch.rb
51
+ - app/patches/trends_controller_patch.rb
52
+ - config/initializers/patches.rb
53
+ - foreman_simplify.gemspec
54
+ - install/foreman_simplify.rb
55
+ - lib/foreman_simplify.rb
56
+ - lib/foreman_simplify/controller_patches.rb
57
+ - lib/foreman_simplify/engine.rb
58
+ - lib/foreman_simplify/version.rb
59
+ homepage: https://github.com/theforeman/foreman_simplify
60
+ licenses: []
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ segments:
72
+ - 0
73
+ hash: -4533729617643303341
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ segments:
81
+ - 0
82
+ hash: -4533729617643303341
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.23
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Plugin for Foreman that simplifies the UI
89
+ test_files: []