Carbon ads, adding filter for tags in API, working on adams theme

master
Nick Sergeant 2012-07-30 12:51:02 -04:00
parent bf21af8dcf
commit 7c1b06891e
12 changed files with 230 additions and 69 deletions

1
.kick
View File

@ -4,6 +4,7 @@ process do |files|
when %r{^(.+).scss$} when %r{^(.+).scss$}
execute "scss -t compressed media/css/style.scss media/css/style.css" execute "scss -t compressed media/css/style.scss media/css/style.css"
execute "scss -t compressed media/css/blog-themes/default/style.scss media/css/blog-themes/default/style.css" execute "scss -t compressed media/css/blog-themes/default/style.scss media/css/blog-themes/default/style.css"
execute "scss -t compressed media/css/blog-themes/pro-adams/style.scss media/css/blog-themes/pro-adams/style.css"
execute "media/css/compile-css.sh" execute "media/css/compile-css.sh"
when %r{^(.+).js$} when %r{^(.+).js$}
execute "media/js/compile-js.sh" execute "media/js/compile-js.sh"

View File

@ -1,61 +1,87 @@
{% extends "base.html" %} {% load snipt_tags %}
{% block body-class %}blog-site{% endblock %} <!DOCTYPE html>
{% block html-class %}blog-site{% endblock %} <html lang="en" class="{% block html-class %}{% endblock %}">
<head>
{% block page-title %}{% if blog_user.username == 'nick' %}// Nick Sergeant {% elif blog_user.username == 'blog' %}// Snipt Blog{% else %}// {{ blog_user.username }}{% endif %}{% endblock %} <title>{% block page-title %}{% if blog_user.username == 'nick' %}// Nick Sergeant {% elif blog_user.username == 'blog' %}// Snipt Blog{% else %}// {{ blog_user.username }}{% endif %}{% endblock %}</title>
<meta charset="utf-8" />
{% if 'page' in request.GET %}
<meta name="robots" content="noindex, follow" />
{% endif %}
{% block page-description %}{% endblock %} <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
{% block rochester-made %}{% endblock %} <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
{% block keyboard-shortcuts %}{% endblock %}
{% block intercom %}{% endblock %}
{% block js %}
{{ block.super }}
window.blog_post = true;
{% endblock %}
{% block header %} <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/blog-themes/pro-adams/style.css?1" />
<header class="main">
<div class="inner group"> {% if has_snipts and not detail %}
<h1> <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ request.path }}?rss{% if not public %}&api_key={{ request.user.api_key.key }}{% endif %}" />
<a href="/"> {% endif %}
{% if blog_user.username == 'nick' %}
Nick Sergeant <!--[if IE]>
{% elif blog_user.username == 'blog' %} <style type="text/css">
Snipt Blog .group {
{% else %} display: block;
{{ blog_user.username }} zoom: 1;
{% endif %} }
</a> </style>
</h1> <![endif]-->
</div>
</header> <!--[if lt IE 9]>
{% endblock %} <script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
{% block sub-header %} <![endif]-->
<header class="sub">
<div class="inner group"> </head>
<ul class="bcrumb">
<li class="prompt">//</li> <body class="{% block body-class %}{% endblock %}">
<li><a href="/">blog</a></li>
{% block breadcrumb %}{% endblock %} <div class="frame">
<li class="rss">
<a href="/?rss">RSS</a> {% block header %}
</li> <header class="main">
</ul> <h1>
</div> <a href="/">
</header> {% if blog_user.username == 'nick' %}
{% endblock %} Nick Sergeant
{% block aside %} {% elif blog_user.username == 'blog' %}
<aside class="main"> Snipt Blog
{% if sidebar %} {% else %}
<section class="sidebar"> {{ blog_user.username }}
{{ sidebar.stylized|safe }} {% endif %}
</section> </a>
{% endif %} </h1>
<nav class="footer {% if sidebar %}with-sidebar{% endif %}"> </header>
<ul class="powered"> {% endblock %}
<li class="snipt"><a href="https://snipt.net/">Blog powered by Snipt</a></li>
</ul> </div>
</nav>
</aside> {% if not debug %}
{% endblock %} <script type="text/javascript">
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '4ed65ee7f5a1f530f1000001');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
<script type="text/javascript">
window._idl = {};
_idl.variant = 'modal';
(function() {
var idl = document.createElement('script');
idl.type = 'text/javascript';
idl.async = true;
idl.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'members.internetdefenseleague.org/include/?url=' + (_idl.url || '') + '&campaign=' + (_idl.campaign || '') + '&variant=' + (_idl.variant || 'banner');
document.getElementsByTagName('body')[0].appendChild(idl);
})();
</script>
{% endif %}
</body>
</html>

