From ed3929dfe7bcf4505c3a639f27be27fd155310c6 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mar 15 2016 14:30:18 +0000 Subject: [PATCH 1/4] Allow feed entries to expand/collapse if they are conglomerates. --- diff --git a/hubs/widgets/feed.py b/hubs/widgets/feed.py index 19b1c27..492fdbd 100644 --- a/hubs/widgets/feed.py +++ b/hubs/widgets/feed.py @@ -43,17 +43,75 @@ template = jinja2.Template("""

{{match['markup']}}

{{match['human_time']}} + {% if match['msg_ids'] | length > 1 %} + + + {% endif %}
{% endfor %} + """) # No chrome around the feed. #from hubs.widgets.chrome import panel #chrome = panel() +def apply_markup(match): + markup = match['subtitle'] + for username in match['usernames']: + args = (username, '@{username}'.format( + url=flask.url_for('hub', name=username), + username=username, + )) + markup = markup.replace(*args) + # TODO -- have to add these to conglomerate first + #match['long_form'] = match['long_form'].replace(*args) + + for package in match['packages']: + args = (package, '{package}'.format( + url='https://apps.fedoraproject.org/packages/' + package, + package=package, + )) + markup = markup.replace(*args) + # TODO -- have to add these to conglomerate first + #match['long_form'] = match['long_form'].replace(*args) + + return markup + @argument(name="username", default=None, @@ -113,25 +171,9 @@ def data(session, widget, username, fmn_context): # Apply some html markup to the subtitles for extra fanciness. for match in matches: - match['markup'] = match['subtitle'] - for username in match['usernames']: - args = (username, '@{username}'.format( - url=flask.url_for('hub', name=username), - username=username, - )) - match['markup'] = match['markup'].replace(*args) - # TODO -- have to add these to conglomerate first - #match['long_form'] = match['long_form'].replace(*args) - - for package in match['packages']: - args = (package, '{package}'.format( - url='https://apps.fedoraproject.org/packages/' + package, - package=package, - )) - match['markup'] = match['markup'].replace(*args) - # TODO -- have to add these to conglomerate first - #match['long_form'] = match['long_form'].replace(*args) - + match['markup'] = apply_markup(match) + for idx, constituent in match['msg_ids'].items(): + constituent['markup'] = apply_markup(constituent) return dict( matches=matches, From ec5a01985fdb72604b86845f7a54459132c885ee Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mar 15 2016 14:43:11 +0000 Subject: [PATCH 2/4] Drop print statement. --- diff --git a/hubs/widgets/feed.py b/hubs/widgets/feed.py index 492fdbd..f777965 100644 --- a/hubs/widgets/feed.py +++ b/hubs/widgets/feed.py @@ -125,7 +125,6 @@ def data(session, widget, username, fmn_context): openid = '%s.id.fedoraproject.org' % username url = '/'.join([fmn_url, 'api', openid, fmn_context]) log.info("Getting FMN preferences from %s" % url) - print(url) response = requests.get(url) messages = [] matches = [] From 8c44c6287edd0cbafc62d42f856c8f47bb4badaa Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mar 15 2016 16:51:50 +0000 Subject: [PATCH 3/4] Move js functions out into their own file. --- diff --git a/hubs/templates/hubs.html b/hubs/templates/hubs.html index 1e87956..5d09b04 100644 --- a/hubs/templates/hubs.html +++ b/hubs/templates/hubs.html @@ -143,6 +143,7 @@ + """) # No chrome around the feed. From 810381335c903fefd8bd0d6a4d59bcc4122028fc Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mar 15 2016 17:04:31 +0000 Subject: [PATCH 4/4] Add forgotten file, because threebean doesn't know how to git. --- diff --git a/hubs/static/js/utils.js b/hubs/static/js/utils.js new file mode 100644 index 0000000..1e97046 --- /dev/null +++ b/hubs/static/js/utils.js @@ -0,0 +1,12 @@ +// These two functions are used by the feed widget to expand and collapse +// entries. +var expand_feed_entries = function(idx) { + $("#expand-" + idx).addClass('hidden'); + $("#collapse-" + idx).removeClass('hidden'); + $("#content-" + idx).removeClass('hidden'); +} +var collapse_feed_entries = function(idx) { + $("#expand-" + idx).removeClass('hidden'); + $("#collapse-" + idx).addClass('hidden'); + $("#content-" + idx).addClass('hidden'); +}