From bd2e6d05d3bc3f929e63c048784111f6560bf5de Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 14 Mar 2020 11:05:36 +0100 Subject: Minor optimizations of the layout for the home page. --- newspipe/templates/home.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/newspipe/templates/home.html b/newspipe/templates/home.html index 1dbfe9cd..a4f60297 100644 --- a/newspipe/templates/home.html +++ b/newspipe/templates/home.html @@ -38,8 +38,8 @@ {% endfor %} @@ -57,8 +57,8 @@ {% endfor %} @@ -94,7 +94,11 @@ - + -- cgit From 37760cba99a29b1eec44b1eef7c7df7deddaad56 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 14 Mar 2020 11:14:56 +0100 Subject: Improved the mamagement of parameter transferd via URL for the search of articles. --- newspipe/bootstrap.py | 1 - newspipe/crawler/default_crawler.py | 2 +- newspipe/models/__init__.py | 4 +--- newspipe/web/forms.py | 2 +- newspipe/web/views/api/v2/article.py | 2 +- newspipe/web/views/api/v2/category.py | 2 +- newspipe/web/views/api/v2/common.py | 2 +- newspipe/web/views/api/v2/feed.py | 8 ++----- newspipe/web/views/article.py | 8 ++----- newspipe/web/views/bookmark.py | 2 +- newspipe/web/views/category.py | 6 +---- newspipe/web/views/common.py | 2 +- newspipe/web/views/feed.py | 4 ++-- newspipe/web/views/home.py | 44 ++++++++++++++++++++--------------- newspipe/web/views/session_mgmt.py | 4 ++-- newspipe/web/views/user.py | 12 ++-------- newspipe/web/views/views.py | 9 +------ 17 files changed, 45 insertions(+), 69 deletions(-) diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py index c30cc631..bbdd038e 100644 --- a/newspipe/bootstrap.py +++ b/newspipe/bootstrap.py @@ -45,7 +45,6 @@ def set_logging( logger.setLevel(log_level) - # Create Flask application application = Flask(__name__, instance_relative_config=True) if os.environ.get("Newspipe_TESTING", False) == "true": diff --git a/newspipe/crawler/default_crawler.py b/newspipe/crawler/default_crawler.py index a0b5566a..3d6222e9 100644 --- a/newspipe/crawler/default_crawler.py +++ b/newspipe/crawler/default_crawler.py @@ -39,7 +39,7 @@ from newspipe.controllers import ArticleController, FeedController from newspipe.lib.article_utils import ( construct_article, extract_id, - get_article_content + get_article_content, ) from newspipe.lib.feed_utils import construct_feed_from, is_parsing_ok from newspipe.lib.utils import newspipe_get diff --git a/newspipe/models/__init__.py b/newspipe/models/__init__.py index a820a43b..c2078cea 100644 --- a/newspipe/models/__init__.py +++ b/newspipe/models/__init__.py @@ -32,7 +32,7 @@ from sqlalchemy.schema import ( DropTable, ForeignKeyConstraint, MetaData, - Table + Table, ) from .article import Article @@ -57,8 +57,6 @@ __all__ = [ ] - - def db_empty(db): "Will drop every datas stocked in db." # From http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything diff --git a/newspipe/web/forms.py b/newspipe/web/forms.py index ce7fd996..0b992e2b 100644 --- a/newspipe/web/forms.py +++ b/newspipe/web/forms.py @@ -39,7 +39,7 @@ from wtforms import ( SubmitField, TextAreaField, TextField, - validators + validators, ) from wtforms.fields.html5 import EmailField, URLField diff --git a/newspipe/web/views/api/v2/article.py b/newspipe/web/views/api/v2/article.py index 638f1bd0..92915006 100644 --- a/newspipe/web/views/api/v2/article.py +++ b/newspipe/web/views/api/v2/article.py @@ -10,7 +10,7 @@ from newspipe.web.views.api.v2.common import ( PyAggAbstractResource, PyAggResourceExisting, PyAggResourceMulti, - PyAggResourceNew + PyAggResourceNew, ) from newspipe.web.views.common import api_permission diff --git a/newspipe/web/views/api/v2/category.py b/newspipe/web/views/api/v2/category.py index ab6e484a..84397991 100644 --- a/newspipe/web/views/api/v2/category.py +++ b/newspipe/web/views/api/v2/category.py @@ -6,7 +6,7 @@ from newspipe.controllers.category import CategoryController from newspipe.web.views.api.v2.common import ( PyAggResourceExisting, PyAggResourceMulti, - PyAggResourceNew + PyAggResourceNew, ) diff --git a/newspipe/web/views/api/v2/common.py b/newspipe/web/views/api/v2/common.py index 5a7d7925..332c07f8 100644 --- a/newspipe/web/views/api/v2/common.py +++ b/newspipe/web/views/api/v2/common.py @@ -31,7 +31,7 @@ from newspipe.web.views.common import ( admin_permission, api_permission, jsonify, - login_user_bundle + login_user_bundle, ) logger = logging.getLogger(__name__) diff --git a/newspipe/web/views/api/v2/feed.py b/newspipe/web/views/api/v2/feed.py index f9e7f8c2..01791a8d 100644 --- a/newspipe/web/views/api/v2/feed.py +++ b/newspipe/web/views/api/v2/feed.py @@ -2,16 +2,12 @@ from flask import current_app from flask_restful import Api from newspipe.bootstrap import application -from newspipe.controllers.feed import ( - DEFAULT_LIMIT, - DEFAULT_MAX_ERROR, - FeedController -) +from newspipe.controllers.feed import DEFAULT_LIMIT, DEFAULT_MAX_ERROR, FeedController from newspipe.web.views.api.v2.common import ( PyAggAbstractResource, PyAggResourceExisting, PyAggResourceMulti, - PyAggResourceNew + PyAggResourceNew, ) from newspipe.web.views.common import api_permission diff --git a/newspipe/web/views/article.py b/newspipe/web/views/article.py index 472ff589..8cea11e4 100644 --- a/newspipe/web/views/article.py +++ b/newspipe/web/views/article.py @@ -8,17 +8,13 @@ from flask import ( redirect, render_template, request, - url_for + url_for, ) from flask_babel import gettext from flask_login import current_user, login_required from newspipe.bootstrap import db -from newspipe.controllers import ( - ArticleController, - CategoryController, - UserController -) +from newspipe.controllers import ArticleController, CategoryController, UserController from newspipe.lib.data import export_json from newspipe.lib.utils import clear_string, redirect_url from newspipe.web.lib.view_utils import etag_match diff --git a/newspipe/web/views/bookmark.py b/newspipe/web/views/bookmark.py index 9cdfc31e..1d07f7e8 100644 --- a/newspipe/web/views/bookmark.py +++ b/newspipe/web/views/bookmark.py @@ -35,7 +35,7 @@ from flask import ( redirect, render_template, request, - url_for + url_for, ) from flask_babel import gettext from flask_login import current_user, login_required diff --git a/newspipe/web/views/category.py b/newspipe/web/views/category.py index 3f65e854..cf52b3dd 100644 --- a/newspipe/web/views/category.py +++ b/newspipe/web/views/category.py @@ -2,11 +2,7 @@ from flask import Blueprint, flash, redirect, render_template, url_for from flask_babel import gettext from flask_login import current_user, login_required -from newspipe.controllers import ( - ArticleController, - CategoryController, - FeedController -) +from newspipe.controllers import ArticleController, CategoryController, FeedController from newspipe.lib.utils import redirect_url from newspipe.web.forms import CategoryForm from newspipe.web.lib.view_utils import etag_match diff --git a/newspipe/web/views/common.py b/newspipe/web/views/common.py index 574974ce..c286888f 100644 --- a/newspipe/web/views/common.py +++ b/newspipe/web/views/common.py @@ -9,7 +9,7 @@ from flask_principal import ( Permission, RoleNeed, identity_changed, - session_identity_loader + session_identity_loader, ) from newspipe.controllers import UserController diff --git a/newspipe/web/views/feed.py b/newspipe/web/views/feed.py index 82d285b6..0a659b17 100644 --- a/newspipe/web/views/feed.py +++ b/newspipe/web/views/feed.py @@ -9,7 +9,7 @@ from flask import ( redirect, render_template, request, - url_for + url_for, ) from flask_babel import gettext from flask_login import current_user, login_required @@ -21,7 +21,7 @@ from newspipe.controllers import ( ArticleController, CategoryController, FeedController, - UserController + UserController, ) from newspipe.lib import misc_utils, utils from newspipe.lib.feed_utils import construct_feed_from diff --git a/newspipe/web/views/home.py b/newspipe/web/views/home.py index 7d4ad604..55739248 100644 --- a/newspipe/web/views/home.py +++ b/newspipe/web/views/home.py @@ -3,23 +3,12 @@ from datetime import datetime import pytz from babel.dates import format_datetime, format_timedelta -from flask import ( - current_app, - flash, - redirect, - render_template, - request, - url_for -) +from flask import current_app, flash, redirect, render_template, request, url_for from flask_babel import get_locale, gettext from flask_login import current_user, login_required from newspipe.bootstrap import application -from newspipe.controllers import ( - ArticleController, - CategoryController, - FeedController -) +from newspipe.controllers import ArticleController, CategoryController, FeedController from newspipe.lib import misc_utils from newspipe.lib.utils import redirect_url from newspipe.web.lib.view_utils import etag_match @@ -52,6 +41,9 @@ def home(): feed_id = int(request.args.get("feed", 0)) liked = int(request.args.get("liked", 0)) == 1 limit = request.args.get("limit", 1000) + query = request.args.get("query", "") + search_title = request.args.get("search_title", "off") + search_content = request.args.get("search_content", "off") if filter_ in ["read", "unread"]: filters["readed"] = filter_ == "read" @@ -71,12 +63,26 @@ def home(): for feed in FeedController(current_user.id).read(error_count__gt=0).all() } - def gen_url(filter_=filter_, limit=limit, feed=feed_id, liked=liked): - return "?filter_=%s&limit=%s&feed=%d&liked=%s" % ( - filter_, - limit, - feed, - 1 if liked else 0, + def gen_url( + filter_=filter_, + limit=limit, + feed=feed_id, + liked=liked, + query=query, + search_title=search_title, + search_content=search_content, + ): + return ( + "?filter_=%s&limit=%s&feed=%d&liked=%s&query=%s&search_title=%s&search_content=%s" + % ( + filter_, + limit, + feed, + 1 if liked else 0, + query, + search_title, + search_content, + ) ) return render_template( diff --git a/newspipe/web/views/session_mgmt.py b/newspipe/web/views/session_mgmt.py index f8822255..c279ffc1 100644 --- a/newspipe/web/views/session_mgmt.py +++ b/newspipe/web/views/session_mgmt.py @@ -8,7 +8,7 @@ from flask import ( render_template, request, session, - url_for + url_for, ) from flask_babel import gettext, lazy_gettext from flask_login import LoginManager, current_user, login_required, logout_user @@ -18,7 +18,7 @@ from flask_principal import ( UserNeed, identity_changed, identity_loaded, - session_identity_loader + session_identity_loader, ) from werkzeug.security import generate_password_hash diff --git a/newspipe/web/views/user.py b/newspipe/web/views/user.py index 110f7c55..4e34bbeb 100644 --- a/newspipe/web/views/user.py +++ b/newspipe/web/views/user.py @@ -1,12 +1,4 @@ -from flask import ( - Blueprint, - flash, - g, - redirect, - render_template, - request, - url_for -) +from flask import Blueprint, flash, g, redirect, render_template, request, url_for from flask_babel import gettext from flask_login import current_user, login_required from flask_paginate import Pagination, get_page_args @@ -17,7 +9,7 @@ from newspipe.controllers import ( BookmarkController, CategoryController, FeedController, - UserController + UserController, ) from newspipe.lib import misc_utils from newspipe.lib.data import import_json, import_opml diff --git a/newspipe/web/views/views.py b/newspipe/web/views/views.py index a19c7dc5..a5d89ef0 100644 --- a/newspipe/web/views/views.py +++ b/newspipe/web/views/views.py @@ -3,14 +3,7 @@ import operator import sys from datetime import datetime, timedelta -from flask import ( - current_app, - flash, - redirect, - render_template, - request, - url_for -) +from flask import current_app, flash, redirect, render_template, request, url_for from flask_babel import gettext from sqlalchemy import desc -- cgit From e5470635de807bc1cd8503c145704beaa60f254f Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 14 Mar 2020 11:31:48 +0100 Subject: Added screenshot in the README. --- README.md | 2 ++ docs/static/newspipe_home-page.png | Bin 0 -> 245970 bytes 2 files changed, 2 insertions(+) create mode 100644 docs/static/newspipe_home-page.png diff --git a/README.md b/README.md index 681690f6..ffa9307d 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ [Newspipe](https://git.sr.ht/~cedric/newspipe) is a web news aggregator. +![Newspipe Home page](docs/static/newspipe_home-page.png "Newspipe Home page") + Newspipe is written in Python. The core technologies are [Flask](http://flask.pocoo.org), [asyncio](https://www.python.org/dev/peps/pep-3156/) and diff --git a/docs/static/newspipe_home-page.png b/docs/static/newspipe_home-page.png new file mode 100644 index 00000000..f5975be0 Binary files /dev/null and b/docs/static/newspipe_home-page.png differ -- cgit
+ {% if feed_id %} + + {% endif%} + {{ _('Feed') }} {{ _('Article') }} {{ _('Date') }}