Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Brown committed Dec 13, 2012
1 parent eabfd17 commit 5b94dc7
Show file tree
Hide file tree
Showing 41 changed files with 9,823 additions and 0 deletions.
Empty file added __init__.py
Empty file.
Empty file added blog/__init__.py
Empty file.
75 changes: 75 additions & 0 deletions blog/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from django.db import models
from django.contrib import admin
# Create your models here.


class Post(models.Model):
title = models.CharField(max_length=60)
body = models.TextField()
created = models.DateTimeField(auto_now_add=True)

def __unicode__(self):
return self.title


class LinksToRead(models.Model):
link = models.URLField()
title = models.CharField(max_length=125)
date_added = models.DateTimeField(auto_now_add=True)
description = models.TextField()

def __unicode__(self):
return self.title


class Code(models.Model):
title = models.CharField(max_length=60)
body = models.TextField()
created = models.DateTimeField(auto_now_add=True)

def __unicode__(self):
return self.title


class Projects(models.Model):
title = models.CharField(max_length=60)
body = models.TextField()

def __unicode__(self):
return self.title


class Research(models.Model):
title = models.CharField(max_length=60)
body = models.TextField()

def __unicode__(self):
return self.title


### Admin

class ResearchAdmin(admin.ModelAdmin):
search_fields = ["title"]


class ProjectsAdmin(admin.ModelAdmin):
search_fields = ["title"]


class PostAdmin(admin.ModelAdmin):
search_fields = ["title"]


class LinksAdmin(admin.ModelAdmin):
search_fields = ["title"]


class CodeAdmin(admin.ModelAdmin):
search_fields = ["title"]

admin.site.register(Post, PostAdmin)
admin.site.register(LinksToRead, LinksAdmin)
admin.site.register(Code, CodeAdmin)
admin.site.register(Research, ResearchAdmin)
admin.site.register(Projects, ProjectsAdmin)
16 changes: 16 additions & 0 deletions blog/tests.py
Original file line number Diff line number Diff line change
@@ -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)
72 changes: 72 additions & 0 deletions blog/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Create your views here.

from django.shortcuts import render_to_response
from models import *
from django.core.paginator import Paginator, InvalidPage, EmptyPage


def Blog(request):
"""Main listing."""
posts = Post.objects.all().order_by("-created")
paginator = Paginator(posts, 2)
recent_posts = Post.objects.all().order_by("-created")[:4]
links = LinksToRead.objects.all()

try:
page = int(request.GET.get("page", '1'))
except ValueError:
page = 1

try:
posts = paginator.page(page)
except (InvalidPage, EmptyPage):
posts = paginator.page(paginator.num_pages)

return render_to_response("BlogTemplate.html", {"posts": posts, "links": links, "recentposts": recent_posts})


def Article(request, post_num):
"""Page for Post"""
post = Post.objects.get(pk=post_num)
posts = Post.objects.all().order_by("-created")
paginator = Paginator(posts, 2)
recent_posts = Post.objects.all().order_by("-created")[:4]
links = LinksToRead.objects.all()

try:
page = int(request.GET.get("page", '1'))
except ValueError:
page = 1

try:
posts = paginator.page(page)
except (InvalidPage, EmptyPage):
posts = paginator.page(paginator.num_pages)
return render_to_response("BlogTemplate.html", {"post": post, "posts": posts, "links": links, "recentposts": recent_posts})


def CodeAndData(request):
"""Page for Code and Data"""
recent_posts = Post.objects.all().order_by("-created")[:4]
links = LinksToRead.objects.all()
posts = Code.objects.all().order_by("-created")

return render_to_response("OtherContentTemplate.html", {"posts": posts, "links": links, "recentposts": recent_posts})


def ProjectContent(request):
"""Page for Projects that I'm Working on"""
recent_posts = Post.objects.all().order_by("-created")[:4]
links = LinksToRead.objects.all()
posts = Projects.objects.all()

return render_to_response("OtherContentTemplate.html", {"posts": posts, "links": links, "recentposts": recent_posts})


def ResearchContent(request):
"""Page for Projects that I'm Working on"""
recent_posts = Post.objects.all().order_by("-created")[:4]
links = LinksToRead.objects.all()
posts = Research.objects.all()

