You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by gj...@apache.org on 2012/11/29 15:07:48 UTC
svn commit: r1415169 - in /incubator/bloodhound/trunk/bloodhound_dashboard:
bhdashboard/layouts/templates/widget_macros.html
bhdashboard/templates/widget.html bhdashboard/templates/widget_macros.html
bhdashboard/web_ui.py bhdashboard/wiki.py setup.py
Author: gjm
Date: Thu Nov 29 14:07:47 2012
New Revision: 1415169
URL: http://svn.apache.org/viewvc?rev=1415169&view=rev
Log:
macros for widgets - towards #138
Added:
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/widget.html (with props)
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/widget_macros.html
- copied unchanged from r1415108, incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/widget_macros.html
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py (with props)
Removed:
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/widget_macros.html
Modified:
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py
incubator/bloodhound/trunk/bloodhound_dashboard/setup.py
Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/widget.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/widget.html?rev=1415169&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/widget.html (added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/widget.html Thu Nov 29 14:07:47 2012
@@ -0,0 +1,33 @@
+<!--!
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<html
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:bh="http://issues.apache.org/bloodhound/wiki/Ui/Dashboard"
+ py:strip="" >
+ <xi:include href="widget_macros.html" />
+
+ <bh:widget id="${id or None}" urn="$widget" py:attrs="opts or {}">
+ <bh:args>
+ <bh:arg name="$argnm" py:for="argnm, value in args.iteritems()">$value</bh:arg>
+ </bh:args>
+ </bh:widget>
+</html>
Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/widget.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/widget.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py?rev=1415169&r1=1415168&r2=1415169&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py Thu Nov 29 14:07:47 2012
@@ -286,6 +286,13 @@ class DashboardModule(Component):
'altlinks' : w.get('altlinks', True) and data.get('altlinks') or None}] \
for k, w, (template, data, wctx) in data_strm)
+ def alert_disabled(self):
+ return tag.div(tag.span('Error', class_='label label-important'),
+ ' Could not load dashboard. Is ',
+ tag.code('bhdashboard.web_ui.DashboardModule'),
+ ' component disabled ?',
+ class_='alert alert-error')
+
#------------------------------------------------------
# Dashboard Helpers to be used in templates
#------------------------------------------------------
Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py?rev=1415169&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py (added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py Thu Nov 29 14:07:47 2012
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+r"""Project dashboard for Apache(TM) Bloodhound
+
+WikiMacros and WikiProcessors related to dashboard system.
+"""
+
+from ast import literal_eval
+
+from genshi.builder import tag
+
+from trac.web.chrome import Chrome
+from trac.wiki.api import parse_args
+from trac.wiki.macros import WikiMacroBase
+
+from bhdashboard.web_ui import DashboardChrome, DashboardModule
+
+class WidgetMacro(WikiMacroBase):
+ """Embed Bloodhound widgets using WikiFormatting.
+ """
+ #: A gettext domain to translate the macro description
+ _domain = None
+
+ #: A macro description
+ _description = """Embed Bloodhound widgets using WikiFormatting."""
+
+ def expand_macro(self, formatter, name, content):
+ """Render widget contents by re-using wiki markup implementation
+ """
+ if self.env[DashboardModule] is None:
+ return DashboardModule(self.env).alert_disabled()
+ largs, kwargs = parse_args(content, strict=True)
+ try:
+ (widget_name ,) = largs
+ except ValueError:
+ template = 'widget_alert.html'
+ data = {
+ 'msgtype' : 'error',
+ 'msglabel' : 'Error',
+ 'msgbody' : tag('Expected ', tag.code(1),
+ ' positional argument (i.e. widget name), but got ',
+ tag.code(len(largs)), ' instead'),
+ 'msgdetails' : [
+ ('Macro name', tag.code('WidgetMacro')),
+ ('Arguments', ', '.join(largs) if largs \
+ else tag.span('None', class_='label')),
+ ],
+ }
+ else:
+ widget_name = widget_name.strip()
+ wopts = {} ; wargs = {}
+
+ def parse_literal(value):
+ try:
+ return literal_eval(value)
+ except (SyntaxError, ValueError):
+ return value
+
+ for argnm, value in kwargs.iteritems():
+ if argnm.startswith('wo_'):
+ wopts[argnm[3:]] = value
+ else :
+ wargs[argnm] = parse_literal(value)
+ template = 'widget.html'
+ data = {
+ 'args' : wargs,
+ 'bhdb' : DashboardChrome(self.env),
+ 'id' : None,
+ 'opts' : wopts,
+ 'widget' : widget_name
+ }
+ return Chrome(self.env).render_template(
+ formatter.req, template, data, fragment=True)
+
Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/bloodhound/trunk/bloodhound_dashboard/setup.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/setup.py?rev=1415169&r1=1415168&r2=1415169&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/setup.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/setup.py Thu Nov 29 14:07:47 2012
@@ -123,6 +123,7 @@ ENTRY_POINTS = r"""
bhdashboard.widgets.report = bhdashboard.widgets.report
bhdashboard.widgets.ticket = bhdashboard.widgets.ticket
bhdashboard.widgets.timeline = bhdashboard.widgets.timeline
+ bhdashboard.wiki = bhdashboard.wiki
"""
setup(