Skip to content

Commit ae6bd1c

Browse files
author
Mark Ng
committed
view progress, data changes, model changes, graph
1 parent ab70294 commit ae6bd1c

File tree

9 files changed

+88
-15
lines changed

9 files changed

+88
-15
lines changed

aggregator/models.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from django.db import models
2-
import feedparser
1+
from django.db import models, connection
2+
import feedparser, pprint
33
import djangofeedparserdates
44

55
# Create your models here.
@@ -15,6 +15,8 @@ class Admin:
1515
class Feed(models.Model):
1616
"""Feed to be aggregated"""
1717
url = models.URLField("Feed URL",max_length=255)
18+
#username = models.CharField("Feed Username", max_length=255, blank=True)
19+
#password = models.CharField("Feed Password", max_length=255, blank=True)
1820
title = models.TextField("Feed Title",blank=True)
1921
link = models.URLField("Link to site",verify_exists=False, max_length=255,blank=True)
2022
description = models.TextField("Feed description",blank=True)
@@ -73,11 +75,12 @@ def refresh(self):
7375
feeditem.author_name = getattr(entry.author_detail, 'name', '')
7476
feeditem.author_email = getattr(entry.author_detail, 'email', '')
7577
feeditem.author_link = getattr(entry.author_detail, 'href', '')
76-
feeditem.content = getattr(entry, 'content')
78+
if hasattr(entry,'content'):
79+
feeditem.content = entry.content[0].value
7780
feeditem.unique_id = getattr(entry, 'id', '')
7881
feeditem.save()
7982
except Exception, e:
80-
pass
83+
print e
8184
return self, 'updated'
8285

8386
class FeedItem(models.Model):

aggregator/models.pyc

87 Bytes
Binary file not shown.

aggregator/templates/index.html

+27-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,33 @@
1010
<div>
1111
<h1><img src="/images/dotDorset.png" alt="dotDorset" /></h1>
1212
{% block content %}
13-
{% for item in blogitems %}
14-
{{ item.title }}
15-
{% endfor %}
13+
<div id="blogs">
14+
<h2>Blogs</h2>
15+
{% for item in blogitems %}
16+
<h3><a href="{{ item.link }}">{{ item.title }}</a></h3>
17+
<h4><a href="{{ item.feed.link }}">{{ item.feed }}</a></h4>
18+
<p>{{ item.description|striptags }}</p>
19+
{% endfor %}
20+
</div>
21+
22+
<div id="twitter">
23+
<h2>Twitter</h2>
24+
{% for item in twitteritems %}
25+
<h3><a href="{{ item.link }}">{{ item.title }}</a></h3>
26+
<h4><a href="{{ item.feed.link }}">{{ item.feed }}</a></h4>
27+
<p>{{ item.description|striptags }}</p>
28+
{% endfor %}
29+
30+
</div>
31+
32+
<div id="mailinglist">
33+
<h2>Mailing List</h2>
34+
{% for item in mlitems %}
35+
<h3><a href="{{ item.link }}">{{ item.title }}</a></h3>
36+
<h4><a href="{{ item.feed.link }}">{{ item.feed }}</a></h4>
37+
<p>{{ item.description|striptags }}</p>
38+
{% endfor %}
39+
</div>
1640
{% endblock %}
1741
</div>
1842
<script type="text/javascript">

aggregator/views.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
def index(request):
88
"""index view"""
9-
blogitems = FeedItem.objects.filter(feed__category__name='Blogs').order_by('pub_date')
10-
twitteritems = FeedItem.objects.filter(feed__category__name='Twitter').order_by('pub_date')
11-
rendered = render_to_string('index.html', {'blogitems': blogitems, 'twitteritems': twitteritems})
9+
blogitems = FeedItem.objects.filter(feed__category__name='Blogs').order_by('-pub_date')[0:5]
10+
twitteritems = FeedItem.objects.filter(feed__category__name='Twitter').order_by('-pub_date')[0:10]
11+
mlitems = FeedItem.objects.filter(feed__category__name='Mailing List').order_by('-pub_date')[0:10]
12+
rendered = render_to_string('index.html', {'blogitems': blogitems, 'twitteritems': twitteritems, 'mlitems': mlitems})
1213
return HttpResponse(rendered)

aggregator/views.pyc

112 Bytes
Binary file not shown.

css/main.css

+33-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ p {margin:0 0 1.5em;}
2323
p img {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;}
2424
p img.right {float:right;margin:1.5em 0 1.5em 1.5em;}
2525
a:focus, a:hover {color:#000;}
26-
a {color:#009;text-decoration:underline;}
26+
a {color:#000;text-decoration:underline;}
2727
blockquote {margin:1.5em;color:#666;font-style:italic;}
2828
strong {font-weight:bold;}
2929
em, dfn {font-style:italic;}
@@ -53,4 +53,35 @@ body div
5353
{
5454
width: 960px;
5555
margin: 0 auto;
56-
}
56+
}
57+
58+
div.half, div#blogs, div#twitter, div#mailinglist
59+
{
60+
width: 470px;
61+
float:left;
62+
margin-right:10px;
63+
}
64+
65+
div.third
66+
{
67+
width: 310px;
68+
float:left;
69+
margin-right:10px;
70+
}
71+
72+
div.quarter
73+
{
74+
width: 230px;
75+
float:left;
76+
margin-right:10px;
77+
}
78+
79+
div.last, div#twitter
80+
{
81+
margin-right: 0px;
82+
}
83+
84+
div#blogs h4 a
85+
{
86+
font-style: italic;
87+
}

data

-1
This file was deleted.

data.json

+1
Large diffs are not rendered by default.

graph.dot

+16-2
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,20 @@ subgraph cluster_dotdorset_aggregator_models {
630630
><FONT COLOR="#7B7B7B" FACE="Helvetica Bold">DateTimeField</FONT
631631
></TD></TR>
632632

633+
<TR><TD ALIGN="LEFT" BORDER="0"
634+
><FONT COLOR="#7B7B7B" FACE="Helvetica Bold">last_modified</FONT
635+
></TD>
636+
<TD ALIGN="LEFT"
637+
><FONT COLOR="#7B7B7B" FACE="Helvetica Bold">DateTimeField</FONT
638+
></TD></TR>
639+
640+
<TR><TD ALIGN="LEFT" BORDER="0"
641+
><FONT COLOR="#7B7B7B" FACE="Helvetica Bold">etag</FONT
642+
></TD>
643+
<TD ALIGN="LEFT"
644+
><FONT COLOR="#7B7B7B" FACE="Helvetica Bold">TextField</FONT
645+
></TD></TR>
646+
633647
<TR><TD ALIGN="LEFT" BORDER="0"
634648
><FONT FACE="Helvetica Bold">category</FONT
635649
></TD>
@@ -720,10 +734,10 @@ subgraph cluster_dotdorset_aggregator_models {
720734
></TD></TR>
721735

722736
<TR><TD ALIGN="LEFT" BORDER="0"
723-
><FONT COLOR="#7B7B7B" FACE="Helvetica Bold">pub_date</FONT
737+
><FONT FACE="Helvetica Bold">pub_date</FONT
724738
></TD>
725739
<TD ALIGN="LEFT"
726-
><FONT COLOR="#7B7B7B" FACE="Helvetica Bold">TimeField</FONT
740+
><FONT FACE="Helvetica Bold">DateTimeField</FONT
727741
></TD></TR>
728742

729743
<TR><TD ALIGN="LEFT" BORDER="0"

0 commit comments

Comments
 (0)