easy_data3 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.idea/EasyData.iml +11 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +11 -0
- data/.idea/modules.xml +9 -0
- data/.idea/vcs.xml +7 -0
- data/Gemfile +6 -0
- data/README.md +44 -0
- data/Rakefile +12 -0
- data/bin/linked_data +5 -0
- data/easy_data.gemspec +28 -0
- data/lib/controllers/easy_datas_controller.rb +340 -0
- data/lib/data_models/RDFa.rb +100 -0
- data/lib/data_models/data_models.rb +74 -0
- data/lib/data_models/linked_data_graph.rb +80 -0
- data/lib/data_models/model_rdf.rb +344 -0
- data/lib/data_models/namespaces/cc.rb +36 -0
- data/lib/data_models/namespaces/cert.rb +33 -0
- data/lib/data_models/namespaces/dc.rb +87 -0
- data/lib/data_models/namespaces/dc11.rb +47 -0
- data/lib/data_models/namespaces/doap.rb +68 -0
- data/lib/data_models/namespaces/exif.rb +192 -0
- data/lib/data_models/namespaces/foaf.rb +93 -0
- data/lib/data_models/namespaces/geo.rb +35 -0
- data/lib/data_models/namespaces/http.rb +50 -0
- data/lib/data_models/namespaces/owl.rb +83 -0
- data/lib/data_models/namespaces/rdfs.rb +41 -0
- data/lib/data_models/namespaces/rsa.rb +35 -0
- data/lib/data_models/namespaces/rss.rb +38 -0
- data/lib/data_models/namespaces/sioc.rb +110 -0
- data/lib/data_models/namespaces/skos.rb +61 -0
- data/lib/data_models/namespaces/wot.rb +45 -0
- data/lib/data_models/namespaces/xhtml.rb +32 -0
- data/lib/data_models/namespaces/xsd.rb +77 -0
- data/lib/data_models/namespaces.rb +28 -0
- data/lib/easy_data/tasks.rb +137 -0
- data/lib/easy_data/templates/easy_datas/_data_publications.html.erb +28 -0
- data/lib/easy_data/templates/easy_datas/_footer.html.erb +5 -0
- data/lib/easy_data/templates/easy_datas/_linked_data_model.html.erb +19 -0
- data/lib/easy_data/templates/easy_datas/_linked_datas.html.erb +19 -0
- data/lib/easy_data/templates/easy_datas/_list_model_info.html.erb +23 -0
- data/lib/easy_data/templates/easy_datas/_list_properties.html.erb +24 -0
- data/lib/easy_data/templates/easy_datas/_list_properties_edit.html.erb +35 -0
- data/lib/easy_data/templates/easy_datas/_menu.html.erb +24 -0
- data/lib/easy_data/templates/easy_datas/_menu_custom.html.erb +18 -0
- data/lib/easy_data/templates/easy_datas/_model_attributes.html.erb +45 -0
- data/lib/easy_data/templates/easy_datas/_model_attributes_edit.html.erb +17 -0
- data/lib/easy_data/templates/easy_datas/_model_attributes_info.html.erb +24 -0
- data/lib/easy_data/templates/easy_datas/_settings.html.erb +33 -0
- data/lib/easy_data/templates/easy_datas/authenticate_user.html.erb +20 -0
- data/lib/easy_data/templates/easy_datas/custom_rdf.html.erb +28 -0
- data/lib/easy_data/templates/easy_datas/info_easy_data.html.erb +7 -0
- data/lib/easy_data/templates/easy_datas/show.html.erb +1 -0
- data/lib/easy_data/templates/easy_datas/show.xml.builder +18 -0
- data/lib/easy_data/templates/easy_datas/show_all.html.erb +1 -0
- data/lib/easy_data/templates/easy_datas/show_all.xml.builder +16 -0
- data/lib/easy_data/templates/easy_datas/view_settings.html.erb +32 -0
- data/lib/easy_data/templates/images/LogoEasyData.jpg +0 -0
- data/lib/easy_data/templates/images/bg_ft.png +0 -0
- data/lib/easy_data/templates/images/bg_link.jpg +0 -0
- data/lib/easy_data/templates/images/easy_data_logo.png +0 -0
- data/lib/easy_data/templates/images/lock.png +0 -0
- data/lib/easy_data/templates/images/loginBt.png +0 -0
- data/lib/easy_data/templates/images/login_bg.png +0 -0
- data/lib/easy_data/templates/images/logo_ft.png +0 -0
- data/lib/easy_data/templates/images/powerby.jpg +0 -0
- data/lib/easy_data/templates/images/rdf_icon.png +0 -0
- data/lib/easy_data/templates/images/rdf_icon_s.png +0 -0
- data/lib/easy_data/templates/images/shadow_menu.png +0 -0
- data/lib/easy_data/templates/layouts/easy_data_layout.html.erb +18 -0
- data/lib/easy_data/templates/rdf/request.xml.builder +1 -0
- data/lib/easy_data/templates/rdf/show.builder +1 -0
- data/lib/easy_data/templates/stylesheets/easy_data_style.css +62 -0
- data/lib/easy_data/version.rb +3 -0
- data/lib/easy_data.rb +107 -0
- data/lib/routes.rb +41 -0
- data/lib/tasks/testing_installation.rb +6 -0
- data/test/data_models_test.rb +11 -0
- data/test/rdfa_test.rb +18 -0
- data/test/unit/RDFa_test.rb +1 -0
- data/test/unit/data_models_test.rb +10 -0
- data/test/unit/linked_data_graph_test.rb +1 -0
- data/test/unit/model_rdf_test.rb +1 -0
- data/test/unit/namespaces_test.rb +2 -0
- metadata +172 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
<span class="title_model"><%=@model%> Model</span>
|
2
|
+
|
3
|
+
<% if @model_attributes["attributes"]%>
|
4
|
+
<span class="title_data_publications"> Attributes </span>
|
5
|
+
<ul>
|
6
|
+
<%@model_attributes["attributes"].each do |att,values|%>
|
7
|
+
<%if values[:privacy] && values[:privacy]!="Hidden" && values[:property]!="not defined"%>
|
8
|
+
<li><span class="<%='lock' if values[:privacy]=="Private"%>" title="<%='Private attribute' if values[:privacy]=="Private"%>"><%=att%></span></li>
|
9
|
+
<%end%>
|
10
|
+
<%end%>
|
11
|
+
</ul>
|
12
|
+
<%end%>
|
13
|
+
|
14
|
+
<%if @model_attributes["associations"] %>
|
15
|
+
<span class="title_data_publications"> Associations </span>
|
16
|
+
<ul>
|
17
|
+
<%@model_attributes["associations"].each do |att,values|%>
|
18
|
+
<%if values[:privacy]!="Hidden" && values[:property]!="not defined"%>
|
19
|
+
<li><span class="<%='lock' if values[:privacy]=="Private"%>" title="<%='Private association' if values[:privacy]=="Private"%>"><%=att%></span></li>
|
20
|
+
<%end%>
|
21
|
+
<%end%>
|
22
|
+
</ul>
|
23
|
+
<%end%>
|
24
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%- form_remote_for :settings,:url => {:controller => "easy_datas",:action=>"custom_settings"},:update => "custom_content" do%>
|
2
|
+
|
3
|
+
<table class="settings_table">
|
4
|
+
<tr>
|
5
|
+
<th colspan="2"><div class="title_data_publications">Proyecto</div></th>
|
6
|
+
</tr>
|
7
|
+
<tr>
|
8
|
+
<td><span>Project's name(?):</span></td><td><%= text_field "project","project",:value =>@settings["project"]["name"] %></td>
|
9
|
+
</tr>
|
10
|
+
<tr>
|
11
|
+
<td><span>Logo(?):</span></td><td><%= select "project","logo",@images,{:selected => @settings["project"]["logo"]||nil,:prompt => "Select logo ..."}%></td>
|
12
|
+
</tr>
|
13
|
+
<tr>
|
14
|
+
<td><span>Description(?):</span></td><td><%= text_area "project","description","cols" => 45,"rows"=>5,:value=>@settings["project"]["description"]%></td>
|
15
|
+
</tr>
|
16
|
+
<tr>
|
17
|
+
<td><span>Contact email(?):</span></td><td><%= text_field "project","email",:value=>@settings["project"]["contact_email"]%></td>
|
18
|
+
</tr>
|
19
|
+
<tr><th colspan="2"><div class="title_data_publications">Access</div></th>
|
20
|
+
<tr>
|
21
|
+
<td><span>User:</span></td><td><%= text_field "user_admin","user",:value=>@settings["user_admin"]["user"]%></td>
|
22
|
+
</tr>
|
23
|
+
<tr>
|
24
|
+
<td><span>Password:</span></td><td><%= password_field "user_admin","pass"%></td>
|
25
|
+
</tr>
|
26
|
+
<tr>
|
27
|
+
<td><span>IP:</span></td><td><%= text_field "access","ip",:value => @settings["access"]["ip"]%></td>
|
28
|
+
</tr>
|
29
|
+
</table>
|
30
|
+
|
31
|
+
<%= submit_tag "Send" %>
|
32
|
+
|
33
|
+
<%end%>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="authenticate">
|
2
|
+
<div class="left"></div>
|
3
|
+
<div class="middle">
|
4
|
+
<%form_remote_tag :url => {:controller => 'easy_datas',:action => "login"},
|
5
|
+
:update => "content" do -%>
|
6
|
+
<span>
|
7
|
+
<%= label_tag :nick,nil,:class => "lbl_auth" %>
|
8
|
+
<%= text_field_tag :nick,nil%>
|
9
|
+
</span>
|
10
|
+
<span>
|
11
|
+
<%= label_tag :password,nil, :class => "lbla_auth"%>
|
12
|
+
<%= password_field_tag ":password",nil%>
|
13
|
+
</span>
|
14
|
+
<%= submit_tag "Access" %>
|
15
|
+
<input type="button" name="reset_form" value="Cancel" onclick="this.form.reset();">
|
16
|
+
<%end%>
|
17
|
+
</div>
|
18
|
+
<div class="right"></div>
|
19
|
+
<div class="bottom"></div>
|
20
|
+
</div>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= render :partial => "menu_custom"%>
|
2
|
+
<%if @models.respond_to?:each%>
|
3
|
+
<div id="custom_content" class="ed_info_content">
|
4
|
+
<div id="list_models" class="list_model_info">
|
5
|
+
<span class="title">Models List</span>
|
6
|
+
<ul>
|
7
|
+
<%@models.each do |model|%>
|
8
|
+
<li class="list_model">
|
9
|
+
<span id="ls_<%= model%>" class="model"><%= link_to_remote model,:url => {:controller => 'easy_datas',
|
10
|
+
:action => :model_attributes,
|
11
|
+
:model => model},
|
12
|
+
:update => "model_attributes",
|
13
|
+
:after => "$('ls_#{model}').className = 'model_active';",
|
14
|
+
:success => "Effect.Appear('model_attributes', { duration: 0.4 });",
|
15
|
+
:failure => "alert('Ooops! An error occurred.')"
|
16
|
+
%>
|
17
|
+
</span>
|
18
|
+
|
19
|
+
</li>
|
20
|
+
<%end%>
|
21
|
+
</ul>
|
22
|
+
</div>
|
23
|
+
<div id="model_attributes" class="ed_info_models" style="display:none"></div>
|
24
|
+
</div>
|
25
|
+
<%else%>
|
26
|
+
<h3> Not list model </h3>
|
27
|
+
<%end%>
|
28
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Show template</h1>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
|
2
|
+
unless @rdf_model.empty?
|
3
|
+
xml.rdf :RDF, @rdf_model[:header] do
|
4
|
+
@rdf_model[:body].each do |element,prop|
|
5
|
+
xml.rdf :Description, {"rdf:about" => prop["description"]} do
|
6
|
+
prop["attributes"].each do |att,value|
|
7
|
+
xml.tag!(att,value)
|
8
|
+
end
|
9
|
+
prop["associations"].each do |assoc,value|
|
10
|
+
value[:id].each do |id|
|
11
|
+
xml.tag!(assoc,nil,{"rdf:resource"=>"#{@host}/s/#{value[:model]}/#{id}"})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Show template</h1>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
|
2
|
+
xml.rdf :RDF, @rdf_model[:header] do
|
3
|
+
@rdf_model[:body].each do |element,prop|
|
4
|
+
xml.rdf :Description, {"rdf:about" => prop["description"]} do
|
5
|
+
prop["attributes"].each do |att,value|
|
6
|
+
xml.tag!(att,value)
|
7
|
+
end
|
8
|
+
prop["associations"].each do |assoc,value|
|
9
|
+
value[:id].each do |id|
|
10
|
+
xml.tag!(assoc,nil,{"rdf:resource"=>"#{@host}/s/#{value[:model]}/#{id}"})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<span class="title_data_publications">Settings</span>
|
2
|
+
<table class="settings_table">
|
3
|
+
<tr>
|
4
|
+
<th>Projects Data</th>
|
5
|
+
</tr>
|
6
|
+
<tr>
|
7
|
+
<td>Project's name: <%=@settings["project"]["name"]||""%></td>
|
8
|
+
</tr>
|
9
|
+
<tr>
|
10
|
+
<td>Logo: <%=(image_tag(image_path(@settings["project"]["logo"])))unless@settings["project"]["logo"].nil?%></td>
|
11
|
+
</tr>
|
12
|
+
<tr>
|
13
|
+
<td>Description: <%=@settings["project"]["description"]%></td>
|
14
|
+
</tr>
|
15
|
+
<tr>
|
16
|
+
<td>Contact Email: <%=@settings["project"]["contact_email"]%></td>
|
17
|
+
</tr>
|
18
|
+
<tr><th>Access Data<th></tr>
|
19
|
+
<tr>
|
20
|
+
<td>User: <%=@settings["user_admin"]["user"]%></td>
|
21
|
+
</tr>
|
22
|
+
<tr>
|
23
|
+
<td>Password: <%=@settings["user_admin"]["pass"]%></td>
|
24
|
+
</tr>
|
25
|
+
<tr>
|
26
|
+
<td>IP: <%=@settings["access"]["ip"]%></td>
|
27
|
+
</tr>
|
28
|
+
</table>
|
29
|
+
|
30
|
+
<%= button_to_remote "Edit Settings",:url => {:controller => "easy_datas",:action => "settings"},
|
31
|
+
:update => "custom_content",
|
32
|
+
:html => {:title => "Project Settings"}%>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
5
|
+
<title></title>
|
6
|
+
<%= javascript_include_tag(:defaults)%>
|
7
|
+
<%= stylesheet_link_tag "easy_data/easy_data_style" %>
|
8
|
+
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="content" class="content">
|
12
|
+
<%= yield %>
|
13
|
+
<%if controller.action_name != "authenticate_user"%>
|
14
|
+
<%= render :partial => "easy_datas/footer"%>
|
15
|
+
<%end%>
|
16
|
+
</div>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
xml.instruct!
|
@@ -0,0 +1 @@
|
|
1
|
+
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
|
@@ -0,0 +1,62 @@
|
|
1
|
+
body{width:100%;height:100%;margin:0;padding:0;font-family:helvetica;background-color:#f7fffe}
|
2
|
+
a{text-decoration:none;border:none}
|
3
|
+
img{border: 0;}
|
4
|
+
.authenticate{background:url("images/LogoEasyData.jpg") no-repeat 0 0;padding-top:250px;padding-left:90px;margin:0 auto;width:560px;overflow:hidden;}
|
5
|
+
.authenticate .left{display:block;background:url("images/login_bg.png") no-repeat 0 0;float:left;width:15px;height:130px;margin-left:50px}
|
6
|
+
.authenticate .right{display:block;background:url("images/login_bg.png") no-repeat -15px 0;float:left;width:15px;height:130px;}
|
7
|
+
.authenticate .middle{background:#487b4c;overflow:hidden;height:130px;width:400px;float:left}
|
8
|
+
.authenticate .middle form{width:300px;height:130px;color:white;font-weight:bold;overflow:hidden;padding: 25px}
|
9
|
+
.authenticate .middle form .lbl_auth{float:left}
|
10
|
+
.authenticate .middle form input{float:right;width:180px}
|
11
|
+
.authenticate .middle form input[type="submit"]{float:left !important;margin-left:115px;margin-top:10px;width:90px !important}
|
12
|
+
.authenticate .middle form input[type="button"]{float:left !important;margin-left:5px;margin-top:10px;width:90px !important}
|
13
|
+
.authenticate .middle form span{width:100%;display:block;overflow:hidden}
|
14
|
+
.authenticate .bottom{display:block;height:95px;width:300px;margin-left:115px;float:left;background:url("images/loginBt.png") no-repeat 0 0}
|
15
|
+
ul{list-style:none;width:90%;float:left;margin-top:20px;padding-left:0px;}
|
16
|
+
ul div.list_attributes{overflow:hidden;background-color:white;color:black;padding:0 5%;}
|
17
|
+
|
18
|
+
ul.attributes_info{width:100%;clear:left;padding:0}
|
19
|
+
div.attributes_info{padding: 1% 3%;overflow:hidden}
|
20
|
+
div.attributes_info div.property{border-bottom:1px black solid;padding:1em}
|
21
|
+
div.attributes_info div.property span.attribute{font-size:1.15em;font-weight:bold;}
|
22
|
+
.rdf_info{color:grey;font-size:12px}
|
23
|
+
|
24
|
+
/*EASY DATA INFO*/
|
25
|
+
.content{width:100%}
|
26
|
+
|
27
|
+
.ed_main_menu{background:#487b4c;overflow:hidden;width:100%;margin:0 auto;display:block;}
|
28
|
+
.ed_main_menu ul{color:white !important;;margin:0px;width:100%;padding:0px 20%}
|
29
|
+
.ed_main_menu ul li{float:left;width:10%;text-align:center;padding:10px 0px;}
|
30
|
+
.ed_main_menu ul li.menu_link{width:10% !important}
|
31
|
+
.ed_main_menu ul li.menu_link a:hover{text-decoration:underline;padding:10px 0px;cursor:pointer}
|
32
|
+
.ed_main_menu ul li a{color:white}
|
33
|
+
.ed_main_menu ul li.layer_menu{font-size:14px;width:300px !important;padding:11px 0;font-weight:bold;max-height:26px}
|
34
|
+
|
35
|
+
|
36
|
+
.ed_info_content{background:url('images/shadow_menu.png') repeat-x 0 0 ;margin:0;padding:2% 20% 2% 20%;overflow:hidden;min-height: 100%;height: auto !important;height: 100%;margin: 0 auto -70px;}
|
37
|
+
.list_model_info{float:left;width:35%;overflow:hidden;border:1px #808080 solid;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;background-color:#ddbc8f}
|
38
|
+
.title{font-size:22px;font-weight:bold;display:block;padding:10px 0 0 20px;color:#808080}
|
39
|
+
.list_model_info ul li{margin:0;overflow:hidden;color:#808080;padding:5px 20px}
|
40
|
+
.list_model_info ul li:hover{margin:0;color:blue !important;}
|
41
|
+
.list_model_info ul li a{color:#808080;font-weight:bold}
|
42
|
+
.list_model_info ul li span{float:left}
|
43
|
+
.list_model_info ul li .model{width:80%;font-size:15px}
|
44
|
+
.list_model_info ul li .model:hover{width:80%;font-size:16px;font-weight:bold;background: url('images/rdf_icon_s.png') no-repeat 0 0; padding-left: 13px;}
|
45
|
+
.list_model_info ul li .model_active{width:80%;font-size:16px;font-weight:bold;background: url('images/rdf_icon_s.png') no-repeat 0 0; padding-left: 13px;}
|
46
|
+
.ed_info_content .list_model_info ul li a:hover{background:#ddbc8f;font-weight:bold;}
|
47
|
+
.ed_info_content .ed_info_models{float:left;width:60%;padding:1% 1%;}
|
48
|
+
.ed_info_content .settings_table{text-align:left;margin-left:5%;margin-bottom:5%;width:90%}
|
49
|
+
.ed_info_content .settings_table th{padding: 10px 0}
|
50
|
+
.ed_info_content ul{margin-left:20px}
|
51
|
+
.title_data_publications{color:#808080;font-weight:bold;text-decoration:underline;width:100%;display:block;padding: 5px 0;margin: 20px 0;overflow:hidden;}
|
52
|
+
.title_model{background:url("images/rdf_icon.png") no-repeat 0 0;padding-left:40px;margin-bottom:20px;width:100%;display:block;color:#808080;font-weight:bold;font-size:30px}.ed_info_content .ed_info_models .data_info{text-decoration:underline;color:#085DAD;font-size:15px;width:100%;display:block;}
|
53
|
+
.linked_data_graphs{margin:50px 0 0 80px;}
|
54
|
+
.linked_data_access{border:1px #ccc solid;width:95%;height:auto;overflow:hidden;margin-top:20px}
|
55
|
+
.lock{background:url("/images/lock.png") no-repeat top right;padding-right:18px;}
|
56
|
+
.simple_data{margin-left:20px;}
|
57
|
+
/*Footer*/
|
58
|
+
|
59
|
+
.easy_data_footer,.push{height:100px;bottom:0;display:block}
|
60
|
+
.easy_data_footer{width:100%;}
|
61
|
+
.easy_data_footer a{margin-left:60%;overflow:hidden}
|
62
|
+
|
data/lib/easy_data.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
require "easy_data/version"
|
2
|
+
require "data_models/data_models"
|
3
|
+
require "action_controller"
|
4
|
+
require "controllers/easy_datas_controller"
|
5
|
+
require "data_models/model_rdf"
|
6
|
+
require "data_models/linked_data_graph"
|
7
|
+
require "data_models/RDFa"
|
8
|
+
require "routes"
|
9
|
+
require 'ftools'
|
10
|
+
require 'ruby-debug'
|
11
|
+
|
12
|
+
|
13
|
+
module EasyData
|
14
|
+
|
15
|
+
module RDF
|
16
|
+
|
17
|
+
autoload :Namespaces, 'data_models/namespaces'
|
18
|
+
|
19
|
+
NAMESPACES = Dir.glob(File.join(File.dirname(__FILE__),'data_models','namespaces','*.rb')).map{ |f| File.basename(f).gsub('.rb','').to_sym } rescue []
|
20
|
+
NAMESPACES.each { |v| autoload v.to_s.upcase.to_sym, "data_models/namespaces/#{v}" unless v == :namespaces }
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.yaml_description_model(model_data)
|
25
|
+
|
26
|
+
attributes = {}
|
27
|
+
associations = {}
|
28
|
+
|
29
|
+
model_data.columns.each do |att|
|
30
|
+
|
31
|
+
if att.primary
|
32
|
+
attributes[att.name] = {:privacy => 'Private',:namespace => 'not defined',:property => 'not defined'}
|
33
|
+
elsif att.name =~ /_id$/
|
34
|
+
attributes[att.name] = "no publication"
|
35
|
+
else
|
36
|
+
attributes[att.name] = {:privacy => 'Public',:namespace => 'not defined',:property => 'not defined'}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
model_data.reflections.keys.each do |ref|
|
42
|
+
associations[ref.to_s] = {:privacy => 'Public',:namespace => 'not defined',:property => 'not defined'}
|
43
|
+
end
|
44
|
+
|
45
|
+
{:privacy => "Private",:namespace => "not defined",:property => "not defined","attributes" => attributes,"associations" => associations}
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.get_view_path
|
49
|
+
File.join(File.dirname(__FILE__), 'easy_data/templates')
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.get_style_path
|
53
|
+
File.join(File.dirname(__FILE__), 'easy_data/templates/stylesheets/easy_data_style.css')
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.get_uri_namespace(namespace)
|
57
|
+
eval "RDF::#{namespace.upcase}.get_uri"
|
58
|
+
end
|
59
|
+
|
60
|
+
#######################################################################
|
61
|
+
# Building Linked Data Graph
|
62
|
+
#######################################################################
|
63
|
+
def self.build_linked_data_graph
|
64
|
+
LinkedDataGraph.build(DataModels.load_models)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def self.refresh_information
|
69
|
+
rdf = ModelRdf.new
|
70
|
+
models = DataModels.load_models
|
71
|
+
|
72
|
+
unless self.info_update?(models,rdf)
|
73
|
+
rdf_models = rdf.get_models.keys
|
74
|
+
|
75
|
+
#Add the new models to rdf's information file
|
76
|
+
models.each do |model|
|
77
|
+
unless rdf_models.keys.include? model
|
78
|
+
model_data = DataModels.get_model_data(model)
|
79
|
+
if model_data.respond_to?:columns
|
80
|
+
rdf.add_model(model,EasyData.yaml_description_model(eval model))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
#Delete the models how they had deleted
|
86
|
+
rdf_models.each do |model|
|
87
|
+
unless models.include?model
|
88
|
+
rdf.delete_model model
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
rdf.save
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def generate_query(model,params)
|
99
|
+
query = "Select #{params.key.join(", ")}
|
100
|
+
FROM #{model};"
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.info_update?(models,rdf)
|
104
|
+
((models | rdf.get_models.keys)-(models & rdf.get_models.keys)).empty?
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
data/lib/routes.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "action_controller"
|
2
|
+
|
3
|
+
module EasyDataRouting
|
4
|
+
def self.routes
|
5
|
+
|
6
|
+
resources :easy_datas do
|
7
|
+
member do
|
8
|
+
#GET
|
9
|
+
get '/custom_rdf', :to => "easy_datas#custom_rdf"
|
10
|
+
get '/authenticate_user',:to => "easy_datas#authenticate_user"
|
11
|
+
get '/s/data_publications', :to => 'easy_datas#info_easy_data'
|
12
|
+
get '/info_easy_data', :to => 'easy_datas#info_easy_data'
|
13
|
+
get '/linked_data', :to => 'easy_datas#linked_data'
|
14
|
+
get '/access_to_data', :to => 'easy_datas#access_to_data'
|
15
|
+
get '/faq', :to => 'easy_datas#faq'
|
16
|
+
get '/logout', :to => 'easy_datas#logout'
|
17
|
+
#POST
|
18
|
+
post '/model_attributes_info', :to => "easy_datas#model_attributes_info"
|
19
|
+
post '/load_linked_data_graph', :to => "easy_datas#load_linked_data_graph"
|
20
|
+
post '/model_attributes/:model', :to => 'easy_datas#model_attributes'
|
21
|
+
post '/model_attributes_edit/:model', :to => 'easy_datas#model_attributes_edit'
|
22
|
+
post '/load_properties/:block/:attribute', :to => 'easy_datas#load_properties'
|
23
|
+
post '/login', :to => 'easy_datas#login'
|
24
|
+
post '/custom_attributes/:model', :to => 'easy_datas#custom_attributes'
|
25
|
+
post '/settings', :to => 'easy_datas#settings'
|
26
|
+
post '/custom_settings', :to => 'easy_datas#custom_settings'
|
27
|
+
post '/view_settings', :to => 'easy_datas#view_settings'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
DataModels.load_models.each do |model|
|
31
|
+
match "/s/#{model.gsub("::","_")}.:format", :to => "easy_datas#show",
|
32
|
+
:about => "/s/#{model.gsub("::","_")}"
|
33
|
+
match "/s/#{model.gsub("::","_").pluralize}.:format",:to => "easy_datas#show_all",
|
34
|
+
:about => "/s/#{model.gsub("::","_").pluralize}"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
data/test/rdfa_test.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'easy_data'
|
3
|
+
|
4
|
+
require 'ruby-debug'
|
5
|
+
|
6
|
+
class RDFaTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@rdfa = RDFa.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_a_tag
|
13
|
+
|
14
|
+
link = @rdfa.a("User",'http://www.google.es','id','class="link"')
|
15
|
+
assert_equal String,link.class
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
|