# HG changeset patch
# User Brian Neal
# Date 1320008412 18000
# Node ID 55e1d68da9259e08902ea3b03bc3d208b4fe501b
# Parent d5f3bb516fd362b529693c34ee8b97c37e109f71
For issue #3, add social media sharing icons to the home page.
diff -r d5f3bb516fd3 -r 55e1d68da925 bns_website/core/templatetags/core_tags.py
--- a/bns_website/core/templatetags/core_tags.py Sun Oct 30 14:51:12 2011 -0500
+++ b/bns_website/core/templatetags/core_tags.py Sun Oct 30 16:00:12 2011 -0500
@@ -3,6 +3,7 @@
"""
from django import template
+from django.contrib.sites.models import Site
register = template.Library()
@@ -11,3 +12,30 @@
@register.inclusion_tag('core/navbar_tag.html')
def navbar(active_tab):
return {'active_tab': active_tab}
+
+
+@register.inclusion_tag('core/social_sharing_tag.html')
+def social_sharing(title, url):
+ """
+ Displays social media sharing buttons.
+
+ """
+ site = Site.objects.get_current()
+ url = _fully_qualify(url, site.domain)
+
+ return {
+ 'title': title,
+ 'url': url,
+ }
+
+
+def _fully_qualify(url, domain):
+ """
+ Returns a "fully qualified" URL by checking the given url.
+ If the url starts with '/' then http://domain is pre-pended
+ onto it. Otherwise the original URL is returned.
+
+ """
+ if url.startswith('/'):
+ url = "http://%s%s" % (domain, url)
+ return url
diff -r d5f3bb516fd3 -r 55e1d68da925 bns_website/static/css/base.css
--- a/bns_website/static/css/base.css Sun Oct 30 14:51:12 2011 -0500
+++ b/bns_website/static/css/base.css Sun Oct 30 16:00:12 2011 -0500
@@ -1,1 +1,14 @@
-body { padding-top: 40px }
+body {
+ padding-top: 40px
+}
+.social-sharing {
+ margin-top: 1.5em;
+}
+.social-sharing ul {
+ margin-left: 0px;
+ list-style: none;
+}
+.social-sharing li {
+ display: inline-block;
+ vertical-align: top;
+}
diff -r d5f3bb516fd3 -r 55e1d68da925 bns_website/templates/base.html
--- a/bns_website/templates/base.html Sun Oct 30 14:51:12 2011 -0500
+++ b/bns_website/templates/base.html Sun Oct 30 16:00:12 2011 -0500
@@ -1,5 +1,8 @@
-
+
Brave New Surf | {% block title %}{% endblock %}
diff -r d5f3bb516fd3 -r 55e1d68da925 bns_website/templates/core/social_sharing_begin.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bns_website/templates/core/social_sharing_begin.html Sun Oct 30 16:00:12 2011 -0500
@@ -0,0 +1,8 @@
+
+
diff -r d5f3bb516fd3 -r 55e1d68da925 bns_website/templates/core/social_sharing_end.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bns_website/templates/core/social_sharing_end.html Sun Oct 30 16:00:12 2011 -0500
@@ -0,0 +1,12 @@
+
+
diff -r d5f3bb516fd3 -r 55e1d68da925 bns_website/templates/core/social_sharing_tag.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bns_website/templates/core/social_sharing_tag.html Sun Oct 30 16:00:12 2011 -0500
@@ -0,0 +1,13 @@
+
diff -r d5f3bb516fd3 -r 55e1d68da925 bns_website/templates/home.html
--- a/bns_website/templates/home.html Sun Oct 30 14:51:12 2011 -0500
+++ b/bns_website/templates/home.html Sun Oct 30 16:00:12 2011 -0500
@@ -2,6 +2,16 @@
{% load url from future %}
{% load core_tags %}
{% block title %}Home{% endblock %}
+{% block custom_meta %}
+
+
+
+
+
+
+
+{% endblock %}
{% block custom_css %}
{% endblock %}
@@ -14,6 +24,7 @@
});
{% endblock %}
+{% block begin_body %}{% include 'core/social_sharing_begin.html' %}{% endblock %}
{% block content %}
{% navbar 'home' %}
@@ -69,6 +80,7 @@
Surf music has never been so vibrant, so diverse, so charged with energy and excitement. It’s time for the new surf classics. It’s time for BRAVE NEW SURF!
Buy Now »
+ {% social_sharing 'Brave New Surf' 'http://bravenewsurf.com' %}
{% endblock %}
+{% block end_body %}{% include 'core/social_sharing_end.html' %}{% endblock %}