Skip to content

Commit

Permalink
Analytics and compression
Browse files Browse the repository at this point in the history
  • Loading branch information
arecker committed Oct 31, 2015
1 parent 3697fe9 commit b56ba60
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
prod_static
*.pyc
db.sqlite3
14 changes: 14 additions & 0 deletions murals/processors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django.conf import settings

from showing.models import Gallery


Expand All @@ -10,3 +12,15 @@ def navbar(request):
'galleries': Gallery.objects.all()
}
}


def analytics(request):
'''
Inject google analytics tracking code into context
'''
ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_ID', False)
if not settings.DEBUG and ga_prop_id:
return {
'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id,
}
return {}
13 changes: 12 additions & 1 deletion murals/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

# 3rd party
'sorl.thumbnail',
'compressor',

# Apps
'showing'
Expand Down Expand Up @@ -52,7 +53,8 @@
'django.contrib.messages.context_processors.messages',

# Custom
'murals.processors.navbar'
'murals.processors.navbar',
'murals.processors.analytics',
],
},
},
Expand All @@ -74,9 +76,18 @@
USE_TZ = True

STATIC_URL = '/static/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
)
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
STATIC_ROOT = os.path.join(BASE_DIR, 'prod_static')
ADMIN_MEDIA_PREFIX = '/media/'

