diff --git a/LICENSE b/LICENSE index 7ac2761..9a00e36 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2016 deflax +Copyright (c) 2015-2017 deflax.net This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/app/__init__.py b/app/__init__.py index 9d7d548..4e6e2ad 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -34,6 +34,9 @@ babel.init_app(app) from .main import main as main_blueprint app.register_blueprint(main_blueprint) +from .news import news as news_blueprint +app.register_blueprint(news_blueprint, url_prefix='/news') + from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/auth') @@ -60,7 +63,7 @@ class CustomJSONEncoder(JSONEncoder): app.json_encoder = CustomJSONEncoder -#if app.debug: +#TODO: if app.debug: if not app.debug: import logging from logging.handlers import RotatingFileHandler @@ -69,7 +72,7 @@ if not app.debug: file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]')) app.logger.addHandler(file_handler) app.logger.setLevel(logging.DEBUG) - app.logger.info('Proxadmin started.') + #app.logger.info('Proxadmin started.') @app.errorhandler(403) def forbidden(e): diff --git a/app/news/__init__.py b/app/news/__init__.py new file mode 100644 index 0000000..ede6ea5 --- /dev/null +++ b/app/news/__init__.py @@ -0,0 +1,3 @@ +from flask import Blueprint +news = Blueprint('news', __name__) +from . import routes diff --git a/app/news/routes.py b/app/news/routes.py new file mode 100644 index 0000000..fb53be6 --- /dev/null +++ b/app/news/routes.py @@ -0,0 +1,40 @@ +from flask import render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g +from . import news + +from functools import lru_cache +import requests +import json +from facepy import GraphAPI + +@lru_cache(maxsize=8) +def get_fb_token(): + payload = {'grant_type': 'client_credentials', 'client_id': current_app.config['FB_APP_ID'], 'client_secret': current_app.config['FB_APP_SECRET']} + response = requests.post('https://graph.facebook.com/oauth/access_token?', params = payload) + fbjson = json.loads(response.text) + fbtoken = fbjson['access_token'] + current_app.logger.info("FB Token: {}".format(fbtoken)) + return fbtoken + +@news.route("/all", methods=['GET']) +def all(): + graph = GraphAPI(get_fb_token()) + #current_app.logger.info(get_fb_token.cache_info()) + page_id = current_app.config['FB_PAGE_ID'] + datas = graph.get(page_id+'/posts?fields=id,message,created_time,link,icon', page=True, retry=3) + posts = [] + for data in datas: + posts.append(data) + content=posts[0]['data'] + return render_template('news/facebook.html', result=content) + +@news.route('/latest') +def latest(): + graph = GraphAPI(get_fb_token()) + page_id = current_app.config['FB_PAGE_ID'] + latest = graph.get(page_id+'/posts?limit=1&fields=id,message,created_time,link', page=True, retry=3) + posts = [] + for data in latest: + posts.append(data) + content=posts[0]['data'] + return render_template('news/latest.html', result=content) + diff --git a/app/settings/routes.py b/app/settings/routes.py index 47d2472..ff60123 100644 --- a/app/settings/routes.py +++ b/app/settings/routes.py @@ -51,7 +51,7 @@ def profile(): form.twofactor.data = current_user.twofactor wallet = "%.2f" % round(current_user.wallet, 3) - current_app.logger.info('wallet: ' + wallet) + current_app.logger.info('[{}] wallet: {}'.format(current_user.email, wallet)) return render_template('settings/profile.html', page=page, form=form, wallet=wallet) diff --git a/app/templates/_formhelpers.html b/app/templates/_formhelpers.html deleted file mode 100644 index 0b6bfda..0000000 --- a/app/templates/_formhelpers.html +++ /dev/null @@ -1,12 +0,0 @@ -{% macro render_field(field) %} -
Yr umami selfies Carles DIY, pop-up Tonx meggings stumptown freegan street art Vice ethnic. Pickled gastropub lo-fi polaroid, ennui selvage meh Tumblr organic iPhone kale chips narwhal Echo Park. Tonx literally distillery Pitchfork McSweeney's semiotics. Stumptown YOLO fanny pack bespoke, kitsch Carles gastropub vegan. Biodiesel ennui church-key McSweeney's, selvage hoodie Brooklyn 90's lomo. Quinoa photo booth cliche semiotics. Roof party Etsy ethnic, fashion axe mlkshk 8-bit paleo.
-Yr umami selfies Carles DIY, pop-up Tonx meggings stumptown freegan street art Vice ethnic. Pickled gastropub lo-fi polaroid, ennui selvage meh Tumblr organic iPhone kale chips narwhal Echo Park. Tonx literally distillery Pitchfork McSweeney's semiotics. Stumptown YOLO fanny pack bespoke, kitsch Carles gastropub vegan. Biodiesel ennui church-key McSweeney's, selvage hoodie Brooklyn 90's lomo. Quinoa photo booth cliche semiotics. Roof party Etsy ethnic, fashion axe mlkshk 8-bit paleo.
-Yr umami selfies Carles DIY, pop-up Tonx meggings stumptown freegan street art Vice ethnic. Pickled gastropub lo-fi polaroid, ennui selvage meh Tumblr organic iPhone kale chips narwhal Echo Park. Tonx literally distillery Pitchfork McSweeney's semiotics. Stumptown YOLO fanny pack bespoke, kitsch Carles gastropub vegan. Biodiesel ennui church-key McSweeney's, selvage hoodie Brooklyn 90's lomo. Quinoa photo booth cliche semiotics. Roof party Etsy ethnic, fashion axe mlkshk 8-bit paleo.
-tel: +359 (0) 32 398 295
email: office@datapoint.bg
We are a dedicated team working to bring you the best hosting in the business.
We are passionate about what we do, and why we do it.
Read More…
Join our newsletter to stay informed on our latest updates and sales.