Tons of cosmetic stuff for public views. Private icon / sub header nav / proper titles / tag list views

master
Nick Sergeant 2011-12-03 00:19:01 -05:00
parent c5f3b24cee
commit d38bef1ab0
11 changed files with 111 additions and 41 deletions

View File

@ -193,6 +193,40 @@ header.main {
}
}
}
header.sub {
.vertical-gradient(#ECECEC, #DBDBDB);
div.inner {
border-left: 1px solid #d0d0d0;
margin: 0 auto;
position: relative;
width: 939px;
z-index: 49;
ul {
border-right: 1px solid #d0d0d0;
padding-left: 16px;
width: 733px;
li {
display: inline-block;
padding: 4px 0 6px 0;
a {
color: #999999;
font: bold 14px @Inconsolata;
text-shadow: 0 1px 0 #FFF;
}
&.prompt {
color: #999999;
font: bold 14px @Inconsolata;
margin-right: 3px;
text-shadow: 0 1px 0 #FFF;
}
}
}
}
}
section.main {
height: 100%;
margin: 0 auto;
@ -241,7 +275,7 @@ section.main {
}
}
section.tags {
margin: 45px 15px;
margin: 0 15px 45px 15px;
h1 {
background: transparent url('/media/images/tags-icon.png') 0 0 no-repeat;
@ -629,6 +663,13 @@ article.snipt {
}
}
}
article.private-snipt {
div.container {
header {
.vertical-gradient-with-image(#FFF, #FFFAF2, url('/media/images/private-icon.png') top right no-repeat);
}
}
}
div.pagination {
margin: 0 15px 35px 15px;
text-align: center;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -69,7 +69,6 @@ STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
if DEBUG:
STATIC_URL = '/media/'
else:
#STATIC_URL = 'https://dn2p0mzo970os.cloudfront.net/'
STATIC_URL = 'https://snipt.s3.amazonaws.com/'
# S3 Settings
@ -80,7 +79,7 @@ AWS_STORAGE_BUCKET_NAME = 'snipt'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = STATIC_URL + 'grappelli/'
ADMIN_MEDIA_PREFIX = 'https://snipt.s3.amazonaws.com/grappelli/'
# Additional locations of static files
STATICFILES_DIRS = (
@ -114,8 +113,8 @@ TEMPLATE_CONTEXT_PROCESSORS = (
MIDDLEWARE_CLASSES = (
'snipt.middleware.www.WWWMiddleware',
'johnny.middleware.LocalStoreClearMiddleware',
'johnny.middleware.QueryCacheMiddleware',
#'johnny.middleware.LocalStoreClearMiddleware',
#'johnny.middleware.QueryCacheMiddleware',
'django.middleware.cache.CacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
@ -155,6 +154,9 @@ INSTALLED_APPS = (
'snipts',
)
if DEBUG:
INSTALLED_APPS += ('django_extensions',)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
@ -202,11 +204,11 @@ ABSOLUTE_URL_OVERRIDES = {
}
# Caching
CACHES = {
'default': dict(
BACKEND = 'johnny.backends.memcached.MemcachedCache',
LOCATION = ['app1575260%40heroku.com@mc7.ec2.northscale.net:11211'],
JOHNNY_CACHE = True,
)
}
JOHNNY_MIDDLEWARE_KEY_PREFIX='johnny_snipt'
#CACHES = {
#'default': dict(
#BACKEND = 'johnny.backends.memcached.MemcachedCache',
#LOCATION = ['127.0.0.1:11211'],
#JOHNNY_CACHE = True,
#)
#}
#JOHNNY_MIDDLEWARE_KEY_PREFIX='johnny_snipt'

View File

@ -9,8 +9,7 @@ class CommentInline(admin.TabularInline):
allow_add = False
class SniptAdmin(admin.ModelAdmin):
# TODO: Make user readonly
#readonly_fields = ('user',)
readonly_fields = ('user',)
list_display = ('title', 'slug', 'user', 'lexer', 'public', 'created', 'modified',)
search_fields = ('title', 'user__username', 'lexer', 'id',)
ordering = ('created',)

View File

@ -2,6 +2,15 @@
{% load pagination_tags %}
{% block page-title %}{% if tag %}/ public / {{ tag }} - {% endif %}{{ block.super }}{% endblock %}
{% block breadcrumb %}
<li><a href="/public/">public</a></li>
{% if tag %}
<li>/ <a href="/public/{{ tag }}/">{{ tag }}</a></li>
{% endif %}
{% endblock %}
{% block tags %}
{% include "snipts/tags-public.html" %}
{% endblock %}

View File

@ -2,6 +2,15 @@
{% load pagination_tags %}
{% block page-title %}/ {{ user.username }}{% if tag %} / {{ tag }}{% endif %} - {{ block.super }}{% endblock %}
{% block breadcrumb %}
<li><a href="/{{ user.username }}/">{{ user.username }}</a></li>
{% if tag %}
<li>/ <a href="/{{ user.username }}/{{ tag }}/">{{ tag }}</a></li>
{% endif %}
{% endblock %}
{% block tags %}
{% include "snipts/tags-user.html" %}
{% endblock %}

View File

@ -1,6 +1,6 @@
{% load humanize %}
<article class="snipt">
<article class="snipt {% if not snipt.public %}private-snipt{% endif %}">
<div class="number">#{{ snipt.id }}</div>
<div class="group">
<div class="container">
@ -44,7 +44,7 @@
{% if public %}
<a href="/public/tag/{{ tag.slug }}/">{{ tag }}</a>
{% else %}
<a href="/{{ request.user.username }}/tag/{{ tag.slug }}/">{{ tag }}</a>
<a href="/{{ snipt.user.username }}/tag/{{ tag.slug }}/">{{ tag }}</a>
{% endif %}
</li>
{% endfor %}

View File

@ -1,9 +1,9 @@
<section class="tags">
<h1>{{ request.user.username }}'s tags</h1>
<h1>{{ user.username }}'s tags</h1>
<ul>
{% for tag in tags %}
<li>
<a href="/{{ request.user.username }}/tag/{{ tag.slug }}/">{{ tag.name }} ({{ tag.count }})</a>
<a href="/{{ user.username }}/tag/{{ tag.slug }}/">{{ tag.name }} ({{ tag.count }})</a>
</li>
{% endfor %}
</ul>

View File

@ -5,5 +5,8 @@ from snipts import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^(?P<user>[^/]+/)?$', views.list_user, name='list-user'),
url(r'^public/$', views.list_public, name='list-public'),
url(r'^public/tag/(?P<tag>[^/]+)/$', views.list_public, name='list-public-tag'),
url(r'^(?P<user>[^/]+)/$', views.list_user, name='list-user'),
url(r'^(?P<user>[^/]+)/tag/(?P<tag>[^/]+)/$', views.list_user, name='list-user-tag'),
)

View File

@ -1,5 +1,5 @@
from snipts.api import PublicSniptResource, PublicTagResource
from django.shortcuts import get_object_or_404
from django.http import HttpResponseRedirect
from django.contrib.auth.models import User
from annoying.decorators import render_to
from django.db.models import Count
@ -8,12 +8,12 @@ from taggit.models import Tag
def home(request):
if request.user.is_authenticated():
return list_user(request, user=request.user)
return HttpResponseRedirect('/%s/' % request.user.username)
else:
return list_public(request)
@render_to('snipts/list-public.html')
def list_public(request):
def list_public(request, tag=None):
tags = Tag.objects.filter(snipt__public=True)
tags = tags.annotate(count=Count('taggit_taggeditem_items__id'))
@ -21,17 +21,19 @@ def list_public(request):
snipts = Snipt.objects.filter(public=True).order_by('-created')
if tag:
snipts = snipts.filter(tags__name__in=[tag])
return {
'snipts': snipts,
'tags': tags,
'tag': tag,
}
@render_to('snipts/list-user.html')
def list_user(request, user):
if type(user) == unicode:
user = get_object_or_404(User, username=user.strip('/'))
def list_user(request, user, tag=None):
user = get_object_or_404(User, username=user)
tags = Tag.objects
snipts = Snipt.objects
@ -46,8 +48,12 @@ def list_user(request, user):
tags = tags.order_by('-count')
snipts = snipts.order_by('-created')
if tag:
snipts = snipts.filter(tags__name__in=[tag])
return {
'snipts': snipts,
'tags': tags,
'tag': tag,
'user': user,
}

View File

@ -42,7 +42,6 @@
</head>
<body class="{% block body-class %}{% endblock %}">
<header class="main">
<div class="inner">
<div class="shadey"></div>
@ -58,7 +57,7 @@
<nav class="public">
<ul>
<li>
<a href="/" class="active">Public snipts</a>
<a href="/public/" {% if '/public/' in request.path or not request.user.is_authenticated %} class="active"{% endif %}>Public snipts</a>
</li>
{% if not request.user.is_authenticated %}
<li>
@ -69,7 +68,7 @@
</li>
{% else %}
<li>
<a href="/">My snipts</a>
<a href="/" {% if request.user.username in request.path %} class="active"{% endif %}>My snipts</a>
</li>
{% endif %}
</ul>
@ -77,18 +76,19 @@
<aside class="nav"></aside>
</div>
</header>
<header class="sub">
<div class="inner">
<ul>
<li class="prompt">/</li>
{% block breadcrumb %}{% endblock %}
</ul>
</div>
</header>
<section class="main group">
<div class="inner">
{% block content %}{% endblock %}
</div>
<aside class="main">
<section class="ad">
<div class="asset"></div>
<div class="meta">
Ads by Yoggrt
</div>
</section>
{% block tags %}{% endblock %}
<nav class="footer">
<ul>
@ -98,8 +98,11 @@
<li class="twitter">
<a href="https://twitter.com/#!/snipt">@snipt</a>
</li>
<li class="pro">
<a href="/pro/">Go Pro</a>
<li class="twitter">
<a href="https://twitter.com/#!/nicksergeant">@nicksergeant</a>
</li>
<li class="twitter">
<a href="https://twitter.com/#!/nickadamssays">@nickadamssays</a>
</li>
</ul>
</nav>
@ -107,7 +110,6 @@
<div class="left-y ruler"></div>
<div class="right-y ruler"></div>
</section>
{% if not debug %}
<script type="text/javascript">
//<![CDATA[
@ -122,6 +124,5 @@
//]]>
</script>
{% endif %}
</body>
</html>