easymarklet 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -14,23 +14,23 @@ Then run:
14
14
 
15
15
  bundle install
16
16
 
17
- Building your bookmarklet code
18
- ---------------------------------
19
-
20
- Add a file to your app/assets/javascripts directory that will hold the
21
- code for your bookmarklet. For example :
22
17
 
23
- app/assets/javascripts/foobaz_bookmarklet.js
18
+ Types of bookmarklets
19
+ ----------------------------------
24
20
 
25
- (function(){
26
- var p = document.createElement('p');
27
- p.appendChild(document.createTextNode('Foo vs. Baz'));
28
- document.body.appendChild(p);
29
- })();
21
+ Easymarklet supports two types of bookmarklets, simple bookmarklets and
22
+ xdm bookmarklets. Simple bookmarklets allow new functionality to be
23
+ injected into a page, but they are restricted in the amount of
24
+ communication that can go back to your app. Xdm bookmarklets use
25
+ [easyXDM](http://easyxdm.net/wp/) to allow cross domain communication.
30
26
 
31
- Linking to your bookmarklet
27
+ Generating a new simple bookmarklet
32
28
  ---------------------------------
33
29
 
30
+ Run something like this:
31
+
32
+ rails generate easymarklet:simple foobaz
33
+
34
34
  Then in a view template you can link to your bookmarklet using the
35
35
  easymarklet_js helper.
36
36
 
@@ -41,24 +41,28 @@ load your bookmarklet code into the current page and execute it. Place
41
41
  some instructions for your users near the link that tells them to drag
42
42
  the link into their bookmark bar.
43
43
 
44
- XDM Bookmarklets
45
- ----------------------------------
44
+ [See the Simple Bookmarklets wiki page for more info.](https://github.com/Octo-Labs/easymarklet/wiki/Simple-Bookmarklets)
46
45
 
47
- * Note : XDM is a work in progress.
48
46
 
49
- To enable cross domain communictaion between your site and other pages
50
- on the 'net we need to be able to generate a fully qualified URL to your
51
- bookmarklet code. To set the correct host you should add this to each
52
- of your confing/environment/*.rb files. Adjust the :host accordingly.
53
- :port is optional.
47
+ Generating a new XDM bookmarklet
48
+ ----------------------------------
49
+
50
+ To enable cross domain communictaion between your site and other pages on the 'net we need to be able to generate a fully qualified URL to your bookmarklet code. To set the correct host you should add this to each of your confing/environment/*.rb files. Adjust the :host accordingly. :port is optional.
54
51
 
55
- config.action_controller.default_url_options = {:host =>
56
- 'localhost', :port => 3000}
52
+ config.action_controller.default_url_options = {:host => 'localhost', :port => 3000}
57
53
 
58
54
  XDM bookmarklet code acts as a consumer for data or a service that is
59
55
  supplied by the provider, a page on your app.
60
56
 
57
+ To generate your bookmarklet run something like this:
58
+
59
+ rails generate easymarklet:xdm barbaz_xdm
60
+
61
+ Then link to the consumer in a view:
62
+
63
+ <%= link_to "Bar Baz!", easymarklet_js('barbaz_xdm_consumer.js') %>
61
64
 
65
+ [See the XDM Bookmarklets wiki page for more info](https://github.com/Octo-Labs/easymarklet/wiki/XDM-Bookmarklets)
62
66
 
63
67
 
64
68
  This project rocks and uses MIT-LICENSE.
@@ -1,3 +1,3 @@
1
1
  module Easymarklet
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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>
@@ -1,6 +1,6 @@
1
1
  (function(){
2
2
 
3
- var <%= name.titleize %>Bookmarklet = {
3
+ var <%= name.camelize %>Bookmarklet = {
4
4
 
5
5
  visible : true,
6
6
  consumer : {
@@ -17,7 +17,7 @@
17
17
  }
18
18
  }
19
19
 
20
- window.<%= name.titleize %>Bookmarklet = <%= name.titleize %>Bookmarklet;
20
+ window.<%= name.camelize %>Bookmarklet = <%= name.camelize %>Bookmarklet;
21
21
 
22
22
  })();
23
23
 
@@ -1,5 +1,5 @@
1
1
  //= require easymarklet/consumer
2
- //= require <%= name %>_xdm
2
+ //= require <%= name %>_bookmarklet
3
3
  //
4
- var <%= name %>_consumer = new Easymarklet.Consumer(<%= name.titleize %>Bookmarklet);
4
+ var <%= name %>_consumer = new Easymarklet.Consumer(<%= name.camelize %>Bookmarklet);
5
5
  <%= name %>_consumer.init();
@@ -1,6 +1,6 @@
1
- //= require easymarklet/producer
2
- //= require <%= name %>_xdm
3
1
  //= require easyXDM
2
+ //= require easymarklet/producer
3
+ //= require <%= name %>_bookmarklet
4
4
 
5
- var <%= name %>_producer = new Easymarklet.Producer(<%= name.titleize %>Bookmarklet);
5
+ var <%= name %>_producer = new Easymarklet.Producer(<%= name.camelize %>Bookmarklet);
6
6
  <%= name %>_producer.init();
@@ -0,0 +1,8 @@
1
+ class <%= name.camelize %>ProducerController < ApplicationController
2
+
3
+ layout '<%= name %>_producer'
4
+
5
+ def index
6
+ end
7
+
8
+ end
@@ -0,0 +1,3 @@
1
+ This is the <%= name %> producer.
2
+
3
+ <%%= link_to_function "Close", "<%= name %>_producer.closeFrame()" %>
@@ -2,10 +2,17 @@ module Easymarklet
2
2
  class XdmGenerator < Rails::Generators::NamedBase
3
3
  source_root File.expand_path('../templates', __FILE__)
4
4
 
5
- def copy_js_file
5
+ def copy_files
6
6
  template "xdm_bookmarklet.js", "app/assets/javascripts/#{file_name}_bookmarklet.js"
7
7
  template "xdm_consumer.js", "app/assets/javascripts/#{file_name}_consumer.js"
8
8
  template "xdm_producer.js", "app/assets/javascripts/#{file_name}_producer.js"
9
+ template "xdm_producer_controller.rb", "app/controllers/#{file_name}_producer_controller.rb"
10
+ template "xdm_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}' => '#{file_name}_producer#index'")
9
16
  end
10
17
 
11
18
  def display_msg
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.1
4
+ version: 0.0.2
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-06 00:00:00.000000000 Z
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -173,9 +173,12 @@ files:
173
173
  - lib/generators/easymarklet/simple/simple_generator.rb
174
174
  - lib/generators/easymarklet/simple/templates/simple_bookmarklet.js
175
175
  - lib/generators/easymarklet/simple/USAGE
176
+ - lib/generators/easymarklet/xdm/templates/views/easymarklet_layout.html.erb
176
177
  - lib/generators/easymarklet/xdm/templates/xdm_bookmarklet.js
177
178
  - lib/generators/easymarklet/xdm/templates/xdm_consumer.js
178
179
  - lib/generators/easymarklet/xdm/templates/xdm_producer.js
180
+ - lib/generators/easymarklet/xdm/templates/xdm_producer_controller.rb
181
+ - lib/generators/easymarklet/xdm/templates/xdm_producer_index.html.erb
179
182
  - lib/generators/easymarklet/xdm/USAGE
180
183
  - lib/generators/easymarklet/xdm/xdm_generator.rb
181
184
  - lib/tasks/easymarklet_tasks.rake
@@ -196,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
199
  version: '0'
197
200
  segments:
198
201
  - 0
199
- hash: -4490360310275386110
202
+ hash: 1957519611268656497
200
203
  required_rubygems_version: !ruby/object:Gem::Requirement
201
204
  none: false
202
205
  requirements:
@@ -205,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
208
  version: '0'
206
209
  segments:
207
210
  - 0
208
- hash: -4490360310275386110
211
+ hash: 1957519611268656497
209
212
  requirements: []
210
213
  rubyforge_project:
211
214
  rubygems_version: 1.8.24