Skip to content

Commit

Permalink
Merge branch 'master' of github.com:durden/dash
Browse files Browse the repository at this point in the history
  • Loading branch information
eloyz committed Jul 31, 2011
2 parents 3132ef8 + 1295a28 commit bbbae30
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 8 deletions.
3 changes: 3 additions & 0 deletions FIXME
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
- Add notes on supported short codes somewhere on post page
- At least try to test installing site from a clean repo
- Add more instructions on how to run locally with extra server for github
mocks?
10 changes: 10 additions & 0 deletions apps/codrspace/static/codrspace.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ a.get-started { font-size: 24px; }
text-align: center;
}

#post-list-content ul#other-links {
list-style-type: none;
margin: 20px 0 0 0;
padding: 0;
}

#post-list-content ul#other-links li {
margin-top: 5px;
}

/* user detail */
#user-detail p {
margin: 5px 0 5px 0;
Expand Down
5 changes: 4 additions & 1 deletion apps/codrspace/templates/post_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
<h2 class="post-header"><a href="{{ post.get_absolute_url }}">{% firstof post.title "Untitled" %}</a></h2>
<div class="post-meta">{{ post.create_dt }}</div>
<div class="post-content">
{{ post.content|explosivo }}
{% load cache %}
{% cache 3600 content %}
{{ post.content|explosivo }}
{% endcache %}
</div>
{% ifequal user post.author %}
<div class="post-options">
Expand Down
22 changes: 15 additions & 7 deletions apps/codrspace/templates/post_list.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{% extends "base.html" %}

{% load markup %}
{% load short_codes %}
{% load syntax_color %}
{% load codrspace_tags %}

{% block content %}
<div id="post-list-content">
Expand All @@ -12,8 +11,11 @@
<ul id="auth-options">
<li><a href="{% url add %}">Add Post</a></li>
<li><a href="{% url signout %}">Sign Out</a></li>
<ul>
</ul>
{% endif %}
<ul id="other-links">
<li><a href="{% random_blog %}">Random Blog &raquo;</a></li>
</ul>
</div>
<div id="right-column">
{% for post in posts %}
Expand All @@ -30,10 +32,16 @@ <h2 class="post-header"><a href="{{ post.get_absolute_url }}">{% firstof post.ti
{% endif %}
</div>
{% empty %}
<div id="no-posts-message">
<p>A little empty ...</p>
<p><a href="{% url add %}">Let's add some posts!</a></p>
</div>
{% if username == request.username %}
<div id="no-posts-message">
<p>A little empty ...</p>
<p><a href="{% url add %}">Let's add some posts!</a></p>
</div>
{% else %}
<div id="no-posts-message">
<p>This person hasn't posted yet :(</p>
</div>
{% endif %}
{% endfor %}
</div>
</div>
Expand Down
19 changes: 19 additions & 0 deletions apps/codrspace/templatetags/codrspace_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.template import Library, TemplateSyntaxError, Variable, Node
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

register = Library()


class RandomBlogNode(Node):
def render(self, context):
random_user = User.objects.order_by('?')[0]
return reverse('post_list', args=[random_user.username])

@register.tag
def random_blog(parser, token):
"""
Get a random bloggers post list page
{% random_blog %}
"""
return RandomBlogNode()
5 changes: 5 additions & 0 deletions apps/codrspace/templatetags/short_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def filter_gist(value):
_colorize_table(content['files'][name]['content'], None)
)

if content['comments'] > 0:
gist_text += '<hr>Join the conversation on ' + \
'<a href="%s#comments">github</a> (%d comments)' % (
content['html_url'], content['comments'])

return (re.sub(pattern, gist_text, markdown.markdown(value)), match)


Expand Down
1 change: 1 addition & 0 deletions apps/codrspace/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def post_detail(request, username, slug, template_name="post_detail.html"):
raise Http404

return render(request, template_name, {
'username': username,
'post': post,
'meta': user.profile.get_meta(),
})
Expand Down
18 changes: 18 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
)

ROOT_URLCONF = 'dash.urls'
Expand Down Expand Up @@ -165,6 +168,21 @@
}
}

CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': '/var/tmp/django_cache',
'TIMEOUT': 3600,
'OPTIONS': {
'MAX_ENTRIES': 1000
}
}
}

CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_SECONDS = 3600
CACHE_MIDDLEWARE_KEY_PREFIX = 'codrspace'

# Custom profile and authentication
AUTH_PROFILE_MODULE = 'codrspace.Profile'
AUTHENTICATION_BACKENDS = (
Expand Down

0 comments on commit bbbae30

Please sign in to comment.