easy_data 0.0.92 → 0.0.95

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ Installation
2
+ --------------
3
+
4
+ In config/routes.rb at the end of routes declarations include:
5
+
6
+ EasyDataRouting.routes(map)
7
+
8
+ <p>After, in [RAILS_HOME]/Rakefile copy this line:</p>
9
+
10
+ <pre><code> require "easy_data/tasks" </code></pre>
11
+
12
+ <p>At the end, execute the next task:</p>
13
+
14
+ <pre><code> rake easy_data:install RAILS_ENV=development </code></pre>
15
+
16
+
17
+ <p>To start with administration, you should assign at admin user:</p>
18
+
19
+ <pre><code> rake easy_data:add_user[user,pass] RAILS_ENV=development </code></pre>
20
+
21
+
22
+ Commandas and Query
23
+ --------------------
24
+
25
+ <p>To get all possibles querys and URI's offers use this url:</p>
26
+
27
+ <pre><code> http://[project_host]/list_models </code></pre>
28
+
29
+
30
+ <p>After, to get any information about any model or resource, used this url: </p>
31
+
32
+ <pre><code> http://[project_host]/foaf/[model]/[id][.format] </code></pre>
33
+
34
+ <ul>
35
+ <li>[model] = any model list in first url</li>
36
+ <li>[id] = to get any information with primary key</li>
37
+ <li>[format] = this is for advance users, get response in this format</li>
38
+ </ul>
39
+
40
+ Collaborations
41
+ ------------------
42
+
43
+ <p>If you want to collaborate on this project or have any ideas and would like to share, please email me at my email, all are welcome!</p>
44
+ <p><a href="mailto:jnillo9@gmail.com" title="jnillo's mail">jnillo9@gmail.com</a></p>
@@ -1,3 +1,4 @@
1
+ require "action_controller"
1
2
  require "action_view"
2
3
  require "builder"
3
4
 
@@ -8,29 +9,35 @@ class EasyDatasController < ActionController::Base
8
9
  before_filter :authenticated, :only => [:custom_rdf]
9
10
 
10
11
  def show
11
- begin
12
- model = (eval params[:model].to_s)
13
-
14
- rdf = ModelRdf.new
15
-
16
- no_valid = lambda{|c| c.nil?||c.empty?}
12
+
13
+ if params[:id].nil? && params[:model] == params[:model].pluralize #Because, the model's name is the sames in pluralize format, example: News
14
+ redirect_to :action => "show_all",:locals => {:model => params[:model]}
15
+ end
16
+ begin
17
+ model = eval params[:model].to_s
17
18
 
18
- @reply = model.find :all, :conditions => {:id => params[:id]}
19
-
20
- unless @reply.nil?
21
- @host="http://"+request.env["HTTP_HOST"]
19
+ conditions = parser_params(params)
20
+
21
+ rdf = ModelRdf.new
22
+
23
+ no_valid = lambda{|c| c.nil?||c.empty?}
24
+
25
+ @reply = model.find :all, :conditions => {:id => params[:id]}
26
+
27
+ unless @reply.nil?
28
+ @host="http://"+request.env["HTTP_HOST"]
22
29
 
23
- @rdf_model = rdf.get_model_rdf(@reply,params[:model],"http://"+request.env["HTTP_HOST"])
24
- end
30
+ @rdf_model = rdf.get_model_rdf(@reply,params[:model],"http://"+request.env["HTTP_HOST"])
31
+ end
25
32
 
26
- @xml = Builder::XmlMarkup.new
33
+ @xml = Builder::XmlMarkup.new
27
34
 
28
35
  if no_valid.call(@rdf_model[:header]) || @reply.nil? # If the URI not available or data no publicated
29
36
  render :nothing => true, :status => 400
30
37
  else
31
38
  respond_to do |format|
32
39
  format.html
33
- format.xml
40
+ format.xml # render :template => "/rdf/request.xml.builder"
34
41
  end
35
42
  end
