Skip to content
This repository has been archived by the owner on Oct 3, 2021. It is now read-only.

Commit

Permalink
Detail pages automagically generate MLA and wikipedi citations. Fixes
Browse files Browse the repository at this point in the history
…#39
  • Loading branch information
palewire committed Jun 11, 2012
1 parent cd39573 commit 319d1a6
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 37 deletions.
19 changes: 0 additions & 19 deletions archive/management/commands/buildserver.py

This file was deleted.

51 changes: 39 additions & 12 deletions archive/models.py
Expand Up @@ -2,21 +2,19 @@
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__)


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()
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
20 changes: 14 additions & 6 deletions archive/templates/screenshot_detail.html
Expand Up @@ -29,14 +29,22 @@ <h2>
</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">
Expand Down
8 changes: 8 additions & 0 deletions project/templates/static/css/styles.css
Expand Up @@ -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;
Expand Down

0 comments on commit 319d1a6

Please sign in to comment.