publish_my_data 0.0.13 → 0.0.14
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/app/controllers/publish_my_data/application_controller.rb +28 -3
- data/app/controllers/publish_my_data/datasets_controller.rb +1 -1
- data/app/controllers/publish_my_data/resources_controller.rb +1 -1
- data/app/controllers/publish_my_data/sparql_controller.rb +1 -1
- data/app/controllers/publish_my_data/themes_controller.rb +1 -1
- data/lib/publish_my_data/concerns/controllers/sparql.rb +1 -1
- data/lib/publish_my_data/paginator.rb +1 -1
- data/lib/publish_my_data/version.rb +1 -1
- data/spec/controllers/publish_my_data/datasets_controller_spec.rb +2 -2
- data/spec/controllers/publish_my_data/resources_controller_spec.rb +1 -1
- data/spec/controllers/publish_my_data/themes_controller_spec.rb +2 -1
- data/spec/dummy/log/test.log +54661 -0
- data/spec/features/uri_dereferencing_spec.rb +1 -1
- metadata +14 -14
@@ -9,6 +9,9 @@ module PublishMyData
|
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
+
def is_request_html_format?
|
13
|
+
(request.format.to_sym || :html) == :html
|
14
|
+
end
|
12
15
|
# TODO: deal with javaascript errors - respond with 200
|
13
16
|
|
14
17
|
def handle_uncaught_error(e)
|
@@ -30,20 +33,42 @@ module PublishMyData
|
|
30
33
|
Rails.logger.info e.backtrace.join("\n")
|
31
34
|
respond_to do |format|
|
32
35
|
format.html { render(:template => "publish_my_data/errors/uncaught", :layout => 'publish_my_data/error', :status => 500) and return false }
|
33
|
-
format.any{
|
36
|
+
format.any{ render(:text => 'Error', :status => 500, :content_type => 'text/plain') and return false }
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
37
40
|
end
|
38
41
|
|
39
42
|
def handle_timeout(e)
|
43
|
+
if defined?(Raven)
|
44
|
+
Raven.capture_message("query timeout", {
|
45
|
+
:extra => {
|
46
|
+
'url' => request.url
|
47
|
+
},
|
48
|
+
:tags => {
|
49
|
+
'message_type' => 'timeout'
|
50
|
+
},
|
51
|
+
:level => 'warning'
|
52
|
+
})
|
53
|
+
end
|
40
54
|
respond_to do |format|
|
41
55
|
format.html { render(:template => "publish_my_data/errors/timeout", :layout => 'publish_my_data/error', :status => 503) and return false }
|
42
|
-
format.any {
|
56
|
+
format.any { render(:text => 'Timeout', :status => 503, :content_type => 'text/plain') and return false }
|
43
57
|
end
|
44
58
|
end
|
45
59
|
|
46
60
|
def handle_response_too_large(e)
|
61
|
+
if defined?(Raven)
|
62
|
+
Raven.capture_message("response too large", {
|
63
|
+
:extra => {
|
64
|
+
'url' => request.url
|
65
|
+
},
|
66
|
+
:tags => {
|
67
|
+
'message_type' => 'too_Large'
|
68
|
+
},
|
69
|
+
:level => 'warning'
|
70
|
+
})
|
71
|
+
end
|
47
72
|
respond_to do |format|
|
48
73
|
format.html { render(:template => "publish_my_data/errors/response_too_large", :layout => 'publish_my_data/error', :status => 400) and return false }
|
49
74
|
format.any { render(:text => "Response too large.", :status => 400, :content_type => 'text/plain') and return false }
|
@@ -56,7 +81,7 @@ module PublishMyData
|
|
56
81
|
Rails.logger.debug(e.backtrace.join("\n"))
|
57
82
|
respond_to do |format|
|
58
83
|
format.html { render(:template => "publish_my_data/errors/not_found", :layout => 'publish_my_data/error', :status => 404) and return false }
|
59
|
-
format.any {
|
84
|
+
format.any { render(:text => "Not Found" ,:status => 404, :content_type => 'text/plain') and return false }
|
60
85
|
end
|
61
86
|
end
|
62
87
|
|
@@ -67,7 +67,7 @@ module PublishMyData
|
|
67
67
|
def render_resource_with_uri(uri)
|
68
68
|
resource = Resource.find(uri)
|
69
69
|
|
70
|
-
if
|
70
|
+
if is_request_html_format?
|
71
71
|
resource.eager_load_predicate_triples!(:labels_only => true)
|
72
72
|
resource.eager_load_object_triples!(:labels_only => true)
|
73
73
|
end
|
@@ -12,7 +12,7 @@ module PublishMyData
|
|
12
12
|
@query_text = params[:query]
|
13
13
|
|
14
14
|
if @query_text.blank?
|
15
|
-
unless
|
15
|
+
unless is_request_html_format? #the html view handles this ok
|
16
16
|
render :text => "no query supplied", :status => 400
|
17
17
|
end
|
18
18
|
else
|
@@ -10,7 +10,7 @@ module PublishMyData
|
|
10
10
|
|
11
11
|
def index
|
12
12
|
# don't bother paginating this for now - there probably wont be that many themes
|
13
|
-
@themes = Theme.all.resources
|
13
|
+
@themes = Theme.all.where("?uri <#{RDF::RDFS.label}> ?label").order("?label").resources
|
14
14
|
respond_with(@themes)
|
15
15
|
end
|
16
16
|
|
@@ -38,7 +38,7 @@ module PublishMyData
|
|
38
38
|
# if there are pagination paramters, then use them
|
39
39
|
if @pagination_params.per_page && @pagination_params.page
|
40
40
|
sparql_query_result = sparql_query.paginate(@pagination_params.page, @pagination_params.per_page)
|
41
|
-
if
|
41
|
+
if is_request_html_format?
|
42
42
|
count = sparql_query.as_pagination_query(@pagination_params.page, @pagination_params.per_page, 1).count
|
43
43
|
@more_pages = (count > @pagination_params.per_page)
|
44
44
|
end
|
@@ -17,7 +17,7 @@ module PublishMyData
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.from_request(request)
|
20
|
-
self.new(per_page: request.params[:per_page], page: request.params[:page], format: request.format.to_sym)
|
20
|
+
self.new(per_page: request.params[:per_page], page: request.params[:page], format: (request.format.to_sym || :html))
|
21
21
|
end
|
22
22
|
|
23
23
|
def ==(other)
|
@@ -41,7 +41,7 @@ module PublishMyData
|
|
41
41
|
context "for a non-existent dataset slug" do
|
42
42
|
it "should return a blank body" do
|
43
43
|
get :show, id: "slug-that-doesnt-exist", use_route: :publish_my_data, :format => format
|
44
|
-
response.body.should
|
44
|
+
response.body.should == "Not Found"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -72,7 +72,7 @@ module PublishMyData
|
|
72
72
|
context "for a non-existent dataset slug" do
|
73
73
|
it "should return a blank body" do
|
74
74
|
get :show, id: "slug-that-doesnt-exist", use_route: :publish_my_data, :format => format
|
75
|
-
response.body.should
|
75
|
+
response.body.should == "Not Found"
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -66,7 +66,8 @@ module PublishMyData
|
|
66
66
|
|
67
67
|
it "should respond with an empty body" do
|
68
68
|
get :show, :id => "theme-that-doesnt-exist", :use_route => :publish_my_data, :format => 'rdf'
|
69
|
-
response.body.strip.should
|
69
|
+
response.body.strip.should == "Not Found"
|
70
|
+
|
70
71
|
end
|
71
72
|
end
|
72
73
|
end
|