Initial commit
This commit is contained in:
0
blog/__init__.py
Normal file
0
blog/__init__.py
Normal file
4
blog/admin.py
Normal file
4
blog/admin.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from django.contrib import admin
|
||||
from blog.models import Post
|
||||
|
||||
admin.site.register(Post)
|
13
blog/models.py
Normal file
13
blog/models.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
class Post(models.Model):
|
||||
user = models.ForeignKey(User)
|
||||
created_at = models.DateTimeField()
|
||||
title = models.CharField(max_length = 100)
|
||||
slug = models.CharField(max_length = 100)
|
||||
content = models.TextField()
|
||||
draft = models.BooleanField()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
19
blog/static/css/admin.css
Normal file
19
blog/static/css/admin.css
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Document : admin.css
|
||||
Created on : 2012.09.05., 15:49:05
|
||||
Author : polonkai.gergely
|
||||
Description:
|
||||
Purpose of the stylesheet follows.
|
||||
*/
|
||||
|
||||
ul.menu {
|
||||
padding: .5em;
|
||||
list-style-type: none;
|
||||
margin: 0 0 1em 0;
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
|
||||
ul.menu li {
|
||||
display: inline;
|
||||
margin-right: 1em;
|
||||
}
|
26
blog/static/css/blog.css
Normal file
26
blog/static/css/blog.css
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Document : blog
|
||||
Created on : 2012.09.14., 14:53:34
|
||||
Author : polonkai.gergely
|
||||
Description:
|
||||
Purpose of the stylesheet follows.
|
||||
*/
|
||||
|
||||
.post {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
p.article-date {
|
||||
text-indent: 0;
|
||||
font-size: 80%;
|
||||
color: #7f7f7f;
|
||||
}
|
||||
|
||||
.paginator {
|
||||
margin: .5em 0;
|
||||
}
|
||||
|
||||
.plusone-container {
|
||||
margin-left: 1em;
|
||||
display: inline;
|
||||
}
|
BIN
blog/static/images/tagcloud.png
Normal file
BIN
blog/static/images/tagcloud.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
11
blog/templates/blog/listing.html
Normal file
11
blog/templates/blog/listing.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends "front_base.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% if posts %}
|
||||
{% for post in posts %}
|
||||
{{ post.title }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>No posts are returned for your query.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
5
blog/templates/blog/view.html
Normal file
5
blog/templates/blog/view.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{% extends "front_base.html" %}
|
||||
|
||||
<div class="post">
|
||||
<h3><a href="{% url 'read' post.created_at.year post.created_at.month post.created_at.day post.slug %}">{{ post.title }}</a></h3>
|
||||
</div>
|
16
blog/tests.py
Normal file
16
blog/tests.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
This file demonstrates writing tests using the unittest module. These will pass
|
||||
when you run "manage.py test".
|
||||
|
||||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.assertEqual(1 + 1, 2)
|
11
blog/urls.py
Normal file
11
blog/urls.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from django.conf.urls import patterns, url
|
||||
from blog import views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', views.index, name='index'),
|
||||
url(r'^feed$', views.feed, name='feed'),
|
||||
url(r'^(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)/(?P<slug>[^/]+)$', views.read, name='read'),
|
||||
url(r'^resume', views.resume, name='resume'),
|
||||
url(r'^about', views.resume, name='about'),
|
||||
url(r'^disclaimer', views.resume, name='disclaimer'),
|
||||
)
|
24
blog/views.py
Normal file
24
blog/views.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import datetime
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from blog.models import Post
|
||||
|
||||
def index(request):
|
||||
last_posts = Post.objects.order_by('-created_at')[:5]
|
||||
context = { 'posts': last_posts }
|
||||
return render(request, 'blog/listing.html', context)
|
||||
|
||||
def read(request, year, month, day, slug):
|
||||
post = get_object_or_404(Post, created_at__year=int(year), created_at__month=int(month), created_at__day=int(day), slug=slug);
|
||||
return render(request, 'blog/view.html', {'post': post})
|
||||
|
||||
def feed(request):
|
||||
return render(request, 'blog/feed.xml', {})
|
||||
|
||||
def resume(request):
|
||||
return render(request, 'resume.html', {})
|
||||
|
||||
def about(request):
|
||||
return renden(request, 'about.html', {})
|
||||
|
||||
def disclaimer(request):
|
||||
return renden(request, 'disclaimer.html', {})
|
Reference in New Issue
Block a user