You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/08/20 15:28:48 UTC
[22/25] git commit: [#6482] import page for existing projects
[#6482] import page for existing projects
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/7b5504f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7b5504f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7b5504f6
Branch: refs/heads/db/6482
Commit: 7b5504f68674906386d6a2d37647c8f5e6e64020
Parents: d924835
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Aug 9 22:14:07 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Aug 20 13:26:59 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/base.py | 45 ++++++++++++--
.../forgeimporters/templates/list_all.html | 62 ++++++++++++++++++++
ForgeImporters/setup.py | 3 +
3 files changed, 104 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7b5504f6/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index ee34ab3..eb5748e 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -22,15 +22,17 @@ from pkg_resources import iter_entry_points
from tg import expose, validate, flash, redirect, config
from tg.decorators import with_trailing_slash
-from pylons import tmpl_context as c
+from pylons import tmpl_context as c, app_globals as g
from formencode import validators as fev, schema
+from webob import exc
from allura.lib.decorators import require_post
from allura.lib.decorators import task
from allura.lib.security import require_access
-from allura.lib.plugin import ProjectRegistrationProvider
+from allura.lib.plugin import ProjectRegistrationProvider, AdminExtension
from allura.lib import helpers as h
from allura.lib import exceptions
+from allura.app import SitemapEntry
from paste.deploy.converters import aslist
@@ -206,16 +208,16 @@ class ToolImporter(object):
source = None # string description of source, must match project importer
controller = None
- @classmethod
- def by_name(self, name):
+ @staticmethod
+ def by_name(name):
"""
Return a ToolImporter subclass instance given its entry-point name.
"""
for ep in iter_entry_points('allura.importers', name):
return ep.load()()
- @classmethod
- def by_app(self, app):
+ @staticmethod
+ def by_app(app):
"""
Return a ToolImporter subclass instance given its target_app class.
"""
@@ -283,3 +285,34 @@ class ToolsValidator(fev.Set):
pl = 's' if len(invalid) > 1 else ''
raise fev.Invalid('Invalid tool%s selected: %s' % (pl, ', '.join(invalid)), value, state)
return valid
+
+class ProjectToolsImportController(object):
+ '''List all importers available'''
+
+ @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)
+ return {
+ 'importers': importers
+ }
+
+ @expose()
+ def _lookup(self, name, *remainder):
+ import_tool = ToolImporter.by_name(name)
+ if import_tool:
+ return import_tool.controller(), remainder
+ else:
+ raise exc.HTTPNotFound
+
+class ImportAdminExtension(AdminExtension):
+ '''Add import link to project admin sidebar'''
+
+ project_admin_controllers = {'import': ProjectToolsImportController}
+
+ def update_project_sidebar_menu(self, sidebar_links):
+ base_url = c.project.url() + 'admin/ext/'
+ link = SitemapEntry('Import', base_url+'import')
+ sidebar_links.append(link)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7b5504f6/ForgeImporters/forgeimporters/templates/list_all.html
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/templates/list_all.html b/ForgeImporters/forgeimporters/templates/list_all.html
new file mode 100644
index 0000000..58c9f34
--- /dev/null
+++ b/ForgeImporters/forgeimporters/templates/list_all.html
@@ -0,0 +1,62 @@
+{#-
+ 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.
+-#}
+{% extends g.theme.master %}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+
+{% 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 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>
+ {% endfor %}
+ </div>
+ {% endfor %}
+{% endblock %}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7b5504f6/ForgeImporters/setup.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/setup.py b/ForgeImporters/setup.py
index b19fd17..d9af953 100644
--- a/ForgeImporters/setup.py
+++ b/ForgeImporters/setup.py
@@ -41,4 +41,7 @@ setup(name='ForgeImporters',
google-code-tracker = forgeimporters.google.tracker:GoogleCodeTrackerImporter
google-code-repo = forgeimporters.google.code:GoogleRepoImporter
trac-tickets = forgeimporters.trac.tickets:TracTicketImporter
+
+ [allura.admin]
+ importers = forgeimporters.base:ImportAdminExtension
""",)