Detect if contact is an email and generate mailto

Some associations may have a contact form on a website
This commit is contained in:
Mathieu Coussens 2020-09-19 09:52:01 +02:00
parent 2acbf8a5e2
commit 2bab6eb659
No known key found for this signature in database
GPG key ID: AEDA22F79003627D
2 changed files with 5 additions and 1 deletions

View file

@ -16,7 +16,7 @@
<%if item[:deelname_link] || item[:contact] || item[:website]%>
<% if item[:deelname_link] %><a href="<%= item[:deelname_link] %>"><%= item[:deelname_link] %></a><% end %>
<div class="contact-container">
<% if item[:contact] %><a href="<%= item[:contact] %>"><%= item[:contact] %></a><%end%>
<% if item[:contact] %><a href="<%= "mailto:" if is_email item[:contact] %><%= item[:contact] %>"><%= item[:contact] %></a><%end%>
<% if item[:website] %><a href="<%= item[:website] %>"><%= item[:website] %></a><%end%>
</div><%end%>
<% if item[:social] %>

View file

@ -84,4 +84,8 @@ module VerenigingenHelper
def image_tag(item)
"<img src='#{ image_url item }' alt='#{ item[:naam] } logo' />"
end
def is_email(item)
item.match URI::MailTo::EMAIL_REGEXP
end
end