From a95fbea7014fbf28f17c4e275179c83d40bf45bf Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Oct 05 2016 10:43:54 +0000 Subject: [PATCH 1/3] some beautification in about widget --- diff --git a/hubs/widgets/about.py b/hubs/widgets/about.py index 7023139..4be594c 100755 --- a/hubs/widgets/about.py +++ b/hubs/widgets/about.py @@ -14,11 +14,16 @@ position = 'both' validator=validators.text, help="Text about a user.") def data(session, widget, text): + ''' Data for the About widget ''' + return dict(text=text) @hint(topics=[_('hubs.widget.update')]) def should_invalidate(message, session, widget): + ''' Checks whether the about widget cache needs an update or not + Called by backend daemon which listens to fedmsg ''' + if not message['topic'].endswith('hubs.widget.update'): return False if message['msg']['widget']['id'] != widget.idx: From aa65f58ae8387ebf860219a8b1f9661c74bb059a Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Oct 05 2016 10:43:54 +0000 Subject: [PATCH 2/3] some beautification in clean_input --- diff --git a/hubs/widgets/clean_input.py b/hubs/widgets/clean_input.py index 46bccbc..316c7a4 100644 --- a/hubs/widgets/clean_input.py +++ b/hubs/widgets/clean_input.py @@ -5,6 +5,7 @@ import bleach def filter_img_src(name, value): ''' Filter in img html tags images coming from a different domain. ''' + import hubs.app if name in ('alt', 'height', 'width', 'class'): return True @@ -16,14 +17,15 @@ def filter_img_src(name, value): def clean(text, ignore=None): - """ For a given html text, escape everything we do not want to support + ''' For a given html text, escape everything we do not want to support to avoid potential security breach. - """ + ''' + if ignore and not isinstance(ignore, (tuple, set, list)): ignore = [ignore] attrs = bleach.ALLOWED_ATTRIBUTES - if not ignore or not 'img' in ignore: + if not ignore or 'img' not in ignore: attrs['img'] = filter_img_src tags = bleach.ALLOWED_TAGS + [ From 3d9d80649dce6887056f6e3b4870f0a6af2302f9 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Oct 05 2016 10:43:54 +0000 Subject: [PATCH 3/3] some beautification in pagureissues widget --- diff --git a/hubs/widgets/pagureissues.py b/hubs/widgets/pagureissues.py index 118f8d5..c9ecd53 100755 --- a/hubs/widgets/pagureissues.py +++ b/hubs/widgets/pagureissues.py @@ -1,9 +1,10 @@ +import requests + from hubs.hinting import hint from hubs.widgets.chrome import panel from hubs.widgets.base import argument from hubs.widgets import templating import hubs.validators as validators -import requests pagure_url = "https://pagure.io/api/0" @@ -17,6 +18,9 @@ position = 'right' validator=validators.pagure_repo, help="Pagure repo name") def data(session, widget, repo): + ''' Data for pagure issues widget + Queries Pagure api for issues ''' + repo = "pagure" url = '/'.join([pagure_url, repo, "issues"]) @@ -65,4 +69,7 @@ def data(session, widget, repo): @hint() def should_invalidate(message, session, widget): + ''' Checks whether pagureissues widget cache needs an update + Run by backend daemon listening to fedmsg ''' + raise NotImplementedError