summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/__init__.py0
-rw-r--r--app/src/admin.py37
-rw-r--r--app/src/models.py93
-rw-r--r--app/src/urls.py16
-rw-r--r--app/src/views.py8
-rw-r--r--config/base_urls.py1
-rw-r--r--design/sass/_src.scss4
-rw-r--r--design/sass/screenv8.scss1
-rw-r--r--design/templates/archives/src_books.html22
-rw-r--r--design/templates/archives/src_home.html0
-rw-r--r--design/templates/details/src_entry.html69
-rw-r--r--design/templates/src_base.html79
12 files changed, 330 insertions, 0 deletions
diff --git a/app/src/__init__.py b/app/src/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/src/__init__.py
diff --git a/app/src/admin.py b/app/src/admin.py
new file mode 100644
index 0000000..2a9a285
--- /dev/null
+++ b/app/src/admin.py
@@ -0,0 +1,37 @@
+from django.contrib import admin
+from .models import Topic, Entry, Book
+from blog.admin import BlogEntryForm
+
+class TopicAdmin(admin.ModelAdmin):
+ prepopulated_fields = {"slug": ('name',), "pluralized_name":('name',)}
+
+class BookAdmin(admin.ModelAdmin):
+ prepopulated_fields = {"slug": ('title',),}
+
+class EntryAdmin(admin.ModelAdmin):
+ form = BlogEntryForm
+ list_display = ('title', 'pub_date', 'enable_comments', 'status')
+ list_filter = ('pub_date', 'enable_comments', 'status')
+ prepopulated_fields = {"slug": ('title',)}
+ fieldsets = (
+ ('Entry', {
+ 'fields': (
+ 'title',
+ 'body_markdown',
+ ('pub_date', 'status'),
+ 'topics',
+ 'meta_description',
+ ('slug', 'enable_comments', 'template_name'),
+ ),
+ 'classes': (
+ 'show',
+ 'extrapretty',
+ 'wide'
+ )
+ }
+ ),
+ )
+
+admin.site.register(Book, BookAdmin)
+admin.site.register(Topic, TopicAdmin)
+admin.site.register(Entry, EntryAdmin)
diff --git a/app/src/models.py b/app/src/models.py
new file mode 100644
index 0000000..f7362cb
--- /dev/null
+++ b/app/src/models.py
@@ -0,0 +1,93 @@
+from django.db import models
+from blog.models import image_url_replace, extract_images
+import markdown
+
+class Topic(models.Model):
+ name = models.CharField(max_length=60)
+ slug = models.SlugField()
+ pluralized_name = models.CharField(max_length=60)
+
+ def __str__(self):
+ return self.name
+
+
+class Entry(models.Model):
+ title = models.CharField(max_length=200)
+ slug = models.SlugField(unique_for_date='pub_date')
+ body_html = models.TextField(blank=True)
+ body_markdown = models.TextField()
+ pub_date = models.DateTimeField('Date published')
+ topics = models.ManyToManyField(Topic, blank=True)
+ last_updated = models.DateTimeField(auto_now=True)
+ enable_comments = models.BooleanField(default=False)
+ PUB_STATUS = (
+ (0, 'Draft'),
+ (1, 'Published'),
+ )
+ status = models.IntegerField(choices=PUB_STATUS, default=0)
+ meta_description = models.CharField(max_length=256, null=True, blank=True)
+ TEMPLATES = (
+ (0, 'default'),
+ )
+ template_name = models.IntegerField(choices=TEMPLATES, default=0)
+
+ class Meta:
+ ordering = ('-pub_date',)
+ get_latest_by = 'pub_date'
+ verbose_name_plural = 'entries'
+
+ def __str__(self):
+ return self.title
+
+ def get_absolute_url(self):
+ return "/src/%s" % self.slug
+
+ def comment_period_open(self):
+ return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date
+
+
+ def get_images(self):
+ return extract_images(self.body_html)
+
+ @property
+ def get_previous_published(self):
+ return self.get_previous_by_pub_date(status__exact=1)
+
+ @property
+ def get_next_published(self):
+ return self.get_next_by_pub_date(status__exact=1)
+
+ def save(self):
+ md = image_url_replace(self.body_markdown)
+ self.body_html = markdown.markdown(md, extensions=['extra'], safe_mode=False)
+ super(Entry, self).save()
+
+
+def get_upload_path(self, filename):
+ return "images/src/%s" % filename
+
+
+class Book(models.Model):
+ title = models.CharField(max_length=200)
+ image = models.FileField(blank=True, null=True, upload_to=get_upload_path)
+ slug = models.SlugField(unique_for_date='pub_date')
+ body_html = models.TextField(blank=True)
+ body_markdown = models.TextField()
+ pub_date = models.DateTimeField('Date published')
+ last_updated = models.DateTimeField(auto_now=True)
+ PUB_STATUS = (
+ (0, 'Draft'),
+ (1, 'Published'),
+ )
+ status = models.IntegerField(choices=PUB_STATUS, default=0)
+ meta_description = models.CharField(max_length=256, null=True, blank=True)
+
+ class Meta:
+ ordering = ('-pub_date',)
+ get_latest_by = 'pub_date'
+
+ def __str__(self):
+ return self.title
+
+ def get_absolute_url(self):
+ return "/src/books/%s" % (self.slug)
diff --git a/app/src/urls.py b/app/src/urls.py
new file mode 100644
index 0000000..c9e8077
--- /dev/null
+++ b/app/src/urls.py
@@ -0,0 +1,16 @@
+from django.conf.urls import *
+from django.views.generic import ListView
+
+from .models import Entry, Book
+
+urlpatterns = patterns('',
+ (r'books/$', ListView.as_view(
+ queryset=Book.objects.filter(status__exact=1).order_by('-pub_date'),
+ template_name="archives/src_books.html",
+ )),
+ (r'(?P<slug>[-\w]+)/$', 'src.views.detail'),
+ (r'^$', ListView.as_view(
+ queryset=Entry.objects.filter(status__exact=1).order_by('-pub_date'),
+ template_name="archives/src_home.html",
+ )),
+)
diff --git a/app/src/views.py b/app/src/views.py
new file mode 100644
index 0000000..f3803b9
--- /dev/null
+++ b/app/src/views.py
@@ -0,0 +1,8 @@
+from django.shortcuts import render_to_response, get_object_or_404
+from django.template import RequestContext
+from .models import Entry
+
+def detail(request, slug):
+ obj = get_object_or_404(Entry, slug__exact=slug)
+ return render_to_response('details/src_entry.html', {'object': obj}, context_instance=RequestContext(request))
+
diff --git a/config/base_urls.py b/config/base_urls.py
index 5388c93..9485a5b 100644
--- a/config/base_urls.py
+++ b/config/base_urls.py
@@ -59,6 +59,7 @@ urlpatterns += patterns('',
(r'^photo/', include('photos.detail_urls')),
(r'^birds/', include('birds.urls')),
(r'^travel-guide/', include('guide.urls')),
+ (r'^src/', include('src.urls')),
# map
(r'^map/', include('locations.urls')),
#about
diff --git a/design/sass/_src.scss b/design/sass/_src.scss
new file mode 100644
index 0000000..b054ffe
--- /dev/null
+++ b/design/sass/_src.scss
@@ -0,0 +1,4 @@
+.src-topics {
+ @include smcaps;
+ @include fontsize(11);
+}
diff --git a/design/sass/screenv8.scss b/design/sass/screenv8.scss
index 5436e27..369bce7 100644
--- a/design/sass/screenv8.scss
+++ b/design/sass/screenv8.scss
@@ -18,6 +18,7 @@
@import "_mailing-list.scss";
@import "_birds.scss";
@import "_books.scss";
+@import "_src.scss";
@import "_inbox.scss";
//@import _large.sass
diff --git a/design/templates/archives/src_books.html b/design/templates/archives/src_books.html
new file mode 100644
index 0000000..bfaffc0
--- /dev/null
+++ b/design/templates/archives/src_books.html
@@ -0,0 +1,22 @@
+{% extends 'src_base.html' %}
+{% load typogrify_tags %}
+{% load comments %}
+
+{% block primary %}
+ <main role="main">
+ {% for object in object_list %}
+ <article class="h-entry hentry post--article{% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %} post--article--double{%endif%}{%endwith%}" itemscope itemType="http://schema.org/Article">
+ <header id="header" class="post--header {% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %}post--header--double{%endif%}{%endwith%}">
+ <img src="{{object.image.url}}" alt="{{object.title}} cover" />
+ <h1 class="p-name entry-title post--title" itemprop="headline">{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|smartypants|safe}}{%else%}{{object.title|smartypants|widont|safe}}{%endif%}</h1>
+ {% if object.slug != 'about' %}<time class="dt-published published dt-updated post--date" datetime="{{object.pub_date|date:'c'}}" itemprop="datePublished">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time>{%endif%}
+ {% if object.topics.all %}<span class="src-topics">Topics: {% for topic in object.topics.all%} <a href="/src/topic/{{topic.slug}}">{{topic.name}}</a>{%if forloop.last%}{%else%}, {%endif%}{%endfor%}</span>{%endif%}
+ <p class="p-author author hide" itemprop="author"><span class="byline-author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Scott Gilbertson</span></span></p>
+ </header>
+ <div id="article" class="e-content entry-content post--body post--body--{% with object.template_name as t %}{%if t == 0 or t == 2 %}single{%endif%}{%if t == 1 or t == 3 %}double{%endif%}{%endwith%}" itemprop="articleBody">
+ {{object.body_html|safe|smartypants|widont}}
+ </div>
+ </article>
+ {%endfor%}
+ </main>
+{% endblock %}
diff --git a/design/templates/archives/src_home.html b/design/templates/archives/src_home.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/design/templates/archives/src_home.html
diff --git a/design/templates/details/src_entry.html b/design/templates/details/src_entry.html
new file mode 100644
index 0000000..3fa4c93
--- /dev/null
+++ b/design/templates/details/src_entry.html
@@ -0,0 +1,69 @@
+{% extends 'src_base.html' %}
+{% load typogrify_tags %}
+{% load comments %}
+
+{% block primary %}
+ <main role="main">
+ <article class="h-entry hentry post--article{% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %} post--article--double{%endif%}{%endwith%}" itemscope itemType="http://schema.org/Article">
+ <header id="header" class="post--header {% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %}post--header--double{%endif%}{%endwith%}">
+ <h1 class="p-name entry-title post--title" itemprop="headline">{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|smartypants|safe}}{%else%}{{object.title|smartypants|widont|safe}}{%endif%}</h1>
+ {% if object.slug != 'about' %}<time class="dt-published published dt-updated post--date" datetime="{{object.pub_date|date:'c'}}" itemprop="datePublished">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time>{%endif%}
+ {% if object.topics.all %}<span class="src-topics">Topics: {% for topic in object.topics.all%} <a href="/src/topic/{{topic.slug}}">{{topic.name}}</a>{%if forloop.last%}{%else%}, {%endif%}{%endfor%}</span>{%endif%}
+ <p class="p-author author hide" itemprop="author"><span class="byline-author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Scott Gilbertson</span></span></p>
+ </header>
+ <div id="article" class="e-content entry-content post--body post--body--{% with object.template_name as t %}{%if t == 0 or t == 2 %}single{%endif%}{%if t == 1 or t == 3 %}double{%endif%}{%endwith%}" itemprop="articleBody">
+ {{object.body_html|safe|smartypants|widont}}
+ </div>
+ </article>
+ {% if object.slug != 'about' %}
+ {% with object.get_next_published as next %}
+ {% with object.get_previous_published as prev %}
+ <nav id="page-navigation">
+ <ul>{% if prev%}
+ <li id="prev"><span class="bl">Previous:</span>
+ <a href="{{ prev.get_absolute_url }}" rel="prev" title=" {{prev.title}}">{{prev.title|safe}}</a>
+ </li>{%endif%}{% if next%}
+ <li id="next"><span class="bl">Next:</span>
+ <a href="{{ next.get_absolute_url }}" rel="next" title=" {{next.title}}">{{next.title|safe}}</a>
+ </li>{%endif%}
+ </ul>
+ </nav>{%endwith%}{%endwith%}
+ {%endif%}
+ </main>
+ {% if object.slug != 'about' %}
+ {% if object.enable_comments %}
+{% get_comment_count for object as comment_count %}
+{%if comment_count > 0 %}
+<p class="comments--header">{{comment_count}} Comment{{ comment_count|pluralize }}</p>
+{% render_comment_list for object %}
+{%endif%}
+{% render_comment_form for object %}
+{% else %}
+<p class="comments--header" style="text-align: center">Sorry, comments have been disabled for this post.</p>
+{%endif%}
+{%endif%}
+{% endblock %}
+{% block js %}
+<script type="text/javascript">
+window.onload = function() {
+ {% if object.enable_comments %}
+{% get_comment_count for object as comment_count %}
+{%if comment_count > 0 %}
+ //delay loading of gravatar images using noscript data-hash attribute
+ dataattr = document.getElementsByClassName("datahashloader");
+ for(var i=0; i<dataattr.length; i++) {
+ var c = dataattr[i].parentNode;
+ var img = document.createElement("img");
+ img.src = 'https://images.luxagraf.net/gravcache/' + dataattr[i].getAttribute('data-hash') + '.jpg';
+ img.className += "gravatar";
+ c.insertBefore(img, c.childNodes[3]);
+ }
+{%endif%}
+{%endif%}
+ {% with object.get_template_name_display as t %}{%if t == "single" or t == "single-dark" %}
+ createMap();
+ var open = false;
+ {%endif%}{%endwith%}
+}
+</script>
+{% endblock %}
diff --git a/design/templates/src_base.html b/design/templates/src_base.html
new file mode 100644
index 0000000..29991a9
--- /dev/null
+++ b/design/templates/src_base.html
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html {%block htmlclass%}{%endblock%} dir="ltr" lang="en-US">
+ {% block sitename %}
+<head>
+ <title>{% block pagetitle %}Luxagraf - Topografical Writings{% endblock %}</title>{%endblock%}
+ <meta charset="utf-8">
+ <meta name="description"
+ content="{% block metadescription %}Luxagraf: recording journeys around the world and just next door.{% endblock %}">
+ <meta name="author" content="Scott Gilbertson">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <!--[if IE]>
+ <script src="/js/html5css3ie.min.js"></script>
+ <![endif]-->
+ <link rel="alternate"
+ type="application/rss+xml"
+ title="Luxagraf RSS feed"
+ href="https://luxagraf.net/rss/">
+ {%block stylesheet%}<link rel="stylesheet"
+ href="/media/screenv8.css"
+ media="screen">{%endblock%}
+ <!--[if IE]>
+ <link rel="stylesheet"
+ href="/media/css/ie.css"
+ media="screen">
+ <![endif]-->
+ {%block extrahead%}{%endblock%}
+</head>
+<body {%block bodyid%}{%endblock%}{%block bodyevents%}{%endblock%}>
+ <div class="wrapper">
+ <div class="header-wrapper">
+ <header role="banner">
+ <h1><a id="logo" href="/" title="home">Luxagraf</a></h1>
+ <h2>SRC: Code Slowly</h2>
+ </header>
+ <nav role="navigation" class="bl">
+ <ul>
+ <li><a href="/src/" title="SRC Home">SRC Archive</a></li>
+ <li><a href="/src/books" title="Ebooks">Books</a></li>
+ <li class="last"><a href="/src/about" title="">About</a></li>
+ </ul>
+ </nav>
+ </div>
+ {% block primary %}{% endblock %}
+ {% block extrabody %}{% endblock %}
+ <footer role="contentinfo">
+ <nav class="bl">
+ <ul>
+ <li><a href="/rss/src/" title="RSS feed">Subscribe</a></li>
+ <li><a href="https://twitter.com/luxagraf" rel="me" title="follow luxagraf on Twitter">@luxagraf</a></li>
+ <li><a href="/contact/" title="contact luxagraf">Contact</a></li>
+ </ul>
+ </nav>
+ <p id="license">
+ &copy; 2003-{% now "Y" %}
+ <span class="h-card"><a class="p-name u-url" href="https://luxagraf.net/">Scott Gilbertson</a><data class="p-nickname" value="luxagraf"></data><data class="p-locality" value="Athens"></data><data class="p-region" value="Georgia"></data><data class="p-country-name" value="United States"></data></span>, except photos, which are licensed under the Creative Commons (<a href="http://creativecommons.org/licenses/by-sa/3.0/" title="read the Attribution-Share Alike 3.0 deed">details</a>).
+ </p>
+ </footer>
+ </div>
+ {% block js %}{% endblock%}
+<!-- Piwik -->
+<script type="text/javascript">
+var _paq = _paq || [];
+_paq.push(["disableCookies"]);
+_paq.push(['trackPageView']);
+_paq.push(['enableLinkTracking']);
+(function() {
+ var u="//stats.luxagraf.net/";
+ _paq.push(['setTrackerUrl', u+'piwik.php']);
+ _paq.push(['setSiteId', 1]);
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+ g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
+})();
+</script>
+<noscript><p><img src="//stats.luxagraf.net/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
+<!-- End Piwik Code -->
+
+
+</body>
+</html>