36
43
  rescue
@@ -45,12 +52,12 @@ class EasyDatasController < ActionController::Base
45
52
  rdf = ModelRdf.new
46
53
 
47
54
  no_valid = lambda{|c| c.nil?||c.empty?}
48
-
55
+
49
56
  @reply = model.find :all || nil
57
+
58
+ @host="http://"+request.env["SERVER_NAME"]
50
59
 
51
- @host="http://"+request.env["HTTP_HOST"]
52
-
53
- @rdf_model = rdf.get_model_rdf(@reply,params[:model],"http://"+request.env["HTTP_HOST"])
60
+ @rdf_model = rdf.get_model_rdf(@reply,params[:model],"http://"+request.env["SERVER_NAME"])
54
61
 
55
62
  @xml = Builder::XmlMarkup.new
56
63
 
@@ -59,7 +66,7 @@ class EasyDatasController < ActionController::Base
59
66
  else
60
67
  respond_to do |format|
61
68
  format.html
62
- format.xml
69
+ format.xml # render :template => "/rdf/request.xml.builder"
63
70
  end
64
71
  end
65
72
  rescue
@@ -86,6 +93,18 @@ class EasyDatasController < ActionController::Base
86
93
  end
87
94
  end
88
95
 
96
+ # Information about access to publicated data
97
+ def access_to_data
98
+ end
99
+
100
+ # Generate Linked Data Graph
101
+ def linked_data
102
+ end
103
+
104
+ # FAQ
105
+ def faq
106
+ end
107
+
89
108
  def custom_rdf
90
109
  @models = DataModels.load_models
91
110
  @settings ||= YAML::load(File.open("#{RAILS_ROOT}/config/easy_data/setting.yaml"))
@@ -1,5 +1,7 @@
1
+ require "fileutils"
1
2
  require 'rake'
2
3
  require 'easy_data'
4
+ require 'active_record'
3
5
 
4
6
 
5
7
  namespace :easy_data do
@@ -48,12 +48,15 @@ div.attributes_info div.property span.attribute{font-size:1.15em;font-weight:bol
48
48
  .ed_info_content .settings_table{text-align:left;margin-left:5%;margin-bottom:5%;width:90%}
49
49
  .ed_info_content .settings_table th{padding: 10px 0}
50
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;}
51
+
52
+ .title_data_publications{color:#808080;background-color:#DDBC8F;font-weight:bold;width:100%;display:block;padding: 5px 10px;overflow:hidden;margin:20px 0;}
53
+ .ed_info_content .ed_info_models .data_info{text-decoration:underline;color:#085DAD;font-size:15px;width:100%;display:block;}
54
+ .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}
53
55
  .linked_data_graphs{margin:50px 0 0 80px;}
54
56
  .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;}
57
+ .lock{background:url("images/lock.png") no-repeat top right;padding-right:18px;}
56
58
  .simple_data{margin-left:20px;}
59
+
57
60
  /*Footer*/
58
61
 
59
62
  .easy_data_footer,.push{height:100px;bottom:0;display:block}
@@ -1,3 +1,3 @@
1
1
  module EasyData
2
- VERSION = "0.0.92"
2
+ VERSION = "0.0.95"
3
3
  end
data/lib/easy_data.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  require "easy_data/version"
2
2
  require "data_models/data_models"
3
+ require "action_controller"
3
4
  require "controllers/easy_datas_controller"
4
5
  require "data_models/model_rdf"
5
6
  require "data_models/linked_data_graph"
6
7
  require "data_models/RDFa"
7
8
  require "routes"
8
- require 'ftools'
9
+ require 'fileutils'
9
10
  require 'ruby-debug'
10
11
 
11
12
 
data/lib/routes.rb CHANGED
@@ -1,39 +1,45 @@
1
+ require "action_controller"
2
+
1
3
  module EasyDataRouting
