Skip to content

Commit

Permalink
Adding external topics page
Browse files Browse the repository at this point in the history
  • Loading branch information
andrelramos committed Aug 27, 2016
1 parent df71da5 commit 522c59b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 31 deletions.
7 changes: 2 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# coding: utf-8

from quokka.core.app import QuokkaModule
from .views import ExternalBlogListView
from .utils import get_external_blog
from .views import AggregatedTopicsListView


module = QuokkaModule("rssaggregator", __name__, template_folder="templates")
module.add_url_rule('/rssaggregator/', view_func=ExternalBlogListView.as_view('external blogs'))

#module.add_app_template_global(get_external_blog)
module.add_url_rule('/aggregated-topics/', view_func=AggregatedTopicsListView.as_view('aggregated topic'))
17 changes: 9 additions & 8 deletions templates/RSSaggregator/external_topics_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
<div class="large-12 columns">
<table class="large-12">
<thead>
<tr>Name</tr>
<tr>Root URL</tr>
<tr>Feeds URL</tr>
<tr>Title</tr>
<tr>Description</tr>
<tr>Topic URL</tr>
<tr>Date</tr>
</thead>

<tbody>
{% for blog in blogs %}
<td>{{ blog.name }}</td>
<td>{{ blog.root_url }}</td>
<td>{{ blog.feeds_url }}</td>
{% for topic in topics %}
<td>{{ topic.title }}</td>
<td>{{ topic.description }}</td>
<td>{{ topic.topic_url }}</td>
<td>{{ topic.date }}</td>
{% endfor %}
</tbody>
</table>
Expand Down
8 changes: 4 additions & 4 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# coding: utf-8
from .models import ExternalBlogs
from .models import AggregatedTopic


def get_external_blog(**kwargs):
blogs = ExternalBlogs.objects(**kwargs)
def get_external_topic(**kwargs):
topics = AggregatedTopic.objects(**kwargs)

return blogs.order_by('name')
return topics.order_by('date')

17 changes: 3 additions & 14 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,13 @@

from flask.views import MethodView
from quokka.core.templates import render_template
from .utils import get_external_blog
from .utils import get_external_topic


class ExternalBlogListView(MethodView):
class AggregatedTopicsListView(MethodView):
"""
Show a full list of external blogs
"""

def get(self):
return render_template('RSSaggregator/blogs_list.html', blogs=get_external_blog())


'''class ExternalBlogView(MethodView):
"""
Show specific external blog
"""
def get(self, blog_id):
blog = get_external_blog(blog_id=blog_id)
contents = get_author_contents(author)
return render_template('authors/detail.html',author=author, contents=contents)'''
return render_template('RSSaggregator/external_topics_list.html', topics=get_external_topic())

0 comments on commit 522c59b

Please sign in to comment.