GithubHelp home page GithubHelp logo

jejacks0n / navigasmic Goto Github PK

View Code? Open in Web Editor NEW
322.0 322.0 29.0 205 KB

Navigasmic: Semantic navigation for Rails using simple view level or configuration definitions.

Ruby 90.64% HTML 9.36%
navigation navigation-structure rails

navigasmic's People

Contributors

andyundso avatar gdott9 avatar gucki avatar hansondr avatar jejacks0n avatar jondoveston avatar jsmestad avatar kevinold avatar kevmoo avatar mikepack avatar pengwynn avatar sborsje avatar shekibobo avatar subosito avatar vincecima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

navigasmic's Issues

group does not take a :link

It should be possible to pass a :link argument to group:

=n.group "My group". :link => root_path do
  =n.item ....
  =n.item ....

:highlights_on in a group

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!

Breadcrumbs

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.

Dynamic item name, is that supported?

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.

Error in Ruby example in the README

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?

I18n support

It would be even more awesome if the names of groups and items could be translated through Rails' I18n framework.

Move to GitHub Actions

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.

image

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.

link_options doesn't work

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.

Support item block definition

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

Is this project still alive?

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.

Groupings

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

Namespaces and Links

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:

  • New Blog
  • Am i doing something wrong?

    Update documentation of :highlights

    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.

    Controller parameter in item brokes nested resources

    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.

    Version releases to Rubygems aren't working right.

    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.

    Add a title to the link tag of a group?

    - 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?

    List items should use classes not ids

    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:

    • People
      • Info
    • Products
      • Info

    :highlights_on for group?

    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:

    image

    image

    But for "show user", there's no entry, so the parent group isn't highlighted:

    image

    image

    I know that I can manually assign a class: 'active' myself, but this should be possible in an easier way.

    Items are being duplicated on render

    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?

    Add custom attribute to link

    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.

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.