return render_to_response("OtherContentTemplate.html", {"posts": posts, "links": links, "recentposts": recent_posts})
11 changes: 11 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/python
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)
113 changes: 113 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Django settings for testing project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '/Users/christbr1985/dreamhost_site/website_data.db', # 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.
}
}

# 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 = 'America/Chicago'

# 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 path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/Users/christbr1985/dreamhost_site/public/media'

# 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 = '/media/'

# 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/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'vq$nx^aogq)rpfrolqsd1l*^pb3a5(7x!$#1vz4212sb8(8zit'

# 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 = (
'/Users/christbr1985/dreamhost_site/templates/',
# 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.
)

STATIC_URL = '/static/'

STATIC_ROOT = '/Users/christbr1985/dreamhost_site/public/static/'

STATICFILES_DIRS = (
"/Users/christbr1985/dreamhost_site/templates",
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_admin_bootstrapped',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'website',
'django.contrib.markup',
'markdown'
)
48 changes: 48 additions & 0 deletions templates/BlogTemplate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends "base_content.html" %}
{% block page_content %}
{% load markup %}
<div class="container">
<div class="row-fluid">
<div class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header-blog">Recent Posts</li>
{% for post in recentposts %}
<li class="nav-link"><a href="#">{{ post.title }}</a></li>
{% endfor %}
<li class="nav-header-blog">What I'm Reading</li>
{% for link in links %}
<li class="nav-link"><a href="{{ link.link }}" rel="tooltip" data-placement="right" data-original-title="{{ link.description }}">{{ link.title }}</a></li>
{% endfor %}

{% if posts.object_list and posts.paginator.num_pages > 1 %}
<li class="nav-header-blog">Navigate Posts</li>
{% if posts.has_previous %}
<li class="nav-link"><a href= "?page={{ posts.previous_page_number }}">&lt;&lt; Newer Posts </a></li>
{% endif %}

{% if posts.has_next %}
<li class="nav-link"><a href="?page={{ posts.next_page_number }}">Older Posts &gt;&gt;</a></li>
{% endif %}
{% endif %}
</ul>
</div><!--/.well -->
</div><!--/span-->
<div class="span9 blog-posts">
<ul>
{% for post in posts %}
<div class="blog-title"><a href="/blog/post_num/{{ post.id }}">{{ post.title }}</a></div>
<ul>
<div class="blog-time">{{ post.created }}</div>
<div class="body-blog">{{ post.body|markdown }}</div>
</ul>
{% endfor %}
</ul>
</div><!--/span-->
</div><!--/row-->

</div><!--/.fluid-container-->

<!-- Next/Prev page links -->

{% endblock %}
48 changes: 48 additions & 0 deletions templates/OtherContentTemplate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends "base_content.html" %}
{% block page_content %}
{% load markup %}
<div class="container">
<div class="row-fluid">
<div class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header-blog">Recent Posts</li>
{% for post in recentposts %}
<li class="nav-link"><a href="#">{{ post.title }}</a></li>
{% endfor %}
<li class="nav-header-blog">What I'm Reading</li>
{% for link in links %}
<li class="nav-link"><a href="{{ link.link }}" rel="tooltip" data-placement="right" data-original-title="{{ link.description }}">{{ link.title }}</a></li>
{% endfor %}

{% if posts.object_list and posts.paginator.num_pages > 1 %}
<li class="nav-header-blog">Navigate Posts</li>
{% if posts.has_previous %}
<li class="nav-link"><a href= "?page={{ posts.previous_page_number }}">&lt;&lt; Newer Posts </a></li>
{% endif %}

{% if posts.has_next %}
<li class="nav-link"><a href="?page={{ posts.next_page_number }}">Older Posts &gt;&gt;</a></li>
{% endif %}
{% endif %}
</ul>
</div><!--/.well -->
</div><!--/span-->
<div class="span9 blog-posts">
<ul>
{% for post in posts %}
<div class="blog-title"><a href="#">{{ post.title }}</a></div>
<ul>
<div class="blog-time">{{ post.created }}</div>
<div class="body-blog">{{ post.body|markdown }}</div>
</ul>
{% endfor %}
</ul>
</div><!--/span-->
</div><!--/row-->

</div><!--/.fluid-container-->

<!-- Next/Prev page links -->

{% endblock %}
Loading

0 comments on commit 5b94dc7

Please sign in to comment.