Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Rename to foreman_abrt
Browse files Browse the repository at this point in the history
  • Loading branch information
mmilata committed Apr 8, 2014
1 parent d4f9f78 commit 1c6be0d
Show file tree
Hide file tree
Showing 23 changed files with 107 additions and 163 deletions.
43 changes: 12 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,23 @@
# ForemanPluginTemplate
# ForemanAbrt

This repo is an example plugin which you can use as a starting point for developing
your own Foreman plugins
*Introdction here*

## Getting Started
## Installation

First, clone this repo to a directory named for your new plugin
See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
for how to install Foreman plugins

git clone https://github.com/theforeman/foreman_plugin_template foreman_my_plugin
## Usage

Now use the provided script to rewrite all the files in the plugin
*Usage here*

cd foreman_my_plugin
./rename.rb foreman_my_plugin
## TODO

The script will also output the required Bundler line to add the plugin to Foreman.
Apply this change, and restart Foreman
*Todo list here*

Once working, update the README with appropriate information, and publish your plugin!
## Contributing

## Out of the box functionality

This example plugin comes with:

* A model and helper concern
* An inherited controller
* A route/view which displays the plugin name
* A plugin registration block adding permissions/roles/menu entry
* A functioning example rake task
* A functioning example test and factory

These examples show how to add to Foreman in various ways.

## Getting help

The Foreman developers IRC channel and mailing list are the best places to get help:

* Freenode: #theforeman-dev
* Google Groups: foreman-dev@googlegroups.com
Fork and send a Pull Request. Thanks!

## Copyright

Expand All @@ -55,3 +35,4 @@ GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

38 changes: 0 additions & 38 deletions README.plugin.md

This file was deleted.

2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'ForemanPluginTemplate'
rdoc.title = 'ForemanAbrt'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module ForemanPluginTemplate
module ForemanAbrt

# Example: Plugin's HostsController inherits from Foreman's HostsController
class HostsController < ::HostsController

# change layout if needed
# layout 'foreman_plugin_template/layouts/new_layout'
# layout 'foreman_abrt/layouts/new_layout'

def new_action
# automatically renders view/foreman_plugin_template/hosts/new_action
# automatically renders view/foreman_abrt/hosts/new_action
end

end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ForemanPluginTemplate
module ForemanAbrt
module HostsHelperExtensions
extend ActiveSupport::Concern

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ForemanPluginTemplate
module ForemanAbrt
module HostExtensions
extend ActiveSupport::Concern

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- insert_before 'div:contains("title_action")' -->
<%= title_actions "<h2>ForemanPluginTemplate</h2>" %>
<%= title_actions "<h2>ForemanAbrt</h2>" %>

<!-- vim: set ft=eruby : -->
1 change: 1 addition & 0 deletions app/views/foreman_abrt/hosts/new_action.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Welcome to <b>ForemanPluginTemplate</b>
Empty file.
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rails.application.routes.draw do

match 'new_action', :to => 'foreman_plugin_template/hosts#new_action'
match 'new_action', :to => 'foreman_abrt/hosts#new_action'

end
18 changes: 18 additions & 0 deletions foreman_abrt.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require File.expand_path('../lib/foreman_abrt/version', __FILE__)

Gem::Specification.new do |s|
s.name = "foreman_abrt"
s.version = ForemanAbrt::VERSION
s.date = Date.today.to_s
s.authors = ["Martin Milata"]
s.email = ["mmilata@redhat.com"]
s.homepage = "TODO"
s.summary = "TODO: Summary of ForemanAbrt."
s.description = "TODO: Description of ForemanAbrt."

s.files = Dir["{app,config,db,lib}/**/*"] + ["LICENSE", "Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]

s.add_dependency "deface"
#s.add_development_dependency "sqlite3"
end
18 changes: 0 additions & 18 deletions foreman_plugin_template.gemspec

This file was deleted.

4 changes: 4 additions & 0 deletions lib/foreman_abrt.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require "foreman_abrt/engine"

module ForemanAbrt
end
54 changes: 54 additions & 0 deletions lib/foreman_abrt/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
require 'deface'

module ForemanAbrt
class Engine < ::Rails::Engine

config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
config.autoload_paths += Dir["#{config.root}/app/overrides"]

# Add any db migrations
initializer "foreman_abrt.load_app_instance_data" do |app|
app.config.paths['db/migrate'] += ForemanAbrt::Engine.paths['db/migrate'].existent
end

initializer 'foreman_abrt.register_plugin', :after=> :finisher_hook do |app|
Foreman::Plugin.register :foreman_abrt do
requires_foreman '>= 1.4'

# Add permissions
security_block :foreman_abrt do
permission :view_foreman_abrt, {:'foreman_abrt/hosts' => [:new_action] }
end

# Add a new role called 'Discovery' if it doesn't exist
role "ForemanAbrt", [:view_foreman_abrt]

#add menu entry
menu :top_menu, :template,
:url_hash => {:controller => :'foreman_abrt/hosts', :action => :new_action },
:caption => 'ForemanAbrt',
:parent => :hosts_menu,
:after => :hosts
end
end

#Include concerns in this config.to_prepare block
config.to_prepare do
begin
Host::Managed.send(:include, ForemanAbrt::HostExtensions)
HostsHelper.send(:include, ForemanAbrt::HostsHelperExtensions)
rescue => e
puts "ForemanAbrt: skipping engine hook (#{e.to_s})"
end
end

rake_tasks do
Rake::Task['db:seed'].enhance do
ForemanAbrt::Engine.load_seed
end
end

end
end
3 changes: 3 additions & 0 deletions lib/foreman_abrt/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module ForemanAbrt
VERSION = "0.0.1"
end
4 changes: 0 additions & 4 deletions lib/foreman_plugin_template.rb

This file was deleted.

54 changes: 0 additions & 54 deletions lib/foreman_plugin_template/engine.rb

This file was deleted.

3 changes: 0 additions & 3 deletions lib/foreman_plugin_template/version.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tasks
namespace :foreman_plugin_template do
namespace :foreman_abrt do
namespace :example do
desc 'Example Task'
task :task => :environment do
Expand All @@ -10,8 +10,8 @@ end

# Tests
namespace :test do
desc "Test ForemanPluginTemplate"
Rake::TestTask.new(:foreman_plugin_template) do |t|
desc "Test ForemanAbrt"
Rake::TestTask.new(:foreman_abrt) do |t|
test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
t.libs << ["test",test_dir]
t.pattern = "#{test_dir}/**/*_test.rb"
Expand All @@ -20,12 +20,12 @@ namespace :test do
end

Rake::Task[:test].enhance do
Rake::Task['test:foreman_plugin_template'].invoke
Rake::Task['test:foreman_abrt'].invoke
end

load 'tasks/jenkins.rake'
if Rake::Task.task_defined?(:'jenkins:setup')
Rake::Task["jenkins:unit"].enhance do
Rake::Task['test:foreman_plugin_template'].invoke
Rake::Task['test:foreman_abrt'].invoke
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FactoryGirl.define do
factory :host do
name 'foreman_plugin_template'
name 'foreman_abrt'
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'test_plugin_helper'

class ForemanPluginTemplateTest < ActiveSupport::TestCase
class ForemanAbrtTest < ActiveSupport::TestCase
setup do
User.current = User.find_by_login "admin"
end
Expand Down

0 comments on commit 1c6be0d

Please sign in to comment.