COMPRESS_ENABLED=True
GOOGLE_ANALYTICS_PROPERTY_ID = 'UA-42540208-9'
1 change: 1 addition & 0 deletions requirements/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ django-flat-theme==1.1.1
django-admin-sortable==2.0.3
Pillow==3.0.0
sorl-thumbnail==12.3
django-compressor==1.5
60 changes: 60 additions & 0 deletions static/css/josefin-slab.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@font-face {
font-family: 'Josefin Slab';
font-style: normal;
font-weight: 100;
src: local('Josefin Slab Thin'), local('JosefinSlab-Thin'), url(http://fonts.gstatic.com/s/josefinslab/v6/etsUjZYO8lTLU85lDhZwUm-gXUWvikdRm39El-Kldqo.ttf) format('truetype');
}
@font-face {
font-family: 'Josefin Slab';
font-style: normal;
font-weight: 300;
src: local('Josefin Slab Light'), local('JosefinSlab-Light'), url(http://fonts.gstatic.com/s/josefinslab/v6/NbE6ykYuM2IyEwxQxOIi2AV_pQ1T3xN3K1c3sB361us.ttf) format('truetype');
}
@font-face {
font-family: 'Josefin Slab';
font-style: normal;
font-weight: 400;
src: local('Josefin Slab'), local('JosefinSlab'), url(http://fonts.gstatic.com/s/josefinslab/v6/46aYWdgz-1oFX11flmyEfYnF5uFdDttMLvmWuJdhhgs.ttf) format('truetype');
}
@font-face {
font-family: 'Josefin Slab';
font-style: normal;
font-weight: 600;
src: local('Josefin Slab SemiBold'), local('JosefinSlab-SemiBold'), url(http://fonts.gstatic.com/s/josefinslab/v6/NbE6ykYuM2IyEwxQxOIi2FFZMcfX2SbzQ69I7OWmkGo.ttf) format('truetype');
}
@font-face {
font-family: 'Josefin Slab';
font-style: normal;
font-weight: 700;
src: local('Josefin Slab Bold'), local('JosefinSlab-Bold'), url(http://fonts.gstatic.com/s/josefinslab/v6/NbE6ykYuM2IyEwxQxOIi2H06qf9KHRHwsVx7iw5MXmY.ttf) format('truetype');
}
@font-face {
font-family: 'Josefin Slab';
font-style: italic;
font-weight: 100;
src: local('Josefin Slab Thin Italic'), local('JosefinSlab-ThinItalic'), url(http://fonts.gstatic.com/s/josefinslab/v6/8BjDChqLgBF3RJKfwHIYhxNDIA8twkEsorcr_fdT1vI.ttf) format('truetype');
}
@font-face {
font-family: 'Josefin Slab';
font-style: italic;
font-weight: 300;
src: local('Josefin Slab Light Italic'), local('JosefinSlab-LightItalic'), url(http://fonts.gstatic.com/s/josefinslab/v6/af9sBoKGPbGO0r21xJuly33uxQAI1Bvm-GxtFNy4yl0.ttf) format('truetype');
}
@font-face {
font-family: 'Josefin Slab';
font-style: italic;
font-weight: 400;
src: local('Josefin Slab Italic'), local('JosefinSlab-Italic'), url(http://fonts.gstatic.com/s/josefinslab/v6/etsUjZYO8lTLU85lDhZwUitfYakCkPqOMDce0h_3gD8.ttf) format('truetype');
}
@font-face {
font-family: 'Josefin Slab';
font-style: italic;
font-weight: 600;
src: local('Josefin Slab SemiBold Italic'), local('JosefinSlab-SemiBoldItalic'), url(http://fonts.gstatic.com/s/josefinslab/v6/af9sBoKGPbGO0r21xJulyzolfeppZzFSKvLyJNPKLMk.ttf) format('truetype');
}
@font-face {
font-family: 'Josefin Slab';
font-style: italic;
font-weight: 700;
src: local('Josefin Slab Bold Italic'), local('JosefinSlab-BoldItalic'), url(http://fonts.gstatic.com/s/josefinslab/v6/af9sBoKGPbGO0r21xJulyyxQL91WRy8t8mPvAX_dIgA.ttf) format('truetype');
}
60 changes: 60 additions & 0 deletions static/css/open-sans.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
src: local('Open Sans Light'), local('OpenSans-Light'), url(http://fonts.gstatic.com/s/opensans/v13/DXI1ORHCpsQm3Vp6mXoaTYnF5uFdDttMLvmWuJdhhgs.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans'), local('OpenSans'), url(http://fonts.gstatic.com/s/opensans/v13/cJZKeOuBrn4kERxqtaUH3aCWcynf_cDxXwCLxiixG1c.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
src: local('Open Sans Semibold'), local('OpenSans-Semibold'), url(http://fonts.gstatic.com/s/opensans/v13/MTP_ySUJH_bn48VBG8sNSonF5uFdDttMLvmWuJdhhgs.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
src: local('Open Sans Bold'), local('OpenSans-Bold'), url(http://fonts.gstatic.com/s/opensans/v13/k3k702ZOKiLJc3WVjuplzInF5uFdDttMLvmWuJdhhgs.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 800;
src: local('Open Sans Extrabold'), local('OpenSans-Extrabold'), url(http://fonts.gstatic.com/s/opensans/v13/EInbV5DfGHOiMmvb1Xr-honF5uFdDttMLvmWuJdhhgs.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 300;
src: local('Open Sans Light Italic'), local('OpenSansLight-Italic'), url(http://fonts.gstatic.com/s/opensans/v13/PRmiXeptR36kaC0GEAetxrfB31yxOzP-czbf6AAKCVo.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
src: local('Open Sans Italic'), local('OpenSans-Italic'), url(http://fonts.gstatic.com/s/opensans/v13/xjAJXh38I15wypJXxuGMBp0EAVxt0G0biEntp43Qt6E.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
src: local('Open Sans Semibold Italic'), local('OpenSans-SemiboldItalic'), url(http://fonts.gstatic.com/s/opensans/v13/PRmiXeptR36kaC0GEAetxi8cqLH4MEiSE0ROcU-qHOA.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
src: local('Open Sans Bold Italic'), local('OpenSans-BoldItalic'), url(http://fonts.gstatic.com/s/opensans/v13/PRmiXeptR36kaC0GEAetxp_TkvowlIOtbR7ePgFOpF4.ttf) format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 800;
src: local('Open Sans Extrabold Italic'), local('OpenSans-ExtraboldItalic'), url(http://fonts.gstatic.com/s/opensans/v13/PRmiXeptR36kaC0GEAetxlDMrAYtoOisqqMDW9M_Mqc.ttf) format('truetype');
}
21 changes: 20 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
{% block title %}
<title>Marissa's Murals</title>
{% endblock %}
{% load compress %}
{% compress css %}
{% include "css.html" %}
{% endcompress %}
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
Expand All @@ -23,9 +26,25 @@
{% block body %}
{% endblock %}
</div>
<!-- {% include "footer.html" %} -->
{% compress js %}
{% include "scripts.html" %}
{% block scripts %}
{% endblock %}
{% endcompress %}

{% if GOOGLE_ANALYTICS_PROPERTY_ID %}
{% compress js inline %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{{ GOOGLE_ANALYTICS_PROPERTY_ID }}', 'auto');
ga('send', 'pageview');

</script>
{% endcompress %}
{% endif %}
</body>
</html>
13 changes: 5 additions & 8 deletions templates/css.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{% load staticfiles %}

<!-- Bootstrap Core CSS -->
{% load compress %}
{% compress css %}
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">

<!-- Custom CSS -->
<link href="{% static 'css/business-casual.css' %}" rel="stylesheet">

<!-- Fonts -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Josefin+Slab:100,300,400,600,700,100italic,300italic,400italic,600italic,700italic" rel="stylesheet" type="text/css">
<link href="{% static 'css/open-sans.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'css/josefin-slab.css' %}" rel="stylesheet" type="text/css">
{% endcompress %}
2 changes: 0 additions & 2 deletions templates/navigation.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<!-- <div class="brand">Marissa's Murals</div> -->
<!-- <div class="address-bar">3481 Melrose Place | Beverly Hills, CA 90210 | 123.456.7890</div> -->
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
Expand Down
4 changes: 0 additions & 4 deletions templates/scripts.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{% load staticfiles %}

<!-- jQuery -->
<script src="{% static 'js/jquery.js' %}"></script>

<!-- Bootstrap Core JavaScript -->
<script src="{% static 'js/bootstrap.min.js' %}"></script>

0 comments on commit b56ba60

Please sign in to comment.