2
- def self.routes
4
+ def self.routes(map)
5
+
6
+ map.with_options :controller => 'easy_datas' do |ed_routes|
7
+ ed_routes.with_options :conditions => {:method => :get} do |ed_views|
8
+ ed_views.connect 'easy_datas/custom_rdf', :action=> "custom_rdf"
9
+ ed_views.connect 'easy_data', :action => "custom_rdf"
10
+ ed_views.connect 'easy_datas/authenticate_user', :action => "authenticate_user"
11
+
12
+ ed_views.connect 's/data_publications', :action => 'info_easy_data'
13
+ ed_views.connect 'easy_datas/info_easy_data', :action => 'info_easy_data'
14
+ ed_views.connect 'easy_datas/linked_data', :action => 'linked_data'
15
+ ed_views.connect 'easy_datas/access_to_data', :action => 'access_to_data'
16
+ ed_views.connect 'easy_datas/faq', :action => 'faq'
17
+
18
+ ed_views.connect 'easy_datas/logout', :action => 'logout'
19
+ DataModels.load_models.each do |model|
20
+ ed_views.connect "s/#{model.gsub("::","_")}", :controller => "easy_datas",
21
+ :action => 'show',
22
+ :model => model,
23
+ :format => 'xml'
24
+ ed_views.connect "s/#{model.gsub("::","_").pluralize}", :controller => "easy_datas",
25
+ :action => 'show_all',
26
+ :model => model,
27
+ :format => 'xml'
3
28
 
4
- resources :easy_datas do
5
- member do
6
- #GET
7
- get '/custom_rdf', :to => "easy_datas#custom_rdf"
8
- get '/authenticate_user',:to => "easy_datas#authenticate_user"
9
- get '/s/data_publications', :to => 'easy_datas#info_easy_data'
10
- get '/info_easy_data', :to => 'easy_datas#info_easy_data'
11
- get '/linked_data', :to => 'easy_datas#linked_data'
12
- get '/access_to_data', :to => 'easy_datas#access_to_data'
13
- get '/faq', :to => 'easy_datas#faq'
14
- get '/logout', :to => 'easy_datas#logout'
15
- #POST
16
- post '/model_attributes_info', :to => "easy_datas#model_attributes_info"
17
- post '/load_linked_data_graph', :to => "easy_datas#load_linked_data_graph"
18
- post '/model_attributes/:model', :to => 'easy_datas#model_attributes'
19
- post '/model_attributes_edit/:model', :to => 'easy_datas#model_attributes_edit'
20
- post '/load_properties/:block/:attribute', :to => 'easy_datas#load_properties'
21
- post '/login', :to => 'easy_datas#login'
22
- post '/custom_attributes/:model', :to => 'easy_datas#custom_attributes'
23
- post '/settings', :to => 'easy_datas#settings'
24
- post '/custom_settings', :to => 'easy_datas#custom_settings'
25
- post '/view_settings', :to => 'easy_datas#view_settings'
26
29
  end
27
- end
28
- DataModels.load_models.each do |model|
29
- match "/s/#{model.gsub("::","_")}/:id.:format", :to => "easy_datas#show",
30
- :about => "/s/#{model.gsub("::","_")}"
31
- match "/s/#{model.gsub("::","_").pluralize}.:format",:to => "easy_datas#show_all",
32
- :about => "/s/#{model.gsub("::","_").pluralize}"
33
- end
30
+ end
31
+ ed_routes.with_options :conditions => {:method => :post} do |ed_actions|
32
+ ed_actions.connect 'easy_datas/model_attributes_info', :action => "model_attributes_info"
33
+ ed_actions.connect 'easy_datas/load_linked_data_graph', :action => "load_linked_data_graph"
34
+ ed_actions.connect 'easy_datas/model_attributes/:model', :action => 'model_attributes'
35
+ ed_actions.connect 'easy_datas/model_attributes_edit/:model', :action => 'model_attributes_edit'
36
+ ed_actions.connect 'easy_datas/load_properties/:block/:attribute', :action => 'load_properties'
37
+ ed_actions.connect 'easy_datas/login', :action => 'login'
38
+ ed_actions.connect 'easy_datas/custom_attributes/:model', :action => 'custom_attributes'
39
+ end
34
40
 
