Skip to content

Commit

Permalink
node pages under development
Browse files Browse the repository at this point in the history
  • Loading branch information
MortenHofft committed Feb 27, 2017
1 parent 00c6803 commit c76fea7
Show file tree
Hide file tree
Showing 21 changed files with 337 additions and 150 deletions.
Binary file added app/assets/img/social/facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/social/google plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/social/instagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/social/linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/social/pinterest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/social/rss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/social/twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/social/vimeo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/img/social/youtube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 15 additions & 2 deletions app/controllers/node/key/nodeKey.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var express = require('express'),
utils = rootRequire('app/helpers/utils'),
helper = rootRequire('app/models/util/util'),
Node = require('../../../models/gbifdata/gbifdata').Node,
_ = require('lodash'),
contributors = require('../../dataset/key/contributors/contributors'),
isDev = rootRequire('config/config').env == 'dev',
router = express.Router();
Expand All @@ -13,20 +14,29 @@ module.exports = function (app) {
};

router.get('/node/:key\.:ext?', function (req, res, next) {
var nodeKey = req.params.key;
var nodeKey = req.params.key,
offset_endorsed = req.query.offset_endorsed,
offset_datasets = req.query.offset_datasets;
if (!utils.isGuid(nodeKey)) {
next();
} else {
Node.get(nodeKey, {expand: ['participant', 'directoryParticipant']}).then(function (node) {
try {
if (node.record.type === 'COUNTRY' && node.record.country) {
node.offset_endorsed = offset_endorsed || 0;
node.offset_datasets = offset_datasets || 0;
if (_.get(node, 'participant.errorType')) {
delete node.participant;
}
if (node.record.type === 'XCOUNTRY' && node.record.country) {
res.redirect('/country/' + node.record.country);
} else {
if (!isDev) {
next();
return;
}
node._computedValues = {};

//create unified contacts with multiple roles per person
let contacts = node.record.contacts;
let nodeContact = {
organization: node.record.title,
Expand All @@ -48,6 +58,9 @@ router.get('/node/:key\.:ext?', function (req, res, next) {
return e.roles.indexOf('HEAD_OF_DELEGATION') > -1;
});

//websites
var websites = _.uniq([].concat(_.get(node, 'record.homepage', [])).concat(_.get(node, 'directoryParticipant.participantUrl', [])));
node._computedValues.associatedWebsites = websites;
let pageData = {
node: node,
_meta: {
Expand Down
1 change: 1 addition & 0 deletions app/helpers/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ module.exports = {
addPortalClasses: addPortalClasses,
insertLinks: linkTools.insertLinks,
linkify: linkTools.linkify,
reduceUrlToDomain: linkTools.reduceUrlToDomain,
getDOILink: linkTools.getDOILink,
readableDOI: linkTools.readableDOI,
toCamelCase: toCamelCase,
Expand Down
14 changes: 13 additions & 1 deletion app/helpers/links/links.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

var _ = require('lodash'),
url = require('url'),
doiRegex = require("doi-regex"),
Autolinker = require('autolinker'),
linkTemplateTarget = '<a href="%s1" target="%s2">%s3</a>',
Expand Down Expand Up @@ -48,6 +49,16 @@ function linkify(text, options) {
return Autolinker.link(text, newOptions);
}

function reduceUrlToDomain(text) {
if (_.isString(text)) {
var parsedUrl = url.parse(text),
domain = parsedUrl.hostname;
return domain;
} else {
return '';
}
}


function getDOILink(text, throwOnMissing) {
var doi;
Expand Down Expand Up @@ -83,7 +94,8 @@ module.exports = {
insertLinks: insertLinks,
linkify: linkify,
getDOILink: getDOILink,
readableDOI: readableDOI
readableDOI: readableDOI,
reduceUrlToDomain: reduceUrlToDomain
};

//console.log(linkify('replace this [email protected] and this one [email protected] and show a link to http://mysite.com but not to relative ones like this /occurrence/234'));
4 changes: 4 additions & 0 deletions app/nunjucks/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ module.exports = function (nunjucksConfiguration) {
nunjucksConfiguration.addFilter('toCamelCase', format.toCamelCase);
})();

(function () {
nunjucksConfiguration.addFilter('reduceUrlToDomain', format.reduceUrlToDomain);
})();

(function () {
nunjucksConfiguration.addFilter('locInt', format.localizeInteger);
})();
Expand Down
14 changes: 4 additions & 10 deletions app/views/pages/dataset/key/contributors/contributors.styl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.dataset-key__contributors {
color $bodyTextColor
&__mail, &__phone {
overflow hidden
text-overflow ellipsis
Expand Down Expand Up @@ -28,6 +29,7 @@
}
&__item {
position relative
padding 10px
> address, > i {
position relative
}
Expand All @@ -52,7 +54,7 @@
margin 0 -($halfGutter)
> div {
flex 0 1 auto
width 33%
width 100%
}
}
}
Expand Down Expand Up @@ -80,22 +82,14 @@
}
}

+isAbove(500px) {
+isAbove(600px) {
.flex-columns {
> div {
width 50%
}
}
}

+isAbove(900px) {
.flex-columns {
> div {
width 33%
}
}
}

.contributor-anchor:target {
+ address {
//.dataset-key__contributors__name, .dataset-key__contributors__title {
Expand Down
64 changes: 38 additions & 26 deletions app/views/pages/node/key/nodeKey.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,62 @@ angular
.controller('nodeKeyCtrl', nodeKeyCtrl);

/** @ngInject */
function nodeKeyCtrl(NodeEndorsedPublishers, NodeDatasets) {
function nodeKeyCtrl(NodeEndorsedPublishers, NodeDatasets, $stateParams, $location, $scope, $window) {
var vm = this;
vm.limit = 5;
vm.endorsed = {};
vm.datasets = {};
vm.maxSize = 5;
vm.limit = 5;


vm.getEndorsed = function() {
NodeEndorsedPublishers.get({id: '0909d601-bda2-42df-9e63-a6d51847ebce', limit: vm.limit},
function(response){
vm.getEndorsed = function () {
NodeEndorsedPublishers.get({id: vm.key, limit: vm.limit, offset: vm.offset_endorsed},
function (response) {
vm.endorsed = response;
},
function(){
function () {
//TODO handle errors
}
);
};
vm.getEndorsed();

vm.getDatasets = function() {
NodeDatasets.get({id: '0909d601-bda2-42df-9e63-a6d51847ebce', limit: vm.limit},
function(response){
vm.getDatasets = function () {
NodeDatasets.get({id: vm.key, limit: vm.limit, offset: vm.currentPage_datasets},
function (response) {
vm.datasets = response;
},
function(){
function () {
//TODO handle errors
}
);
};
vm.getDatasets();

//vm.endorsedPageChanged = function() {
// vm.offset = (vm.currentPage - 1) * vm.limit;
// $location.hash('datasets');
// $scope.$watchCollection($location.search('offset', vm.offset), function () {
// $window.location.reload();
// })
//};

//vm.setInitials = function(offset, limit, key) {
// vm.offset = offset || 0;
// vm.limit = limit;
// vm.key = key;
// vm.currentPage = Math.floor(vm.offset / vm.limit) + 1;
//};

vm.setKey = function (key, offset_endorsed, offset_datasets) {
vm.key = key;
vm.offset_endorsed = offset_endorsed;
vm.currentPage_endorsed = Math.floor(vm.offset_endorsed / vm.limit) + 1;

vm.offset_datasets = offset_datasets;
vm.currentPage_datasets = Math.floor(vm.offset_datasets / vm.limit) + 1;
vm.getDatasets();
vm.getEndorsed();
};

vm.pageChanged_endorsed = function () {
vm.offset_endorsed = (vm.currentPage_endorsed - 1) * vm.limit;
$scope.$watchCollection($location.search('offset_endorsed', vm.offset_endorsed), function () {
$window.location.reload();
});
//$state.go($state.current, {limit: vm.limit, offset_endorsed: vm.offset_endorsed}, {inherit: true, notify: true, reload: true});
};
vm.pageChanged_datasets = function () {
vm.offset_datasets = (vm.currentPage_datasets - 1) * vm.limit;
$scope.$watchCollection($location.search('offset_datasets', vm.offset_datasets), function () {
$window.location.reload();
});
//$state.go($state.current, {limit: vm.limit, offset_datasets: vm.offset_datasets}, {inherit: true, notify: true, reload: true});
};

}

Expand Down
Loading

0 comments on commit c76fea7

Please sign in to comment.