incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [23/25] git commit: [#6482] change page to show importers in a grid
Date Tue, 20 Aug 2013 13:28:49 GMT
[#6482] change page to show importers in a grid


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/451a6915
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/451a6915
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/451a6915

Branch: refs/heads/db/6482
Commit: 451a6915eb37292a00331d9d1030d90646696dc9
Parents: 7b5504f
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Tue Aug 13 19:20:11 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Aug 20 13:27:53 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/base.py           | 31 +++++++++--
 .../forgeimporters/templates/list_all.html      | 58 ++++++++------------
 2 files changed, 51 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/451a6915/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index eb5748e..a5023da 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -17,6 +17,7 @@
 
 import logging
 import urllib2
+from collections import defaultdict
 
 from pkg_resources import iter_entry_points
 
@@ -292,11 +293,33 @@ class ProjectToolsImportController(object):
     @with_trailing_slash
     @expose('jinja:forgeimporters:templates/list_all.html')
     def index(self, *a, **kw):
-        importers = {}
-        for app_name, app in g.entry_points['tool'].iteritems():
-            importers[app] = ToolImporter.by_app(app)
+        # make dictionaries of both axis
+        importers_by_source = defaultdict(dict)
+        importers_by_tool = defaultdict(dict)
+        for ep in iter_entry_points('allura.importers'):
+            importer = ep.load()
+            importers_by_source[importer.source][ep.name] = importer
+            for tool in aslist(importer.target_app):
+                importers_by_tool[tool][ep.name] = importer
+
+        relevant_tools = sorted(importers_by_tool.keys(), key=lambda t: t.tool_label)
+
+        # build a full matrix including empty spots
+        importer_matrix = dict() # source -> [importer names]
+        for source, src_importers in importers_by_source.iteritems():
+            row = list()
+            for tool in relevant_tools:
+                for ep_name, importer in src_importers.iteritems():
+                    if tool in aslist(importer.target_app):
+                        row.append(ep_name)
+                        break
+                else:
+                    row.append(None)
+            importer_matrix[source] = row
+
         return {
-            'importers': importers
+            'tools': relevant_tools,
+            'importer_matrix': importer_matrix,
         }
 
     @expose()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/451a6915/ForgeImporters/forgeimporters/templates/list_all.html
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/templates/list_all.html b/ForgeImporters/forgeimporters/templates/list_all.html
index 58c9f34..b91e0df 100644
--- a/ForgeImporters/forgeimporters/templates/list_all.html
+++ b/ForgeImporters/forgeimporters/templates/list_all.html
@@ -21,42 +21,32 @@
 
 {% block title %}{{c.project.name}} / Import{% endblock %}
 
-{% block header %}Import from external sources{% endblock %}
-
-{% block extra_css %}
-<style type="text/css">
-    .tool {
-        margin-bottom: 3em;
-    }
-    .tool img {
-        float: left;
-        margin: 0 1em;
-    }
-    .importer .descr {
-        margin: 0 2em 1em 2em;
-    }
-</style>
-{% endblock %}
+{% block header %}Import{% endblock %}
 
 {% block content %}
-    {% for tool, tool_importers in importers.iteritems() %}
-        <div class="tool">
-        {% for importer_name, importer in tool_importers.iteritems() %}
-            {% if loop.first %}
-                <img src="{{ g.theme.app_icon_url(tool, 48) }}" alt="{{ tool.tool_label
}} icon">
-                <h2>{{ tool.tool_label }}</h2>
-            {% endif %}
-            <div class="importer">
-                <a href="{{importer_name}}"><h3>
-                {{importer.source}}:
-                {{importer.tool_label}}
-                </h3>
-                </a>
-                <div class="descr">
-                {{importer.tool_description}}
-                </div>
-            </div>
+<p>
+    To import from one of these external sources into your project, just click on "Import"
and fill out the form.
+</p>
+<table>
+    <thead>
+    <tr>
+        <th></th>
+        {% for tool in tools %}
+            <th>{{tool.tool_label}}</th>
+        {% endfor %}
+    </tr>
+    </thead>
+    {% for source, importers in importer_matrix|dictsort %}
+        <tr>
+        <td><strong>{{ source }}</strong></td>
+        {% for importer_name in importers %}
+            <td>
+                {% if importer_name %}
+                <a href="{{importer_name}}">Import</a>
+                {% endif %}
+            </td>
         {% endfor %}
-        </div>
+        </tr>
     {% endfor %}
+</table>
 {% endblock %}


Mime
View raw message