diff options
-rw-r--r-- | pyaggr3g470r/models.py | 2 | ||||
-rw-r--r-- | pyaggr3g470r/templates/article.html | 12 | ||||
-rw-r--r-- | pyaggr3g470r/templates/home.html | 6 | ||||
-rw-r--r-- | pyaggr3g470r/views.py | 10 |
4 files changed, 24 insertions, 6 deletions
diff --git a/pyaggr3g470r/models.py b/pyaggr3g470r/models.py index f1cac323..a36c27fe 100644 --- a/pyaggr3g470r/models.py +++ b/pyaggr3g470r/models.py @@ -47,7 +47,7 @@ class Article(DynamicDocument): like = BooleanField() retrieved_date = DateTimeField(required=True, default=datetime.now) - def __unicode__(self): + def __str__(self): return 'Article: %s' % self.title if __name__ == "__main__": diff --git a/pyaggr3g470r/templates/article.html b/pyaggr3g470r/templates/article.html new file mode 100644 index 00000000..9c4fe287 --- /dev/null +++ b/pyaggr3g470r/templates/article.html @@ -0,0 +1,12 @@ +{% extends "layout.html" %} +{% block content %} +<div class="container"> + <div class="jumbotron"> + <h1>{{ article.title }}</h1> + <h6>{{ article.date }}</h6> + </div> + <div class="jumbotron"> + {{ article.content|safe }} + </div> +</div><!-- /.container --> +{% endblock %}
\ No newline at end of file diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index 76104e68..b6e24a50 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -11,19 +11,19 @@ <div class="row"> <div class="col-xs-6 col-sm-4 col-md-4"> {% if feed.articles[number].readed %}<h3>{% else %}<h1>{% endif %} - {{ feed.articles[number].title }}<h2> + <a href="/article/{{ feed.articles[number].id }}">{{ feed.articles[number].title }}</a><h2> {% if feed.articles[number].readed %}</h3>{% else %}</h1>{% endif %} <h6>{{ feed.articles[number].date }}</h6> </div> <div class="col-xs-6 col-sm-4 col-md-4"> {% if feed.articles[number+1].readed %}<h3>{% else %}<h1>{% endif %} - {{ feed.articles[number+1].title }}<h2> + <a href="/article/{{ feed.articles[number+1].id }}">{{ feed.articles[number+1].title }}</a><h2> {% if feed.articles[number+1].readed %}</h3>{% else %}</h1>{% endif %} <h6>{{ feed.articles[number+1].date }}</h6> </div> <div class="col-xs-6 col-sm-4 col-md-4"> {% if feed.articles[number+2].readed %}<h3>{% else %}<h1>{% endif %} - {{ feed.articles[number+2].title }}<h2> + <a href="/article/{{ feed.articles[number+2].id }}">{{ feed.articles[number+2].title }}</a><h2> {% if feed.articles[number+2].readed %}</h3>{% else %}</h1>{% endif %} <h6>{{ feed.articles[number+2].date }}</h6> </div> diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 9ca5d163..eb1bf0c0 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -35,5 +35,11 @@ def feeds(): @app.route('/feed/<feed_id>', methods=['GET']) def feed(feed_id=None): - feed = models.Watch.objects(id=feed_id).first() - return render_template('feed.html', feed=feed)
\ No newline at end of file + feed = models.Article.objects(id=feed_id).first() + return render_template('feed.html', feed=feed) + +@app.route('/article/<article_id>', methods=['GET']) +def article(article_id=None): + article = models.Article.objects(id=article_id).first() + print article.content + return render_template('article.html', article=article)
\ No newline at end of file |