rtriplify 0.0.2 → 0.0.3
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 +202 -36
- data/lib/app/controllers/triplify_controller.rb +22 -19
- data/lib/rtriplify.rb +7 -4
- data/lib/tripleizer.rb +103 -84
- metadata +3 -3
data/README
CHANGED
@@ -1,55 +1,221 @@
|
|
1
|
-
|
2
|
-
========
|
1
|
+
=rtriplify
|
3
2
|
|
4
|
-
|
5
|
-
a rdf-mapping of your existing database and serves it out to the (semantic)-web.
|
3
|
+
==What is rtriplify
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
rtriplify is a ruby clone of the triplify-php version. It is used to create
|
6
|
+
an rdf-mapping of your existing database and serves it's content out to the (semantic)-web.
|
7
|
+
It offers several opportunities to improve your application with semantic-data in several
|
8
|
+
RDF- and output formats. The following RDF-formats are supported:
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
serve your content as RDFa. But I think, if you have generated the mapping file
|
14
|
-
for your database it's just the consequence to place RDFa on your page instead.
|
15
|
-
RTriplify gives you the right tools to place RDFa tags on your Webpage without having
|
16
|
-
to do a full code review of your templates. And of course, search engines like google
|
17
|
-
and yahoo already watch for these tags. Google already rewards RDFa tags with some specials.
|
18
|
-
For further informations please see here [1] or [2] here
|
10
|
+
* RDF/N3
|
11
|
+
* RDFa (eperimental feature - please see details)
|
19
12
|
|
13
|
+
You can serve these formats in the following output-formats:
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
* JSON (N3)
|
16
|
+
* RDF/N3 file (N3)
|
17
|
+
* As hidden div in the view of your application (RDFa)
|
24
18
|
|
25
|
-
|
26
|
-
=======
|
19
|
+
==How to serve data
|
27
20
|
|
28
|
-
|
21
|
+
You have to do several steps to configure and run a rtriplify instance with your Application.
|
22
|
+
For experienced users just do the following steps:
|
29
23
|
|
30
|
-
then place a triplify.yml file in the config folder of your RoR-application.
|
31
|
-
Probably it's the best idea to use the sample config file included in the gem or
|
32
|
-
you can download a clean sample file here [3] too.
|
33
24
|
|
34
|
-
|
35
|
-
it's well documented. I think you can start now and change the config so that it
|
36
|
-
will fit to your Application.
|
25
|
+
1. install rtriplify
|
37
26
|
|
38
|
-
|
27
|
+
2. add "triplify.yml" file to your app/config folder
|
39
28
|
|
40
|
-
|
29
|
+
3. configure the mapping to your datamodel
|
30
|
+
|
31
|
+
4. add route for rtriplify controller (optional)
|
32
|
+
|
33
|
+
|
34
|
+
For further information, these steps now in detail:
|
35
|
+
|
36
|
+
=== Install rtriplify
|
37
|
+
|
38
|
+
The easiest way to install rtriplify is by using ruby gem (of course you need a running ruby/rails environment).
|
39
|
+
Just open your command-prompt and input:
|
40
|
+
|
41
|
+
gem install rtriplify
|
42
|
+
|
43
|
+
Another possibility is to install triplify as rails-plugin. In this case,
|
44
|
+
go to the root folder of you application and install it by executing the following command on your commandline:
|
45
|
+
|
46
|
+
ruby script/plugin install http://github.com/rtriplify/rtriplify.git
|
47
|
+
|
48
|
+
Of course you can download the source from github and install it manually too.
|
49
|
+
|
50
|
+
=== Add configuration
|
51
|
+
|
52
|
+
rtriplify just starts up with your application, if you have placed a "triplify.yml" configuration file in the "app/config" folder.
|
53
|
+
Please add such a file. You can download a sample configuration file from https://github.com/rtriplify/rtriplify/blob/master/lib/config/triplify_demo.yml.
|
54
|
+
This configuration file located at lib/config/triplify_demo.yml folder of your triplify installation directory too.
|
55
|
+
(if installed as plugin you can find it at your-app-folder/vendor/plugin/rtriplify/lib/config/triplify_demo.yml)
|
56
|
+
Please don't forget to rename it to "triplify.yml".
|
57
|
+
|
58
|
+
=== Edit configuration
|
59
|
+
|
60
|
+
Usaly the sample configuration has all configuration possibilitys inside of it and
|
61
|
+
is well documentated. I think you can start now and change the configuration in a way that it
|
62
|
+
will fit to your Application. Please note that this configuration file is using the yaml syntax.
|
63
|
+
If your application doesn't start after installing the rtriplify,
|
64
|
+
please make sure, you have a well formed yaml configuration file.
|
65
|
+
|
66
|
+
Please see configuration attributes section for further information
|
67
|
+
|
68
|
+
|
69
|
+
=== Serve content
|
70
|
+
|
71
|
+
Rtriplify allows you to serve content in different ways:
|
72
|
+
|
73
|
+
1. As N3-File download with or without subclasses (all referencing objects)
|
74
|
+
2. N3-JSON with oder without subclasses
|
75
|
+
3. As embedded RDFa
|
76
|
+
|
77
|
+
Just add following route in the route.config:
|
41
78
|
|
42
79
|
map.connect 'triplify/*specs', :controller => 'triplify', :action => "tripleize"
|
43
80
|
|
44
|
-
|
45
|
-
|
81
|
+
Now you can get triples without subclasses under the link:
|
82
|
+
/triplify to get all triples
|
83
|
+
Depending on your configuration you can call
|
84
|
+
/triplify/RDF-Class
|
85
|
+
or
|
86
|
+
/triplify/RDF-Class/id
|
87
|
+
too, to get more specified set of triples.
|
88
|
+
Just do a JSON request on this URI to get it as JSON Object.
|
89
|
+
That' the same way, php-triplify works.
|
90
|
+
|
91
|
+
Now, if you want to serve specific triples in your application, e.g. under a product page,
|
92
|
+
rtriplify gives you the possibility to use respond_to functionality of Ruby on Rails.
|
93
|
+
Just modify your controller function to something similar to the following example:
|
94
|
+
|
95
|
+
def show
|
96
|
+
#load object
|
97
|
+
@product = product.find(@params[:id])
|
98
|
+
|
99
|
+
#new instance of Tripleizer
|
100
|
+
t = Tripleizer.new
|
101
|
+
respond_to do |format|
|
102
|
+
format.html
|
103
|
+
# render n3 triples
|
104
|
+
format.n3 { render :text => t.rdf("Product",[@product]) }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
It's important that you give the t.rdf function the correct parameters.
|
109
|
+
First parameter is the RDF-Class, second parameter is an array with some instances
|
110
|
+
of your models that should be used for rdf generation. Please note, that all
|
111
|
+
triples are generated iterative including all triples of RDF-subclasses.
|
112
|
+
|
113
|
+
If you want to use the RDFa feature of triplify you can generate the triples in a similar way.
|
114
|
+
Just store them as a variable and you can display them on your view at the wished position.
|
115
|
+
|
116
|
+
def show
|
117
|
+
#load_object
|
118
|
+
@product = product.find(@params[:id])
|
119
|
+
|
120
|
+
#new instance of Tripleizer
|
121
|
+
t = Tripleizer.new
|
122
|
+
#get RDFa - text
|
123
|
+
@rdfa = t.rdfa("Offer",[@variants,@product_properties])
|
124
|
+
|
125
|
+
respond_to do |format|
|
126
|
+
format.html
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
Please note that this feature is experimental. It's a possibility to embedd RDFa tags as hidden tags on your page without a complete review of your views.
|
131
|
+
And of course, search engines like google and yahoo look for these tags. Google already rewards RDFa tags with some special functions.
|
132
|
+
|
133
|
+
For further informations please see here:
|
134
|
+
|
135
|
+
http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=99170 or
|
136
|
+
http://developer.yahoo.com/searchmonkey/ (sadly this project is discontinued)
|
137
|
+
|
138
|
+
|
139
|
+
=== Config attributes
|
140
|
+
|
141
|
+
Here you will find some description configurating your rtriplify file.
|
142
|
+
|
143
|
+
namespaces:
|
144
|
+
xmlns: http://www.w3.org/1999/xhtml/
|
145
|
+
All namespaces for your application. Please use them in your application to
|
146
|
+
get the data better linked .
|
147
|
+
|
148
|
+
queries:
|
149
|
+
In general there are two possibilites to configure your rdf Data. First is by
|
150
|
+
using sql queries like in the php version of triplify. Please have a look at
|
151
|
+
http://triplify.svn.sourceforge.net/viewvc/triplify/triplify-php/config.dist.php?view=markup
|
152
|
+
to find out how to configure.
|
153
|
+
|
154
|
+
Secound possibility and may be the more "rails-way" is to use active record.
|
155
|
+
you have two hierarchy levels for configuration. First, the group and secound,
|
156
|
+
the Active record model.
|
157
|
+
A configuration line in the model has always the Schema
|
158
|
+
nameOfField: ar_field
|
159
|
+
|
160
|
+
ID field has a special meaning. The ID field is always the Subject of the RDF triples.
|
161
|
+
If your model has a relation to another Model you can reference the field by using
|
162
|
+
the "->" symbol. For example if your Country has States just reference it by
|
163
|
+
"state->State: states" before the "->" Symbol. Behind this Symbol, the predicate is written.
|
164
|
+
|
165
|
+
Additional you can define a filter e.g.
|
166
|
+
filter:
|
167
|
+
ID: ">213 and id <224"
|
168
|
+
|
169
|
+
query:
|
170
|
+
Type:
|
171
|
+
Model:
|
172
|
+
attribute_name: field_name
|
173
|
+
|
174
|
+
In different scenarios, the "attribute_name: field_name" is to simple, you can extend these commands in the following ways:
|
175
|
+
|
176
|
+
*attribute_name: submodel.field_name
|
177
|
+
*attribute_name-> Ref_class: ref_model.reference_id
|
178
|
+
*attrubute_name->Ref_class: ref_model*reference_id
|
179
|
+
*attrubute_name->Ref_class: MODEL( 'model-class','rdf-resource class')*field_name or, if multiple values
|
180
|
+
*attr_name: CONST(gr:Sell,gr:datatype)
|
181
|
+
*attr_name: CONST(gr:Sell,LINK)
|
182
|
+
*sql_query: sql_query like in triplify ..See here for further information
|
183
|
+
|
184
|
+
If your RDF/N3 and RDFa model have different schemas, you can add a rdfa_query node. Subnodes follow the same syntax as "query"-nodes.
|
185
|
+
|
186
|
+
rdfa_query:
|
187
|
+
|
188
|
+
Objects are classified according to their type. However, you can specify
|
189
|
+
a mapping here, if objects of a certain type should be associated with a
|
190
|
+
different class (e.g. classify all users as 'foaf:person'). If you are
|
191
|
+
unsure it is safe to leave this configuration array empty.
|
192
|
+
|
193
|
+
objectProperties:
|
194
|
+
field_name: type
|
195
|
+
|
196
|
+
Mapping a class to a specified type
|
197
|
+
|
198
|
+
classMap:
|
199
|
+
class: gr:Offering
|
200
|
+
|
201
|
+
The licence under which you publish your data
|
202
|
+
license: http://creativecommons.org/licenses/by/3.0/us/
|
203
|
+
|
204
|
+
Additional metadata
|
205
|
+
You can add arbitrary metadata. The keys of the following array are
|
206
|
+
properties, the values will be represented as respective property values.
|
207
|
+
|
208
|
+
metadata:
|
209
|
+
dc:title: test
|
210
|
+
dc:publisher: test
|
46
211
|
|
47
|
-
|
48
|
-
|
212
|
+
|
213
|
+
Specify on which URI level to expose the data - possible values are:
|
49
214
|
|
215
|
+
* Use 0 or ommit to expose all available content on the highest level all content will be exposed when /triplify/ is accessed on your server. This configuration is recommended for small to medium websites.
|
50
216
|
|
217
|
+
* Use 1 to publish only links to the classes on the highest level and all content will be exposed when for example /triplify/user/ is accessed.
|
51
218
|
|
219
|
+
* Use 2 to publish only links on highest and classes level and all content will be exposed on the instance level, e.g. when /triplify/user/1/ is accessed.
|
52
220
|
|
53
|
-
|
54
|
-
[3] sample config
|
55
|
-
Copyright (c) 2010 Nico Patitz, released under the MIT license
|
221
|
+
LinkedDataDepth: 2
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'configatron'
|
2
|
-
|
2
|
+
#
|
3
3
|
class TriplifyController < ActionController::Base
|
4
4
|
|
5
5
|
def tripleize
|
@@ -61,11 +61,13 @@ class TriplifyController < ActionController::Base
|
|
61
61
|
#get all models
|
62
62
|
def model t, model_group
|
63
63
|
models = t.find_models model_group
|
64
|
-
models
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
if models
|
65
|
+
models.values[0].each do |model_name, model_attributes|
|
66
|
+
if model_name.to_s =="sql_query"
|
67
|
+
t.write_sql(models.keys[0],model_attributes,output)
|
68
|
+
else
|
69
|
+
t.write_model(model_name, models.keys[0])
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
@@ -74,22 +76,23 @@ class TriplifyController < ActionController::Base
|
|
74
76
|
def index t,param
|
75
77
|
subclass,id = param
|
76
78
|
models = t.find_models subclass
|
77
|
-
models
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
79
|
+
if models
|
80
|
+
models.values[0].each do |model_name, model_attributes|
|
81
|
+
if model_name.to_s =="sql_query"
|
82
|
+
#some magic is needed here ..parse the sql query?
|
83
|
+
else
|
84
|
+
m = Model.new model_name, models.keys[0].to_s
|
85
|
+
row_values=m.get_row_by_id(id).first
|
86
|
+
c1=Hash.new
|
87
|
+
if row_values
|
88
|
+
m.model.columns_hash.each_with_index do |column_name,i|
|
89
|
+
c1[column_name[0]]=eval("row_values.#{column_name}")
|
90
|
+
end
|
91
|
+
t.extract_id_line model_attributes, c1,row_values,m.get_datatypes
|
92
|
+
t.make_triples(c1, models.keys[0].to_s , "", m.get_datatypes)
|
87
93
|
end
|
88
|
-
t.extract_id_line model_attributes, c1,row_values,m.get_datatypes
|
89
|
-
t.make_triples(c1, models.keys[0].to_s , "", m.get_datatypes)
|
90
94
|
end
|
91
95
|
end
|
92
|
-
|
93
96
|
end
|
94
97
|
#render :text => t.make_triples(c1, controller , "", t.dbd_types)
|
95
98
|
|
data/lib/rtriplify.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
require 'configatron'
|
2
2
|
|
3
3
|
if File.exists?('config/triplify.yml')
|
4
|
-
#loading
|
5
|
-
|
4
|
+
#loading all plugin files
|
6
5
|
%w{ models controllers helpers}.each do |dir|
|
7
6
|
path = File.join(File.dirname(__FILE__), 'app', dir)
|
8
7
|
$LOAD_PATH << path
|
9
8
|
ActiveSupport::Dependencies.load_paths << path
|
10
9
|
ActiveSupport::Dependencies.load_once_paths.delete(path)
|
11
10
|
end
|
12
|
-
# load settings
|
13
|
-
configatron.configure_from_yaml('config/triplify.yml')
|
11
|
+
# load settings from conig
|
12
|
+
configatron.configure_from_yaml('config/triplify.yml')
|
13
|
+
#register Mime-type
|
14
|
+
Mime::Type.register "text/n3", :n3
|
14
15
|
end
|
15
16
|
|
16
17
|
|
18
|
+
|
19
|
+
|
data/lib/tripleizer.rb
CHANGED
@@ -1,14 +1,24 @@
|
|
1
1
|
require 'configatron'
|
2
2
|
require 'json'
|
3
3
|
|
4
|
+
# This is the core class of triplify
|
5
|
+
# Use instance of this class to get your defined RDF data
|
6
|
+
|
7
|
+
|
8
|
+
# Author:: Nico Patitz (mailto:nico.patitz@gmx.de)
|
9
|
+
# Copyright:: Copyright (c) 2010 Nico Patitz
|
10
|
+
# License:: Distributes under the same terms as triplify
|
11
|
+
|
12
|
+
|
4
13
|
class Tripleizer
|
5
|
-
#
|
14
|
+
# build new instance
|
15
|
+
# define you can define output param
|
6
16
|
def initialize output=nil
|
7
17
|
@object_properties = configatron.objectProperties.to_hash
|
8
18
|
@object_namespaces = configatron.namespaces.to_hash
|
9
19
|
@class_map = configatron.classMap.to_hash
|
10
20
|
@output=output
|
11
|
-
@version="0.0.
|
21
|
+
@version="0.0.2"
|
12
22
|
@json_hash = Hash.new
|
13
23
|
@output_json = nil;
|
14
24
|
@base_uri = "http://example.com/"
|
@@ -16,9 +26,9 @@ class Tripleizer
|
|
16
26
|
|
17
27
|
# stores RDF output as string
|
18
28
|
attr_accessor :output
|
19
|
-
# rtriplify
|
29
|
+
# rtriplify-version showed in RDF
|
20
30
|
attr_reader :version
|
21
|
-
#
|
31
|
+
# the RDF data as a json object
|
22
32
|
attr_accessor :output_json
|
23
33
|
# base uri..if not set, std. from config is used
|
24
34
|
attr_accessor :base_uri
|
@@ -32,21 +42,22 @@ class Tripleizer
|
|
32
42
|
rdf_string =""
|
33
43
|
#get configuration start ->classes
|
34
44
|
m = find_models(rdf_start_class)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
if m
|
46
|
+
m.values[0].each do |mod,attributes|
|
47
|
+
unless mod.eql?("sql_query")
|
48
|
+
t_mod = Model.new(mod, rdf_start_class, class_map[mod.to_s])
|
49
|
+
#if sql...
|
50
|
+
key = t_mod.get_key
|
51
|
+
t_mod.get_rows.each do |item|
|
52
|
+
rdf_string<<rdf_by_id(mod,rdf_start_class,eval("item.#{key}"))
|
53
|
+
end
|
43
54
|
end
|
44
55
|
end
|
45
56
|
end
|
46
57
|
rdf_string
|
47
58
|
end
|
48
59
|
|
49
|
-
# get a
|
60
|
+
# get a RDF node by its ID and resource-class.
|
50
61
|
# Iterative Function, so be carefull with your config not to produce endless loops
|
51
62
|
def rdf_by_id model_name, class_name, id
|
52
63
|
puts model_name
|
@@ -142,15 +153,16 @@ class Tripleizer
|
|
142
153
|
end
|
143
154
|
|
144
155
|
#get configuration start ->classes
|
145
|
-
m = find_models(rdf_start_class)
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
156
|
+
m = find_models(rdf_start_class,true)
|
157
|
+
if m
|
158
|
+
m.values[0].each do |mod,attributes|
|
159
|
+
unless mod.eql?("sql_query")
|
160
|
+
t_mod = Model.new(mod, rdf_start_class, class_map[mod.to_s])
|
161
|
+
#if sql...
|
162
|
+
key = t_mod.get_key
|
163
|
+
t_mod.get_rows.each do |item|
|
164
|
+
rdfa_string<<find_rdfa_by_id(rdf_start_class,eval("item.#{key}"))
|
165
|
+
end
|
154
166
|
end
|
155
167
|
end
|
156
168
|
end
|
@@ -163,76 +175,78 @@ class Tripleizer
|
|
163
175
|
id = id.to_s
|
164
176
|
rdfa_string = "<div about=\"#{rdf_start_class+"/"<<id}\" typeof=\"#{@class_map[rdf_start_class.to_sym]}\">\n"
|
165
177
|
#get configuration start ->classes
|
166
|
-
m = find_models(rdf_start_class)
|
167
|
-
m
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
field_class.
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
178
|
+
m = find_models(rdf_start_class,true)
|
179
|
+
if m
|
180
|
+
m.values[0].each do |mod,attributes|
|
181
|
+
unless mod.to_s.eql?("sql_query")
|
182
|
+
t_mod = Model.new(mod, rdf_start_class)
|
183
|
+
#if sql...
|
184
|
+
item=t_mod.get_row_by_id(id).first
|
185
|
+
t_mod.model_attributes.each do |name,link_field|
|
186
|
+
#property
|
187
|
+
#link to other ress
|
188
|
+
if name.to_s.include? "->"
|
189
|
+
m_class,role_mod = name.to_s.split "->"
|
190
|
+
|
191
|
+
if role_mod.eql?("sql_query")
|
192
|
+
hello=""
|
193
|
+
else
|
194
|
+
if link_field.include?("*")
|
195
|
+
field_class,field= link_field.to_s.split("*")
|
196
|
+
if field_class.to_s[0..5]=="MODEL("
|
197
|
+
field_class.gsub!("MODEL(","Model.new(")
|
198
|
+
submodel= eval(field_class.to_s).get_rows
|
199
|
+
rdfa_string<<"<div rel=\"#{m_class}\">\n"
|
200
|
+
submodel.each do |line|
|
201
|
+
rdfa_string<<find_rdfa_by_id(role_mod , eval("line.#{field.to_s}"))
|
202
|
+
end
|
203
|
+
rdfa_string<<"</div>\n"
|
204
|
+
else
|
205
|
+
subitem = eval("item.#{field_class}")
|
206
|
+
rdfa_string<<"<div rel=\"#{m_class}\">\n"
|
207
|
+
subitem.each do |subline|
|
208
|
+
rdfa_string<< find_rdfa_by_id(role_mod , eval("subline.#{field.to_s}"))
|
209
|
+
end
|
210
|
+
rdfa_string<<"</div>\n"
|
189
211
|
end
|
190
|
-
rdfa_string<<"</div>\n"
|
191
212
|
else
|
192
|
-
subitem = eval("item.#{field_class}")
|
193
213
|
rdfa_string<<"<div rel=\"#{m_class}\">\n"
|
194
|
-
|
195
|
-
rdfa_string<< find_rdfa_by_id(role_mod , eval("subline.#{field.to_s}"))
|
196
|
-
end
|
214
|
+
rdfa_string << find_rdfa_by_id(role_mod , eval("item.#{link_field.to_s}"))
|
197
215
|
rdfa_string<<"</div>\n"
|
198
216
|
end
|
199
|
-
else
|
200
|
-
rdfa_string<<"<div rel=\"#{m_class}\">\n"
|
201
|
-
rdfa_string << find_rdfa_by_id(role_mod , eval("item.#{link_field.to_s}"))
|
202
|
-
rdfa_string<<"</div>\n"
|
203
|
-
end
|
204
|
-
end
|
205
|
-
else
|
206
|
-
write=true
|
207
|
-
#just a property
|
208
|
-
#CONST(
|
209
|
-
#Model(
|
210
|
-
if link_field.to_s[0..5] =="CONST("
|
211
|
-
write=false
|
212
|
-
val,data_type= t_mod.get_const(link_field)
|
213
|
-
if data_type=="LINK"
|
214
|
-
#link
|
215
|
-
rdfa_string<<"<div rel= \"#{name}\" resource=\"#{val}\"> </div>\n"
|
216
|
-
else
|
217
|
-
#value
|
218
|
-
rdfa_string<<"<div property= \"#{name}\" content=\"#{val}\" datatype=\"#{data_type}\"> </div>\n"
|
219
217
|
end
|
220
218
|
else
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
219
|
+
write=true
|
220
|
+
#just a property
|
221
|
+
#CONST(
|
222
|
+
#Model(
|
223
|
+
if link_field.to_s[0..5] =="CONST("
|
224
|
+
write=false
|
225
|
+
val,data_type= t_mod.get_const(link_field)
|
226
|
+
if data_type=="LINK"
|
227
|
+
#link
|
228
|
+
rdfa_string<<"<div rel= \"#{name}\" resource=\"#{val}\"> </div>\n"
|
229
|
+
else
|
230
|
+
#value
|
231
|
+
rdfa_string<<"<div property= \"#{name}\" content=\"#{val}\" datatype=\"#{data_type}\"> </div>\n"
|
232
|
+
end
|
233
|
+
else
|
234
|
+
m_class,field= link_field.to_s.split("*")
|
235
|
+
if name.to_s[0..5]=="MODEL("
|
236
|
+
m_class.gsub!("MODEL(","Model.new(")
|
237
|
+
submodel= eval(m_class.to_s).get_rows
|
238
|
+
submodel.each do |line|
|
239
|
+
datatype="string"
|
240
|
+
rdfa_string<<"<div property= \"#{ref_pred}\" content=\"#{eval("line.#{field.to_s.downcase}")}\" datatype=\"#{data_type}\"> </div>\n"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
if field
|
244
|
+
write = false
|
245
|
+
#rdfa_string<<find_rdfa_by_id("","")
|
228
246
|
end
|
229
247
|
end
|
230
|
-
if
|
231
|
-
write = false
|
232
|
-
#rdfa_string<<find_rdfa_by_id("","")
|
233
|
-
end
|
248
|
+
rdfa_string<<"<div property= \"#{name}\" content=\"#{eval("item.#{link_field}")}\"></div>\n" if write
|
234
249
|
end
|
235
|
-
rdfa_string<<"<div property= \"#{name}\" content=\"#{eval("item.#{link_field}")}\"></div>\n" if write
|
236
250
|
end
|
237
251
|
end
|
238
252
|
end
|
@@ -246,8 +260,13 @@ class Tripleizer
|
|
246
260
|
|
247
261
|
# Find all the models to the given key ( the RDF-Class name)
|
248
262
|
# returns a hash with the RDF-Class name as key and the models as value
|
249
|
-
|
250
|
-
|
263
|
+
# rdfa -> if true, watch for a RDFa section
|
264
|
+
def find_models key, rdfa=nil
|
265
|
+
if rdfa
|
266
|
+
model_groups = eval("configatron.rdfa_query") ? eval("configatron.rdfa_query").to_hash : eval("configatron.query").to_hash
|
267
|
+
else
|
268
|
+
model_groups = eval("configatron.query").to_hash
|
269
|
+
end
|
251
270
|
model_groups.each do |model_group_name,model_group|
|
252
271
|
if model_group_name.to_s.downcase == key.downcase
|
253
272
|
return {model_group_name=>model_group}
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nico Patitz
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2010-12-05 21:24:22.797000 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|