35
-
36
-
41
+ #Ajax routes:
42
+ # map.resources :easy_datas,:member => {:load_properties => :post}
43
+ end
37
44
  end
38
45
  end
39
-
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_data
3
3
  version: !ruby/object:Gem::Version
4
- hash: 167
5
- prerelease:
4
+ hash: 161
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 92
10
- version: 0.0.92
9
+ - 95
10
+ version: 0.0.95
11
11
  platform: ruby
12
12
  authors:
13
13
  - jnillo
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-28 00:00:00 Z
18
+ date: 2012-11-27 00:00:00 +01:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: hpricot
@@ -75,16 +76,13 @@ extensions: []
75
76
  extra_rdoc_files: []
76
77
 
77
78
  files:
78
- - .gemrc
79
- - .gemtest
80
- - .gitignore
81
79
  - .idea/EasyData.iml
82
80
  - .idea/encodings.xml
83
81
  - .idea/misc.xml
84
82
  - .idea/modules.xml
85
83
  - .idea/vcs.xml
86
84
  - Gemfile
87
- - README
85
+ - README.md
88
86
  - Rakefile
89
87
  - bin/linked_data
90
88
  - easy_data.gemspec
@@ -161,6 +159,7 @@ files:
161
159
  - test/unit/linked_data_graph_test.rb
162
160
  - test/unit/model_rdf_test.rb
163
161
  - test/unit/namespaces_test.rb
162
+ has_rdoc: true
164
163
  homepage: http://rubygems.org/gem/easy_data
165
164
  licenses: []
166
165
 
@@ -190,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
189
  requirements: []
191
190
 
192
191
  rubyforge_project: easy_data
193
- rubygems_version: 1.8.10
192
+ rubygems_version: 1.3.7
194
193
  signing_key:
195
194
  specification_version: 3
196
195
  summary: Blau blau Easily publish the linked data data model of your project RoR
@@ -202,4 +201,3 @@ test_files:
202
201
  - test/unit/linked_data_graph_test.rb
203
202
  - test/unit/model_rdf_test.rb
204
203
  - test/unit/namespaces_test.rb
205
- has_rdoc:
data/.gemrc DELETED
@@ -1,8 +0,0 @@
1
- test_options:
2
- auto_test_on_install: true
3
- test_on_install: true
4
- install_development_dependencies: false
5
- test_development_dependencies: false
6
- upload_results: false
7
- force_install: true
8
- force_uninstall_on_failure: true
data/.gemtest DELETED
@@ -1 +0,0 @@
1
-
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- lib/task/testing_installation.rb
6
- bin/linked_data
7
- init.rb
8
- setup.rb
9
- .rvmrc
data/README DELETED
@@ -1,35 +0,0 @@
1
- Installation
2
- ===============
3
-
4
- In config/routes.rb at the end of routes declarations include:
5
-
6
- EasyDataRouting.routes(map)
7
-
8
- After, in [RAILS_HOME]/Rakefile copy this line:
9
-
10
- require "easy_data/tasks"
11
-
12
- At the end, execute the next task:
13
-
14
- rake easy_data:install RAILS_ENV=development
15
-
16
- To start with administration, you should assign at admin user:
17
-
18
- rake easy_data:add_user[user,pass] RAILS_ENV=development
19
-
20
- Commandas and Query
21
- ======================
22
-
23
- To get all possibles querys and URI's offers use this url:
24
-
25
- http://[project_host]/list_models
26
-
27
- After, to get any information about any model or resource, used this url:
28
-
29
- http://[project_host]/foaf/[model]/[id][.format]
30
-
31
- [model] = any model list in first url
32
- [id] = to get any information with primary key
33
- [format] = this is for advance users, get response in this format
34
-
35
-