Working on blog
parent
34bc88b2ef
commit
a55f79921e
|
@ -1,8 +1,33 @@
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
class SubdomainMiddleware:
|
|
||||||
|
class BlogMiddleware:
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
request.subdomain = None
|
request.blog_user = None
|
||||||
|
|
||||||
host = request.META.get('HTTP_HOST', '')
|
host = request.META.get('HTTP_HOST', '')
|
||||||
host_s = host.replace('www.', '').split('.')
|
host_s = host.replace('www.', '').split('.')
|
||||||
if len(host_s) > 2:
|
|
||||||
request.subdomain = ''.join(host_s[:-2])
|
if host != 'snipt.net' and host != 'snipt.localhost':
|
||||||
|
# nick.snipt.net or nicksergeant.com or blog.nicksergeant.com
|
||||||
|
|
||||||
|
if len(host_s) > 2:
|
||||||
|
# nick.snipt.net or blog.nicksergeant.com
|
||||||
|
|
||||||
|
if host_s[1] == 'snipt':
|
||||||
|
# nick.snipt.net or nick.snipt.localhost
|
||||||
|
|
||||||
|
blog_user = ''.join(host_s[:-2]).replace('-', '_')
|
||||||
|
request.blog_user = get_object_or_404(User, username__iexact=blog_user)
|
||||||
|
else:
|
||||||
|
# blog.nicksergeant.com
|
||||||
|
|
||||||
|
# Get user for that domain
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# nicksergeant.com
|
||||||
|
|
||||||
|
# Get user for that domain
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
{% extends "blogs/base.html" %}
|
|
||||||
|
|
||||||
{% load compress pagination_tags %}
|
|
||||||
|
|
||||||
{% block js %}
|
|
||||||
{{ block.super }}
|
|
||||||
window.detail = false;
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block body-class %}{{ block.super }} blog-homepage{% endblock %}
|
|
||||||
|
|
||||||
{% block css %}
|
|
||||||
{% compress css %}
|
|
||||||
<link rel="stylesheet" type="text/x-scss" href="{{ STATIC_URL }}css/style.scss" />
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/themes.css" />
|
|
||||||
{% endcompress %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block main %}
|
|
||||||
<section class="frame">
|
|
||||||
<h1 class="blog-title">
|
|
||||||
<a href="/">
|
|
||||||
{% if user.username == 'nick' %}
|
|
||||||
Nick Sergeant
|
|
||||||
{% else %}
|
|
||||||
{{ user.username }}
|
|
||||||
{% endif %}
|
|
||||||
</a>
|
|
||||||
</h1>
|
|
||||||
{% if homepage.lexer == 'markdown' %}
|
|
||||||
<div class="markdown">
|
|
||||||
{{ homepage.stylized|safe }}
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
{{ homepage.stylized|safe }}
|
|
||||||
{% endif %}
|
|
||||||
</section>
|
|
||||||
{% endblock %}
|
|
|
@ -14,7 +14,7 @@
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{% compress css %}
|
{% compress css %}
|
||||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/bootstrap.css" />
|
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/bootstrap.css" />
|
||||||
<link rel="stylesheet" type="text/x-scss" href="{{ STATIC_URL }}css/style.scss" />
|
<link rel="stylesheet" type="text/x-scss" href="{{ STATIC_URL }}css/blog-themes/default/style.scss" />
|
||||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/themes.css" />
|
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/themes.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/chosen.css" />
|
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/chosen.css" />
|
||||||
{% endcompress %}
|
{% endcompress %}
|
||||||
|
@ -26,5 +26,20 @@
|
||||||
{% block sub-header %}{% endblock %}
|
{% block sub-header %}{% endblock %}
|
||||||
{% block rochester-made %}{% endblock %}
|
{% block rochester-made %}{% endblock %}
|
||||||
{% block aside %}{% endblock %}
|
{% block aside %}{% endblock %}
|
||||||
{% block header %}{% endblock %}
|
|
||||||
{% block keyboard-shortcuts %}{% endblock %}
|
{% block keyboard-shortcuts %}{% endblock %}
|
||||||
|
{% block header %}{% endblock %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<section class="frame">
|
||||||
|
<h1 class="blog-title">
|
||||||
|
<a href="/">
|
||||||
|
{% if blog_user.username == 'nick' %}
|
||||||
|
Nick Sergeant
|
||||||
|
{% else %}
|
||||||
|
{{ blog_user.username }}
|
||||||
|
{% endif %}
|
||||||
|
</a>
|
||||||
|
</h1>
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends "blogs/themes/default/base.html" %}
|
||||||
|
|
||||||
|
{% load compress pagination_tags %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ block.super }}
|
||||||
|
window.detail = false;
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body-class %}{{ block.super }} blog-homepage{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if homepage.lexer == 'markdown' %}
|
||||||
|
<div class="markdown">
|
||||||
|
{{ homepage.stylized|safe }}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
{{ homepage.stylized|safe }}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "blogs/base.html" %}
|
{% extends "blogs/themes/default/base.html" %}
|
||||||
|
|
||||||
{% load compress pagination_tags %}
|
{% load compress pagination_tags %}
|
||||||
|
|
||||||
|
@ -7,22 +7,11 @@
|
||||||
window.detail = false;
|
window.detail = false;
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block header %}
|
|
||||||
<header class="main">
|
|
||||||
<h1 class="blog-title">
|
|
||||||
<a href="/">
|
|
||||||
{% if user.username == 'nick' %}
|
|
||||||
Nick Sergeant{% else %}
|
|
||||||
{{ user.username }}{% endif %}'s Blog
|
|
||||||
</a>
|
|
||||||
</h1>
|
|
||||||
</header>
|
|
||||||
{% endblock %}
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<section class="snipts" id="snipts">
|
<section class="snipts" id="snipts">
|
||||||
{% autopaginate snipts 10 %}
|
{% autopaginate snipts 10 %}
|
||||||
{% for snipt in snipts %}
|
{% for snipt in snipts %}
|
||||||
{% include "blogs/snipt-list.html" %}
|
{% include "blogs/themes/default/snipt-list.html" %}
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<div class="empty-snipts">
|
<div class="empty-snipts">
|
||||||
{{ user.username }} has no public blog posts.
|
{{ user.username }} has no public blog posts.
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.conf.urls.defaults import *
|
||||||
|
|
||||||
|
urlpatterns = patterns('',
|
||||||
|
url(r'^$', views.blog_homepage, name='blog-homepage'),
|
||||||
|
url(r'^blog/$', views.blog, name='blog'),
|
||||||
|
)
|
|
@ -1,29 +1,33 @@
|
||||||
from django.shortcuts import get_object_or_404, render_to_response
|
from django.shortcuts import render_to_response
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from annoying.decorators import render_to
|
from annoying.decorators import render_to
|
||||||
|
|
||||||
from snipts.models import Snipt
|
from snipts.models import Snipt
|
||||||
|
|
||||||
|
|
||||||
@render_to('blogs/homepage.html')
|
@render_to('blogs/themes/default/homepage.html')
|
||||||
def blog_homepage(request, user, homepage):
|
def blog_homepage(request):
|
||||||
|
|
||||||
|
try:
|
||||||
|
homepage = Snipt.objects.get(user=request.blog_user, title__iexact='Homepage', blog_post=True, public=True)
|
||||||
|
except Snipt.DoesNotExist:
|
||||||
|
return blog_list(request)
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'homepage': homepage,
|
'homepage': homepage,
|
||||||
'user': user,
|
'blog_user': request.blog_user,
|
||||||
}
|
}
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@render_to('blogs/list.html')
|
@render_to('blogs/themes/default/list.html')
|
||||||
def blog_list(request, user):
|
def blog_list(request):
|
||||||
|
|
||||||
snipts = Snipt.objects.filter(user=user, blog_post=True, public=True).order_by('-created').exclude(title__iexact='Homepage')
|
snipts = Snipt.objects.filter(user=request.blog_user, blog_post=True, public=True).order_by('-created').exclude(title__iexact='Homepage')
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'snipts': snipts,
|
'snipts': snipts,
|
||||||
'user': user,
|
'blog_user': request.blog_user,
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'rss' in request.GET:
|
if 'rss' in request.GET:
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
body.blog-site {
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
section.frame {
|
||||||
|
margin: 0 auto;
|
||||||
|
padding-top: 50px;
|
||||||
|
width: 500px;
|
||||||
|
}
|
||||||
|
h1.blog-title {
|
||||||
|
font-size: 34px;
|
||||||
|
margin-bottom: 50px;
|
||||||
|
margin-top: 0;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #0094AF;
|
||||||
|
font-weight: normal;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
header.main {
|
||||||
|
background: none;
|
||||||
|
border-bottom: 0;
|
||||||
|
height: auto;
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 940px;
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin: 0;
|
||||||
|
padding: 29px 0 0 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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%);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Page
|
||||||
|
html, body {
|
||||||
|
background: #F5F2F3 url('/static/images/bg.gif') top left repeat;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
color: #666;
|
||||||
|
font: normal 14px/16px $Helvetica;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
|
||||||
|
li {
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utils
|
||||||
|
.group:after {
|
||||||
|
content: ".";
|
||||||
|
display: block;
|
||||||
|
height: 0;
|
||||||
|
clear: both;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
color: #B3B3B3;
|
||||||
|
font: normal 17px/24px $Helvetica;
|
||||||
|
|
||||||
|
h1.blog-title {
|
||||||
|
line-height: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body.blog-homepage {
|
||||||
|
padding-bottom: 39px;
|
||||||
|
|
||||||
|
p {
|
||||||
|
font: normal 17px/24px $Helvetica;
|
||||||
|
margin: 17px 0;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
line-height: 24px;
|
||||||
|
margin: 5px 15px;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
display: block;
|
||||||
|
margin: 53px auto 0 auto;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
color: #898989;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #292929;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1310
media/css/style.css
1310
media/css/style.css
File diff suppressed because it is too large
Load Diff
|
@ -1429,61 +1429,3 @@ body.blog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blogs
|
|
||||||
body.blog-site {
|
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
section.frame {
|
|
||||||
margin: 0 auto;
|
|
||||||
padding-top: 50px;
|
|
||||||
width: 500px;
|
|
||||||
}
|
|
||||||
h1.blog-title {
|
|
||||||
font-size: 34px;
|
|
||||||
margin-bottom: 50px;
|
|
||||||
margin-top: 0;
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: #0094AF;
|
|
||||||
font-weight: normal;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
header.main {
|
|
||||||
background: none;
|
|
||||||
border-bottom: 0;
|
|
||||||
height: auto;
|
|
||||||
margin: 0 auto;
|
|
||||||
width: 940px;
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
margin: 0;
|
|
||||||
padding: 29px 0 0 15px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
body.blog-homepage {
|
|
||||||
color: #B3B3B3;
|
|
||||||
font: normal 17px/24px $Helvetica;
|
|
||||||
|
|
||||||
li {
|
|
||||||
line-height: 24px;
|
|
||||||
margin: 5px 0;
|
|
||||||
}
|
|
||||||
p:last-of-type {
|
|
||||||
margin: 0;
|
|
||||||
padding-bottom: 56px;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
display: block;
|
|
||||||
margin: 53px auto 0 auto;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #898989;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: #292929;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ MIDDLEWARE_CLASSES = (
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'pagination.middleware.PaginationMiddleware',
|
'pagination.middleware.PaginationMiddleware',
|
||||||
'blogs.middleware.SubdomainMiddleware',
|
'blogs.middleware.BlogMiddleware',
|
||||||
)
|
)
|
||||||
|
|
||||||
ROOT_URLCONF = 'snipt.urls'
|
ROOT_URLCONF = 'snipt.urls'
|
||||||
|
|
|
@ -6,7 +6,6 @@ from snipts import views
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^$', views.home, name='home'),
|
url(r'^$', views.home, name='home'),
|
||||||
url(r'^public/$', views.list_public, name='list-public'),
|
url(r'^public/$', views.list_public, name='list-public'),
|
||||||
url(r'^blog/$', views.blog, name='blog'),
|
|
||||||
url(r'^public/tag/(?P<tag_slug>[^/]+)/$', views.list_public, name='list-public-tag'),
|
url(r'^public/tag/(?P<tag_slug>[^/]+)/$', views.list_public, name='list-public-tag'),
|
||||||
url(r'^embed/(?P<snipt_key>[^/]+)/$', views.embed, name='embed'),
|
url(r'^embed/(?P<snipt_key>[^/]+)/$', views.embed, name='embed'),
|
||||||
url(r'^raw/(?P<snipt_key>[^/]+)/$', views.raw, name='raw'),
|
url(r'^raw/(?P<snipt_key>[^/]+)/$', views.raw, name='raw'),
|
||||||
|
|
|
@ -20,29 +20,14 @@ RESULTS_PER_PAGE = getattr(settings, 'HAYSTACK_SEARCH_RESULTS_PER_PAGE', 20)
|
||||||
|
|
||||||
def home(request):
|
def home(request):
|
||||||
|
|
||||||
if request.subdomain:
|
if request.blog_user:
|
||||||
subdomain = request.subdomain.replace('-', '_')
|
return blog_homepage(request)
|
||||||
user = get_object_or_404(User, username__iexact=subdomain)
|
|
||||||
|
|
||||||
try:
|
|
||||||
homepage = Snipt.objects.get(user=user, title__iexact='Homepage', blog_post=True, public=True)
|
|
||||||
return blog_homepage(request, user, homepage)
|
|
||||||
except Snipt.DoesNotExist:
|
|
||||||
return blog_list(request, user)
|
|
||||||
|
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
return HttpResponseRedirect('/%s/' % request.user.username)
|
return HttpResponseRedirect('/%s/' % request.user.username)
|
||||||
else:
|
else:
|
||||||
return list_public(request)
|
return list_public(request)
|
||||||
|
|
||||||
def blog(request):
|
|
||||||
if request.subdomain:
|
|
||||||
subdomain = request.subdomain.replace('-', '_')
|
|
||||||
user = get_object_or_404(User, username__iexact=subdomain)
|
|
||||||
return blog_list(request, user)
|
|
||||||
else:
|
|
||||||
return list_user(request, 'blog')
|
|
||||||
|
|
||||||
@render_to('snipts/detail.html')
|
@render_to('snipts/detail.html')
|
||||||
def detail(request, username, snipt_slug):
|
def detail(request, username, snipt_slug):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue