~cedric/newspipe

53c4c6d6864f08036a9e169fe165986b6305c8d6 — Cédric Bonhomme 1 year, 2 months ago b5a10a5
Removed Flask-SSLify and Heroku default support.
M newspipe/bootstrap.py => newspipe/bootstrap.py +0 -2
@@ 15,8 15,6 @@ def set_logging(log_path=None, log_level=logging.INFO, modules=(),
    if not modules:
        modules = ('root', 'bootstrap', 'runserver',
                   'web', 'crawler.default_crawler', 'manager', 'plugins')
    if conf.ON_HEROKU:
        log_format = '%(levelname)s %(message)s'
    if log_path:
        if not os.path.exists(os.path.dirname(log_path)):
            os.makedirs(os.path.dirname(log_path))

M newspipe/conf.py => newspipe/conf.py +5 -25
@@ 4,6 4,7 @@

This file contain the variables used by the application.
"""
import configparser as confparser
import os
import logging



@@ 22,7 23,6 @@ TIME_ZONE = {
    "fr": "Europe/Paris"
}

ON_HEROKU = int(os.environ.get('HEROKU', 0)) == 1
DEFAULTS = {"platform_url": "https://www.newspipe.org/",
            "self_registration": "false",
            "cdn_address": "",


@@ 47,27 47,10 @@ DEFAULTS = {"platform_url": "https://www.newspipe.org/",
            "feed_refresh_interval": "120"
            }

if not ON_HEROKU:
    import configparser as confparser
    # load the configuration
    config = confparser.SafeConfigParser(defaults=DEFAULTS)
    config.read(os.path.join(BASE_DIR, "conf/conf.cfg"))
else:
    class Config(object):
        def get(self, _, name):
            return os.environ.get(name.upper(), DEFAULTS.get(name))

        def getint(self, _, name):
            return int(self.get(_, name))

        def getboolean(self, _, name):
            value = self.get(_, name)
            if value == 'true':
                return True
            elif value == 'false':
                return False
            return None
    config = Config()
# load the configuration
config = confparser.SafeConfigParser(defaults=DEFAULTS)
config.read(os.path.join(BASE_DIR, "conf/conf.cfg"))


WEBSERVER_HOST = config.get('webserver', 'host')


@@ 88,10 71,7 @@ try:
    TOKEN_VALIDITY_PERIOD = config.getint('misc', 'token_validity_period')
except:
    TOKEN_VALIDITY_PERIOD = int(config.get('misc', 'token_validity_period'))
if not ON_HEROKU:
    LOG_PATH = os.path.abspath(config.get('misc', 'log_path'))
else:
    LOG_PATH = ''
LOG_PATH = os.path.abspath(config.get('misc', 'log_path'))
LOG_LEVEL = {'debug': logging.DEBUG,
             'info': logging.INFO,
             'warn': logging.WARN,

M newspipe/notifications/emails.py => newspipe/notifications/emails.py +2 -6
@@ 46,13 46,9 @@ def send_async_email(mfrom, mto, msg):

def send(*args, **kwargs):
    """
    This functions enables to send email through SendGrid
    or a SMTP server.
    This functions enables to send email via different method.
    """
    if conf.ON_HEROKU:
        send_sendgrid(**kwargs)
    else:
        send_smtp(**kwargs)
    send_smtp(**kwargs)

def send_smtp(to="", bcc="", subject="", plaintext="", html=""):
    """

M newspipe/runserver.py => newspipe/runserver.py +0 -3
@@ 22,9 22,6 @@ import calendar
from bootstrap import conf, application, populate_g
from flask_babel import Babel, format_datetime

if conf.ON_HEROKU:
    from flask_sslify import SSLify
    SSLify(application, subdomains=True)

babel = Babel(application)


M newspipe/web/templates/about_more.html => newspipe/web/templates/about_more.html +1 -2
@@ 2,8 2,7 @@
{% block content %}
<div class="container">
    <ul class="list-group">
        <li class="list-group-item">{{ _('Newspipe version') }}: <a href="https://git.sr.ht/~cedric/Newspipe/refs/{{newspipe_version}}">{{newspipe_version}}</a></li>
        <li class="list-group-item">{{ _('Running on Heroku') }}: {{on_heroku}}</li>
        <li class="list-group-item">{{ _('Newspipe version') }}: <a href="https://git.sr.ht/~cedric/newspipe/refs/{{newspipe_version}}">{{newspipe_version}}</a></li>
        <li class="list-group-item">{{ _('Registration') }}: {{registration}}</li>
        <li class="list-group-item">{{ _('Python version') }}: {{python_version}}</li>
        <li class="list-group-item">{{ _('Number of users') }}: {{nb_users}}</li>

M newspipe/web/templates/layout.html => newspipe/web/templates/layout.html +1 -1
@@ 47,7 47,7 @@
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            {% if current_user.is_authenticated %}
                {% if conf.CRAWLING_METHOD == "default" and (not conf.ON_HEROKU or current_user.is_admin) %}
                {% if conf.CRAWLING_METHOD == "default" and current_user.is_admin %}
                    <li><a href="/fetch"><span class="glyphicon glyphicon-import"></span> {{ _('Fetch') }}</a></li>
                {% endif %}
                <li class="dropdown">

M newspipe/web/views/home.py => newspipe/web/views/home.py +1 -2
@@ 162,8 162,7 @@ def fetch(feed_id=None):
    Triggers the download of news.
    News are downloaded in a separated process.
    """
    if conf.CRAWLING_METHOD == "default" \
            and (not conf.ON_HEROKU or current_user.is_admin):
    if conf.CRAWLING_METHOD == "default" and current_user.is_admin:
        misc_utils.fetch(current_user.id, feed_id)
        flash(gettext("Downloading articles..."), "info")
    else:

M newspipe/web/views/views.py => newspipe/web/views/views.py +0 -2
@@ 88,8 88,6 @@ def about():
def about_more():
    return render_template('about_more.html',
                newspipe_version=__version__.split()[1],
                on_heroku=[conf.ON_HEROKU and 'Yes' or 'No'][0],
                registration=[conf.SELF_REGISTRATION and 'Open' or 'Closed'][0],
                python_version="{}.{}.{}".format(*sys.version_info[:3]),
                nb_users=UserController().read().count())


M poetry.lock => poetry.lock +1 -15
@@ 262,17 262,6 @@ SQLAlchemy = ">=0.8.0"

[[package]]
category = "main"
description = "Force SSL on your Flask app."
name = "flask-sslify"
optional = false
python-versions = "*"
version = "0.1.5"

[package.dependencies]
Flask = "*"

[[package]]
category = "main"
description = "Simple integration of Flask and WTForms."
name = "flask-wtf"
optional = false


@@ 589,7 578,7 @@ idna = ">=2.0"
multidict = ">=4.0"

[metadata]
content-hash = "6714462ca1b9ea98f6ec5d7ef69d7ddbed1ae0687cbff95accbcda74074714a2"
content-hash = "55d68271b42d43858eb45a17f1de68d89ed73cd5b72a497af0d64185b1c9ca1b"
python-versions = "^3.8"

[metadata.files]


@@ 687,9 676,6 @@ flask-sqlalchemy = [
    {file = "Flask-SQLAlchemy-2.4.1.tar.gz", hash = "sha256:6974785d913666587949f7c2946f7001e4fa2cb2d19f4e69ead02e4b8f50b33d"},
    {file = "Flask_SQLAlchemy-2.4.1-py2.py3-none-any.whl", hash = "sha256:0078d8663330dc05a74bc72b3b6ddc441b9a744e2f56fe60af1a5bfc81334327"},
]
flask-sslify = [
    {file = "Flask-SSLify-0.1.5.tar.gz", hash = "sha256:d33e1d3c09cd95154176aa8a7319418e52129fc482dd56d8a8ad7c24500d543e"},
]
flask-wtf = [
    {file = "Flask-WTF-0.14.3.tar.gz", hash = "sha256:d417e3a0008b5ba583da1763e4db0f55a1269d9dd91dcc3eb3c026d3c5dbd720"},
    {file = "Flask_WTF-0.14.3-py2.py3-none-any.whl", hash = "sha256:57b3faf6fe5d6168bda0c36b0df1d05770f8e205e18332d0376ddb954d17aef2"},

M pyproject.toml => pyproject.toml +0 -1
@@ 26,7 26,6 @@ Flask-RESTful = "^0.3.8"
Flask-Restless = "^0.17.0"
Flask-paginate = "^0.5.5"
Flask-Babel = "^1.0.0"
Flask-SSLify = "^0.1.5"
Flask-Migrate = "^2.5.2"
Flask-Script = "^2.0.6"
WTForms = "^2.2.1"