From 791b715958004f08f03dbabc82629b370eda9f4a Mon Sep 17 00:00:00 2001 From: Eric Barbour Date: Jul 14 2016 14:40:39 +0000 Subject: Use application config to set the SSE url * Use app.config to set SSE url * Pin min version for flask-oidc * Readme instructions for SSE url --- diff --git a/.gitignore b/.gitignore index 74ff6cc..096613a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ build/ scratch/ npm-debug.log -client_secrets.json \ No newline at end of file +client_secrets.json +hubs.js diff --git a/README.rst b/README.rst index 095bc30..531a78a 100644 --- a/README.rst +++ b/README.rst @@ -205,14 +205,15 @@ will just grow and grow over time:: [2015-07-01 14:33:21][ fedmsg INFO] copr has 6 entries [2015-07-01 14:33:21][ fedmsg INFO] askbot has 2 entries -Build JavaScript assets. Add ``--w`` for live reloading:: +Change the ``SSE_URL`` location in ``default_config.py`` to point to the +streaming server then build JavaScript assets. Add ``--w`` for live reloading:: $ cd hubs/static/client && node_modules/.bin/webpack **Lastly**, (fingers crossed) start up the fedora-hubs webapp and load your profile page. Change back to the project root and run:: - $ python runserver.py + $ python runserver.py -c config Once there are some messages that get into your local database that *should* show up on your feed.. they should appear there. (At very least, diff --git a/hubs/default_config.py b/hubs/default_config.py index 0ce12f8..4125923 100755 --- a/hubs/default_config.py +++ b/hubs/default_config.py @@ -9,6 +9,7 @@ PROMOTED_GROUPS = [ HUB_OF_THE_MONTH = 'commops' +SSE_URL = 'http://localhost:8080/user/' OIDC_CLIENT_SECRETS = os.path.join(os.path.dirname( os.path.abspath(__file__)), '..', 'client_secrets.json') diff --git a/hubs/defaults.py b/hubs/defaults.py index 4b2049d..ddd04db 100755 --- a/hubs/defaults.py +++ b/hubs/defaults.py @@ -11,7 +11,8 @@ def add_user_widgets(session, hub, username, fullname): plugin='feed', index=0, left=True, _config=json.dumps({ 'username': username, - 'fmn_context': 'irc', # TODO -- make this 'hubs' + 'fmn_context': 'irc', # TODO -- make this 'hubs', + 'message_limit': 20 })) hub.widgets.append(widget) diff --git a/hubs/widgets/feed.py b/hubs/widgets/feed.py index f6cf651..42b3cb5 100755 --- a/hubs/widgets/feed.py +++ b/hubs/widgets/feed.py @@ -92,6 +92,9 @@ class PythonObjectEncoder(json.JSONEncoder): def data(session, widget, username, fmn_context, message_limit): messages = [] matches = [] + # Avoid circular import + from hubs.app import app + feed_url = app.config['SSE_URL'] + username preference = get_remote_preference(username, fmn_context) if preference: try: @@ -114,7 +117,7 @@ def data(session, widget, username, fmn_context, message_limit): total, pages, rows = datanommer.models.Message.grep( start=end - delta, end=end, - rows_per_page=bazillion, + rows_per_page=message_limit, page=page, order='desc', **fmn_hinting @@ -154,7 +157,11 @@ def data(session, widget, username, fmn_context, message_limit): # And tack on a unique identifier for each top level entry. match['dom_id'] = six.text_type(uuid.uuid4()) matches = json.dumps(matches, cls=PythonObjectEncoder) - return dict(matches=matches, message_limit=message_limit) + return dict( + matches=matches, + message_limit=message_limit, + feed_url=feed_url + ) @hint(ubiquitous=True) diff --git a/hubs/widgets/templates/feed.html b/hubs/widgets/templates/feed.html index 9973c29..755bec9 100644 --- a/hubs/widgets/templates/feed.html +++ b/hubs/widgets/templates/feed.html @@ -7,7 +7,7 @@ (function() { const FeedElement = React.createElement(Feed, { matches: {{ matches }}, - url: 'localhost:8080/user/skrzepto', + url: '{{ feed_url }}', messageLimit: {{ message_limit }} }); reactRender(FeedElement, document.getElementById('feed')); diff --git a/requirements.txt b/requirements.txt index 883cb24..01e9cc9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ dogpile.cache fedmsg fedmsg_meta_fedora_infrastructure flask -flask-oidc +flask-oidc>=1.0.3 fmn.lib fmn.rules gunicorn