diff --git a/app/assets/javascripts/darkswarm/directives/link_to_service.js.coffee b/app/assets/javascripts/darkswarm/directives/link_to_service.js.coffee new file mode 100644 index 0000000000..dc0f513588 --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/link_to_service.js.coffee @@ -0,0 +1,8 @@ +Darkswarm.directive "linkToService", -> + restrict: 'E' + replace: true + scope: { + ref: '=' + service: '=' + } + template: '' diff --git a/app/assets/javascripts/darkswarm/filters/ext_url.js.coffee b/app/assets/javascripts/darkswarm/filters/ext_url.js.coffee new file mode 100644 index 0000000000..8d4b8b90fe --- /dev/null +++ b/app/assets/javascripts/darkswarm/filters/ext_url.js.coffee @@ -0,0 +1,9 @@ +Darkswarm.filter "ext_url", () -> + urlPattern = /^https?:\/\// + (url, prefix) -> + if (!url) + return url + if (url.match(urlPattern)) + return url + else + return prefix + url diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index d1013cfed4..6115410b43 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -32,33 +32,13 @@ %p {{ group.state }} .small-8.medium-4.columns.text-right - - / TODO: Maikel can we use the same logic on contacts partial to render these? doesn't work with the angular binding... - - / .follow-icons{bindonce: true} - / %span - / =link_to_service "http://twitter.com/", @group.twitter do - / %i.ofn-i_041-twitter - / %span - / =link_to_service "https://www.facebook.com/", @group.facebook do - / %i.ofn-i_044-facebook - / %span - / =link_to_service "https://www.linkedin.com/in/", @group.linkedin do - / %i.ofn-i_042-linkedin - / %span - / =link_to_service "http://instagram.com/", @group.instagram do - / %i.ofn-i_043-instagram - %p - {{ group.facebook }} - %br - {{ group.twitter }} - %br - {{ group.instagram }} - %br - {{ group.email }} - %br - {{ group.website }} + %link-to-service.ofn-i_050-mail-circle{service: '""', ref: 'group.email.split("").reverse().join("")', mailto: true} + %link-to-service.ofn-i_049-web{service: '"http://"', ref: 'group.website'} + %link-to-service.ofn-i_041-twitter{service: '"http://twitter.com/"', ref: 'group.twitter'} + %link-to-service.ofn-i_044-facebook{service: '"https://www.facebook.com/"', ref: 'group.facebook'} + %link-to-service.ofn-i_042-linkedin{service: '"https://www.linkedin.com/in/"', ref: 'group.linkedin'} + %link-to-service.ofn-i_043-instagram{service: '"http://instagram.com/"', ref: 'group.instagram'} .group{"ng-show" => "groups.length == 0"} .row.pad-top