master
Nick Sergeant 2012-06-01 01:21:28 -04:00
parent 7fbe04ed7d
commit 0e8508806d
9 changed files with 337 additions and 187 deletions

View File

@ -1,5 +1,7 @@
{% extends "base.html" %}
{% load compress %}
{% block meta %}
{% if 'page' in request.get_full_path %}
<meta name="robots" content="noindex, follow" />
@ -7,16 +9,21 @@
{% endblock %}
{% block body-class %}blog-site{% endblock %}
{% block html-class %}blog-site{% endblock %}
{% block css %}
{% compress 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/css" href="{{ STATIC_URL }}css/themes.css" />
{% endcompress %}
{% endblock %}
{% block page-title %}{{ user.username }}'s blog - Powered by Snipt.net{% endblock %}
{% block header %}
<header class="blog">
<div class="inner">
<h1><a href="/">{{ user.username }}'s blog</a></h1>
</div>
</header>
{% endblock %}
{% block page-description %}{% endblock %}
{% block sub-header %}{% endblock %}
{% block rochester-made %}{% endblock %}
{% block aside %}{% endblock %}
{% block header %}{% endblock %}
{% block keyboard-shortcuts %}{% endblock %}

View File

@ -0,0 +1,38 @@
{% 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 %}

View File

@ -7,6 +7,17 @@
window.detail = false;
{% 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 %}
<section class="snipts" id="snipts">
{% autopaginate snipts 10 %}

View File

@ -6,11 +6,19 @@ from annoying.decorators import render_to
from snipts.models import Snipt
@render_to('blogs/list.html')
def list_blog(request, subdomain):
@render_to('blogs/homepage.html')
def blog_homepage(request, user, homepage):
context = {
'homepage': homepage,
'user': user,
}
return context
@render_to('blogs/list.html')
def blog_list(request, user):
subdomain = subdomain.replace('-', '_')
user = get_object_or_404(User, username__iexact=subdomain)
snipts = Snipt.objects.filter(user=user, blog_post=True, public=True).order_by('-created')
context = {

View File

@ -1263,20 +1263,53 @@ body.blog article.snipt section.code {
height: auto;
}
body.blog-site header.blog div.inner {
border-left: 1px solid rgba(229, 229, 229, 0.25);
margin: 30px auto 0 auto;
width: 939px;
body.blog-site {
color: #B3B3B3;
font: normal 17px/24px "Helvetica Neue", Helvetica, Arial, "Liberation Sans", FreeSans, sans-serif;
margin: 0;
}
body.blog-site header.blog div.inner h1 {
body.blog-site section.frame {
margin: 0 auto;
padding-top: 50px;
width: 500px;
}
body.blog-site h1.blog-title {
font-size: 34px;
margin-bottom: 50px;
margin-top: 0;
}
body.blog-site h1.blog-title a {
color: #0094AF;
font: normal 34px "Helvetica Neue", Helvetica, Arial, "Liberation Sans", FreeSans, sans-serif;
margin-left: 15px;
}
body.blog-site header.blog div.inner h1 a {
color: #0094AF;
}
body.blog-site header.blog div.inner h1 a:hover {
color: #292929;
font-weight: normal;
text-decoration: none;
}
body.blog-site a {
color: #898989;
}
body.blog-site a:hover {
color: #292929;
}
body.blog-site header.main {
background: none;
border-bottom: 0;
height: auto;
margin: 0 auto;
width: 940px;
}
body.blog-site header.main h1 {
margin: 0;
padding: 29px 0 0 15px;
}
body.blog-homepage li {
line-height: 24px;
margin: 5px 0;
}
body.blog-homepage p:last-of-type {
margin: 0;
padding-bottom: 56px;
}
body.blog-homepage img {
display: block;
margin: 53px auto 0 auto;
}

View File

@ -1432,26 +1432,57 @@ body.blog {
// Blogs
body.blog-site {
header.blog {
div.inner {
border-left: 1px solid rgba(229, 229, 229, .25);
margin: 30px auto 0 auto;
width: 939px;
color: #B3B3B3;
font: normal 17px/24px $Helvetica;
margin: 0;
h1 {
color: #0094AF;
font: normal 34px $Helvetica;
margin-left: 15px;
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;
a {
color: #0094AF;
font-weight: normal;
text-decoration: none;
}
}
a {
color: #898989;
&:hover {
color: #292929;
text-decoration: none;
}
}
}
&:hover {
color: #292929;
}
}
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 {
li {
line-height: 24px;
margin: 5px 0;
}
p:last-of-type {
margin: 0;
padding-bottom: 56px;
}
img {
display: block;
margin: 53px auto 0 auto;
}
}

View File

@ -6,6 +6,7 @@ from snipts import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
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'^embed/(?P<snipt_key>[^/]+)/$', views.embed, name='embed'),
url(r'^raw/(?P<snipt_key>[^/]+)/$', views.raw, name='raw'),

View File

@ -7,7 +7,7 @@ from django.template import RequestContext
from annoying.decorators import render_to
from snipts.models import Favorite, Snipt
from django.db.models import Count
from blogs.views import list_blog
from blogs.views import blog_homepage, blog_list
from django.conf import settings
from django.db.models import Q
from taggit.models import Tag
@ -21,13 +21,28 @@ RESULTS_PER_PAGE = getattr(settings, 'HAYSTACK_SEARCH_RESULTS_PER_PAGE', 20)
def home(request):
if request.subdomain:
return list_blog(request, request.subdomain)
subdomain = request.subdomain.replace('-', '_')
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():
return HttpResponseRedirect('/%s/' % request.user.username)
else:
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')
def detail(request, username, snipt_slug):

View File

@ -6,7 +6,9 @@
<title>{% block page-title %}Snipt{% endblock %}</title>
<meta charset="utf-8" />
<meta name="description" content="Long-term memory for coders. Share and store code snippets." />
{% block page-description %}
<meta name="description" content="Long-term memory for coders. Share and store code snippets." />
{% endblock %}
{% block meta %}{% endblock %}
@ -131,152 +133,156 @@
</div>
</header>
{% endblock %}
<section class="main group" id="main">
<div class="inner">
{% block content %}{% endblock %}
{% block rochester-made %}
<div class="rochester-made">
<a href="http://rochestermade.com/" title="Rochester Made">
<img src="{{ STATIC_URL }}images/rochester-made.png" alt="" />
</a>
</div>
{% block main %}
<section class="main group" id="main">
<div class="inner">
{% block content %}{% endblock %}
{% block rochester-made %}
<div class="rochester-made">
<a href="http://rochestermade.com/" title="Rochester Made">
<img src="{{ STATIC_URL }}images/rochester-made.png" alt="" />
</a>
</div>
{% endblock %}
</div>
{% block aside %}
<aside class="main">
<nav class="footer">
<ul>
<li class="api">
<a href="/api/" {% if '/api/' in request.path %}class="active"{% endif %}>API</a>
</li>
<li class="blog">
<a href="/blog/" {% if '/blog/' in request.path %}class="active"{% endif %}>Blog</a>
</li>
<li class="roadmap">
<a href="/todo/" {% if '/todo/' in request.path %}class="active"{% endif %}>Roadmap</a>
</li>
<li class="twitter">
<a href="https://twitter.com/#!/snipt">@snipt</a>
</li>
</ul>
</nav>
{% block tags %}{% endblock %}
</aside>
{% endblock %}
</div>
{% block aside %}
<aside class="main">
<nav class="footer">
<ul>
<li class="api">
<a href="/api/" {% if '/api/' in request.path %}class="active"{% endif %}>API</a>
</li>
<li class="blog">
<a href="/blog/" {% if '/blog/' in request.path %}class="active"{% endif %}>Blog</a>
</li>
<li class="roadmap">
<a href="/todo/" {% if '/todo/' in request.path %}class="active"{% endif %}>Roadmap</a>
</li>
<li class="twitter">
<a href="https://twitter.com/#!/snipt">@snipt</a>
</li>
</ul>
</nav>
{% block tags %}{% endblock %}
</aside>
{% endblock %}
<div class="left-y ruler"></div>
<div class="right-y ruler"></div>
</section>
<div class="left-y ruler"></div>
<div class="right-y ruler"></div>
</section>
{% endblock %}
<section class="main group hidden" id="main-edit"></section>
<div class="modal hide" id="keyboard-shortcuts">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3><span>Keyboard shortcuts</span></h3>
{% block keyboard-shortcuts %}
<div class="modal hide" id="keyboard-shortcuts">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3><span>Keyboard shortcuts</span></h3>
</div>
<div class="modal-body">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Key</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td>h</td>
<td>Show / hide keyboard shortcuts</td>
</tr>
<tr>
<td>/</td>
<td>Focus search field</td>
</tr>
<tr>
<td>esc</td>
<td>Unfocus search field / deselect snipt</td>
</tr>
<tr>
<td>j</td>
<td>Next snipt</td>
</tr>
<tr>
<td>k</td>
<td>Previous snipt</td>
</tr>
<tr>
<td>o / return</td>
<td>Go to snipt</td>
</tr>
<tr>
<td>u</td>
<td>Go to snipt's author</td>
</tr>
<tr>
<td>e</td>
<td>Expand / collapse snipt</td>
</tr>
<tr>
<td>v</td>
<td>Embed snipt</td>
</tr>
<tr>
<td>c</td>
<td>Copy snipt</td>
</tr>
<tr>
<td>&lt;ctrl-e&gt;</td>
<td>Edit snipt</td>
</tr>
<tr>
<td>&lt;ctrl-delete&gt; or &lt;ctrl-backspace&gt;</td>
<td>Delete snipt</td>
</tr>
<tr>
<td>&lt;ctrl-n&gt;</td>
<td>Add new snipt</td>
</tr>
<tr>
<td>&lt;ctrl-s&gt;</td>
<td>Save snipt</td>
</tr>
<tr>
<td>&lt;ctrl-c&gt;</td>
<td>Save snipt and close</td>
</tr>
<tr>
<td>n</td>
<td>Next page</td>
</tr>
<tr>
<td>p</td>
<td>Previous page</td>
</tr>
<tr>
<td>g</td>
<td>Scroll to top of page</td>
</tr>
<tr>
<td>G</td>
<td>Scroll to bottom of page</td>
</tr>
<tr>
<td>&lt;ctrl-h&gt;</td>
<td>Back</td>
</tr>
<tr>
<td>&lt;ctrl-l&gt;</td>
<td>Forward</td>
</tr>
<tr>
<td>t</td>
<td>Open new window/tab</td>
</tr>
<tr>
<td>r</td>
<td>Refresh page</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="modal-body">
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Key</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td>h</td>
<td>Show / hide keyboard shortcuts</td>
</tr>
<tr>
<td>/</td>
<td>Focus search field</td>
</tr>
<tr>
<td>esc</td>
<td>Unfocus search field / deselect snipt</td>
</tr>
<tr>
<td>j</td>
<td>Next snipt</td>
</tr>
<tr>
<td>k</td>
<td>Previous snipt</td>
</tr>
<tr>
<td>o / return</td>
<td>Go to snipt</td>
</tr>
<tr>
<td>u</td>
<td>Go to snipt's author</td>
</tr>
<tr>
<td>e</td>
<td>Expand / collapse snipt</td>
</tr>
<tr>
<td>v</td>
<td>Embed snipt</td>
</tr>
<tr>
<td>c</td>
<td>Copy snipt</td>
</tr>
<tr>
<td>&lt;ctrl-e&gt;</td>
<td>Edit snipt</td>
</tr>
<tr>
<td>&lt;ctrl-delete&gt; or &lt;ctrl-backspace&gt;</td>
<td>Delete snipt</td>
</tr>
<tr>
<td>&lt;ctrl-n&gt;</td>
<td>Add new snipt</td>
</tr>
<tr>
<td>&lt;ctrl-s&gt;</td>
<td>Save snipt</td>
</tr>
<tr>
<td>&lt;ctrl-c&gt;</td>
<td>Save snipt and close</td>
</tr>
<tr>
<td>n</td>
<td>Next page</td>
</tr>
<tr>
<td>p</td>
<td>Previous page</td>
</tr>
<tr>
<td>g</td>
<td>Scroll to top of page</td>
</tr>
<tr>
<td>G</td>
<td>Scroll to bottom of page</td>
</tr>
<tr>
<td>&lt;ctrl-h&gt;</td>
<td>Back</td>
</tr>
<tr>
<td>&lt;ctrl-l&gt;</td>
<td>Forward</td>
</tr>
<tr>
<td>t</td>
<td>Open new window/tab</td>
</tr>
<tr>
<td>r</td>
<td>Refresh page</td>
</tr>
</tbody>
</table>
</div>
</div>
{% endblock %}
<div class="hidden" id="templates">
{% include 'snipts/snipt-js-template.html' %}
{% include 'snipts/snipt-edit-js-template.html' %}