jejacks0n / navigasmic Goto Github PK
View Code? Open in Web Editor NEWNavigasmic: Semantic navigation for Rails using simple view level or configuration definitions.
Navigasmic: Semantic navigation for Rails using simple view level or configuration definitions.
I need to make my web application accessible, so I have to tell screenreader users what the current menu item is by adding a aria-label="current"
to the active link.
How can this be done?
It should be possible to pass a :link argument to group:
=n.group "My group". :link => root_path do
=n.item ....
=n.item ....
I think options
should be link_options
here.
Hi. I'm trying to set an 'n.group' to be highlighted, but it doesn't work. Rails instead generates an HTML tag like 'highlighted_on="controller_name"'. How can I make a group receive the "active" class when I'm viewing one of his sons? Thank you for your time!
From README.md:
Navigasmic::Builder::CrumbBuilder (incomplete)
Is it still incomplete or is the readme outdated?
We should do something about it either way: complete the code or fix the readme.
ie this should also work:
:highlights_on => proc { Time.now.wday == 2 || !logged_in? }
Did not see an option for this, but how would you go about displaying something like current_user.email
for an item name.
n.group n.proc { current_user.email } do
was something we tried, but that doesn't appear to work.
module UsersHelper
def user_menu(user)
semantic_navigation class: "dropdown-menu" do |n|
n.item "edit", [:edit, user]
end
end
end
Calling =user_menu(@user)
(haml) does not output anything. Putting the semantic_navigation
call directly inside the template works as expected.
I think there is an error in the README, under Usage / Defining Navigation in Initializer:
config.semantic_navigation :primary do |n|
n.group 'Blog', class: 'blog' do
'<li>Custom Node</li>'.html_safe # <----------- THIS LINE
n.item 'Articles', controller: '/blog/posts'
n.item 'Links', controller: '/blog/links'
end
end
How is the line marked above supposed to work? It looks to me that it just creates a string that gets discarded right away. It tried the code and indeed, "Custom Node" did not appear in the output. (It did work the the HAML version below it)
Did I miss something or is it a bug in the README? If it is a bug, how would one achieve the same effect?
It would be even more awesome if the names of groups and items could be translated through Rails' I18n framework.
It should be able to use =semantic_navigation (insteaf of -semantic_navigation) in haml views as it's with form_for etc.
Hello!
We would like to update our app to Ruby 3.2, but run into the issue reported in #57.
I'm happy to submit a fix, but would need a proper CI setup to check that I break nothing in older Ruby versions. Travis tells that the project no longer exists on their platform, or at least, it is not public.
Would it be an option to move to GitHub Actions for you? would make it easier for future contributors to run the tests on their fork. also, it's free for public projects.
Hi,
I can't set the link_options.
I would like to set a logout link:
n.item 'Sign out', 'destroy_user_session_path', method: 'delete', hidden_unless: proc{ user_signed_in? }
but the link_optins in the builder.link_generator are empty.
Because the item is not always text-only, it would be nice to add support for the following syntax:
<% semantic_navigation :app_nav, html: { class: 'nav' } do |n| %>
<%= n.item link: blah_path do %>
<i class="icon-th"></i> Blah
<% end %>
<%= n.item link: page_path('help') do %>
<i class="icon-question-sign"></i> Help & Support
<% end %>
<% end %>
I have a monkeypatch that I used with 0.5.6 here https://gist.github.com/clyfe/4714797
Both Navigasmic and the html5-boilerplate gems declare a method named add_class and, depending on the load order in Rails' Gemfile, one clobbers the other. Given the popularity of the html5-boilerplate gem, please consider renaming Navigasmic's method.
I set "highlights_on: false" to the item, but LI-tag still have class 'active' when I'm on that page.
Hello
I loved Navigasmic, but as it doesn't seem to be alive anymore, I removed it from my projects. I especially miss a feature like this: #47
All the best.
For the life of me I cannot get the groupings to work. I even pasted your example directly in:
<% semantic_navigation :utility_nav do |n| %>
<%= n.group 'Media' do %>
<%= n.item 'Image Gallery', :link => '/media/images', :highlights_on => '/media/videos' %>
<%= n.item 'Videos', :link => '/media/videos', :disabled_if => proc { true } %>
<%= n.item 'Contact Us' # auto links to the contact_us_path if it exists %>
<% end %>
<% end %>
and I get the following error:
line ##: syntax error, unexpected ')'
....concat(( n.group 'Media' do ).to_s); @output_buffer.concat ...
line ##: syntax error, unexpected kEND, expecting ')'
; end ; @output_buffer.concat "\n\t\t\t\t\t\t "
line ##: syntax error, unexpected kEND, expecting ')'
; end ; @output_buffer.concat "\n\t...
I'm running 2.3.10.
Let me know what I'm missing
-- Nick
Can I create a group inside a grup ? (aka submenu)
Im using the following code to generate a link to Admin::BlogsController#new
<%= n.item t('navigation.admin.blog.new'), :link_to => '/admin/blogs/new', :hidden_unless => proc { current_user.try(:admin?) } %>
I have also tried the following:
<%= n.item t('navigation.admin.blog.new'), :link_to => { :controller => '/admin/blogs', :action => 'new' }, :hidden_unless => proc { current_user.try(:admin?) } %>
Both result in the link following html output:
Am i doing something wrong?
To highlight a link, you've got to do somehting like:
= navigation.item "Section", :highlights => [{:controller => :section}]
However, the documentations says the option is named "highlights_on", which I guess it was correct at some time.
Thanks.
I worked with simple_navigation already, and now I stumbled over navigasmic. So what do you think differentiates the two gems? You could mention the differences in the README, too.
Thank you!
Hi,
for first, Navigasmatic is really great! :)
For second, when i use controller parameter in navigation item brokes router for nested resources.
One example for thousands words:
= semantic_navigation :user, config: :bootstrap, class: 'pull-right' do |n|
- n.item 'title', controller: 'categories'
- n.item 'user profile', edit_user_registration_path
It generates link path correctly but when is clicked on user profile it gives:
No route matches {:controller=>"devise/categories"}
Right route is devise/registrations
When is used categories_path
it works.
I'm using this for Rails apps, and it's really useful. But would it work with Middleman apps, too?
As mentioned in #35.
Version bumps should be made in their own commits. I'm not sure what the problem is with pushing official releases, but I've never been able to use the RubyGems version of navigasmic, and always had to use the github source. It seems like new versions are still just pushing up older releases with the new version name.
- navigation.group flag(current_locale_flag), id: :language_chooser, title: t('.choose_language') do ... end
This adds the title
to the li
tag, but I'd like to add it to the a
tag. Is this possible?
The reason is that ids should be unique. Having <li id="videos"></li>
means you can't (validly) have <div id="videos"></div>
on the page.
The following nav structure would also result in duplicates:
I notice that nobody seems to care about this gem anymore. What a pity.
Anyways, another question: I'd like to use :highlights_on
on groups: for example when displaying a user, the users
group should be active, although there is no explicit show user
item in it.
To compare, the "list users" has a menu entry, so the parent group is highlighted:
But for "show user", there's no entry, so the parent group isn't highlighted:
I know that I can manually assign a class: 'active'
myself, but this should be possible in an easier way.
I am trying to set up a managed navigation menu. I have Menu and Page models that determine what links should be shown in the menu.
class Menu < ActiveRecord::Base
attr_accessible :name, :slug
has_many :pages
end
class Page < ActiveRecord::Base
belongs_to :menu
attr_accessible :link, :order, :title, :menu_id
end
I am looping through the pages and having navigasmic render them.
<div id="navigation">
<%= semantic_navigation :primary do |n| %>
<% Menu.find_by_slug(:primary).pages.each do |page| %>
<%= n.item page.title, page.link %>
<% end %>
<% end %>
</div>
I only have 2 pages in the DB at the moment.
irb(main):002:0> Menu.find_by_slug(:primary).pages
Menu Load (1.0ms) SELECT "menus".* FROM "menus" WHERE "menus"."slug" = 'primary' LIMIT 1
Page Load (0.0ms) SELECT "pages".* FROM "pages" WHERE "pages"."menu_id" = 1
=> [#<Page id: 2, title: "Blog", link: "/posts", order: 1, menu_id: 1, created_at: "2013-01-26 16:10:51", updated_at: "2013-01-26 16:23:56">, #<Page id: 1, title: "New Book", link: "/books/new", order:0, menu_id: 1, created_at: "2013-01-26 16:06:43", updated_at: "2013-01-26 16:24:07">]
But, when I view the navigation container, it renders the first page 4 times and the second one twice.
<ul class="semantic-navigation" id="primary">
<li><a href="/posts"><span>Blog</span></a></li>
<li><a href="/posts"><span>Blog</span></a></li>
<li><a href="/books/new"><span>New Book</span></a></li>
<li><a href="/posts"><span>Blog</span></a></li>
<li><a href="/posts"><span>Blog</span></a></li>
<li><a href="/books/new"><span>New Book</span></a></li>
</ul>
I have no idea how it is behaving so oddly. Am I doing something wrong?
Hey, nice gem! Can you add support for a link that needs highlighting on multiple routes?
Gavin
This library currently doesn't support bootstrap 4.0. Can you please add in support for it?
In v1.1.0, the file .../gems/navigasmic-1.1.0/lib/navigasmic/rails/engine.rb is getting an error with the reference to a (ruby 3.2.x) removed method, exists?, it should be exist?
gems/navigasmic-1.1.0/lib/navigasmic/rails/engine.rb:10:in
block in <class:Engine>': undefined method
exists?' for File:Class (NoMethodError)
I want to add a custom accesskey="0"
attribute to one of my menu items, but I don't seem to be able to find out how to do this. I played around with link_options
without success, though this really looks like it has to be the right place to do this, but it places a link_options="{:accesskey=>0}"
on the li
element, not on the a
.
Any help is highly appreciated.
Is this possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.