Mercurial > public > bravenewsurf
changeset 12:55e1d68da925
For issue #3, add social media sharing icons to the home page.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 30 Oct 2011 16:00:12 -0500 |
parents | d5f3bb516fd3 |
children | 6b664ec90f2f |
files | bns_website/core/templatetags/core_tags.py bns_website/static/css/base.css bns_website/templates/base.html bns_website/templates/core/social_sharing_begin.html bns_website/templates/core/social_sharing_end.html bns_website/templates/core/social_sharing_tag.html bns_website/templates/home.html |
diffstat | 7 files changed, 92 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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; +}
--- 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 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="en" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:og="http://ogp.me/ns#" + xmlns:fb="https://www.facebook.com/2008/fbml"> <head> <title>Brave New Surf | {% block title %}{% endblock %}</title> <meta charset="utf-8" />
--- /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 @@ +<div id="fb-root"></div> +<script type="text/javascript">(function(d, s, id) { + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) {return;} + js = d.createElement(s); js.id = id; js.async = true; + js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; + fjs.parentNode.insertBefore(js, fjs); +}(document, 'script', 'facebook-jssdk'));</script>
--- /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 @@ +<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> +<script type="text/javascript"> +window.___gcfg = { + lang: 'en-US' +}; + +(function() { + var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; + po.src = 'https://apis.google.com/js/plusone.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); +})(); +</script>
--- /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 @@ +<div class="social-sharing"> +<ul> +<li> +<a href="https://twitter.com/share" class="twitter-share-button" data-text="{{ title }}" data-url="{{ url }}" data-count="horizontal" data-via="dblcrown">Tweet</a> +</li> +<li> +<div class="g-plusone" data-size="medium" data-href="{{ url }}"></div> +</li> +<li> +<div class="fb-like" data-href="{{ url }}" data-send="true" data-layout="button_count" data-width="90" data-show-faces="false"></div> +</li> +</ul> +</div>
--- 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 %} +<meta property="og:title" content="Brave New Surf" /> +<meta property="og:type" content="album" /> +<meta property="og:url" content="http://bravenewsurf.com/" /> +<meta property="og:image" content="http://bravenewsurf.com{{ STATIC_URL }}images/bns_cover.jpg" /> +<meta property="og:site_name" content="Brave New Surf" /> +<meta property="og:description" + content="The home page for the surf music compilation album Brave New Surf. Visit for news, reviews, and song samples." /> +<meta property="fb:admins" content="100001558124013" /> +{% endblock %} {% block custom_css %} <link rel="stylesheet" href="{{ STATIC_URL }}js/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" /> {% endblock %} @@ -14,6 +24,7 @@ }); </script> {% 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! </p> <p><a href="{% url 'buy' %}" class="btn primary">Buy Now »</a></p> + {% social_sharing 'Brave New Surf' 'http://bravenewsurf.com' %} </div> <div class="span7"> <div class="alert-message block-message info"> @@ -124,3 +136,4 @@ </div> </div> {% endblock %} +{% block end_body %}{% include 'core/social_sharing_end.html' %}{% endblock %}