active_path 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/README.md +86 -0
- data/Rakefile +15 -0
- data/active_path.gemspec +16 -0
- data/lib/active_path.rb +12 -0
- data/lib/active_path/configuration.rb +19 -0
- data/lib/active_path/configuration/partial.rb +16 -0
- data/lib/active_path/configuration/partials.rb +26 -0
- data/lib/active_path/engine.rb +16 -0
- data/lib/active_path/helpers/rendering_helper.rb +19 -0
- data/lib/active_path/path_hints.rb +7 -0
- data/lib/active_path/renderer/partial_renderer.rb +37 -0
- data/lib/active_path/version.rb +3 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c266106395a8b3ddf51e549973c80c6ec6dc7579
|
4
|
+
data.tar.gz: 2e87efdefac0cbaf5ea7beeff94d6c72e0288fab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4404aac557635185c5137d150998b1109d157f1483fef74e607c407a66c8d35c113e6d12a7c0d975d1d886e764df1424309b3798d8f7abeccdacb8b4649df5f
|
7
|
+
data.tar.gz: 66bd5809c1fad03f9ac28ab528b6018bc4b7d908e33b74746d3c3535a8647e6195d79accd5ebf6eaf45f7d55c957cfb4689962747fea7a561a8d98e62509723b
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# ActivePath:
|
2
|
+
View injection and path hints for Rails 5.
|
3
|
+
|
4
|
+
|
5
|
+
##Installation
|
6
|
+
|
7
|
+
Add to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'active_path'
|
11
|
+
```
|
12
|
+
|
13
|
+
Add the initializer `config/initializers/active_path.rb` and enable `ActivePath`:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
|
17
|
+
ActivePath.configure do |config|
|
18
|
+
|
19
|
+
config.enabled = true
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
|
26
|
+
##Configuration
|
27
|
+
|
28
|
+
**Basic view injection.**
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
|
32
|
+
ActivePath.configure do |config|
|
33
|
+
|
34
|
+
...
|
35
|
+
|
36
|
+
config.partials.prepend('page_content').with('example/test')
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
```
|
41
|
+
|
42
|
+
The above example assumes your application renders a partial called 'page_content' and you want to `prepend` a partial called 'example/test'.
|
43
|
+
|
44
|
+
Your partial will have the same local parameters access as the prepended partial.
|
45
|
+
|
46
|
+
--
|
47
|
+
|
48
|
+
**More ways to inject content into views**
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
|
52
|
+
ActivePath.configure do |config|
|
53
|
+
|
54
|
+
...
|
55
|
+
|
56
|
+
config.partials.prepend('page_content').with(
|
57
|
+
partial: 'example/test',
|
58
|
+
helper: ExampleHelper
|
59
|
+
)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
The above example is similar to the first but also adds your helper to the view.
|
66
|
+
|
67
|
+
--
|
68
|
+
|
69
|
+
**Path hints:** (use in development only)
|
70
|
+
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
|
74
|
+
ActivePath.configure do |config|
|
75
|
+
|
76
|
+
...
|
77
|
+
|
78
|
+
config.path_hints = true
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
```
|
83
|
+
|
84
|
+
All partials will be wrapped in a border, red for uncached, green for cached.
|
85
|
+
|
86
|
+
Feel free to [submit issues](https://github.com/ryaan-anthony/active-path/issues) or [help make it better](https://github.com/ryaan-anthony/active-path/pulls).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
4
|
+
require 'active_path/version'
|
5
|
+
|
6
|
+
desc "Release version #{ActivePath::VERSION} of the gem"
|
7
|
+
task :release do
|
8
|
+
|
9
|
+
system "git tag -a v#{ActivePath::VERSION} -m 'Tagging #{ActivePath::VERSION}'"
|
10
|
+
system 'git push --tags'
|
11
|
+
|
12
|
+
system "gem build active_path.gemspec"
|
13
|
+
system "gem push active_path-#{ActivePath::VERSION}.gem"
|
14
|
+
system "rm active_path-#{ActivePath::VERSION}.gem"
|
15
|
+
end
|
data/active_path.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'active_path/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'active_path'
|
6
|
+
s.version = ActivePath::VERSION
|
7
|
+
s.date = '2018-04-28'
|
8
|
+
s.summary = "ActivePath"
|
9
|
+
s.description = "Path hints and layout injection"
|
10
|
+
s.authors = ["Ryan Tulino"]
|
11
|
+
s.email = 'rtulino@gmail.com'
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.homepage = 'http://rubygems.org/gems/active_path'
|
14
|
+
s.required_ruby_version = '>= 2.2.0'
|
15
|
+
s.add_dependency 'rails', '~> 5'
|
16
|
+
end
|
data/lib/active_path.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'active_path/configuration/partials'
|
2
|
+
module ActivePath
|
3
|
+
module Configuration
|
4
|
+
class << self
|
5
|
+
def setup_defaults
|
6
|
+
configuration.active_path = ActiveSupport::Configurable::Configuration.new
|
7
|
+
configuration.active_path.partials = Partials.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def config
|
11
|
+
configuration.active_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def configuration
|
15
|
+
Rails.configuration
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'active_path/configuration/partial'
|
2
|
+
module ActivePath
|
3
|
+
module Configuration
|
4
|
+
class Partials
|
5
|
+
attr_reader :partials
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@partials = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepend(key)
|
12
|
+
partial(key, true)
|
13
|
+
end
|
14
|
+
|
15
|
+
def append(key)
|
16
|
+
partial(key, false)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def partial(key, prepend = true)
|
22
|
+
@partials["#{key}/#{prepend}"] ||= Partial.new(key)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'active_path/helpers/rendering_helper'
|
2
|
+
module ActivePath
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
isolate_namespace ActivePath
|
5
|
+
|
6
|
+
config.before_configuration do
|
7
|
+
Configuration.setup_defaults
|
8
|
+
|
9
|
+
# Include the render helper in the controller
|
10
|
+
ActiveSupport.on_load(:action_controller_base) do
|
11
|
+
next unless ActivePath.config.enabled
|
12
|
+
_helpers.module_eval { include ActivePath::Helpers::RenderingHelper }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'active_path/renderer/partial_renderer'
|
2
|
+
module ActivePath
|
3
|
+
module Helpers
|
4
|
+
module RenderingHelper
|
5
|
+
extend ActionView::Helpers::RenderingHelper
|
6
|
+
def render(options = {}, locals = {}, &block)
|
7
|
+
active_path_renderer(options, locals).render do
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def active_path_renderer(options, locals)
|
15
|
+
Renderer::PartialRenderer.new(options, locals)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ActivePath
|
2
|
+
module Renderer
|
3
|
+
class PartialRenderer
|
4
|
+
attr_reader :options, :locals
|
5
|
+
|
6
|
+
def initialize(options, locals)
|
7
|
+
@options = options
|
8
|
+
@locals = locals
|
9
|
+
end
|
10
|
+
|
11
|
+
def render
|
12
|
+
buffer = yield
|
13
|
+
before.each { |output| buffer.prepend(output) }
|
14
|
+
after.each { |output| buffer.concat(output) }
|
15
|
+
buffer
|
16
|
+
end
|
17
|
+
|
18
|
+
def before
|
19
|
+
partials.prepend(partial).attachments
|
20
|
+
end
|
21
|
+
|
22
|
+
def after
|
23
|
+
partials.append(partial).attachments
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def partials
|
29
|
+
ActivePath.config.partials
|
30
|
+
end
|
31
|
+
|
32
|
+
def partial
|
33
|
+
options.is_a?(Hash) ? options[:partial] : options.to_s
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_path
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Tulino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-28 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: '5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5'
|
27
|
+
description: Path hints and layout injection
|
28
|
+
email: rtulino@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ".gitignore"
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- active_path.gemspec
|
37
|
+
- lib/active_path.rb
|
38
|
+
- lib/active_path/configuration.rb
|
39
|
+
- lib/active_path/configuration/partial.rb
|
40
|
+
- lib/active_path/configuration/partials.rb
|
41
|
+
- lib/active_path/engine.rb
|
42
|
+
- lib/active_path/helpers/rendering_helper.rb
|
43
|
+
- lib/active_path/path_hints.rb
|
44
|
+
- lib/active_path/renderer/partial_renderer.rb
|
45
|
+
- lib/active_path/version.rb
|
46
|
+
homepage: http://rubygems.org/gems/active_path
|
47
|
+
licenses: []
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 2.2.0
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 2.6.11
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: ActivePath
|
69
|
+
test_files: []
|