Use local feed as default
This commit is contained in:
@@ -47,17 +47,17 @@ def csrf_token(context):
|
||||
def index(request):
|
||||
''' Redirects to main page -- info page if user authenticated, or marketing if not
|
||||
'''
|
||||
entries = None
|
||||
if settings.RSS_URL:
|
||||
feed = cache.get("students_index_rss_feed")
|
||||
if feed == None:
|
||||
feed = feedparser.parse(settings.RSS_URL)
|
||||
cache.set("students_index_rss_feed", feed, settings.RSS_TIMEOUT)
|
||||
entries = feed['entries'][0:3]
|
||||
for entry in entries:
|
||||
soup = BeautifulSoup(entry.description)
|
||||
if soup.img:
|
||||
entry.image = soup.img['src']
|
||||
feed_data = settings.RSS_URL if hasattr(settings, 'RSS_URL') else render_to_string("feed.rss", None)
|
||||
feed = cache.get("students_index_rss_feed")
|
||||
|
||||
if feed == None:
|
||||
feed = feedparser.parse(feed_data)
|
||||
cache.set("students_index_rss_feed", feed, settings.RSS_TIMEOUT)
|
||||
|
||||
entries = feed['entries'][0:3]
|
||||
for entry in entries:
|
||||
soup = BeautifulSoup(entry.description)
|
||||
entry.image = soup.img['src'] if soup.img else None
|
||||
|
||||
if settings.COURSEWARE_ENABLED and request.user.is_authenticated():
|
||||
return redirect(reverse('dashboard'))
|
||||
|
||||
@@ -104,7 +104,7 @@ LIB_URL = '/static/js/'
|
||||
# Dev machines shouldn't need the book
|
||||
# BOOK_URL = '/static/book/'
|
||||
BOOK_URL = 'https://mitxstatic.s3.amazonaws.com/book_images/' # For AWS deploys
|
||||
RSS_URL = 'https://github.com/blog.atom'
|
||||
# RSS_URL = r'lms/templates/feed.rss'
|
||||
RSS_TIMEOUT = 600
|
||||
|
||||
# Configuration option for when we want to grab server error pages
|
||||
|
||||
25
lms/templates/feed.rss
Normal file
25
lms/templates/feed.rss
Normal file
@@ -0,0 +1,25 @@
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
|
||||
<id>tag:mitx.mit.edu,2012:/blog</id>
|
||||
<link type="text/html" rel="alternate" href="http://mitx.mit.edu/blog"/>
|
||||
<link type="application/atom+xml" rel="self" href="https://github.com/blog.atom"/>
|
||||
<title>The GitHub Blog</title>
|
||||
<updated>2012-07-16T14:08:12-07:00</updated>
|
||||
<entry>
|
||||
<id>tag:mitx.mit.edu,2012:Post/3</id>
|
||||
<published>2012-07-16T14:08:12-07:00</published>
|
||||
<updated>2012-07-16T14:08:12-07:00</updated>
|
||||
<link type="text/html" rel="alternate" href="#"/>
|
||||
<title>Online Classes Cut Costs, But Do They Dilute Brands?</title>
|
||||
<content type="html"><img src="${static.url('images/courses/space1.jpg')}" />A Description</content>
|
||||
</entry>
|
||||
<entry>
|
||||
<id>tag:mitx.mit.edu,2012:Post/3</id>
|
||||
<published>2012-07-16T14:08:12-07:00</published>
|
||||
<updated>2012-07-16T14:08:12-07:00</updated>
|
||||
<link type="text/html" rel="alternate" href="#"/>
|
||||
<title>Online Classes Cut Costs, But Do They Dilute Brands?</title>
|
||||
<content type="html">A Description</content>
|
||||
</entry>
|
||||
</feed>
|
||||
@@ -94,7 +94,7 @@
|
||||
<section class="blog-posts">
|
||||
%for entry in entries:
|
||||
<article>
|
||||
%if hasattr(entry, 'image'):
|
||||
%if entry.image:
|
||||
<a href="${entry.link}" class="post-graphics">
|
||||
<img src="${entry.image}" />
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user