theforeman/foreman — pull request #987 by abenari (2013-10-28 15:40:10+00:00)
Title: Topbar5

Plugin interface for registering a plugin
including
name, url, description, author, author url,
adding permission
adding roles
manipulating menu items.

example plugin can look like this one:
```ruby
Foreman::Plugin.register :discovery do
name 'Discovery plugin'
author 'Greg Sutcliffe'
description 'MaaS Discovery Plugin engine for Foreman'
version VERSION
requires_foreman '1.3'

# Add permissions
security_block :discovery do
permission :perform_discovery, {:discovers =>
[:index, :show, :update, :new, :edit, :destroy,
:create, :auto_complete_search,
:update_multiple_organization,
:select_multiple_location,
:refresh_facts,
:update_multiple_location,
:submit_multiple_destroy,
:multiple_destroy]}
end

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

#add menu entry
menu :top_menu, :discovery, :url_hash => {:controller=> :discovers, :action=>:index},
:caption=> 'Discovered Hosts',
:parent => :hosts_menu,
:after=>:hosts
end
```