Initial commit
This commit is contained in:
commit
4b29603d79
40 changed files with 850 additions and 0 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
*.pyc
|
||||||
|
local_settings.py
|
||||||
|
static
|
||||||
|
.toudou
|
||||||
|
test.db
|
0
__init__.py
Normal file
0
__init__.py
Normal file
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 blog.models import Post
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
admin.site.register(Post)
|
33
blog/models.py
Normal file
33
blog/models.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
from django.db import models
|
||||||
|
from main.models import Tag, Activity
|
||||||
|
from django.db.models.signals import post_save, post_delete
|
||||||
|
|
||||||
|
class Post(models.Model):
|
||||||
|
subject = models.CharField(max_length=500)
|
||||||
|
body = models.TextField()
|
||||||
|
tags = models.ManyToManyField(Tag, null=True, blank=True)
|
||||||
|
postdate = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.subject
|
||||||
|
|
||||||
|
def post_saved_callback(sender, **kwargs):
|
||||||
|
if kwargs['created']:
|
||||||
|
acttype = 'add'
|
||||||
|
else:
|
||||||
|
acttype = 'edit'
|
||||||
|
|
||||||
|
a = Activity(actcategory='blog',
|
||||||
|
actdescription=kwargs["instance"].subject,
|
||||||
|
acttype = acttype,
|
||||||
|
objpk = kwargs["instance"].pk)
|
||||||
|
a.save()
|
||||||
|
|
||||||
|
def post_deleted_callback(sender, **kwargs):
|
||||||
|
a = Activity(actcategory='blog',
|
||||||
|
actdescription=kwargs["instance"].subject,
|
||||||
|
acttype = 'delete')
|
||||||
|
a.save()
|
||||||
|
|
||||||
|
post_save.connect(post_saved_callback, sender=Post)
|
||||||
|
post_delete.connect(post_deleted_callback, sender=Post)
|
23
blog/tests.py
Normal file
23
blog/tests.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
"""
|
||||||
|
This file demonstrates two different styles of tests (one doctest and one
|
||||||
|
unittest). These will both pass when you run "manage.py test".
|
||||||
|
|
||||||
|
Replace these 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.failUnlessEqual(1 + 1, 2)
|
||||||
|
|
||||||
|
__test__ = {"doctest": """
|
||||||
|
Another way to test that 1 + 1 is equal to 2.
|
||||||
|
|
||||||
|
>>> 1 + 1 == 2
|
||||||
|
True
|
||||||
|
"""}
|
||||||
|
|
9
blog/urls.py
Normal file
9
blog/urls.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from django.conf.urls.defaults import *
|
||||||
|
|
||||||
|
urlpatterns = patterns('blog.views',
|
||||||
|
(r'^$', 'index'),
|
||||||
|
(r'^(?P<page>\d+)/$', 'index'),
|
||||||
|
(r'^post/(?P<post_id>\d+)/$', 'post'),
|
||||||
|
(r'^tags/$', 'tags'),
|
||||||
|
(r'^tag/(?P<tag_name>[\w_]+)/$', 'tag'),
|
||||||
|
)
|
55
blog/views.py
Normal file
55
blog/views.py
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# Create your views here.
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import render_to_response
|
||||||
|
from django.template import Context, loader
|
||||||
|
from django.views.generic.simple import direct_to_template
|
||||||
|
from blog.models import Post, Tag
|
||||||
|
|
||||||
|
def index(request, page=0):
|
||||||
|
item_count = 7
|
||||||
|
|
||||||
|
page = int(page)
|
||||||
|
start_num = (page * item_count)
|
||||||
|
end_num = start_num + item_count
|
||||||
|
|
||||||
|
post_list = Post.objects.all().order_by("-postdate")[start_num:end_num]
|
||||||
|
|
||||||
|
has_previous = page > 0
|
||||||
|
has_next = end_num < Post.objects.all().count()
|
||||||
|
|
||||||
|
c = {
|
||||||
|
'postlist': post_list,
|
||||||
|
'has_next': has_next,
|
||||||
|
'has_previous': has_previous,
|
||||||
|
'next_page': page + 1,
|
||||||
|
'previous_page': page - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return direct_to_template(request, "blog/posts.html", c)
|
||||||
|
|
||||||
|
def post(request, post_id):
|
||||||
|
post = Post.objects.filter(pk=post_id)
|
||||||
|
t = loader.get_template("blog/posts.html")
|
||||||
|
c = Context({
|
||||||
|
'postlist': post,
|
||||||
|
})
|
||||||
|
|
||||||
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
|
def tags(request):
|
||||||
|
tag_list = Tag.objects.all()
|
||||||
|
t = loader.get_template("blog/tags.html")
|
||||||
|
c = Context({
|
||||||
|
'taglist': tag_list,
|
||||||
|
})
|
||||||
|
|
||||||
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
|
def tag(request, tag_name):
|
||||||
|
post_list = Post.objects.filter(tags__name=tag_name)
|
||||||
|
t = loader.get_template("blog/posts.html")
|
||||||
|
c = Context({
|
||||||
|
'postlist': post_list,
|
||||||
|
})
|
||||||
|
|
||||||
|
return HttpResponse(t.render(c))
|
0
links/__init__.py
Normal file
0
links/__init__.py
Normal file
4
links/admin.py
Normal file
4
links/admin.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from links.models import Bookmark
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
admin.site.register(Bookmark)
|
35
links/models.py
Normal file
35
links/models.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
from django.db import models
|
||||||
|
from main.models import Tag, Activity
|
||||||
|
from django.db.models.signals import post_save, post_delete
|
||||||
|
|
||||||
|
class Bookmark(models.Model):
|
||||||
|
url = models.URLField(primary_key=True, max_length=255)
|
||||||
|
date = models.DateTimeField(auto_now_add=True)
|
||||||
|
name = models.CharField(max_length=255)
|
||||||
|
description = models.TextField()
|
||||||
|
# tags = models.ManyToManyField(Tag, null=True, blank=True)
|
||||||
|
priority = models.IntegerField(null=True, blank=True)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def bookmark_saved_callback(sender, **kwargs):
|
||||||
|
if kwargs['created']:
|
||||||
|
acttype = 'add'
|
||||||
|
else:
|
||||||
|
acttype = 'edit'
|
||||||
|
|
||||||
|
a = Activity(actcategory='link',
|
||||||
|
actdescription=kwargs["instance"].name,
|
||||||
|
acttype = acttype,
|
||||||
|
objpk = kwargs["instance"].pk)
|
||||||
|
a.save()
|
||||||
|
|
||||||
|
def bookmark_deleted_callback(sender, **kwargs):
|
||||||
|
a = Activity(actcategory='link',
|
||||||
|
actdescription=kwargs["instance"].name,
|
||||||
|
acttype = 'delete')
|
||||||
|
a.save()
|
||||||
|
|
||||||
|
post_save.connect(bookmark_saved_callback, sender=Bookmark)
|
||||||
|
post_delete.connect(bookmark_deleted_callback, sender=Bookmark)
|
16
links/tests.py
Normal file
16
links/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)
|
5
links/urls.py
Normal file
5
links/urls.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.conf.urls.defaults import patterns
|
||||||
|
|
||||||
|
urlpatterns = patterns('links.views',
|
||||||
|
(r'^$', 'index'),
|
||||||
|
)
|
12
links/views.py
Normal file
12
links/views.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
from links.models import Bookmark
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.template import Context, loader
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
bookmark_list = Bookmark.objects.all().order_by("-date")[:100]
|
||||||
|
t = loader.get_template("links/links.html")
|
||||||
|
c = Context({
|
||||||
|
'bookmarklist': bookmark_list,
|
||||||
|
})
|
||||||
|
|
||||||
|
return HttpResponse(t.render(c))
|
15
local_settings.py.example
Normal file
15
local_settings.py.example
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
DEBUG = False
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
||||||
|
'NAME': '', # Or path to database file if using sqlite3.
|
||||||
|
'USER': '', # Not used with sqlite3.
|
||||||
|
'PASSWORD': '', # Not used with sqlite3.
|
||||||
|
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
|
||||||
|
'PORT': '', # Set to empty string for default. Not used with sqlite3.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make this unique, and don't share it with anybody.
|
||||||
|
SECRET_KEY = '00000000000000000000000000000000000000000000000000'
|
0
main/__init__.py
Normal file
0
main/__init__.py
Normal file
4
main/admin.py
Normal file
4
main/admin.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from main.models import Tag
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
admin.site.register(Tag)
|
24
main/models.py
Normal file
24
main/models.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
class Tag(models.Model):
|
||||||
|
name = models.CharField(primary_key=True, max_length=200)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class Activity(models.Model):
|
||||||
|
ACTCATEGORY_CHOICES = (
|
||||||
|
('blog', 'Blog post'),
|
||||||
|
('project', 'Project page'),
|
||||||
|
('link', 'Link'),
|
||||||
|
)
|
||||||
|
ACTTYPE_CHOICES = (
|
||||||
|
('add', 'Add'),
|
||||||
|
('edit', 'Edit'),
|
||||||
|
('delete', 'Delete'),
|
||||||
|
)
|
||||||
|
date = models.DateTimeField(auto_now=True)
|
||||||
|
actcategory = models.CharField(max_length=100, choices=ACTCATEGORY_CHOICES)
|
||||||
|
actdescription = models.CharField(max_length=500)
|
||||||
|
acttype = models.CharField(max_length=6)
|
||||||
|
objpk = models.CharField(max_length=300, null=True)
|
0
main/signals.py
Normal file
0
main/signals.py
Normal file
23
main/tests.py
Normal file
23
main/tests.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
"""
|
||||||
|
This file demonstrates two different styles of tests (one doctest and one
|
||||||
|
unittest). These will both pass when you run "manage.py test".
|
||||||
|
|
||||||
|
Replace these 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.failUnlessEqual(1 + 1, 2)
|
||||||
|
|
||||||
|
__test__ = {"doctest": """
|
||||||
|
Another way to test that 1 + 1 is equal to 2.
|
||||||
|
|
||||||
|
>>> 1 + 1 == 2
|
||||||
|
True
|
||||||
|
"""}
|
||||||
|
|
4
main/urls.py
Normal file
4
main/urls.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from django.conf.urls.defaults import *
|
||||||
|
|
||||||
|
urlpatterns = patterns('main.views',
|
||||||
|
(r'^$', 'index'))
|
13
main/views.py
Normal file
13
main/views.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import render_to_response
|
||||||
|
from django.template import Context, loader
|
||||||
|
from main.models import Activity
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
activity_list = Activity.objects.all().order_by("-date")[:5]
|
||||||
|
t = loader.get_template("home.html")
|
||||||
|
c = Context({
|
||||||
|
"activitylist": activity_list,
|
||||||
|
})
|
||||||
|
|
||||||
|
return HttpResponse(t.render(c))
|
11
manage.py
Normal file
11
manage.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env python2
|
||||||
|
from django.core.management import execute_manager
|
||||||
|
try:
|
||||||
|
import settings # Assumed to be in the same directory.
|
||||||
|
except ImportError:
|
||||||
|
import sys
|
||||||
|
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
execute_manager(settings)
|
0
projects/__init__.py
Normal file
0
projects/__init__.py
Normal file
6
projects/admin.py
Normal file
6
projects/admin.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from projects.models import Project, Language, Screenshot
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
admin.site.register(Project)
|
||||||
|
admin.site.register(Language)
|
||||||
|
admin.site.register(Screenshot)
|
59
projects/models.py
Normal file
59
projects/models.py
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
from django.db import models
|
||||||
|
from main.models import Tag, Activity
|
||||||
|
from django.db.models.signals import post_save, post_delete
|
||||||
|
|
||||||
|
class Language(models.Model):
|
||||||
|
name = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class Screenshot(models.Model):
|
||||||
|
url = models.URLField(max_length=255)
|
||||||
|
description = models.CharField(max_length=300)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.description
|
||||||
|
|
||||||
|
class Project(models.Model):
|
||||||
|
STATUS_CHOICES = (
|
||||||
|
('active', "Active"),
|
||||||
|
('onhold', "On Hold"),
|
||||||
|
('dropped', "Dropped"),
|
||||||
|
)
|
||||||
|
|
||||||
|
slug = models.SlugField(max_length=255, primary_key=True)
|
||||||
|
name = models.CharField(max_length=300)
|
||||||
|
status = models.CharField(max_length=8, choices=STATUS_CHOICES)
|
||||||
|
tagline = models.CharField(max_length=140, null=True, blank=True)
|
||||||
|
languages = models.ManyToManyField(Language, null=True, blank=True)
|
||||||
|
source_url = models.URLField(max_length=255, null=True, blank=True)
|
||||||
|
bugtracker_url = models.URLField(max_length=255, null=True, blank=True)
|
||||||
|
wiki_url = models.URLField(max_length=255, null=True, blank=True)
|
||||||
|
description = models.TextField()
|
||||||
|
screenshots = models.ForeignKey(Screenshot, null=True, blank=True)
|
||||||
|
# tags = models.ManyToManyField(Tag, null=True, blank=True)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def project_saved_callback(sender, **kwargs):
|
||||||
|
if kwargs['created']:
|
||||||
|
acttype = 'add'
|
||||||
|
else:
|
||||||
|
acttype = 'edit'
|
||||||
|
|
||||||
|
a = Activity(actcategory='project',
|
||||||
|
actdescription=kwargs["instance"].name,
|
||||||
|
acttype = acttype,
|
||||||
|
objpk = kwargs["instance"].pk)
|
||||||
|
a.save()
|
||||||
|
|
||||||
|
def project_deleted_callback(sender, **kwargs):
|
||||||
|
a = Activity(actcategory='project',
|
||||||
|
actdescription=kwargs["instance"].name,
|
||||||
|
acttype = 'delete')
|
||||||
|
a.save()
|
||||||
|
|
||||||
|
post_save.connect(project_saved_callback, sender=Project)
|
||||||
|
post_delete.connect(project_deleted_callback, sender=Project)
|
13
projects/urls.py
Normal file
13
projects/urls.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from django.conf.urls.defaults import *
|
||||||
|
from projects.models import Project, Language
|
||||||
|
|
||||||
|
project_info_dict = {
|
||||||
|
'queryset': Project.objects.all(),
|
||||||
|
}
|
||||||
|
|
||||||
|
urlpatterns = patterns('',
|
||||||
|
(r'^$',
|
||||||
|
'django.views.generic.list_detail.object_list',
|
||||||
|
project_info_dict),
|
||||||
|
(r'^(?P<object_id>[\w-]+)/$', 'projects.views.project'),
|
||||||
|
)
|
24
projects/views.py
Normal file
24
projects/views.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.template import Context, loader
|
||||||
|
from projects.models import Project
|
||||||
|
|
||||||
|
def project(request, object_id):
|
||||||
|
project = Project.objects.get(pk=object_id)
|
||||||
|
stats_dict = {
|
||||||
|
"Status": project.get_status_display(),
|
||||||
|
"Languages": ", ".join([language.name for language in project.languages.all()]),
|
||||||
|
}
|
||||||
|
links_dict = {
|
||||||
|
"Source": project.source_url,
|
||||||
|
"Bugtracker": project.bugtracker_url,
|
||||||
|
"Wiki": project.wiki_url,
|
||||||
|
}
|
||||||
|
|
||||||
|
t = loader.get_template("projects/project_detail.html")
|
||||||
|
c = Context({
|
||||||
|
"object": project,
|
||||||
|
"stats": stats_dict,
|
||||||
|
"links": links_dict,
|
||||||
|
})
|
||||||
|
|
||||||
|
return HttpResponse(t.render(c))
|
91
settings.py
Normal file
91
settings.py
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
# Django settings for website project.
|
||||||
|
import os, sys
|
||||||
|
from local_settings import *
|
||||||
|
|
||||||
|
DEPLOY_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
sys.path.insert(0, DEPLOY_PATH)
|
||||||
|
|
||||||
|
TEMPLATE_DEBUG = DEBUG
|
||||||
|
|
||||||
|
ADMINS = (
|
||||||
|
('Tom Willemsen', 'ryuslash@gmail.com'),
|
||||||
|
)
|
||||||
|
|
||||||
|
MANAGERS = ADMINS
|
||||||
|
|
||||||
|
# Local time zone for this installation. Choices can be found here:
|
||||||
|
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||||
|
# although not all choices may be available on all operating systems.
|
||||||
|
# On Unix systems, a value of None will cause Django to use the same
|
||||||
|
# timezone as the operating system.
|
||||||
|
# If running in a Windows environment this must be set to the same as your
|
||||||
|
# system time zone.
|
||||||
|
TIME_ZONE = 'Europe/Brussels'
|
||||||
|
|
||||||
|
# Language code for this installation. All choices can be found here:
|
||||||
|
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||||
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
|
SITE_ID = 1
|
||||||
|
|
||||||
|
# If you set this to False, Django will make some optimizations so as not
|
||||||
|
# to load the internationalization machinery.
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
# If you set this to False, Django will not format dates, numbers and
|
||||||
|
# calendars according to the current locale
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||||
|
# Example: "/home/media/media.lawrence.com/"
|
||||||
|
MEDIA_ROOT = ''
|
||||||
|
|
||||||
|
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||||
|
# trailing slash if there is a path component (optional in other cases).
|
||||||
|
# Examples: "http://media.lawrence.com", "http://example.com/media/"
|
||||||
|
MEDIA_URL = ''
|
||||||
|
|
||||||
|
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
|
||||||
|
# trailing slash.
|
||||||
|
# Examples: "http://foo.com/media/", "/media/".
|
||||||
|
ADMIN_MEDIA_PREFIX = '/media/'
|
||||||
|
|
||||||
|
# List of callables that know how to import templates from various sources.
|
||||||
|
TEMPLATE_LOADERS = (
|
||||||
|
'django.template.loaders.filesystem.Loader',
|
||||||
|
'django.template.loaders.app_directories.Loader',
|
||||||
|
# 'django.template.loaders.eggs.Loader',
|
||||||
|
)
|
||||||
|
|
||||||
|
MIDDLEWARE_CLASSES = (
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
)
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'urls'
|
||||||
|
|
||||||
|
TEMPLATE_DIRS = (
|
||||||
|
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
|
||||||
|
# Always use forward slashes, even on Windows.
|
||||||
|
# Don't forget to use absolute paths, not relative paths.
|
||||||
|
'%s/templates' % DEPLOY_PATH,
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALLED_APPS = (
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.sites',
|
||||||
|
'django.contrib.messages',
|
||||||
|
# Uncomment the next line to enable the admin:
|
||||||
|
'django.contrib.admin',
|
||||||
|
# Uncomment the next line to enable admin documentation:
|
||||||
|
# 'django.contrib.admindocs',
|
||||||
|
'main',
|
||||||
|
'blog',
|
||||||
|
'projects',
|
||||||
|
'links',
|
||||||
|
)
|
50
templates/admin/login.html
Normal file
50
templates/admin/login.html
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block extrastyle %}{% load adminmedia %}{{ block.super }}<link rel="stylesheet" type="text/css" href="/static/css/login.css" />{% endblock %}
|
||||||
|
|
||||||
|
{% block bodyclass %}login{% endblock %}
|
||||||
|
|
||||||
|
{% block nav-global %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content_title %}{% endblock %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if form.errors and not form.non_field_errors and not form.this_is_the_login_form.errors %}
|
||||||
|
<p class="errornote">
|
||||||
|
{% blocktrans count form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if form.non_field_errors or form.this_is_the_login_form.errors %}
|
||||||
|
{% for error in form.non_field_errors|add:form.this_is_the_login_form.errors %}
|
||||||
|
<p class="errornote">
|
||||||
|
{{ error }}
|
||||||
|
</p>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="content-main">
|
||||||
|
<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
|
||||||
|
<div class="form-row">
|
||||||
|
{% if not form.this_is_the_login_form.errors %}{{ form.username.errors }}{% endif %}
|
||||||
|
<label for="id_username" class="required">{% trans 'Username:' %}</label> {{ form.username }}
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
{% if not form.this_is_the_login_form.errors %}{{ form.password.errors }}{% endif %}
|
||||||
|
<label for="id_password" class="required">{% trans 'Password:' %}</label> {{ form.password }}
|
||||||
|
<input type="hidden" name="this_is_the_login_form" value="1" />
|
||||||
|
<input type="hidden" name="next" value="{{ next }}" />
|
||||||
|
</div>
|
||||||
|
<div class="submit-row">
|
||||||
|
<label> </label><input type="submit" value="{% trans 'Log in' %}" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
document.getElementById('id_username').focus()
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
44
templates/base.html
Normal file
44
templates/base.html
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<!-- -*- Mode: django-html-mumamo -*- -->
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>ryuslash | {% block subtitle %}linux and coding{% endblock %}</title>
|
||||||
|
<link href="/static/css/main.css" type="text/css" rel="stylesheet" />
|
||||||
|
{% block extrastyle %}{% endblock %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container">
|
||||||
|
<div id="header">
|
||||||
|
<img id="logo" src="/static/img/logo.png" width="100" height="100" />
|
||||||
|
<h1 id="title">
|
||||||
|
<span id="ryu">ryu</span><span id="slash">slash</span>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div id="body">
|
||||||
|
<div class="clearleft"></div>
|
||||||
|
<div id="menu">
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
root
|
||||||
|
</div>
|
||||||
|
<a href="/">home</a><br />
|
||||||
|
<a href="/blog/">blog</a><br />
|
||||||
|
<a href="/projects/">projects</a><br />
|
||||||
|
<a href="/links/">links</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% block submenu %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
<div id="content">
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
<div class="clear"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="footer">
|
||||||
|
Copyright © 2011 Tom Willemsen
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
5
templates/blog/base.html
Normal file
5
templates/blog/base.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block subtitle %}
|
||||||
|
blog
|
||||||
|
{% endblock %}
|
42
templates/blog/posts.html
Normal file
42
templates/blog/posts.html
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<!-- -*- Mode: django-html-mumamo -*- -->
|
||||||
|
|
||||||
|
{% extends "blog/base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if postlist %}
|
||||||
|
{% for post in postlist %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<a href="/blog/post/{{ post.pk }}/">
|
||||||
|
<span class="title">{{ post.subject }}</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% autoescape off %}
|
||||||
|
{{ post.body|linebreaksbr }}
|
||||||
|
{% endautoescape %}
|
||||||
|
<div class="footer">
|
||||||
|
Date posted: {{ post.postdate|date:"r" }}
|
||||||
|
Tags:
|
||||||
|
{% for tag in post.tags.all %}
|
||||||
|
{% if forloop.counter > 1 %}, {% endif %}
|
||||||
|
<a href="/blog/tag/{{ tag.name }}">{{ tag.name }}</a>
|
||||||
|
{% empty %}
|
||||||
|
None
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<div class="navigation">
|
||||||
|
{% if has_next %}
|
||||||
|
<a class="next" href="/blog/{{ next_page }}/">next</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if has_previous %}
|
||||||
|
<a class="previous" href="/blog/{{ previous_page }}/">previous</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
Yeah I know, I'm boring.
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
19
templates/blog/tags.html
Normal file
19
templates/blog/tags.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<!-- -*- Mode: django-html-mumamo -*- -->
|
||||||
|
|
||||||
|
{% extends "blog/base.html" %}
|
||||||
|
|
||||||
|
{% block subtitle %}
|
||||||
|
blog/tags
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<ul>
|
||||||
|
{% for tag in taglist %}
|
||||||
|
<li>
|
||||||
|
<a href="/blog/tag/{{ tag.name }}">{{ tag.name }}</a>
|
||||||
|
</li>
|
||||||
|
{% empty %}
|
||||||
|
Sorry, no tags here.
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
88
templates/home.html
Normal file
88
templates/home.html
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
This will, hopefully, eventually, become my website.
|
||||||
|
<strong>Rejoice!</strong>
|
||||||
|
<p>
|
||||||
|
Some places you can already find me:
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="http://gitorious.org/~ryuslash">Gitorious</a>
|
||||||
|
- This is where I host most of my projects.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://github.com/ryuslash">Github</a>
|
||||||
|
- Sometimes I host projects here as well, but I prefer
|
||||||
|
Gitorious.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="http://stackoverflow.com/users/459915/slash">Stack Overflow</a>
|
||||||
|
- Don't really do much there, but I did just get my
|
||||||
|
first reputation points.
|
||||||
|
<br/>
|
||||||
|
<a href="http://stackoverflow.com/users/459915/slash">
|
||||||
|
<img src="http://stackoverflow.com/users/flair/459915.png?theme=dark"
|
||||||
|
width="208" height="58"
|
||||||
|
alt="profile for slash at Stack Overflow, Q&A
|
||||||
|
for professional and enthusiast
|
||||||
|
programmers"
|
||||||
|
title="profile for slash at Stack Overflow, Q&A
|
||||||
|
for professional and enthusiast programmers" />
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% for activity in activitylist %}
|
||||||
|
<div class="activity_{% cycle 'even' 'uneven' %}
|
||||||
|
{% if forloop.last %}activity_last{% endif %}">
|
||||||
|
{{ activity.date|date:'d M H:i:' }}
|
||||||
|
{% if activity.actcategory == "blog" %}
|
||||||
|
{% if activity.acttype == "add" %}
|
||||||
|
I ranted about
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.acttype == "edit" %}
|
||||||
|
I changed my opinion about
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.acttype == "delete" %}
|
||||||
|
I lost my opinion about
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.objpk %}
|
||||||
|
<a href="/blog/post/{{ activity.objpk }}/">
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.actcategory == "project" %}
|
||||||
|
{% if activity.acttype == "add" %}
|
||||||
|
I started a project named
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.acttype == "edit" %}
|
||||||
|
I updated the info on project
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.acttype == "delete" %}
|
||||||
|
I quit project
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.objpk %}
|
||||||
|
<a href="/projects/{{ activity.objpk }}/">
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.actcategory == "link" %}
|
||||||
|
{% if activity.acttype == "add" %}
|
||||||
|
I found
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.acttype == "edit" %}
|
||||||
|
I corrected
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.acttype == "delete" %}
|
||||||
|
I unlinked
|
||||||
|
{% endif %}
|
||||||
|
{% if activity.objpk %}
|
||||||
|
<a href="/links/">
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{{ activity.actdescription }}
|
||||||
|
{% if activity.objpk %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
20
templates/links/links.html
Normal file
20
templates/links/links.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block subtitle %}
|
||||||
|
links
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<span class="title">links</span>
|
||||||
|
</div>
|
||||||
|
{% if bookmarklist %}
|
||||||
|
{% for link in bookmarklist %}
|
||||||
|
<a href="{{ link.url }}">{{ link.name }}</a><br/>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
No links, no where...
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
3
templates/projects/base.html
Normal file
3
templates/projects/base.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<!-- -*- Mode: django-html-mumamo -*- -->
|
||||||
|
|
||||||
|
{% extends "base.html" %}
|
52
templates/projects/project_detail.html
Normal file
52
templates/projects/project_detail.html
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<!-- -*- Mode: django-html-mumamo -*- -->
|
||||||
|
|
||||||
|
{% extends "projects/base.html" %}
|
||||||
|
|
||||||
|
{% block subtitle %}
|
||||||
|
projects/{{ object.name }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<span class="title">{{ object.name }}</span>
|
||||||
|
<span class="tagline">{{ object.tagline }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{% autoescape off %}
|
||||||
|
{{ object.description|linebreaksbr }}
|
||||||
|
{% endautoescape %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<span class="title">Stats</title>
|
||||||
|
</div>
|
||||||
|
{% for key, value in stats.items %}
|
||||||
|
{% if value %}
|
||||||
|
{{ key }}: {{ value }}<br/>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<span class="title">Links</title>
|
||||||
|
</div>
|
||||||
|
{% for key, value in links.items %}
|
||||||
|
{% if value %}
|
||||||
|
<a href="{{ value }}">{{ key }}</a><br/>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if object.screenshots %}
|
||||||
|
<p>
|
||||||
|
Screenshots here
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
20
templates/projects/project_list.html
Normal file
20
templates/projects/project_list.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<!-- -*- Mode: django-html-mumamo -*- -->
|
||||||
|
|
||||||
|
{% extends "projects/base.html" %}
|
||||||
|
|
||||||
|
{% block subtitle %}
|
||||||
|
projects
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if object_list %}
|
||||||
|
<dl>
|
||||||
|
{% for project in object_list %}
|
||||||
|
<dt><a href="/projects/{{ project.slug }}/">{{ project.name }}</a></dt>
|
||||||
|
<dd>{{ project.tagline }}</dd>
|
||||||
|
{% endfor %}
|
||||||
|
</dl>
|
||||||
|
{% else %}
|
||||||
|
Well, you know me, I'm lazy. Got nothing going on.
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
19
urls.py
Normal file
19
urls.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from django.conf.urls.defaults import *
|
||||||
|
from settings import DEPLOY_PATH, DEBUG
|
||||||
|
|
||||||
|
# Uncomment the next two lines to enable the admin:
|
||||||
|
from django.contrib import admin
|
||||||
|
admin.autodiscover()
|
||||||
|
|
||||||
|
urlpatterns = patterns('',
|
||||||
|
(r'^blog/', include("blog.urls")),
|
||||||
|
(r'^projects/', include("projects.urls")),
|
||||||
|
(r'^links/', include("links.urls")),
|
||||||
|
(r'^admin/', include(admin.site.urls)),
|
||||||
|
(r'^', include("main.urls")),
|
||||||
|
)
|
||||||
|
|
||||||
|
if DEBUG:
|
||||||
|
urlpatterns += patterns('',
|
||||||
|
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '%s/static' % DEPLOY_PATH})
|
||||||
|
)
|
Loading…
Reference in a new issue