publish_my_data 1.3.19 → 1.3.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -75,9 +75,9 @@
75
75
  // 1. the label
76
76
  ////////////////////
77
77
  var field = $('<div class="field"></div>');
78
-
79
- console.log(lockedDimensionsSelector);
80
-
78
+
79
+ // console.log(lockedDimensionsSelector);
80
+
81
81
  $(lockedDimensionsSelector).append(field);
82
82
 
83
83
  // 1. the label for this dimension
@@ -97,7 +97,7 @@
97
97
  valuesDropdown.disable(); // create as disbaled
98
98
 
99
99
  // add it to our collection
100
- console.log(valuesDropdown);
100
+ // console.log(valuesDropdown);
101
101
  lockedDimensionValuesDropdowns.push(valuesDropdown);
102
102
 
103
103
  // use the special locked dimension wirer-upper for the locked dims.
@@ -337,4 +337,4 @@
337
337
 
338
338
 
339
339
  $.extend(true, window, { Swirrl: { CubeDimensionsControls: CubeDimensionsControls }});
340
- })(jQuery);
340
+ })(jQuery);
@@ -123,35 +123,111 @@
123
123
  // unsubscribe
124
124
  cubeGrid.onCubeDimensionsReady.unsubscribe(setInitialGridStatus);
125
125
 
126
- $.ajax({
127
- url: "http://" + siteDomain + "/data/" + datasetSlug + "/cube/recommended_dimensions.json",
128
- dataType: 'json',
129
- success: function(recommendedDimensions){
130
-
131
- // for locked dims, just set the uris
132
- for ( var dim in recommendedDimensions.locked_dimensions ) {
133
- cubeGrid.setLockedDimensionValue( dim, recommendedDimensions.locked_dimensions[dim] )
134
- }
126
+ if (queryStringHasInitialDimensions()) {
127
+ var initialDimensions = getDimensionsFromParams();
128
+ loadInitialDimensions(initialDimensions);
129
+ } else {
130
+ // we'll need to load in the default dimensions then
131
+ $.ajax({
132
+ url: "http://" + siteDomain + "/data/" + datasetSlug + "/cube/recommended_dimensions.json",
133
+ dataType: 'json',
134
+ success: function(recommendedDimensions){
135
+ loadInitialDimensions(recommendedDimensions);
136
+ },
137
+ error: function(jqXHR, _, _) {
138
+ setGridError(jqXHR.status);
139
+ }
140
+ });
141
+ }
142
+ }
135
143
 
136
- // for the other dimensions, find the appropriate object
137
- var columnsDimension = cubeGrid.getDimensionWithUri(recommendedDimensions.columns_dimension);
138
- var rowsDimension = cubeGrid.getDimensionWithUri(recommendedDimensions.rows_dimension);
144
+ /*
139
145
 
140
- cubeGrid.setColumnsDimension(columnsDimension);
141
- cubeGrid.setRowsDimension(rowsDimension);
142
- cubeGrid.showCSVDownloadLink();
143
- },
144
- error: function(jqXHR, _, _) {
145
- setGridError(jqXHR.status);
146
+ The grid viewer will attempt to load initial settings from the query string failing this, it requests default dimensions via ajax.
147
+
148
+ Example query string:
149
+
150
+ http://127.0.0.1:3000/data/school-attainment?rows_dimension=http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2FrefSCQFLevel&columns_dimension=http%3A%2F%2Fdata.opendatascotland.org%2Fdef%2Fstatistical-dimensions%2FrefPeriod&http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2FrefQualificationsAwarded=http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2Fconcept%2Fschools%2Fqualifications-awarded%2F5-or-more&http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2FrefSchoolSet=http%3A%2F%2Flinked.glasgow.gov.uk%2Fid%2Furban-assets%2Fschools%2Fschool-set%2Fglasgow&http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2FrefYearGroup=http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2Fconcept%2Fschools%2Fyear-group%2Fs4
151
+
152
+ or (same thing again, with friendlier formatting)
153
+
154
+ http://127.0.0.1:3000/data/school-attainment?
155
+ rows_dimension=http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2FrefSCQFLevel
156
+ &columns_dimension=http%3A%2F%2Fdata.opendatascotland.org%2Fdef%2Fstatistical-dimensions%2FrefPeriod
157
+ &http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2FrefQualificationsAwarded=http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2Fconcept%2Fschools%2Fqualifications-awarded%2F5-or-more
158
+ &http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2FrefSchoolSet=http%3A%2F%2Flinked.glasgow.gov.uk%2Fid%2Furban-assets%2Fschools%2Fschool-set%2Fglasgow
159
+ &http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2FrefYearGroup=http%3A%2F%2Flinked.glasgow.gov.uk%2Fdef%2Fconcept%2Fschools%2Fyear-group%2Fs4
160
+
161
+ */
162
+
163
+ function getRowsDimensionFromParams(){
164
+ return params.rows_dimension;
165
+ }
166
+
167
+ function getColsDimensionFromParams(){
168
+ return params.columns_dimension;
169
+ }
170
+
171
+ function getLockedDimensionsFromParams(){
172
+ var locked = {};
173
+ for(var key in params){
174
+ if (looksLikePredicate(key)){
175
+ var predicate = decodeURIComponent(key);
176
+ var val = decodeURIComponent(params[key]);
177
+ locked[predicate] = val;
146
178
  }
147
- });
179
+ }
180
+ return locked;
181
+ }
148
182
 
