adamcooke / actionnav Goto Github PK
View Code? Open in Web Editor NEW๐บ A navigation manager for Rails apps
License: MIT License
๐บ A navigation manager for Rails apps
License: MIT License
Although I am likely to be against any "dump whatever you need here"-attributes, an Item#extra
or Item#meta
attribute would be really helpful, to cover e.g. additional style hints (we mix presentation and logic here, but icon
does that already) or indication which http method to use on a specific link.
How would you like the API to look like? Want to specify it via some tests/specs in a branch and I give it a go?
As far as I understand, title
, url
, etc. accept a Proc to be evaluated at runtime. I however miss some information on how to add items themselves to the nav that are unknown prior to runtime and class definition.
Think of navigation entries that are linked to database entries, e.g. I want to define this in my FacilityNavigation
(the example is made up):
class FacilityNavigation < ActionNav::Base
# ...
item :rooms do
title "Rooms"
Room.each do |room|
item room.name.to_sym do
title room.name
url { Rails.application.routes.url_helpers.room_path(room)
end
end
# ...
end
This will only populate with items that were present on the time of the class evaluation (which in my understanding - depending on the underlying server - most likely happened on server start).
I didnt surf the code yet, but probably something along a dynamic_items { ... }
could be implemented, where the whole given block is only evaluated at access time.
Or do I just miss something?
Items could be marked "auto-active" if their url
matches the current PATH_INFO
(ideally even more clever). This way, if you have simple routes, you dont need to care about setting the current item active.
Quickest hack to achieve that for every item is to overwrite ItemInstance#active?
:
def active?
@base.active_path?(*self.path) || self.url == @base.controller.instance_eval { request.env['PATH_INFO'] } # or Rails `current_url?()`
end
Not a nice solution, but works. I'd be happy to hear your oppinion and to see the API you'd dream to have ( Item#active_if? { current_path.in? [] }
?).
The README should be fixed to include name change (at the very least the "Installation" section :) ).
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.