phcdevworks_active_menus 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +31 -0
- data/Rakefile +32 -0
- data/app/assets/config/phcdevworks_active_menus_manifest.js +3 -0
- data/app/assets/javascripts/phcdevworks_active_menus/application.js +0 -0
- data/app/assets/stylesheets/phcdevworks_active_menus/application.scss +0 -0
- data/app/controllers/phcdevworks_active_menus/application_controller.rb +5 -0
- data/app/helpers/phcdevworks_active_menus/application_helper.rb +20 -0
- data/app/jobs/phcdevworks_active_menus/application_job.rb +4 -0
- data/app/mailers/phcdevworks_active_menus/application_mailer.rb +6 -0
- data/app/models/phcdevworks_active_menus/application_record.rb +5 -0
- data/app/views/layouts/phcdevworks_active_menus/application.html.erb +18 -0
- data/lib/phcdevworks_active_menus.rb +5 -0
- data/lib/phcdevworks_active_menus/engine.rb +11 -0
- data/lib/phcdevworks_active_menus/version.rb +3 -0
- data/lib/tasks/phcdevworks_active_menus_tasks.rake +4 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 63f3b236375801e45029266d77490ac7af914fafcfd9b4059f1e814252f14ba2
|
4
|
+
data.tar.gz: 992c06187f7a2388b63f50fca8b30fa27ba971cf29278ee18d3298bf3965ec25
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fbc91395db1e180ed9e1653550f956edf944caaa58d11483f6f5acb73aaedf22c712cab8e2c8f5e21a85de3809b55c39b9c5b5281eaf553a2320158515618e60
|
7
|
+
data.tar.gz: 8bb277515e8de6972e57af118b826a39bb9040680cea637ec182c8c0a4b1dcb80ae09441d1aa5d526340dd2ddab30257c0caf81f828bdac25148aaafdc46cc95
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 - PHCDEVWORKS
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
### PHCDevworks Active Menus for Rails 6 (Add Active Class to Menus)
|
2
|
+
PHCDevworks Active Menus Rails 6 engine with helpers to add active class to menus.
|
3
|
+
|
4
|
+
* Add active class based on current controller.
|
5
|
+
* Add active class based on current action.
|
6
|
+
* Add active class based on both current controller plus current action.
|
7
|
+
|
8
|
+
#### Step 1 - Add PHCDevworks Active Menus to your gemfile
|
9
|
+
|
10
|
+
gem 'phcdevworks_active_menus'
|
11
|
+
bundle install
|
12
|
+
|
13
|
+
#### Step 2 - Load Helpers in the Application's Controller
|
14
|
+
Add the line of code below into your app/controllers/application_controller.rb (application's controller file).
|
15
|
+
|
16
|
+
helper PhcdevworksActiveMenus::Engine.helpers
|
17
|
+
|
18
|
+
#### How to Add Active Class Based on Controller Only (Often used for main menu items with sub-menus.)
|
19
|
+
Add the line of code in between <div class""> tag.
|
20
|
+
|
21
|
+
<%= phc_menu_active_controller("ExampleControllerName") %>
|
22
|
+
|
23
|
+
#### How to Add Active Class Based on Action Only (Often used for submenu items.)
|
24
|
+
Add the line of code in between <div class""> tag.
|
25
|
+
|
26
|
+
<%= phc_menu_active_action("ExampleActionName") %>
|
27
|
+
|
28
|
+
#### How to Add Active Class Based on Action Only (Used if you need to get specific.)
|
29
|
+
Add the line of code in between <div class""> tag.
|
30
|
+
|
31
|
+
<%= phc_menu_active_action_controller("ExampleControllerName", "ExampleActionName") %>
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'PhcdevworksActiveMenus'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/test_app/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PhcdevworksActiveMenus
|
2
|
+
module ApplicationHelper
|
3
|
+
|
4
|
+
# Add Active to Menu Based on Controller Name
|
5
|
+
def phc_menu_active_controller(controller_name)
|
6
|
+
params[:controller] == controller_name ? "active" : nil
|
7
|
+
end
|
8
|
+
|
9
|
+
# Add Active to Menu Based on Controller Name
|
10
|
+
def phc_menu_active_action(action_name)
|
11
|
+
params[:action] == action_name ? "active" : nil
|
12
|
+
end
|
13
|
+
|
14
|
+
# Add Active to Menu Based on Both Controller Name and Action
|
15
|
+
def phc_menu_active_action_controller(controller_name, action_name)
|
16
|
+
params[:controller] == controller_name && params[:action] == action_name ? "active" : nil
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
|
5
|
+
<title>PHCDevworks Active Menus</title>
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
<%= csp_meta_tag %>
|
8
|
+
|
9
|
+
<%= stylesheet_link_tag "phcdevworks_active_menus/application", media: "all" %>
|
10
|
+
<%= javascript_include_tag "phcdevworks_active_menus/application" %>
|
11
|
+
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
|
15
|
+
<%= yield %>
|
16
|
+
|
17
|
+
</body>
|
18
|
+
</html>
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phcdevworks_active_menus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- PHCDevworks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.0.rc1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.0.rc1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sassc-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Rails helpers to add active class to menu items based on controller and
|
56
|
+
controller action.
|
57
|
+
email:
|
58
|
+
- developers@phcdevworks.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- MIT-LICENSE
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- app/assets/config/phcdevworks_active_menus_manifest.js
|
67
|
+
- app/assets/javascripts/phcdevworks_active_menus/application.js
|
68
|
+
- app/assets/stylesheets/phcdevworks_active_menus/application.scss
|
69
|
+
- app/controllers/phcdevworks_active_menus/application_controller.rb
|
70
|
+
- app/helpers/phcdevworks_active_menus/application_helper.rb
|
71
|
+
- app/jobs/phcdevworks_active_menus/application_job.rb
|
72
|
+
- app/mailers/phcdevworks_active_menus/application_mailer.rb
|
73
|
+
- app/models/phcdevworks_active_menus/application_record.rb
|
74
|
+
- app/views/layouts/phcdevworks_active_menus/application.html.erb
|
75
|
+
- lib/phcdevworks_active_menus.rb
|
76
|
+
- lib/phcdevworks_active_menus/engine.rb
|
77
|
+
- lib/phcdevworks_active_menus/version.rb
|
78
|
+
- lib/tasks/phcdevworks_active_menus_tasks.rake
|
79
|
+
homepage: https://phcdevworks.com/
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubygems_version: 3.0.3
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: PHCDevworks - Helpers - Active Menus
|
102
|
+
test_files: []
|