locomotive_plugins 1.0.1 → 1.1.0
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 +8 -8
- data/lib/locomotive/plugin.rb +24 -1
- data/lib/locomotive/plugin/js3.rb +15 -0
- data/lib/version.rb +1 -1
- data/spec/lib/locomotive/plugin_spec.rb +8 -0
- data/spec/support/plugins/my_plugin.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
MWY0YzE2YWNmMjMzMGQxOTZmNjQzMWY5MWI1ZDhiNzAxNWY5OTczZQ==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
YmE3OGQ3NjliNTVkN2JmYzU1OTc2MGNhZmUxM2UyNGM5NDIxZDljZg==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
NDdmNjhmZTljM2VkODExMDkzZTllNWFmNTZkZmM2YTQyNjkyYjg2ZTQxNGFl
|
|
10
|
+
NTFlZjE2MzJmZjc3NTk0ZjQ1ZDk4YzNhNTA0NDFiMWFmODU1NDZlMjJiZjk5
|
|
11
|
+
MDViNTgyNDE1ZjIzNjE2YjVmMWFkNjYyNGVmMjdmYzY2YTMwOWI=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
MWE3MzlmNTg5MWU4NDY5Mzk3ZjI5M2ZiYTg1OWIwY2QzZWU5NDU1OTk1ZWU4
|
|
14
|
+
ZDk2OWIyNTJhMWI3OGFjZjNhYTg2OWRkYjY4ZjgyYjEwYTUyZmY3OWZmYTMw
|
|
15
|
+
ZjYzZTIzMGVkMjAwOWY4OTIxY2YzODE1YWQzMGM1Y2U3ZTY4ZDU=
|
data/lib/locomotive/plugin.rb
CHANGED
|
@@ -15,6 +15,7 @@ module Locomotive
|
|
|
15
15
|
include LoadInitialization
|
|
16
16
|
include Liquid
|
|
17
17
|
include RackAppHelpers
|
|
18
|
+
include JS3
|
|
18
19
|
|
|
19
20
|
# @private
|
|
20
21
|
#
|
|
@@ -95,7 +96,29 @@ module Locomotive
|
|
|
95
96
|
nil
|
|
96
97
|
end
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
# Override this method to specify ruby objects accessable via the global
|
|
100
|
+
# javascript context. The return value must be a hash whoes keys are the
|
|
101
|
+
# variable names and the values are the objects. The objects will be
|
|
102
|
+
# included in the global context after being prefixed with the plugin_id.
|
|
103
|
+
#
|
|
104
|
+
# Note:
|
|
105
|
+
# therubyracer is not able to execute class methods so please ensure
|
|
106
|
+
# that the objects you pass in are not classes.
|
|
107
|
+
#
|
|
108
|
+
# @exaple
|
|
109
|
+
# class MyPlugin
|
|
110
|
+
# def self.javascript_context
|
|
111
|
+
# {
|
|
112
|
+
# :things => ::Locomotive::Plugins::Variable.new {Thing.all},
|
|
113
|
+
# :say => lambda{|this,word,times| word * times}
|
|
114
|
+
# }
|
|
115
|
+
# end
|
|
116
|
+
# end
|
|
117
|
+
def javascript_context
|
|
118
|
+
{}
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
end ## class
|
|
99
122
|
|
|
100
123
|
# This variable is set by LocomotiveCMS. It contains the controller which
|
|
101
124
|
# is handling the current request.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Locomotive
|
|
2
|
+
module Plugin
|
|
3
|
+
# This module add helpers for using js3 (JavaScript on the Server Side)
|
|
4
|
+
module JS3
|
|
5
|
+
|
|
6
|
+
# The js3 context
|
|
7
|
+
#
|
|
8
|
+
# @return a V8 context object
|
|
9
|
+
def js3_context
|
|
10
|
+
Locomotive::Plugins.js3_context
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/version.rb
CHANGED
|
@@ -42,5 +42,13 @@ module Locomotive
|
|
|
42
42
|
PluginWithRackApp.rack_app.should_not be_nil
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
it 'should optionally supply a js3 context' do
|
|
46
|
+
MyPlugin.javascript_context.keys.should == [:variable, :method]
|
|
47
|
+
UselessPlugin.javascript_context.should == {}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should be able to get a js3 context' do
|
|
51
|
+
@plugin.respond_to?(:js3_context).should be true
|
|
52
|
+
end
|
|
45
53
|
end
|
|
46
54
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: locomotive_plugins
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Colibri Software
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: locomotive_liquid
|
|
@@ -108,6 +108,7 @@ files:
|
|
|
108
108
|
- lib/locomotive/plugin/class_tracker.rb
|
|
109
109
|
- lib/locomotive/plugin/config_ui.rb
|
|
110
110
|
- lib/locomotive/plugin/exceptions.rb
|
|
111
|
+
- lib/locomotive/plugin/js3.rb
|
|
111
112
|
- lib/locomotive/plugin/liquid.rb
|
|
112
113
|
- lib/locomotive/plugin/liquid/context_helpers.rb
|
|
113
114
|
- lib/locomotive/plugin/liquid/drop_extension.rb
|