Ive set up a client side script using jQuery that I think meets the requirements you requested.
$.setAllowExternalLinksFollowed = function(externalLinkWhitelistArray) {
"use strict";
var $externalDomLinks = $('a[href^="http"]');
$externalDomLinks.each(function() {
var $linkInstance = $(this);
// Nofollow all ext links
$linkInstance.attr('rel', 'nofollow');
externalLinkWhitelistArray.forEach(function(whiteListedUri) {
if ($linkInstance.attr('href') === whiteListedUri) {
// Get rid of rel=nofollow from whitelisted links
$linkInstance.attr('rel', '');
}
});
});
};
Which would be initialized in the views needed like so:
"use strict"
$.setAllowExternalLinksFollowed([
'http://www.google.com',
'http://www.cnn.com'
]);
All other external links will have rel="nofollow" in the DOM inspector once this script has a chance to parse and manip the DOM. The whitelisted uri's will instead have the attribute rel="nofollow" truncated to rel="" (or whatever you see fit for your project with minor adjustment).
See it in action with this pen:
http://codepen.io/nicholasabrams/pen/qdXWxB
I hope it fits the bill!
PS: If you would like to do this on the server side, you must do it in the area of your backend code where the links are generated, and do a similar comparison to what appears in the jQuery solution offered. Without seeing the backend code that renders/generates the links it would not be feasible to replicate a solution for the serverside (do the links come from an array, or are they static? We have no way of doing anything on the server if the links are static - which they are for all we know based on the OP.