aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-07-07 21:30:45 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-07-07 21:30:45 +0200
commite3499ba1dab00c7f6fac834dcb8dbd5379e7f921 (patch)
treed83ea2649cebc460be0b654af6021723f1842abd /pyaggr3g470r
parentAdded 'warning' CSS class for table rows of disabled feeds. (diff)
downloadnewspipe-e3499ba1dab00c7f6fac834dcb8dbd5379e7f921.tar.gz
newspipe-e3499ba1dab00c7f6fac834dcb8dbd5379e7f921.tar.bz2
newspipe-e3499ba1dab00c7f6fac834dcb8dbd5379e7f921.zip
It is now possible to add new feeds with a bookmarklet.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/models.py4
-rw-r--r--pyaggr3g470r/templates/about.html13
-rw-r--r--pyaggr3g470r/views.py12
3 files changed, 25 insertions, 4 deletions
diff --git a/pyaggr3g470r/models.py b/pyaggr3g470r/models.py
index 63d547a9..5139c1d4 100644
--- a/pyaggr3g470r/models.py
+++ b/pyaggr3g470r/models.py
@@ -99,10 +99,10 @@ class Feed(db.Model):
Represent a station.
"""
id = db.Column(db.Integer, primary_key = True)
- title = db.Column(db.String(), default="New station")
+ title = db.Column(db.String(), default="No title")
description = db.Column(db.String(), default="FR")
link = db.Column(db.String())
- site_link = db.Column(db.String(), default="New station")
+ site_link = db.Column(db.String(), default="")
email_notification = db.Column(db.Boolean(), default=False)
enabled = db.Column(db.Boolean(), default=True)
created_date = db.Column(db.DateTime(), default=datetime.now)
diff --git a/pyaggr3g470r/templates/about.html b/pyaggr3g470r/templates/about.html
index 3c4304e5..0a33e9aa 100644
--- a/pyaggr3g470r/templates/about.html
+++ b/pyaggr3g470r/templates/about.html
@@ -2,11 +2,22 @@
{% block content %}
<div class="container">
<div class="jumbotron">
+ <h1>{{ _('About') }}</h1>
<p>{{ _('pyAggr3g470r is a simple news aggregator you can use everywhere.') }}</p>
<p>{{ _('This software is under AGPLv3 license. You are welcome to copy, modify or
redistribute the <a href="https://bitbucket.org/cedricbonhomme/pyaggr3g470r">source code</a>
according to the <a href="https://www.gnu.org/licenses/agpl-3.0.html">Affero GPL</a> license.') }}</p>
<p>{{ _('Found a bug? Report it <a href="https://bitbucket.org/cedricbonhomme/pyaggr3g470r/issues">here</a>.') }}</p>
</div>
+ <div class="jumbotron">
+ <h1>{{ _('Help') }}</h1>
+ <p>{{ _('If you have any problem, <a href="http://wiki.cedricbonhomme.org/contact">contact</a> the adminstrator.') }}</p>
+ <p>{{ _('The documentation of the RESTful API is <a href="https://bitbucket.org/cedricbonhomme/pyaggr3g470r#rst-header-web-service">here</a>.') }}</p>
+ <p>{{ _('You can subscribe to new feeds with a bookmarklet. Drag <a href="%(bookmarklet)s">this link</a> to your browser bookmarks.', bookmarklet='javascript:window.location="https://pyaggr3g470r.herokuapp.com/bookmarklet?url="+encodeURIComponent(document.location)') }}</p>
+ </div>
+ <div class="jumbotron">
+ <h1>{{ _('Donation') }}</h1>
+ <p>{{ _('If you wish and if you like pyAggr3g470r, you can donate via bitcoin <a href="https://blockexplorer.com/address/1GVmhR9fbBeEh7rP1qNq76jWArDdDQ3otZ">1GVmhR9fbBeEh7rP1qNq76jWArDdDQ3otZ</a>. Thank you!') }}</p>
+ </div>
</div><!-- /.container -->
-{% endblock %}
+{% endblock %} \ No newline at end of file
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index 9081795e..2478a86f 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -29,7 +29,7 @@ __license__ = "AGPLv3"
import os
import datetime
from flask import abort, render_template, request, flash, session, \
- url_for, redirect, g, current_app, make_response
+ url_for, redirect, g, current_app, make_response, jsonify
from flask.ext.login import LoginManager, login_user, logout_user, \
login_required, current_user, AnonymousUserMixin
from flask.ext.principal import Principal, Identity, AnonymousIdentity, \
@@ -629,6 +629,7 @@ def history():
user = User.query.filter(User.id == g.user.id).first()
return render_template('history.html')
+@app.route('/bookmarklet', methods=['GET'])
@app.route('/create_feed', methods=['GET', 'POST'])
@app.route('/edit_feed/<int:feed_id>', methods=['GET', 'POST'])
@login_required
@@ -675,6 +676,15 @@ def edit_feed(feed_id=None):
return render_template('edit_feed.html', action=gettext("Edit the feed"), form=form, feed=feed, \
not_on_heroku = not conf.ON_HEROKU)
+ # Enable the user to add a feed with a bookmarklet
+ if None is not request.args.get('url', None):
+ existing_feed = [feed for feed in g.user.feeds if feed.link == request.args.get('url', None)]
+ if len(existing_feed) == 0:
+ g.user.feeds.append(Feed(link=request.args.get('url', None)))
+ db.session.commit()
+ return jsonify({"message":"ok"})
+ return jsonify({"message":"Feed already in the database."})
+
# Return an empty form in order to create a new feed
return render_template('edit_feed.html', action=gettext("Add a feed"), form=form, \
not_on_heroku = not conf.ON_HEROKU)
bgstack15