View File

@ -28,10 +28,12 @@ def blog_list(request, username_or_custom_slug=None):
context['snipts'] = context['snipts'][:20] context['snipts'] = context['snipts'][:20]
return rss(request, context) return rss(request, context)
if request.blog_user.profile.is_pro: #if request.blog_user.profile.is_pro:
template = 'blogs/themes/pro-adams/list.html' #template = 'blogs/themes/pro-adams/list.html'
else: #else:
template = 'blogs/themes/default/list.html' #template = 'blogs/themes/default/list.html'
template = 'blogs/themes/default/list.html'
return render_to_response( return render_to_response(
template, template,
@ -60,10 +62,12 @@ def blog_post(request, username_or_custom_slug):
'snipt': snipt, 'snipt': snipt,
} }
if request.blog_user.profile.is_pro: #if request.blog_user.profile.is_pro:
template = 'blogs/themes/pro-adams/post.html' #template = 'blogs/themes/pro-adams/post.html'
else: #else:
template = 'blogs/themes/default/post.html' #template = 'blogs/themes/default/post.html'
template = 'blogs/themes/default/post.html'
return render_to_response( return render_to_response(
template, template,

View File

@ -0,0 +1 @@
html,body{background:#F2F2F2;margin:0;padding:0}body{color:#666;font:normal 14px/16px "Helvetica Neue",Helvetica,Arial,"Liberation Sans",FreeSans,sans-serif;text-rendering:optimizeLegibility}.group:after{content:".";display:block;height:0;clear:both;visibility:hidden}.hidden{display:none}

View File

@ -0,0 +1,85 @@
// Fonts
$Helvetica: 'Helvetica Neue', Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif;
$Consolas: Consolas, Menlo, "Courier New", monospace;
// Mixins
@mixin border-radius($radius: 5px) {
-webkit-background-clip: padding-box;
-webkit-border-radius: $radius;
-moz-background-clip: padding-box;
-moz-border-radius: $radius;
border-radius: $radius;
background-clip: padding-box;
}
@mixin box-shadow($horizontal: 0px, $vertical: 1px, $blur: 2px, $color: #CCC) {
-webkit-box-shadow: $horizontal $vertical $blur $color;
-moz-box-shadow: $horizontal $vertical $blur $color;
box-shadow: $horizontal $vertical $blur $color;
}
@mixin inset-box-shadow($horizontal: 0px, $vertical: 1px, $blur: 2px, $color: #CCC) {
-webkit-box-shadow: inset $horizontal $vertical $blur $color;
-moz-box-shadow: inset $horizontal $vertical $blur $color;
box-shadow: inset $horizontal $vertical $blur $color;
}
@mixin multi-color-border($top, $sides, $bottom) {
border-top: 1px solid $top;
border-left: 1px solid $sides;
border-right: 1px solid $sides;
border-bottom: 1px solid $bottom;
}
@mixin multi-border-radius($topLeft: 5px, $topRight: 5px, $bottomRight: 5px, $bottomLeft: 5px) {
-webkit-border-top-left-radius: $topLeft;
-webkit-border-top-right-radius: $topRight;
-webkit-border-bottom-right-radius: $bottomRight;
-webkit-border-bottom-left-radius: $bottomLeft;
-moz-border-radius-topleft: $topLeft;
-moz-border-radius-topright: $topRight;
-moz-border-radius-bottomright: $bottomRight;
-moz-border-radius-bottomleft: $bottomLeft;
border-top-left-radius: $topLeft;
border-top-right-radius: $topRight;
border-bottom-right-radius: $bottomRight;
border-bottom-left-radius: $bottomLeft;
}
@mixin vertical-gradient($start: #000, $stop: #FFF) { background: ($start + $stop) / 2;
background: -webkit-gradient(linear, left top, left bottom, from($start), to($stop));
background: -moz-linear-gradient(center top, $start 0%, $stop 100%);
background: -moz-gradient(center top, $start 0%, $stop 100%);
}
@mixin vertical-gradient-with-image($image, $start: #000, $stop: #FFF) {
background: ($start + $stop) / 2 $image;
background: $image, -webkit-gradient(linear, left top, left bottom, from($start), to($stop));
background: $image, -moz-linear-gradient(center top, $start 0%, $stop 100%);
background: $image, -moz-gradient(center top, $start 0%, $stop 100%);
}
@mixin opacity($op) {
-khtml-opacity: $op;
-moz-opacity: $op;
opacity: $op;
}
// Page
html, body {
background: #F2F2F2;
margin: 0;
padding: 0;
}
body {
color: #666;
font: normal 14px/16px $Helvetica;
text-rendering: optimizeLegibility;
}
// Utils
.group:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.hidden {
display: none;
}
// Global

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1358,8 +1358,7 @@ div.empty-snipts {
@include border-radius(8px); @include border-radius(8px);
} }
div.site-notice { div.site-notice {
margin: 20px; margin: 30px;
margin-right: 30px;
padding-right: 14px; padding-right: 14px;
text-align: center; text-align: center;

View File

@ -57,6 +57,17 @@ class PublicTagResource(ModelResource):
allowed_methods = ['get'] allowed_methods = ['get']
cache = SimpleCache() cache = SimpleCache()
def build_filters(self, filters=None):
if filters is None:
filters = {}
orm_filters = super(PublicTagResource, self).build_filters(filters)
if 'q' in filters:
orm_filters['slug'] = filters['q']
return orm_filters
def dehydrate(self, bundle): def dehydrate(self, bundle):
bundle.data['absolute_url'] = '/public/tag/%s/' % bundle.obj.slug bundle.data['absolute_url'] = '/public/tag/%s/' % bundle.obj.slug
bundle.data['snipts'] = '/api/public/snipt/?tag=%d' % bundle.obj.id bundle.data['snipts'] = '/api/public/snipt/?tag=%d' % bundle.obj.id
@ -134,6 +145,16 @@ class PrivateTagResource(ModelResource):
always_return_data = True always_return_data = True
cache = SimpleCache() cache = SimpleCache()
def build_filters(self, filters=None):
if filters is None:
filters = {}
orm_filters = super(PublicTagResource, self).build_filters(filters)
if 'q' in filters:
orm_filters['slug'] = filters['q']
return orm_filters
def dehydrate(self, bundle): def dehydrate(self, bundle):
bundle.data['absolute_url'] = '/%s/tag/%s/' % (bundle.request.user.username, bundle.data['absolute_url'] = '/%s/tag/%s/' % (bundle.request.user.username,
bundle.obj.slug) bundle.obj.slug)

View File

@ -11,5 +11,8 @@
{% endblock %} {% endblock %}
{% block aside-top %} {% block aside-top %}
{% if not request.user.profile.is_pro %}
{% include 'carbon.html' %}
{% endif %}
{% include "snipts/tags-public.html" %} {% include "snipts/tags-public.html" %}
{% endblock %} {% endblock %}

View File

@ -13,6 +13,9 @@
{% endblock %} {% endblock %}
{% block aside-top %} {% block aside-top %}
{% if not request.user.profile.is_pro %}
{% include 'carbon.html' %}
{% endif %}
<div class="profile group"> <div class="profile group">
<span class="avatar" title="Manage your avatar at Gravatar.com" style="background-image: url('https://secure.gravatar.com/avatar/{{ user.email|md5 }}?s=50');"></span> <span class="avatar" title="Manage your avatar at Gravatar.com" style="background-image: url('https://secure.gravatar.com/avatar/{{ user.email|md5 }}?s=50');"></span>
<div class="meta"> <div class="meta">

18
templates/carbon.html Normal file
View File

@ -0,0 +1,18 @@
<section class="ad">
<div id="carbonads-container">
<div class="carbonad">
<div id="azcarbon"></div>
<script type="text/javascript">
var z = document.createElement("script");
z.type = "text/javascript";
z.async = true;
z.src = "https://engine.carbonads.com/z/12124/azcarbon_2_1_0_VERT";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(z, s);
</script>
</div>
</div>
</section>
<div class="go-pro">
<a href="/pro/">Get rid of these annoying ads &raquo;</a>
</div>