publish_my_data 0.0.32 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/publish_my_data/small-spinner.gif +0 -0
- data/app/assets/images/publish_my_data/sort-asc.gif +0 -0
- data/app/assets/images/publish_my_data/sort-desc.gif +0 -0
- data/app/assets/javascripts/bootstrap/affix.js +126 -0
- data/app/assets/javascripts/bootstrap/alert.js +98 -0
- data/app/assets/javascripts/bootstrap/button.js +109 -0
- data/app/assets/javascripts/bootstrap/carousel.js +217 -0
- data/app/assets/javascripts/bootstrap/collapse.js +179 -0
- data/app/assets/javascripts/bootstrap/dropdown.js +154 -0
- data/app/assets/javascripts/bootstrap/modal.js +246 -0
- data/app/assets/javascripts/bootstrap/popover.js +117 -0
- data/app/assets/javascripts/bootstrap/scrollspy.js +158 -0
- data/app/assets/javascripts/bootstrap/tab.js +135 -0
- data/app/assets/javascripts/bootstrap/tooltip.js +386 -0
- data/app/assets/javascripts/bootstrap/transition.js +56 -0
- data/app/assets/javascripts/publish_my_data/grid/10_data-loader.js +142 -0
- data/app/assets/javascripts/publish_my_data/grid/20_cube-grid.js +512 -0
- data/app/assets/javascripts/publish_my_data/grid/30_cube-dimension.js +77 -0
- data/app/assets/javascripts/publish_my_data/grid/40_cube-dimension-dropdown.js +87 -0
- data/app/assets/javascripts/publish_my_data/grid/45_cube-dimension-label.js +58 -0
- data/app/assets/javascripts/publish_my_data/grid/50_cube-dimensions-controls.js +336 -0
- data/app/assets/javascripts/publish_my_data/grid/60_dataset_cube_grid.js +187 -0
- data/app/assets/javascripts/publish_my_data/grid/70_sparql_results_grid.js +135 -0
- data/app/assets/javascripts/publish_my_data/select_text.js +27 -0
- data/app/assets/javascripts/publish_my_data.js +3 -0
- data/app/assets/javascripts/slick_grid/10_event-drag.js +402 -0
- data/app/assets/javascripts/slick_grid/20_slick-core.js +458 -0
- data/app/assets/javascripts/slick_grid/30_slick-grid.js +3295 -0
- data/app/assets/stylesheets/bootstrap/_alerts.scss +67 -0
- data/app/assets/stylesheets/bootstrap/_badges.scss +51 -0
- data/app/assets/stylesheets/bootstrap/_breadcrumbs.scss +23 -0
- data/app/assets/stylesheets/bootstrap/_button-groups.scss +248 -0
- data/app/assets/stylesheets/bootstrap/_buttons.scss +160 -0
- data/app/assets/stylesheets/bootstrap/_carousel.scss +209 -0
- data/app/assets/stylesheets/bootstrap/_close.scss +33 -0
- data/app/assets/stylesheets/bootstrap/_code.scss +56 -0
- data/app/assets/stylesheets/bootstrap/_component-animations.scss +29 -0
- data/app/assets/stylesheets/bootstrap/_dropdowns.scss +194 -0
- data/app/assets/stylesheets/bootstrap/_forms.scss +350 -0
- data/app/assets/stylesheets/bootstrap/_glyphicons.scss +232 -0
- data/app/assets/stylesheets/bootstrap/_grid.scss +346 -0
- data/app/assets/stylesheets/bootstrap/_input-groups.scss +127 -0
- data/app/assets/stylesheets/bootstrap/_jumbotron.scss +40 -0
- data/app/assets/stylesheets/bootstrap/_labels.scss +58 -0
- data/app/assets/stylesheets/bootstrap/_list-group.scss +88 -0
- data/app/assets/stylesheets/bootstrap/_media.scss +56 -0
- data/app/assets/stylesheets/bootstrap/_mixins.scss +728 -0
- data/app/assets/stylesheets/bootstrap/_modals.scss +145 -0
- data/app/assets/stylesheets/bootstrap/_navbar.scss +625 -0
- data/app/assets/stylesheets/bootstrap/_navs.scss +229 -0
- data/app/assets/stylesheets/bootstrap/_normalize.scss +396 -0
- data/app/assets/stylesheets/bootstrap/_pager.scss +55 -0
- data/app/assets/stylesheets/bootstrap/_pagination.scss +83 -0
- data/app/assets/stylesheets/bootstrap/_panels.scss +148 -0
- data/app/assets/stylesheets/bootstrap/_popovers.scss +133 -0
- data/app/assets/stylesheets/bootstrap/_print.scss +100 -0
- data/app/assets/stylesheets/bootstrap/_progress-bars.scss +95 -0
- data/app/assets/stylesheets/bootstrap/_responsive-utilities.scss +209 -0
- data/app/assets/stylesheets/bootstrap/_scaffolding.scss +130 -0
- data/app/assets/stylesheets/bootstrap/_tables.scss +236 -0
- data/app/assets/stylesheets/bootstrap/_theme.scss +232 -0
- data/app/assets/stylesheets/bootstrap/_thumbnails.scss +31 -0
- data/app/assets/stylesheets/bootstrap/_tooltip.scss +95 -0
- data/app/assets/stylesheets/bootstrap/_type.scss +238 -0
- data/app/assets/stylesheets/bootstrap/_utilities.scss +42 -0
- data/app/assets/stylesheets/bootstrap/_variables.scss +620 -0
- data/app/assets/stylesheets/bootstrap/_wells.scss +29 -0
- data/app/assets/stylesheets/bootstrap/bootstrap.scss +59 -0
- data/app/assets/stylesheets/publish_my_data/core.scss +244 -0
- data/app/assets/stylesheets/publish_my_data/data_grid.scss +103 -0
- data/app/assets/stylesheets/publish_my_data/variables.scss +1 -0
- data/app/assets/stylesheets/{publish_my_data.css → publish_my_data.scss} +13 -2
- data/app/assets/stylesheets/slick_grid/slick_grid.scss +155 -0
- data/app/assets/stylesheets/slick_grid/slick_grid_default_theme.scss +97 -0
- data/app/controllers/concerns/publish_my_data/data_cube.rb +42 -0
- data/app/controllers/publish_my_data/data_cube/dimensions_controller.rb +58 -0
- data/app/controllers/publish_my_data/data_cube/observations_controller.rb +54 -0
- data/app/controllers/publish_my_data/datasets_controller.rb +0 -11
- data/app/controllers/publish_my_data/example_resources_controller.rb +11 -0
- data/app/controllers/publish_my_data/home_controller.rb +4 -0
- data/app/controllers/publish_my_data/information_resources_controller.rb +0 -13
- data/app/helpers/publish_my_data/application_helper.rb +66 -0
- data/app/helpers/publish_my_data/crumb_helper.rb +61 -0
- data/app/helpers/publish_my_data/datasets_helper.rb +31 -0
- data/app/helpers/publish_my_data/resources_helper.rb +24 -0
- data/app/models/concerns/publish_my_data/cube_results.rb +51 -0
- data/app/models/concerns/publish_my_data/dataset_powers.rb +13 -0
- data/app/models/publish_my_data/data_cube/cube.rb +358 -0
- data/app/models/publish_my_data/data_cube/dimension.rb +58 -0
- data/app/models/publish_my_data/vocabulary.rb +0 -4
- data/app/views/layouts/publish_my_data/application.html.haml +18 -0
- data/app/views/layouts/publish_my_data/error.html.haml +21 -0
- data/app/views/publish_my_data/classes/show.html.haml +28 -0
- data/app/views/publish_my_data/concept_schemes/show.html.haml +79 -0
- data/app/views/publish_my_data/concepts/show.html.haml +28 -0
- data/app/views/publish_my_data/data_cube/_controls.html.haml +19 -0
- data/app/views/publish_my_data/data_cube/_grid.html.haml +37 -0
- data/app/views/publish_my_data/datasets/_example_resources.html.haml +47 -0
- data/app/views/publish_my_data/datasets/_types_table.html.erb +33 -0
- data/app/views/publish_my_data/datasets/index.html.haml +32 -0
- data/app/views/publish_my_data/datasets/show.html.haml +186 -0
- data/app/views/publish_my_data/errors/not_found.html.haml +18 -0
- data/app/views/publish_my_data/errors/response_too_large.html.haml +16 -0
- data/app/views/publish_my_data/errors/timeout.html.haml +16 -0
- data/app/views/publish_my_data/errors/uncaught.html.haml +16 -0
- data/app/views/publish_my_data/example_resources/index.js.erb +1 -0
- data/app/views/publish_my_data/home/accessibility.html.haml +1 -0
- data/app/views/publish_my_data/home/docs.html.haml +1 -0
- data/app/views/publish_my_data/home/home.html.haml +5 -0
- data/app/views/publish_my_data/home/privacy.html.haml +1 -0
- data/app/views/publish_my_data/ontologies/show.html.haml +100 -0
- data/app/views/publish_my_data/properties/show.html.haml +28 -0
- data/app/views/publish_my_data/resources/_resource_data.html.haml +16 -0
- data/app/views/publish_my_data/resources/_sparql_section.html.haml +22 -0
- data/app/views/publish_my_data/resources/index.html.haml +37 -0
- data/app/views/publish_my_data/resources/show.html.haml +36 -0
- data/app/views/publish_my_data/shared/_browser_warning.html.haml +4 -0
- data/app/views/publish_my_data/shared/_deprecation_notice.html.haml +8 -0
- data/app/views/publish_my_data/shared/_footer.html.haml +11 -0
- data/app/views/publish_my_data/shared/_google_analytics.html.haml +11 -0
- data/app/views/publish_my_data/shared/_logo.html.haml +1 -0
- data/app/views/publish_my_data/shared/_meta_title.html.haml +2 -0
- data/app/views/publish_my_data/sparql/_form.html.haml +28 -0
- data/app/views/publish_my_data/sparql/_formats_dropdown.html.haml +11 -0
- data/app/views/publish_my_data/sparql/endpoint.html.haml +125 -0
- data/app/views/publish_my_data/sparql/formats_dropdowns/_ask.html.haml +7 -0
- data/app/views/publish_my_data/sparql/formats_dropdowns/_construct.html.haml +7 -0
- data/app/views/publish_my_data/sparql/formats_dropdowns/_describe.html.haml +1 -0
- data/app/views/publish_my_data/sparql/formats_dropdowns/_select.html.haml +9 -0
- data/app/views/publish_my_data/themes/index.html.haml +30 -0
- data/app/views/publish_my_data/themes/show.html.haml +43 -0
- data/config/routes.rb +20 -5
- data/lib/publish_my_data/version.rb +1 -1
- data/lib/publish_my_data.rb +7 -12
- data/spec/controllers/publish_my_data/datasets_controller_spec.rb +0 -75
- data/spec/controllers/publish_my_data/information_resources_controller_spec.rb +2 -11
- data/spec/dummy/config/environments/development.rb +0 -4
- data/spec/dummy/config/environments/test.rb +0 -4
- data/spec/dummy/log/test.log +62962 -0
- data/spec/dummy/tmp/cache/sass/e509ccd4d793d2c162d70125e9f3656b6c28f357/(__TEMPLATE__)c +0 -0
- data/spec/features/running_a_sparql_query_spec.rb +1 -1
- data/spec/features/uri_dereferencing_spec.rb +1 -1
- metadata +200 -58
- data/app/controllers/concerns/publish_my_data/data_download.rb +0 -22
- data/app/controllers/publish_my_data/vocabularies_controller.rb +0 -18
- data/app/views/layouts/publish_my_data/application.html.erb +0 -13
- data/app/views/layouts/publish_my_data/error.html.erb +0 -13
- data/app/views/publish_my_data/classes/show.html.erb +0 -3
- data/app/views/publish_my_data/concept_schemes/_concepts.html.erb +0 -18
- data/app/views/publish_my_data/concept_schemes/show.html.erb +0 -11
- data/app/views/publish_my_data/concepts/show.html.erb +0 -3
- data/app/views/publish_my_data/datasets/index.html.erb +0 -20
- data/app/views/publish_my_data/datasets/show.html.erb +0 -18
- data/app/views/publish_my_data/errors/not_found.html.erb +0 -1
- data/app/views/publish_my_data/errors/response_too_large.html.erb +0 -1
- data/app/views/publish_my_data/errors/timeout.html.erb +0 -1
- data/app/views/publish_my_data/errors/uncaught.html.erb +0 -6
- data/app/views/publish_my_data/ontologies/show.html.erb +0 -17
- data/app/views/publish_my_data/properties/show.html.erb +0 -3
- data/app/views/publish_my_data/resources/_predicates_table.html.erb +0 -30
- data/app/views/publish_my_data/resources/_predicates_table_head.html.erb +0 -6
- data/app/views/publish_my_data/resources/_resource_formats.html.erb +0 -4
- data/app/views/publish_my_data/resources/_summaries.html.erb +0 -18
- data/app/views/publish_my_data/resources/_uri_and_label.html.erb +0 -3
- data/app/views/publish_my_data/resources/index.html.erb +0 -40
- data/app/views/publish_my_data/resources/show.html.erb +0 -3
- data/app/views/publish_my_data/sparql/_ask_formats.html.erb +0 -3
- data/app/views/publish_my_data/sparql/_construct_formats.html.erb +0 -3
- data/app/views/publish_my_data/sparql/_describe_formats.html.erb +0 -1
- data/app/views/publish_my_data/sparql/_error_message.html.erb +0 -3
- data/app/views/publish_my_data/sparql/_form.html.erb +0 -4
- data/app/views/publish_my_data/sparql/_formats.html.erb +0 -6
- data/app/views/publish_my_data/sparql/_pagination.html.erb +0 -6
- data/app/views/publish_my_data/sparql/_results.html.erb +0 -5
- data/app/views/publish_my_data/sparql/_results_data.html.erb +0 -4
- data/app/views/publish_my_data/sparql/_select_formats.html.erb +0 -3
- data/app/views/publish_my_data/sparql/endpoint.html.erb +0 -10
- data/app/views/publish_my_data/themes/index.html.erb +0 -13
- data/app/views/publish_my_data/themes/show.html.erb +0 -15
- data/config/initializers/20_s3_setup.rb +0 -4
- data/spec/controllers/publish_my_data/vocabularies_controller_spec.rb +0 -14
- data/spec/support/data_download.rb +0 -60
@@ -0,0 +1,54 @@
|
|
1
|
+
module PublishMyData
|
2
|
+
module DataCube
|
3
|
+
class ObservationsController < PublishMyData::ApplicationController
|
4
|
+
|
5
|
+
include PublishMyData::DataCubeController
|
6
|
+
|
7
|
+
before_filter :get_dimensions, :get_pagination_params, :only => [:index]
|
8
|
+
|
9
|
+
# GET /data/:dataset_slug/cube/observations
|
10
|
+
# params:
|
11
|
+
# rows_dimension = http://row-dimension-uri
|
12
|
+
# columns_dimension = http://column-dimension-uri
|
13
|
+
# http://locked-dimension-1-uri: http://locked-dimension-1-value-uri
|
14
|
+
# order_by_column = http://column-uri (optional - will order by rows labels if not provided).
|
15
|
+
# order_desc = true/false (default false)
|
16
|
+
# page (default 1)
|
17
|
+
# per_page (default 500, min 1, max 5000).
|
18
|
+
def index
|
19
|
+
|
20
|
+
respond_to do |format|
|
21
|
+
format.json do
|
22
|
+
render json: @cube.grid_observations(
|
23
|
+
@page,
|
24
|
+
@per_page,
|
25
|
+
@rows_dimension_uri,
|
26
|
+
@columns_dimension_uri,
|
27
|
+
@locked_dimensions,
|
28
|
+
params[:order_desc], # optional
|
29
|
+
params[:order_by_column] #optional
|
30
|
+
)
|
31
|
+
end
|
32
|
+
# this doesn't use the page and per page params send to the controller.
|
33
|
+
# it returns the whole result set as one .
|
34
|
+
format.csv do
|
35
|
+
filename = "#{@dataset.slug.gsub("/", "|")}.csv"
|
36
|
+
headers["Content-Type"] ||= 'text/csv'
|
37
|
+
headers["Content-Disposition"] = "attachment; filename=\"#{filename}\""
|
38
|
+
|
39
|
+
render :text =>@cube.csv_observations(
|
40
|
+
@rows_dimension_uri,
|
41
|
+
@columns_dimension_uri,
|
42
|
+
@locked_dimensions,
|
43
|
+
params[:order_desc], # optional
|
44
|
+
params[:order_by_column] #optional
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -2,20 +2,9 @@ require_dependency "publish_my_data/application_controller"
|
|
2
2
|
|
3
3
|
module PublishMyData
|
4
4
|
class DatasetsController < ApplicationController
|
5
|
-
include PublishMyData::DataDownload
|
6
5
|
|
7
6
|
respond_to :html, :ttl, :rdf, :nt, :json, :text
|
8
7
|
|
9
|
-
def dump
|
10
|
-
@dataset = Dataset.find_by_slug(params[:id])
|
11
|
-
# if we can't find a current download it's cos we haven't generated it yet since ds was modified
|
12
|
-
# ... and we should 404.
|
13
|
-
url = find_latest_download_url_for_resource(@dataset)
|
14
|
-
raise Tripod::Errors::ResourceNotFound unless url
|
15
|
-
|
16
|
-
redirect_to url
|
17
|
-
end
|
18
|
-
|
19
8
|
# /data?page=2&per_page=10
|
20
9
|
def index
|
21
10
|
@pagination_params = ResourcePaginationParams.from_request(request)
|
@@ -4,7 +4,6 @@ module PublishMyData
|
|
4
4
|
class InformationResourcesController < ApplicationController
|
5
5
|
|
6
6
|
include ResourceRendering
|
7
|
-
include DataDownload
|
8
7
|
|
9
8
|
respond_to :html, :ttl, :rdf, :nt, :json, :text
|
10
9
|
|
@@ -22,18 +21,6 @@ module PublishMyData
|
|
22
21
|
render_resource(resource)
|
23
22
|
end
|
24
23
|
|
25
|
-
# http://example.com/def/blah/dump
|
26
|
-
def dump
|
27
|
-
uri = "http://#{PublishMyData.local_domain}/def/#{params[:id]}"
|
28
|
-
resource = PublishMyData::Resource.find(uri, local: true)
|
29
|
-
|
30
|
-
# if we can't find a current download it's cos we haven't generated it yet since ds was modified
|
31
|
-
# ... and we should 404.
|
32
|
-
url = find_latest_download_url_for_resource(resource)
|
33
|
-
raise Tripod::Errors::ResourceNotFound unless url
|
34
|
-
|
35
|
-
redirect_to url
|
36
|
-
end
|
37
24
|
end
|
38
25
|
|
39
26
|
end
|
@@ -1,4 +1,70 @@
|
|
1
1
|
module PublishMyData
|
2
2
|
module ApplicationHelper
|
3
|
+
def page_title(title=nil)
|
4
|
+
content_for :page_title do
|
5
|
+
"| #{title}"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def page_description(description)
|
10
|
+
content_for :page_description do
|
11
|
+
content_tag(:meta, '', name: 'description', content: description)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def link_to_home
|
16
|
+
link_to 'Home', '/'
|
17
|
+
end
|
18
|
+
|
19
|
+
def pagination_required?(resources, pagination_params)
|
20
|
+
(resources.total_count > pagination_params.per_page)
|
21
|
+
end
|
22
|
+
|
23
|
+
def top_section(h1=nil, h2=nil, h1_label=nil, h2_label=nil, &block)
|
24
|
+
content_tag(:section, id: 'top') do
|
25
|
+
main_content = ""
|
26
|
+
main_content << content_tag(:div, class: 'row container') do
|
27
|
+
content_tag(:div, class: 'sixteen columns') do
|
28
|
+
top_row_content = ""
|
29
|
+
top_row_content << content_tag(:h3, h1_label) if h1_label
|
30
|
+
top_row_content << content_tag(:h1, h1) if h1
|
31
|
+
top_row_content << content_tag(:h3, h2_label) if h2_label
|
32
|
+
top_row_content << content_tag(:h2, h2, class: "hardwrap click-to-select") if h2
|
33
|
+
top_row_content.html_safe
|
34
|
+
end
|
35
|
+
end
|
36
|
+
main_content << capture(&block) if block && capture(&block)
|
37
|
+
main_content.html_safe
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def bottom_formats_section(message=nil, *links)
|
42
|
+
content_tag(:section, id: 'bottom') do
|
43
|
+
content_tag(:div, class: 'row container') do
|
44
|
+
content_tag(:div, class: 'sixteen columns') do
|
45
|
+
content_tag(:ul) do
|
46
|
+
list = ""
|
47
|
+
list << content_tag(:li) do
|
48
|
+
if message
|
49
|
+
"This <strong>#{message}</strong> is available as".html_safe
|
50
|
+
else
|
51
|
+
"This <strong>page</strong> is available as".html_safe
|
52
|
+
end
|
53
|
+
end
|
54
|
+
#always show HTML (doens't link to anywhere)
|
55
|
+
list << content_tag(:li) do
|
56
|
+
content_tag :a, "HTML", class: "selected"
|
57
|
+
end
|
58
|
+
|
59
|
+
list << links.reduce('') { |c, link|
|
60
|
+
c << content_tag(:li, link)
|
61
|
+
}.html_safe
|
62
|
+
|
63
|
+
list.html_safe
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
3
69
|
end
|
4
70
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module PublishMyData
|
2
|
+
module CrumbHelper
|
3
|
+
|
4
|
+
def crumb_list_item(link_text, link_path, css_class=nil)
|
5
|
+
content_tag :li, :class => css_class do
|
6
|
+
link_to link_text, link_path
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def data_home_crumb
|
11
|
+
crumb_list_item("Home", "/")
|
12
|
+
end
|
13
|
+
|
14
|
+
def themes_crumb
|
15
|
+
crumb_list_item("All Themes", themes_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def theme_crumb(theme, is_final=false)
|
19
|
+
link_text = "Theme"
|
20
|
+
link_text += ": <b>#{truncate(theme.label.to_s, length: 12)}</b>" unless is_final
|
21
|
+
crumb_list_item(raw(link_text), theme_path(theme), "datasets")
|
22
|
+
end
|
23
|
+
|
24
|
+
def dataset_crumb(dataset, is_final=false)
|
25
|
+
link_text = "Dataset"
|
26
|
+
link_text += ": <b>#{truncate(dataset.title.to_s, length: 12)}</b>" unless is_final
|
27
|
+
crumb_list_item(raw(link_text), dataset_path(dataset), "dataset")
|
28
|
+
end
|
29
|
+
|
30
|
+
def type_crumb(rdf_type_uri, dataset, is_final=false)
|
31
|
+
if is_final
|
32
|
+
link_text = "Resources of type"
|
33
|
+
truncate_length = 20
|
34
|
+
else
|
35
|
+
link_text = "Type"
|
36
|
+
truncate_length = 10
|
37
|
+
end
|
38
|
+
rdf_type = RdfType.find(rdf_type_uri) rescue nil
|
39
|
+
type_label = rdf_type.label if rdf_type && rdf_type.label.present?
|
40
|
+
link_text += ": <b>#{truncate(type_label.to_s, length: truncate_length)}</b>" if type_label
|
41
|
+
crumb_list_item(raw(link_text), list_resources_path(:dataset => dataset, :type_uri => rdf_type_uri), "type")
|
42
|
+
end
|
43
|
+
|
44
|
+
def resource_crumb(text="Resource")
|
45
|
+
crumb_list_item(text, "#", "resource")
|
46
|
+
end
|
47
|
+
|
48
|
+
def ontology_crumb(ontology, is_final=false)
|
49
|
+
link_text = "Ontology"
|
50
|
+
link_text += ": <b>#{truncate(ontology.label.to_s, length: 12)}</b>" unless is_final || ontology.label.blank?
|
51
|
+
crumb_list_item(raw(link_text), resource_path_from_uri(ontology.uri), "docs")
|
52
|
+
end
|
53
|
+
|
54
|
+
def concept_scheme_crumb(concept_scheme, is_final=false)
|
55
|
+
link_text = "Concept Scheme"
|
56
|
+
link_text += ": <b>#{truncate(concept_scheme.label.to_s, length: 12)}</b>" unless is_final || concept_scheme.label.blank?
|
57
|
+
crumb_list_item(raw(link_text), resource_path_from_uri(concept_scheme.uri), "docs")
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PublishMyData
|
2
|
+
module DatasetsHelper
|
3
|
+
def formatted_date(date_string)
|
4
|
+
DateTime.parse(date_string).to_s(:long)
|
5
|
+
end
|
6
|
+
|
7
|
+
def link_to_resource_uri_or_label(resource, term)
|
8
|
+
link_to resource_uri_or_label(resource, term), resource_path_from_uri(term)
|
9
|
+
end
|
10
|
+
|
11
|
+
def vocabulary_class(dataset, uri)
|
12
|
+
dataset.ontologies.each_with_index do |ontology, index|
|
13
|
+
uris = ontology.classes.map(&:uri) + ontology.properties.map(&:uri)
|
14
|
+
return "ontology_#{index}" if uris.any?{|u| uri == u}
|
15
|
+
end
|
16
|
+
dataset.concept_schemes.each_with_index do |concept_scheme, index|
|
17
|
+
uris = concept_scheme.concepts.map(&:uri)
|
18
|
+
return "concept_scheme_#{index}" if uris.any?{|u| uri == u}
|
19
|
+
end
|
20
|
+
return ''
|
21
|
+
end
|
22
|
+
|
23
|
+
def example_resource_for_type(dataset, type)
|
24
|
+
dataset.example_resources.detect {|r| r.rdf_type.include?(type.uri) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def types_for_example_resource(dataset, example_resource)
|
28
|
+
dataset.types.select {|t| example_resource.rdf_type.include?(t.uri) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -24,5 +24,29 @@ module PublishMyData
|
|
24
24
|
publish_my_data.show_resource_path(:uri => uri.to_s)
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
def resources_list_table_title
|
29
|
+
|
30
|
+
str = "<strong> #{pluralize @resources.total_count, 'resource'}</strong>"
|
31
|
+
if @type_filter
|
32
|
+
str += " of type "
|
33
|
+
if @type
|
34
|
+
str += link_to @type.label || @type.uri, resource_path_from_uri(@type.uri)
|
35
|
+
else
|
36
|
+
str += link_to @type_filter, resource_path_from_uri(@type_filter)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
if @dataset_filter
|
41
|
+
str += " in dataset "
|
42
|
+
if @dataset
|
43
|
+
str += link_to @dataset.title, @dataset
|
44
|
+
else
|
45
|
+
str += link_to @dataset_filter, resource_path_from_uri(@dataset_filter)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
str.html_safe
|
50
|
+
end
|
27
51
|
end
|
28
52
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module PublishMyData
|
4
|
+
module CubeResults
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
def loop_and_page_sparql_query(sparql, page_size=5000)
|
8
|
+
results = []
|
9
|
+
try_again = true
|
10
|
+
page = 1
|
11
|
+
while try_again
|
12
|
+
page_start = Time.now
|
13
|
+
# we need to paginate
|
14
|
+
sparql_query = PublishMyData::SparqlQuery.new(sparql, {:request_format => :json} )
|
15
|
+
sparql_query_result = JSON.parse(sparql_query.paginate(page, page_size).to_s)["results"]["bindings"]
|
16
|
+
try_again = (sparql_query_result.length == page_size) # this page is full - keep going!
|
17
|
+
page += 1
|
18
|
+
results += sparql_query_result
|
19
|
+
Rails.logger.debug(">>>> getting page of sparql took #{Time.now - page_start}s")
|
20
|
+
end
|
21
|
+
results
|
22
|
+
end
|
23
|
+
|
24
|
+
# pass sparql results and convert to a minimal hash
|
25
|
+
# ready for conversion to json.
|
26
|
+
def uris_and_labels_only(sparql_results)
|
27
|
+
|
28
|
+
start_uris_and_labels = Time.now
|
29
|
+
|
30
|
+
uris_and_labels_array = []
|
31
|
+
uris_hash = {}
|
32
|
+
|
33
|
+
# use a hash so we only get one result per label
|
34
|
+
sparql_results.each do |result|
|
35
|
+
uri = result["uri"]["value"]
|
36
|
+
label = result["label"]["value"] if result["label"]
|
37
|
+
uris_hash[uri] ||= label # only store the label if we've not got one
|
38
|
+
end
|
39
|
+
|
40
|
+
# now go through and make it into a hash
|
41
|
+
uris_hash.each_pair do |uri, label|
|
42
|
+
uris_and_labels_array << {uri: uri, label: label }
|
43
|
+
end
|
44
|
+
|
45
|
+
uris_and_labels_array
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
@@ -72,6 +72,19 @@ module PublishMyData
|
|
72
72
|
Theme.find(self.theme.to_s) rescue nil
|
73
73
|
end
|
74
74
|
|
75
|
+
def is_cube?
|
76
|
+
# return false # return false for now!!
|
77
|
+
!!(Resource.where("?uri <http://purl.org/linked-data/cube#dataSet> <#{self.uri}>").graph(self.data_graph_uri).count > 0)
|
78
|
+
end
|
79
|
+
|
80
|
+
def cube
|
81
|
+
if is_cube?
|
82
|
+
PublishMyData::DataCube::Cube.new(self)
|
83
|
+
else
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
75
88
|
module ClassMethods
|
76
89
|
include PublishMyData::AllFeatures::ClassMethods
|
77
90
|
|