spearwolf-microdata_fu 0.1.2
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.
- data/README.rdoc +53 -0
- data/VERSION.yml +4 -0
- data/lib/microdata_fu.rb +7 -0
- data/lib/microdata_fu_helper.rb +7 -0
- metadata +57 -0
data/README.rdoc
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
= microdata_fu (rails plugin)
|
2
|
+
|
3
|
+
A simple rails plugin which enables you to..
|
4
|
+
|
5
|
+
- store <em>non-visible data</em> (microdata) into your html
|
6
|
+
- read-out the data from javascript
|
7
|
+
|
8
|
+
|
9
|
+
== How to Install
|
10
|
+
|
11
|
+
First, add microdata_fu to your list of gems in <tt>config/environment.rb</tt>:
|
12
|
+
|
13
|
+
config.gem 'spearwolf-microdata_fu', :lib => 'microdata_fu', :source => 'http://gems.github.com'
|
14
|
+
|
15
|
+
Then insert into your html layout the microdata_fu tag (<em>e.g.</em> <tt>app/views/layouts/application.html.erb</tt>):
|
16
|
+
|
17
|
+
<head>
|
18
|
+
..
|
19
|
+
<%= microdata_fu %>
|
20
|
+
..
|
21
|
+
</head>
|
22
|
+
|
23
|
+
|
24
|
+
== Usage Example
|
25
|
+
|
26
|
+
=== Define microdata in your controller
|
27
|
+
|
28
|
+
class MyController << ApplicationController
|
29
|
+
def index
|
30
|
+
microdata :foo, 'foo'
|
31
|
+
microdata :bar, { :abc => 'ABC', :xyz => 123 }
|
32
|
+
microdata :user, User.find(params[:id])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
=== Read-out microdata from javascript
|
38
|
+
|
39
|
+
In javascript you can read-out the microdata through the microdata_fu api:
|
40
|
+
|
41
|
+
var foo = microdata_fu.read('foo');
|
42
|
+
|
43
|
+
or use the optional callback function:
|
44
|
+
|
45
|
+
mircodata_fu.read('bar', function(bar) {
|
46
|
+
/* ...do whatever you want with bar here...
|
47
|
+
if bar is undefined the code won't be executed */
|
48
|
+
});
|
49
|
+
|
50
|
+
|
51
|
+
== Author
|
52
|
+
|
53
|
+
Copyright (c) 2008-2009 Wolfger Schramm <wolfger@spearwolf.de>, released under the MIT license
|
data/VERSION.yml
ADDED
data/lib/microdata_fu.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
module MicrodataFuHelper
|
2
|
+
|
3
|
+
def microdata_fu
|
4
|
+
md = flash[:microdata].map {|k,v| "'#{escape_javascript(k)}':#{v}" }.join(",")
|
5
|
+
javascript_tag "var microdata_fu = /* created by spearwolf <wolfger@spearwolf.de> */(function(){var _md_fu={#{md}};var md={get:function(k){return _md_fu[k];}};return{read:function(k,fn){var v=md.get(k);if(fn!=undefined&&v!=undefined){v=fn(v);}return v;}}})();"
|
6
|
+
end
|
7
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spearwolf-microdata_fu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wolfger Schramm
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-19 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Read-out (rails generated) microdata from javascript
|
17
|
+
email: wolfger@spearwolf.de
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README.rdoc
|
26
|
+
- VERSION.yml
|
27
|
+
- lib/microdata_fu.rb
|
28
|
+
- lib/microdata_fu_helper.rb
|
29
|
+
has_rdoc: true
|
30
|
+
homepage: http://github.com/spearwolf/microdata_fu
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options:
|
33
|
+
- --inline-source
|
34
|
+
- --charset=UTF-8
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: "0"
|
42
|
+
version:
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.2.0
|
53
|
+
signing_key:
|
54
|
+
specification_version: 2
|
55
|
+
summary: TODO
|
56
|
+
test_files: []
|
57
|
+
|