easymarklet 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/easymarklet/consumer.js.erb +6 -2
- data/app/assets/javascripts/easymarklet/producer.js.erb +9 -6
- data/app/assets/javascripts/easymarklet/simple.js.erb +52 -0
- data/lib/easymarklet/version.rb +1 -1
- data/lib/generators/easymarklet/bare/USAGE +12 -0
- data/lib/generators/easymarklet/bare/bare_generator.rb +19 -0
- data/lib/generators/easymarklet/bare/templates/bare_bookmarklet.js +7 -0
- data/lib/generators/easymarklet/iframe/USAGE +15 -0
- data/lib/generators/easymarklet/iframe/iframe_generator.rb +27 -0
- data/lib/generators/easymarklet/iframe/templates/iframe_bookmarklet.js +23 -0
- data/lib/generators/easymarklet/iframe/templates/iframe_consumer.js +5 -0
- data/lib/generators/easymarklet/iframe/templates/iframe_producer.js +6 -0
- data/lib/generators/easymarklet/iframe/templates/iframe_producer_controller.rb +8 -0
- data/lib/generators/easymarklet/iframe/templates/iframe_producer_index.html.erb +3 -0
- data/lib/generators/easymarklet/iframe/templates/views/easymarklet_layout.html.erb +16 -0
- data/lib/generators/easymarklet/simple/simple_generator.rb +2 -1
- data/lib/generators/easymarklet/simple/templates/simple_bookmarklet.css +12 -0
- data/lib/generators/easymarklet/simple/templates/simple_bookmarklet.js +20 -2
- data/lib/generators/easymarklet/xdm/templates/xdm_bookmarklet.js +1 -1
- data/lib/generators/easymarklet/xdm/xdm_generator.rb +2 -2
- metadata +17 -4
@@ -8,6 +8,7 @@
|
|
8
8
|
if(bookmarklet.producer == null){ alert('Your bookmarklet definition is missing a producer.'); return; }
|
9
9
|
|
10
10
|
var _this = this;
|
11
|
+
_this.producer = null;
|
11
12
|
//console.log('Easymarklet.Consumer : init');
|
12
13
|
var bookmarklet = bookmarklet
|
13
14
|
var s1, s2, isLoaded = false, xhr, head = document.getElementsByTagName('head')[0];
|
@@ -42,10 +43,13 @@
|
|
42
43
|
var dest = full_host + bookmarklet.producer.path
|
43
44
|
|
44
45
|
// here we put the main code, in this case we expose an ajax endpoint
|
45
|
-
|
46
|
+
_this.producer = new easyXDM.Rpc({
|
46
47
|
remote: dest,
|
47
48
|
container: easymarkletDiv,
|
48
|
-
|
49
|
+
onReady: function(){
|
50
|
+
if(bookmarklet.consumer.init){
|
51
|
+
bookmarklet.consumer.init();
|
52
|
+
}
|
49
53
|
//xhr.post("example/glossary.php", {
|
50
54
|
// param1: "a",
|
51
55
|
// param2: "b"
|
@@ -9,7 +9,6 @@
|
|
9
9
|
|
10
10
|
var _this = this;
|
11
11
|
_this.consumer = null;
|
12
|
-
//console.log('Easymarklet.Producert : init');
|
13
12
|
|
14
13
|
this.init = function(){
|
15
14
|
_this.createRpcChannel();
|
@@ -22,8 +21,8 @@
|
|
22
21
|
for (var key in bookmarklet.consumer.methods) {
|
23
22
|
if (bookmarklet.consumer.methods.hasOwnProperty(key)) {
|
24
23
|
//console.log(key);
|
25
|
-
rpcConfig.remote[key] = bookmarklet.consumer.methods[key];
|
26
|
-
_this[key]
|
24
|
+
rpcConfig.remote[key] = {}; //bookmarklet.consumer.methods[key];
|
25
|
+
//_this[key]
|
27
26
|
}
|
28
27
|
}
|
29
28
|
rpcConfig.remote.closeFrame = {};
|
@@ -33,7 +32,7 @@
|
|
33
32
|
for (var key in bookmarklet.producer.methods) {
|
34
33
|
if (bookmarklet.producer.methods.hasOwnProperty(key)) {
|
35
34
|
//console.log(key);
|
36
|
-
rpcConfig.local[key] =
|
35
|
+
rpcConfig.local[key] = bookmarklet.producer.methods[key]; //We just stub these since they're not called on this side
|
37
36
|
}
|
38
37
|
}
|
39
38
|
|
@@ -41,12 +40,16 @@
|
|
41
40
|
}
|
42
41
|
|
43
42
|
this.createRpcChannel = function(){
|
43
|
+
|
44
44
|
_this.consumer = new easyXDM.Rpc(
|
45
45
|
/** The channel configuration*/
|
46
46
|
{
|
47
|
-
local: "/assets/cors/index.html",
|
48
|
-
swf: "/assets/easyxdm.swf",
|
47
|
+
//local: "/assets/cors/index.html",
|
48
|
+
//swf: "/assets/easyxdm.swf",
|
49
49
|
onReady: function(){
|
50
|
+
if(bookmarklet.producer.init){
|
51
|
+
bookmarklet.producer.init();
|
52
|
+
}
|
50
53
|
//console.log("calling the remote test....");
|
51
54
|
//Cicero.EasymarkletFrame.remote.alertMessage("just a test...");
|
52
55
|
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
var Easymarklet = window.Easymarklet || {}
|
4
|
+
|
5
|
+
Easymarklet.Simple = function(bookmarklet){
|
6
|
+
if(bookmarklet == null){ alert('You must pass some bookmarklet to Easymarklet.Simple.'); return;}
|
7
|
+
if(bookmarklet.init == null){ alert('Your bookmarklet is missing an init function.'); return; }
|
8
|
+
//if(bookmarklet.consumer == null){ alert('Your bookmarklet definition is missing a consumer.'); return; }
|
9
|
+
//if(bookmarklet.producer == null){ alert('Your bookmarklet definition is missing a producer.'); return; }
|
10
|
+
|
11
|
+
var _this = this;
|
12
|
+
var bookmarklet = bookmarklet
|
13
|
+
var head = document.getElementsByTagName('head')[0];
|
14
|
+
|
15
|
+
var consumer_url = encodeURIComponent(document.location);
|
16
|
+
var protocol = 'http://'
|
17
|
+
var host = '<%= Rails.application.config.action_controller.default_url_options[:host] %>';
|
18
|
+
var port = '<%= Rails.application.config.action_controller.default_url_options[:port] %>';
|
19
|
+
port = port === '' ? '' : ':' + port;
|
20
|
+
var full_host = protocol + host + port;
|
21
|
+
|
22
|
+
this.loadCss = function(){
|
23
|
+
//Load the css
|
24
|
+
bookmarklet.css = [].concat(bookmarklet.css)
|
25
|
+
for(var i = 0; i<bookmarklet.css.length; i++){
|
26
|
+
var src = bookmarklet.css[i]
|
27
|
+
var css = document.createElement('LINK');
|
28
|
+
css.href = full_host + src;
|
29
|
+
css.type = 'text/css';
|
30
|
+
css.media = 'screen';
|
31
|
+
css.rel = 'stylesheet';
|
32
|
+
head.appendChild(css);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
this.init = function(){
|
37
|
+
this.loadCss();
|
38
|
+
if(bookmarklet.init){
|
39
|
+
bookmarklet.init();
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
} // Easymarklet.Simple = function(){
|
44
|
+
|
45
|
+
|
46
|
+
// Now expose the Easymarklet to the global object
|
47
|
+
window.Easymarklet = Easymarklet;
|
48
|
+
|
49
|
+
|
50
|
+
})();
|
51
|
+
|
52
|
+
|
data/lib/easymarklet/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
Description:
|
2
|
+
Generate a simple (non-xdm) bookmarklet.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate easymarklet:simple foobaz
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
app/assets/javascripts/foobaz_bookmarklet.js
|
9
|
+
|
10
|
+
Then you could link to it with:
|
11
|
+
<%= link_to "FooBaz Simple", easymarklet_js('foobaz_bookmarklet.js') %>
|
12
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Easymarklet
|
2
|
+
class BareGenerator < Rails::Generators::NamedBase
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def copy_js_file
|
6
|
+
template "bare_bookmarklet.js", "app/assets/javascripts/#{file_name}_bookmarklet.js"
|
7
|
+
end
|
8
|
+
|
9
|
+
def display_msg
|
10
|
+
puts ""
|
11
|
+
puts "You can link to your new bookmarklet with this :"
|
12
|
+
puts ""
|
13
|
+
puts "<%= link_to '#{file_name.titleize}', easymarklet_js('#{file_name}_bookmarklet.js') %>"
|
14
|
+
puts ""
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Description:
|
2
|
+
Generate a new xdm bookmarklet.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate easymarklet:xdm foobaz
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
app/assets/javascripts/foobaz_bookmarklet.js
|
9
|
+
app/assets/javascripts/foobaz_consumer.js
|
10
|
+
app/assets/javascripts/foobaz_producer.js
|
11
|
+
|
12
|
+
|
13
|
+
Then you could link to it with:
|
14
|
+
<%= link_to "FooBaz XDM", easymarklet_js('foobaz_consumer.js') %>
|
15
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Easymarklet
|
2
|
+
class IframeGenerator < Rails::Generators::NamedBase
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def copy_files
|
6
|
+
template "iframe_bookmarklet.js", "app/assets/javascripts/#{file_name}_bookmarklet.js"
|
7
|
+
template "iframe_consumer.js", "app/assets/javascripts/#{file_name}_consumer.js"
|
8
|
+
template "iframe_producer.js", "app/assets/javascripts/#{file_name}_producer.js"
|
9
|
+
template "iframe_producer_controller.rb", "app/controllers/#{file_name}_producer_controller.rb"
|
10
|
+
template "iframe_producer_index.html.erb", "app/views/#{file_name}_producer/index.html.erb"
|
11
|
+
template "views/easymarklet_layout.html.erb", "app/views/layouts/#{file_name}_producer.html.erb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_routes
|
15
|
+
route("match '#{file_name}_producer' => '#{file_name}_producer#index'")
|
16
|
+
end
|
17
|
+
|
18
|
+
def display_msg
|
19
|
+
puts ""
|
20
|
+
puts "You can link to your new bookmarklet with this :"
|
21
|
+
puts ""
|
22
|
+
puts "<%= link_to '#{file_name.titleize}', easymarklet_js('#{file_name}_consumer.js') %>"
|
23
|
+
puts ""
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
(function(){
|
2
|
+
|
3
|
+
var <%= name.camelize %>Bookmarklet = {
|
4
|
+
|
5
|
+
visible : true,
|
6
|
+
consumer : {
|
7
|
+
css : [], // could be an array or a string
|
8
|
+
methods : { // The methods that the producer can call
|
9
|
+
|
10
|
+
}
|
11
|
+
},
|
12
|
+
producer : {
|
13
|
+
path : "/<%= name %>_producer", // The path on your app that provides your data service
|
14
|
+
methods : { // The methods that the consumer can call
|
15
|
+
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
window.<%= name.camelize %>Bookmarklet = <%= name.camelize %>Bookmarklet;
|
21
|
+
|
22
|
+
})();
|
23
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= name.titleize %> Producer</title>
|
5
|
+
<%%= stylesheet_link_tag "application", :media => "all" %>
|
6
|
+
<%%= javascript_include_tag "application" %>
|
7
|
+
<%%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%%= yield %>
|
12
|
+
|
13
|
+
<%%= javascript_include_tag "<%= name %>_producer" %>
|
14
|
+
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -3,7 +3,8 @@ module Easymarklet
|
|
3
3
|
source_root File.expand_path('../templates', __FILE__)
|
4
4
|
|
5
5
|
def copy_js_file
|
6
|
-
|
6
|
+
template "simple_bookmarklet.js", "app/assets/javascripts/#{file_name}_bookmarklet.js"
|
7
|
+
template "simple_bookmarklet.css", "app/assets/stylesheets/#{file_name}_bookmarklet.css"
|
7
8
|
end
|
8
9
|
|
9
10
|
def display_msg
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#<%= name %>_insert{
|
2
|
+
position:absolute;
|
3
|
+
top:10px;
|
4
|
+
left:10px;
|
5
|
+
background:black;
|
6
|
+
border:3px double white;
|
7
|
+
color:white;
|
8
|
+
padding:10px;
|
9
|
+
-webkit-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);
|
10
|
+
-moz-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);
|
11
|
+
box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);
|
12
|
+
}
|
@@ -1,6 +1,24 @@
|
|
1
|
+
//= require easymarklet/simple
|
2
|
+
|
1
3
|
(function(){
|
4
|
+
|
5
|
+
var <%= name.camelize %>Bookmarklet = {
|
6
|
+
css : ['/assets/<%= name %>_bookmarklet.css'], // could be an array or a single string
|
7
|
+
init : function(){
|
8
|
+
var div = document.createElement('div')
|
9
|
+
div.id = '<%= name %>_insert'
|
10
|
+
div.appendChild(document.createTextNode('<%= name.camelize %> Insert'))
|
11
|
+
div.onclick = function(){
|
12
|
+
document.body.removeChild(div);
|
13
|
+
}
|
14
|
+
document.body.appendChild(div);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
window.<%= name.camelize %>Bookmarklet = <%= name.camelize %>Bookmarklet;
|
2
19
|
|
3
|
-
|
20
|
+
})();
|
4
21
|
|
22
|
+
var <%= name %>_simple = new Easymarklet.Simple(<%= name.camelize %>Bookmarklet);
|
23
|
+
<%= name %>_simple.init();
|
5
24
|
|
6
|
-
})();
|
@@ -12,14 +12,14 @@ module Easymarklet
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def create_routes
|
15
|
-
route("match '#{file_name}' => '#{file_name}_producer#index'")
|
15
|
+
route("match '#{file_name}_producer' => '#{file_name}_producer#index'")
|
16
16
|
end
|
17
17
|
|
18
18
|
def display_msg
|
19
19
|
puts ""
|
20
20
|
puts "You can link to your new bookmarklet with this :"
|
21
21
|
puts ""
|
22
|
-
puts "<%= link_to '#{file_name.titleize}',
|
22
|
+
puts "<%= link_to '#{file_name.titleize}', easymarklet_js('#{file_name}_consumer.js') %>"
|
23
23
|
puts ""
|
24
24
|
end
|
25
25
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easymarklet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -164,13 +164,26 @@ extra_rdoc_files: []
|
|
164
164
|
files:
|
165
165
|
- app/assets/javascripts/easymarklet/consumer.js.erb
|
166
166
|
- app/assets/javascripts/easymarklet/producer.js.erb
|
167
|
+
- app/assets/javascripts/easymarklet/simple.js.erb
|
167
168
|
- app/helpers/easymarklet/link_helper.rb
|
168
169
|
- config/initializers/jasminerice.rb
|
169
170
|
- config/routes.rb
|
170
171
|
- lib/easymarklet/engine.rb
|
171
172
|
- lib/easymarklet/version.rb
|
172
173
|
- lib/easymarklet.rb
|
174
|
+
- lib/generators/easymarklet/bare/bare_generator.rb
|
175
|
+
- lib/generators/easymarklet/bare/templates/bare_bookmarklet.js
|
176
|
+
- lib/generators/easymarklet/bare/USAGE
|
177
|
+
- lib/generators/easymarklet/iframe/iframe_generator.rb
|
178
|
+
- lib/generators/easymarklet/iframe/templates/iframe_bookmarklet.js
|
179
|
+
- lib/generators/easymarklet/iframe/templates/iframe_consumer.js
|
180
|
+
- lib/generators/easymarklet/iframe/templates/iframe_producer.js
|
181
|
+
- lib/generators/easymarklet/iframe/templates/iframe_producer_controller.rb
|
182
|
+
- lib/generators/easymarklet/iframe/templates/iframe_producer_index.html.erb
|
183
|
+
- lib/generators/easymarklet/iframe/templates/views/easymarklet_layout.html.erb
|
184
|
+
- lib/generators/easymarklet/iframe/USAGE
|
173
185
|
- lib/generators/easymarklet/simple/simple_generator.rb
|
186
|
+
- lib/generators/easymarklet/simple/templates/simple_bookmarklet.css
|
174
187
|
- lib/generators/easymarklet/simple/templates/simple_bookmarklet.js
|
175
188
|
- lib/generators/easymarklet/simple/USAGE
|
176
189
|
- lib/generators/easymarklet/xdm/templates/views/easymarklet_layout.html.erb
|
@@ -199,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
212
|
version: '0'
|
200
213
|
segments:
|
201
214
|
- 0
|
202
|
-
hash:
|
215
|
+
hash: -4191531238921313582
|
203
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
217
|
none: false
|
205
218
|
requirements:
|
@@ -208,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
221
|
version: '0'
|
209
222
|
segments:
|
210
223
|
- 0
|
211
|
-
hash:
|
224
|
+
hash: -4191531238921313582
|
212
225
|
requirements: []
|
213
226
|
rubyforge_project:
|
214
227
|
rubygems_version: 1.8.24
|