From 443932c6bffbf1663e6b7e2c173226311faaa0d8 Mon Sep 17 00:00:00 2001 From: Shaily Date: Oct 22 2017 11:06:56 +0000 Subject: [PATCH 1/3] Remove pattern lab CSS --- diff --git a/hubs/templates/master.html b/hubs/templates/master.html index 3f344a9..01a0ad2 100644 --- a/hubs/templates/master.html +++ b/hubs/templates/master.html @@ -2,7 +2,6 @@ {% block title %}{% endblock %} - From 58011e58080baaf6bdfe3aee2b88f570406b3122 Mon Sep 17 00:00:00 2001 From: Shaily Date: Oct 22 2017 11:08:16 +0000 Subject: [PATCH 2/3] Add markdown rendering capability to Sticky Note widget --- diff --git a/hubs/widgets/sticky/__init__.py b/hubs/widgets/sticky/__init__.py index 13c6af3..7399bff 100644 --- a/hubs/widgets/sticky/__init__.py +++ b/hubs/widgets/sticky/__init__.py @@ -2,8 +2,11 @@ from __future__ import unicode_literals from hubs.widgets import validators from hubs.widgets.base import Widget +from hubs.widgets.caching import CachedFunction from hubs.widgets.view import RootWidgetView +from markdown import markdown + class Sticky(Widget): @@ -11,9 +14,12 @@ class Sticky(Widget): label = "Sticky Note" position = "both" display_css = "card-info" + is_large = True parameters = [ dict( name="text", + render_tag="textarea", + render_attributes={"rows": "30"}, label="Text", default="Lorem ipsum dolor...", validator=validators.Text, @@ -24,7 +30,18 @@ class Sticky(Widget): class BaseView(RootWidgetView): def get_context(self, instance, *args, **kwargs): - # TODO -- render with markdown + md = ParseMarkdown(instance) return dict( - text=instance.config["text"], - ) + text=md() + ) + + +class ParseMarkdown(CachedFunction): + + def execute(self): + text = self.instance.config["text"] + return markdown(text, extensions=['markdown.extensions.extra', + 'markdown.extensions.sane_lists']) + + def should_invalidate(self, message): + return False diff --git a/requirements.txt b/requirements.txt index 4a42cec..8232aff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,7 @@ fmn.lib fmn.rules gunicorn html5lib==0.9999999 +markdown munch psycopg2 pymongo From e8e1e4c71804ba06940724998cfe1dcae53dafb1 Mon Sep 17 00:00:00 2001 From: Shaily Date: Oct 25 2017 23:04:58 +0000 Subject: [PATCH 3/3] Add markdown test for Sticky Note widget --- diff --git a/hubs/tests/widgets/test_sticky.py b/hubs/tests/widgets/test_sticky.py new file mode 100644 index 0000000..d4b9902 --- /dev/null +++ b/hubs/tests/widgets/test_sticky.py @@ -0,0 +1,25 @@ +from __future__ import unicode_literals + +from . import WidgetTest + + +class StickyTest(WidgetTest): + + plugin = "sticky" + initial_widget_config = { + "text": """| Tables | Are | Cool | + | ------------- |:-------------:| -----:| + | col 3 is | right-aligned | $1600 | + | col 2 is | centered | $12 | + | zebra stripes | are neat | $1 | + """ + } + + def populate(self): + super(StickyTest, self).populate() + self._add_widget_under_test() + + def test_markdown_parse(self): + func = self.widget.module.get_cached_functions()['ParseMarkdown'] + result = func(self.widget).execute() + self.assertRegexpMatches(result, r'^(?s).*
$')