https://github.com/alexwayfer/flame-menu
Menu for Flame application
https://github.com/alexwayfer/flame-menu
Last synced: over 1 year ago
JSON representation
Menu for Flame application
- Host: GitHub
- URL: https://github.com/alexwayfer/flame-menu
- Owner: AlexWayfer
- License: mit
- Created: 2020-10-03T20:57:58.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-08T09:25:02.000Z (about 2 years ago)
- Last Synced: 2024-04-08T10:41:13.372Z (about 2 years ago)
- Language: Ruby
- Size: 49.8 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Flame Menu
[](https://cirrus-ci.com/github/AlexWayfer/flame-menu)
[](https://codecov.io/gh/AlexWayfer/flame-menu)
[](https://codeclimate.com/github/AlexWayfer/flame-menu)
[](https://inch-ci.org/github/AlexWayfer/flame-menu)
[](LICENSE.txt)
[](https://rubygems.org/gems/flame-menu)
Navigation menu for Flame applications.
There are helper methods (like `@menu.current`),
but you have to write an HTML layout by yourself (as you want to).
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'flame-menu'
```
And then execute:
```shell
bundle install
```
Or install it yourself as:
```shell
gem install flame-menu
```
## Usage
```ruby
# controllers/site/_controller.rb
module MyApplication
module Site
class Controller < MyApplication::Controller
include Flame::Menu
## Automatic look-up for controllers like `Site::AboutController`
MENU_ITEMS = %i[
index
about
faq
].freeze
protected
## Must be defined, but can be simply `true` for public access
def available?(controller = self.class)
## Example:
# return false unless authenticated_account
# return true if controller::PERMISSION.nil?
#
# authenticated_account.split(',').include? controller::PERMISSION.to_s
end
end
end
end
```
```erb
<% if @menu %>
<%
@menu.current.ancestors.reverse.each do |parent|
items = parent.available
next if items.size < 2
%>
<% items.each do |item| %>
<%=
t.site.header.nav[parent.key][item.key]
%>
<% end %>
<% end %>
<% end %>
```
## Development
After checking out the repo, run `bundle install` to install dependencies.
Then, run `toys rspec` to run the tests.
To install this gem onto your local machine, run `toys gem install`.
To release a new version, run `toys gem release %version%`.
See how it works [here](https://github.com/AlexWayfer/gem_toys#release).
## Contributing
Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/flame-menu).
## License
The gem is available as open source under the terms of the
[MIT License](https://opensource.org/licenses/MIT).