|
60 | 60 | }); |
61 | 61 | }; |
62 | 62 |
|
63 | | - service.getItemMetadata = function(itemId, download=false) { |
64 | | - return $http.get(djangoUrl.reverse('api_metadata', {'item_id': itemId}), {'download': download}) |
| 63 | + service.getItemMetadata = function(itemId) { |
| 64 | + return $http.get(djangoUrl.reverse('api_metadata', {'item_id': itemId})) |
65 | 65 | .then( |
66 | 66 | function (resp) { |
67 | 67 | return resp.data; |
|
140 | 140 | curated: DcrPaths.CURATED |
141 | 141 | } |
142 | 142 |
|
143 | | - $scope.sortType = 'label'; // set the default sort type |
| 143 | + $scope.sortType = 'label'; // set the default sort type |
144 | 144 | $scope.sortDir = 'ASC'; // set the default sort order |
145 | 145 |
|
146 | 146 | $scope.browse = function($event, item, page) { |
|
175 | 175 | $scope.model.display.hasMetadata = true |
176 | 176 |
|
177 | 177 | if ($scope.model.metadata.Rights.value === 'ODC PDDL') { |
| 178 | + $scope.model.display.rightsUrl = 'http://www.opendatacommons.org/licenses/pddl/1.0/' |
178 | 179 | $scope.model.display.Rights = 'This data is made available under the Public Domain Dedication and License v1.0 whose full text can be found at <a href="http://www.opendatacommons.org/licenses/pddl/1.0/"> http://www.opendatacommons.org/licenses/pddl/1.0/ </a>'; |
179 | 180 | } else if ($scope.model.metadata.Rights.value === 'CC0') { |
| 181 | + $scope.model.display.rightsUrl = 'https://creativecommons.org/share-your-work/public-domain/cc0/' |
180 | 182 | $scope.model.display.Rights = '<a rel="license" href="https://creativecommons.org/share-your-work/public-domain/cc0/"><img alt="Creative Commons License Badge" style="border-width:0" src="' + window.location.origin + '/static/img/CC0.png"/></a><br />This work is available in the public domain under the <a rel="license" href="https://creativecommons.org/share-your-work/public-domain/cc0/">Creative Commons CC0 agreement</a>.'; |
181 | 183 | } else if ($scope.model.metadata.Rights.value === 'CC-BY') { |
| 184 | + $scope.model.display.rightsUrl = 'http://creativecommons.org/licenses/by/4.0/' |
182 | 185 | $scope.model.display.Rights = '<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License Badge" style="border-width:0" src="' + window.location.origin + '/static/img/CCBY.png"/></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.'; |
183 | 186 | } else { |
| 187 | + $scope.model.display.rightsUrl = $scope.model.metadata.Rights.value |
184 | 188 | $scope.model.display.Rights = $scope.model.metadata.Rights.value |
185 | 189 | } |
186 | 190 |
|
|
201 | 205 | $scope.model.display.alreadyDisplayed.push('Publisher', 'Publication Year', 'DOI') |
202 | 206 | } |
203 | 207 |
|
| 208 | + /* create schema.org tags */ |
| 209 | + $scope.getValue = function(obj, keypath) { |
| 210 | + var current = obj; |
| 211 | + while (keypath.length) { |
| 212 | + const nextPath = keypath.shift(); |
| 213 | + if (!current.hasOwnProperty(nextPath)) { |
| 214 | + return undefined; |
| 215 | + } |
| 216 | + current = current[nextPath]; |
| 217 | + } |
| 218 | + return current; |
| 219 | + } |
| 220 | + |
| 221 | + $scope.maybeAssign = function(obj) { |
| 222 | + var objectToAssignTo = obj; |
| 223 | + return function (key, getVal) { |
| 224 | + var val = (typeof getVal === 'function') |
| 225 | + ? getVal() |
| 226 | + : getVal; |
| 227 | + if (val == null) return objectToAssignTo; |
| 228 | + objectToAssignTo[key] = val; |
| 229 | + return objectToAssignTo; |
| 230 | + } |
| 231 | + } |
| 232 | + var data = { |
| 233 | + "@context": "http://schema.org", |
| 234 | + "@type": "Dataset", |
| 235 | + "sameAs": window.location.href, |
| 236 | + "includedInDataCatalog": "http://datacommons.cyverse.org/", |
| 237 | + }; |
| 238 | + |
| 239 | + var assignTo = $scope.maybeAssign(data); |
| 240 | + |
| 241 | + assignTo('url', function() { |
| 242 | + return ($scope.getValue($scope.model.metadata, ['Identifier', 'value'])) |
| 243 | + ? 'https://doi.org/' + $scope.model.metadata.Identifier.value |
| 244 | + : null |
| 245 | + }) |
| 246 | + assignTo('name', $scope.getValue($scope.model.metadata, ['Title', 'value'])) |
| 247 | + assignTo('description', $scope.getValue($scope.model.metadata, ['Description', 'value'])) |
| 248 | + assignTo('keywords', $scope.getValue($scope.model.metadata, ['Subject', 'value'])) |
| 249 | + assignTo('license', $scope.getValue($scope.model.display, ['rightsUrl'])) |
| 250 | + assignTo('identifier', function() { |
| 251 | + return ($scope.getValue($scope.model.metadata, ['Identifier', 'value'])) |
| 252 | + ? 'DOI: ' + $scope.model.metadata.Identifier.value |
| 253 | + : null |
| 254 | + }) |
| 255 | + assignTo('citation', $scope.getValue($scope.model.display, ['readableCitation'])) |
| 256 | + assignTo('creator', function() { |
| 257 | + return ($scope.getValue($scope.model.metadata, ['Creator', 'value'])) |
| 258 | + ? { |
| 259 | + "type": "Person", |
| 260 | + "name": $scope.model.metadata.Creator.value |
| 261 | + } |
| 262 | + : null |
| 263 | + }) |
| 264 | + assignTo('datePublished', $scope.getValue($scope.model.metadata, ['Publication Year', 'value'])) |
| 265 | + assignTo('publisher', function() { |
| 266 | + return ($scope.getValue($scope.model.metadata, ['Publisher', 'value'])) |
| 267 | + ? { |
| 268 | + "type": "Organization", |
| 269 | + "name": $scope.model.metadata.Publisher.value |
| 270 | + } |
| 271 | + : null |
| 272 | + }) |
| 273 | + assignTo('contributor', $scope.getValue($scope.model.metadata, ['Contributor', 'value'])) |
| 274 | + |
| 275 | + angular.element(document.querySelector('#schemaTags')).html(JSON.stringify(data)) |
| 276 | + |
204 | 277 |
|
205 | 278 | } |
206 | 279 | }) |
|
210 | 283 | $scope.model.collection = null; |
211 | 284 | $scope.model.pagination.show = false; |
212 | 285 | if (item.type === 'dir') { |
213 | | - promises.push($scope.getContents(item.path, page)); |
| 286 | + promises.push($scope.getContents(item.path, page, $scope.sortType, $scope.sortDir)); |
214 | 287 | } |
215 | 288 |
|
216 | 289 | /* reset preview */ |
|
234 | 307 | }); |
235 | 308 | }; |
236 | 309 |
|
237 | | - $scope.getContents = function(path, page, sortType='label', sortDir='ASC') { |
| 310 | + $scope.getContents = function(path, page, sortType, sortDir) { |
238 | 311 | return DcrFileService.getListItem(path, page, sortType, sortDir).then( |
239 | 312 | function(results) { |
240 | 313 | $scope.model.collection = results; |
|
0 commit comments