Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Detail pages automagically generate MLA and wikipedi citations. Fixes #…

  • Loading branch information...
commit 319d1a6599e60fef6f71c3c6ccf47700a8496bcd 1 parent cd39573
@palewire palewire authored
View
19 archive/management/commands/buildserver.py
@@ -1,19 +0,0 @@
-from project import urls
-from django.conf import settings
-from django.conf.urls.defaults import *
-from django.core.management.commands import runserver
-
-
-class Command(runserver.Command):
- help = "Starts a variation of Django's runserver designed to serve the static files you've built."
-
- def handle(self, *args, **kwds):
- urls.urlpatterns = patterns("bakery.static_views",
- url(r"^(.*)$", "serve", {
- "document_root": settings.BUILD_DIR,
- 'show_indexes': True,
- 'default': 'index.html'
- }),
- )
- runserver.Command.handle(self, *args, **kwds)
-
View
51 archive/models.py
@@ -2,10 +2,12 @@
import logging
from archive import managers
from django.db import models
+from datetime import datetime
from django.conf import settings
from pytz import common_timezones
from taggit.managers import TaggableManager
from toolbox.thumbs import ImageWithThumbsField
+from django.template.defaultfilters import date as dateformat
logger = logging.getLogger(__name__)
@@ -13,10 +15,6 @@ class Site(models.Model):
"""
A news website included in the archive.
"""
- detail_views = [
- #'archive.views.SiteDetail',
- ]
-
name = models.CharField(max_length=150)
slug = models.SlugField(unique=True)
url = models.URLField()
@@ -51,10 +49,6 @@ class Update(models.Model):
"""
A periodic update to the archive.
"""
- detail_views = [
- #'archive.views.UpdateDetail',
- ]
-
start = models.DateTimeField()
objects = managers.UpdateManager()
@@ -87,10 +81,6 @@ class Screenshot(models.Model):
"""
A snapshot of web page.
"""
- detail_views = [
- #'archive.views.ScreenshotDetail',
- ]
-
site = models.ForeignKey(Site)
update = models.ForeignKey(Update)
timestamp = models.DateTimeField(blank=True, null=True)
@@ -120,6 +110,43 @@ def get_image_name(self):
def get_crop_name(self):
return '%s-%s-%s-crop.png' % (self.site.slug, self.update.id, self.id)
+
+ def get_mla_citation(self):
+ """
+ The proper way to cite a screenshot in MLA style.
+ """
+ style = '"%(title)s." <em>PastPages</em>. %(creation_date)s. Web. %(today)s. &lt;%(url)s&gt;'
+ data = dict(
+ title = "%s homepage" % self.site.name,
+ creation_date = dateformat(self.timestamp, 'j N Y'),
+ today = dateformat(datetime.now().today(), 'j N Y'),
+ url = "http://www.pastpages.org%s" % self.get_absolute_url(),
+ )
+ return style % data
+ mla_citation = property(get_mla_citation)
+
+ def get_wikipedia_citation(self):
+ """
+ The proper way to cite a screenshot in Wikipedia markup.
+ """
+ style = """{{cite web<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;| url = %(url)s<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;| title = %(title)s<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;| publisher = PastPages<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;| date = %(creation_date)s<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;| accessdate = %(today)s<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;| ref = {{harvid|PastPages-%(id)s|%(year)s}}<br>
+ }}"""
+ data = dict(
+ title = "%s homepage" % self.site.name,
+ creation_date = dateformat(self.timestamp, 'N j, Y'),
+ today = dateformat(datetime.now().today(), 'N j, Y'),
+ url = "http://www.pastpages.org%s" % self.get_absolute_url(),
+ year = dateformat(self.timestamp, 'Y'),
+ id = str(self.id),
+ )
+ return style % data
+ wikipedia_citation = property(get_wikipedia_citation)
class Champion(models.Model):
View
20 archive/templates/screenshot_detail.html
@@ -29,14 +29,22 @@
</div>
</div>
<div class="row">
- <div class="twelvecol last">
- <div class="twocol" style="float:right;">
- {% if next %}<a href="{{ next.get_absolute_url }}">Next &raquo;</a>{% endif %}
- </div>
- <div class="twocol">
- {% if prev %}<a href="{{ prev.get_absolute_url }}">&laquo; Previous</a>{% endif %}
+ <div class="twocol">
+ {% if prev %}<a href="{{ prev.get_absolute_url }}">&laquo; Previous</a>{% endif %}
+ </div>
+ <div class="eightcol" style="text-align:center;">
+ <p><a onclick="$('#citation').dialog({width: 400, title:'Citations', resizable: false })">Citations</a></p>
+ <div id="citation" style="display:none;">
+ <h5>MLA</h5>
+ <small>{{ object.mla_citation|safe }}</small>
+ <br><br>
+ <h5>Wikipedia</h5>
+ <small>{{ object.wikipedia_citation|safe }}</small>
</div>
</div>
+ <div class="twocol last">
+ {% if next %}<a href="{{ next.get_absolute_url }}">Next &raquo;</a>{% endif %}
+ </div>
</div>
<div class="row">
<div class="twelvecol last">
View
8 project/templates/static/css/styles.css
@@ -5,8 +5,16 @@
body {
font-family: "Arvo", Arial, sans-serif;
}
+ a {
+ color: #0000FF;
+ text-decoration:underline;
+ }
+ a:visited {
+ color: #800080;
+ }
a:hover {
text-decoration:none;
+ cursor: pointer;
}
a:active {
color: red;
Please sign in to comment.
Something went wrong with that request. Please try again.