183
+ function looksLikePredicate(candidate){
184
+ if (candidate === "rows_dimension") return false;
185
+ if (candidate === "columns_dimension") return false
186
+ return true; // TODO - assumes that we don't have any other query params probably better to actually look for something that begins http://
187
+ }
188
+
189
+ function getDimensionsFromParams(){
190
+ var initalDimensions = {};
191
+ initalDimensions["rows_dimension"] = decodeURIComponent(getRowsDimensionFromParams());
192
+ initalDimensions["columns_dimension"] = decodeURIComponent(getColsDimensionFromParams());
193
+ initalDimensions["locked_dimensions"] = getLockedDimensionsFromParams();
194
+ return initalDimensions;
195
+ }
196
+ function queryStringHasInitialDimensions(){
197
+ return(getColsDimensionFromParams() && getColsDimensionFromParams());
198
+ }
199
+
200
+ function loadInitialDimensions(initalDimensions){
201
+ // for locked dims, just set the uris
202
+ for ( var dim in initalDimensions.locked_dimensions ) {
203
+ cubeGrid.setLockedDimensionValue( dim, initalDimensions.locked_dimensions[dim] )
204
+ }
205
+ // for the other dimensions, find the appropriate object
206
+ var columnsDimension = cubeGrid.getDimensionWithUri(initalDimensions.columns_dimension);
207
+ var rowsDimension = cubeGrid.getDimensionWithUri(initalDimensions.rows_dimension);
208
+
209
+ cubeGrid.setColumnsDimension(columnsDimension);
210
+ cubeGrid.setRowsDimension(rowsDimension);
211
+ cubeGrid.showCSVDownloadLink();
212
+ }
213
+
214
+ function decomposeQueryString(){
215
+ var params = {};
216
+ var qs = window.location.search.substring(1);
217
+ var qss = qs.split("&");
218
+ for (var i=0;i<qss.length;i++) {
219
+ var q = qss[i].split("=");
220
+ params[q[0]]=q[1];
221
+ }
222
+ return params;
149
223
  }
150
224
 
151
225
  // set initial status
152
226
  setTitle('&nbsp;');
153
227
  setGridStatus('Initializing grid...', true);
154
228
 
229
+ var params = decomposeQueryString();
230
+
155
231
  var cubeGrid = new Swirrl.CubeGrid(elementSelector, siteDomain, datasetSlug, pageSize);
156
232
 
157
233
  cubeGrid.onAjaxError.subscribe(function (e, args) {
@@ -184,4 +260,4 @@
184
260
 
185
261
 
186
262
  $.extend(true, window, { Swirrl: { DatasetCubeGrid: DatasetCubeGrid }});
187
- })(jQuery);
263
+ })(jQuery);
@@ -11,7 +11,7 @@
11
11
  .hidden_when_javascript_available
12
12
  - @additional_formats.each do |f|
13
13
  = label(f[:format])
14
- .codesmall.click_to_select=f[:link]
14
+ %code.codesmall.block.click_to_select=f[:link]
15
15
  =link_to "(download #{f[:format]})", f[:link]
16
16
 
17
17
  :javascript
@@ -19,4 +19,4 @@
19
19
  e.preventDefault();
20
20
  $(e.target).parent().hide();
21
21
  $(e.target).closest(".pmd_row").find(".hidden_when_javascript_available").show();
22
- });
22
+ });
@@ -25,7 +25,9 @@
25
25
  - if resource.data_graph_uri
26
26
  %p
27
27
  Resources in this dataset are stored a named graph. This graph can be used in SPARQL queries to restrict results to this dataset.
28
- = content_tag :kbd, resource.data_graph_uri, class:'click_to_select', style:"font-size:1em; margin-bottom:12px; display:block;"
28
+
29
+ = content_tag :code, resource.data_graph_uri, class:'click_to_select block'
30
+
29
31
  %p
30
32
  For a live example of how to use this, #{link_to_sparql_tool_with_graph(resource.data_graph_uri)}.
31
33
  - else
@@ -1,3 +1,3 @@
1
1
  module PublishMyData
2
- VERSION = "1.3.19"
2
+ VERSION = "1.3.20"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publish_my_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.19
4
+ version: 1.3.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -543,7 +543,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
543
543
  version: '0'
544
544
  segments:
545
545
  - 0
546
- hash: -4509544715574366370
546
+ hash: 2450841921704577124
547
547
  required_rubygems_version: !ruby/object:Gem::Requirement
548
548
  none: false
549
549
  requirements: