Change social links display
- Refactored icon matching code (generates cleaner HTML)
- The social links now only show an icon with a tooltip when hovering.
- The normal links now use the icon matching code
diff --git a/templates/base.html b/templates/base.html
index 6fc27ed..4003e03 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -40,6 +40,54 @@
{% include "modules/analytics.html" %}
</head>
+{% macro get_icon(link) %}
+ {%- set class = 'fa-external-link-square' -%}
+
+ {# Attempt to normalize link URLs #}
+ {%- set temp = link|lower|replace('http://', '')|replace('https://', '')|replace('www.', '') -%}
+
+ {# Choosing a specific link icon #}
+ {%- if temp.startswith('bitcoin:') %}{% set class = 'fa-btc' %}
+ {% elif temp.startswith('irc:') %}{% set class = 'fa-comments' %}
+ {% elif temp.startswith('mailto:') %}{% set class = 'fa-envelope' %}
+ {% elif temp.startswith('skype:') %}{% set class = 'fa-skype' -%}
+
+ {%- elif temp.endswith('.pdf') or
+ temp.endswith('.txt') or
+ temp.endswith('.doc') or
+ temp.endswith('.docx') %}{% set class = 'fa-file-text' -%}
+
+ {%- elif temp.startswith('bitbucket.org') %}{% set class = 'fa-bitbucket' %}
+ {% elif temp.startswith('delicious.com') %}{% set class = 'fa-delicious' %}
+ {% elif temp.startswith('deviantart.com') %}{% set class = 'fa-deviantart' %}
+ {% elif temp.startswith('facebook.com') %}{% set class = 'fa-facebook' %}
+ {% elif temp.startswith('flickr.com') %}{% set class = 'fa-flickr' %}
+ {% elif temp.startswith('foursquare.com') %}{% set class = 'fa-foursquare' %}
+ {% elif temp.startswith('github.com') %}{% set class = 'fa-github' %}
+ {% elif temp.startswith('instagram.com') %}{% set class = 'fa-instagram' %}
+ {% elif temp.startswith('last.fm') %}{% set class = 'fa-lastfm' %}
+ {% elif temp.startswith('linkedin.com') %}{% set class = 'fa-linkedin' %}
+ {% elif temp.startswith('news.ycombinator.com') %}{% set class = 'fa-hacker-news' %}
+ {% elif temp.startswith('pinterest.com') %}{% set class = 'fa-pinterest' %}
+ {% elif temp.startswith('plus.google.com') %}{% set class = 'fa-google-plus' %}
+ {% elif temp.startswith('reddit.com') %}{% set class = 'fa-reddit' %}
+ {% elif temp.startswith('spotify.com') %}{% set class = 'fa-spotify' %}
+ {% elif temp.startswith('stackoverflow.com') %}{% set class = 'fa-stack-overflow' %}
+ {% elif temp.startswith('steamcommunity.com') %}{% set class = 'fa-steam' %}
+ {% elif temp.startswith('soundcloud.com') %}{% set class = 'fa-soundcloud' %}
+ {% elif temp.startswith('twitch.tv') %}{% set class = 'fa-twitch' %}
+ {% elif temp.startswith('twitter.com') %}{% set class = 'fa-twitter' %}
+ {% elif temp.startswith('vimeo.com') %}{% set class = 'fa-vimeo-square' %}
+ {% elif temp.startswith('vine.co') %}{% set class = 'fa-vine' %}
+ {% elif temp.startswith('youtube.com') %}{% set class = 'fa-youtube' -%}
+
+ {%- elif '.stackexchange.com' in temp %}{% set class = 'fa-stack-exchange' %}
+ {% elif '.tumblr.com' in temp %}{% set class = 'fa-tumblr' %}
+ {% endif -%}
+
+ <i class="fa {{ class }} fa-lg"></i>
+{%- endmacro -%}
+
<body>
<aside>
<div id="user_meta">
@@ -50,65 +98,18 @@
</a>
<h2><a href="{{ SITEURL }}" class="nohover">{{ SITENAME }}</a></h2>
<p>{{ TAGLINE }}</p>
- <ul>
+ <div class="social">
{% for name, link in SOCIAL %}
-
- {# Attempt to normalize link URLs #}
- {% set temp = link|lower|replace('http://', '')|replace('https://', '')|replace('www.', '') %}
-
- {% set class = 'fa-external-link-square' %}
-
- {% if MANGLE_EMAILS and temp.startswith('mailto:') %}
- <li><a data-email="{{ link|reverse }}" title="You need javascript enabled to view this email" class="email">{{ name }}<i class="fa fa-envelope fa-lg"></i></a></li>
+ {% if MANGLE_EMAILS and link.startswith('mailto:') %}
+ <a data-email="{{ link|reverse }}" data-title="{{ name }}" title="You need javascript enabled to view this email" class="email">{{ get_icon(link) }}</a>
{% else %}
-
- {# Choosing a specific link icon #}
- {% if temp.startswith('bitcoin:') %}{% set class = 'fa-btc' %}
- {% elif temp.startswith('irc:') %}{% set class = 'fa-comments' %}
- {% elif temp.startswith('mailto:') %}{% set class = 'fa-envelope' %}
- {% elif temp.startswith('skype:') %}{% set class = 'fa-skype' %}
-
- {% elif temp.endswith('.pdf') or
- temp.endswith('.txt') or
- temp.endswith('.doc') or
- temp.endswith('.docx') %}{% set class = 'fa-file-text' %}
-
- {% elif temp.startswith('bitbucket.org') %}{% set class = 'fa-bitbucket' %}
- {% elif temp.startswith('delicious.com') %}{% set class = 'fa-delicious' %}
- {% elif temp.startswith('deviantart.com') %}{% set class = 'fa-deviantart' %}
- {% elif temp.startswith('facebook.com') %}{% set class = 'fa-facebook' %}
- {% elif temp.startswith('flickr.com') %}{% set class = 'fa-flickr' %}
- {% elif temp.startswith('foursquare.com') %}{% set class = 'fa-foursquare' %}
- {% elif temp.startswith('github.com') %}{% set class = 'fa-github' %}
- {% elif temp.startswith('instagram.com') %}{% set class = 'fa-instagram' %}
- {% elif temp.startswith('last.fm') %}{% set class = 'fa-lastfm' %}
- {% elif temp.startswith('linkedin.com') %}{% set class = 'fa-linkedin' %}
- {% elif temp.startswith('news.ycombinator.com') %}{% set class = 'fa-hacker-news' %}
- {% elif temp.startswith('pinterest.com') %}{% set class = 'fa-pinterest' %}
- {% elif temp.startswith('plus.google.com') %}{% set class = 'fa-google-plus' %}
- {% elif temp.startswith('reddit.com') %}{% set class = 'fa-reddit' %}
- {% elif temp.startswith('spotify.com') %}{% set class = 'fa-spotify' %}
- {% elif temp.startswith('stackoverflow.com') %}{% set class = 'fa-stack-overflow' %}
- {% elif temp.startswith('steamcommunity.com') %}{% set class = 'fa-steam' %}
- {% elif temp.startswith('soundcloud.com') %}{% set class = 'fa-soundcloud' %}
- {% elif temp.startswith('twitch.tv') %}{% set class = 'fa-twitch' %}
- {% elif temp.startswith('twitter.com') %}{% set class = 'fa-twitter' %}
- {% elif temp.startswith('vimeo.com') %}{% set class = 'fa-vimeo-square' %}
- {% elif temp.startswith('vine.co') %}{% set class = 'fa-vine' %}
- {% elif temp.startswith('youtube.com') %}{% set class = 'fa-youtube' %}
-
- {% elif '.stackexchange.com' in temp %}{% set class = 'fa-stack-exchange' %}
- {% elif '.tumblr.com' in temp %}{% set class = 'fa-tumblr' %}
-
- {% endif %}
-
- <li><a href="{{ link }}">{{ name }}<i class="fa {{ class }} fa-lg"></i></a></li>
+ <a href="{{ link }}" title="{{ name }}">{{ get_icon(link) }}</a>
{% endif %}
{% endfor %}
- </ul>
+ </div>
<ul>
{% for name, link in LINKS %}
- <li><a href="{{ link }}">{{ name }}<i class="fa fa-external-link-square fa-lg"></i></a></li>
+ <li><a href="{{ link }}">{{ name }}{{ get_icon(link) }}</a></li>
{% endfor %}
</ul>
</div>
@@ -164,10 +165,12 @@
var e = document.querySelectorAll(".email");
for (var i = 0; i < e.length; i++) {
var email = e[i].getAttribute("data-email")
+ var title = e[i].getAttribute("data-title") || "Email"
if (email){
e[i].href = email.split("").reverse().join("");
+ e[i].setAttribute("title", title);
e[i].removeAttribute("data-email");
- e[i].removeAttribute("title");
+ e[i].removeAttribute("data-title");
e[i].removeAttribute("class");
}
}