Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 462EBC463 for ; Fri, 19 Jul 2013 14:55:25 +0000 (UTC) Received: (qmail 55127 invoked by uid 500); 19 Jul 2013 14:55:24 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 55012 invoked by uid 500); 19 Jul 2013 14:55:22 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 54478 invoked by uid 99); 19 Jul 2013 14:55:19 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jul 2013 14:55:19 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A11028AEE45; Fri, 19 Jul 2013 14:55:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tvansteenburgh@apache.org To: allura-commits@incubator.apache.org Date: Fri, 19 Jul 2013 14:55:19 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] git commit: [#6456] Added class for parsing GC project data [#6456] Added class for parsing GC project data Also, some minor touchups on the template Signed-off-by: Cory Johns Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/ade1deb7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ade1deb7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ade1deb7 Branch: refs/heads/master Commit: ade1deb7957570b9f40b4d7e1adf212f9ce68da3 Parents: da05d21 Author: Cory Johns Authored: Fri Jul 19 14:22:24 2013 +0000 Committer: Tim Van Steenburgh Committed: Fri Jul 19 14:54:50 2013 +0000 ---------------------------------------------------------------------- Allura/allura/nf/allura/css/site_style.css | 9 +++ ForgeImporters/forgeimporters/base.py | 2 +- .../forgeimporters/google/__init__.py | 68 ++++++++++++++++++++ .../forgeimporters/templates/project_base.html | 2 +- 4 files changed, 79 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ade1deb7/Allura/allura/nf/allura/css/site_style.css ---------------------------------------------------------------------- diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css index 0b4eb92..94db371 100644 --- a/Allura/allura/nf/allura/css/site_style.css +++ b/Allura/allura/nf/allura/css/site_style.css @@ -3060,6 +3060,15 @@ ul.dropdown ul li a:hover { background: transparent; color: red; border: 0; + padding: 0; + font-weight: 300; +} +#project-import-form #project-url { + font-size: 12px; + font-weight: 300; +} +#project-import-form #url-fragment { + font-weight: 600; } #project-import-form .tool { float: left; http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ade1deb7/ForgeImporters/forgeimporters/base.py ---------------------------------------------------------------------- diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py index 39a350c..c3b6946 100644 --- a/ForgeImporters/forgeimporters/base.py +++ b/ForgeImporters/forgeimporters/base.py @@ -72,7 +72,7 @@ class ToolImporter(object): source = None controller = None - def import_tool(self, project, mount_point): + def import_tool(self, project=None, mount_point=None): """ Override this method to perform the tool import. """ http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ade1deb7/ForgeImporters/forgeimporters/google/__init__.py ---------------------------------------------------------------------- diff --git a/ForgeImporters/forgeimporters/google/__init__.py b/ForgeImporters/forgeimporters/google/__init__.py new file mode 100644 index 0000000..0e5c894 --- /dev/null +++ b/ForgeImporters/forgeimporters/google/__init__.py @@ -0,0 +1,68 @@ +# 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. + +import urllib +import urllib2 +from urlparse import urlparse +from collections import defaultdict + +from BeautifulSoup import BeautifulSoup + +from allura import model as M + + +class GoogleCodeProjectExtractor(object): + PAGE_MAP = { + 'project_info': 'http://code.google.com/p/%s/', + } + + LICENSE_MAP = defaultdict(lambda:'Other/Proprietary License', { + 'Apache License 2.0': 'Apache Software License', + 'Artistic License/GPL': 'Artistic License', + 'Eclipse Public License 1.0': 'Eclipse Public License', + 'GNU GPL v2': 'GNU General Public License (GPL', + 'GNU GPL v3': 'GNU General Public License (GPL', + 'GNU Lesser GPL': 'GNU Library or Lesser General Public License (LGPL)', + 'MIT License': 'License :: OSI-Approved Open Source :: MIT License', + 'Mozilla Public License 1.1': 'Mozilla Public License 1.1 (MPL 1.1)', + 'New BSD License': 'BSD License', + 'Other Open Source': 'Other/Proprietary License', + }) + + def __init__(self, project): + gc_project_name = project.get_tool_data('google-code', 'project_name') + page = urllib2.urlopen(PAGE_MAP[page] % urllib.quote(gc_project_name)) + self.project = project + self.page = BeautifulSoup(page) + + def get_short_description(self): + self.project.short_description = str(self.page.find(itemprop='description')).strip() + + def get_icon(self): + icon_url = self.page.find(itemprop='image').src + icon_name = urllib.unquote(urlparse(icon_url).path).split('/')[-1] + fp = urllib2.urlopen(icon_url) + M.ProjectFile.save_image( + icon_name, fp, fp.info()['content-type'], square=True, + thumbnail_size=(48,48), + thumbnail_meta=dict(project_id=self.project._id, category='icon')) + + def get_license(self): + license = str(self.page.find(text='Code license:').findNext('td')).strip() + trove = M.TroveCategory.query.get(fullname=LICENSE_MAP[license]) + self.project.trove_license.append(trove._id) + http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ade1deb7/ForgeImporters/forgeimporters/templates/project_base.html ---------------------------------------------------------------------- diff --git a/ForgeImporters/forgeimporters/templates/project_base.html b/ForgeImporters/forgeimporters/templates/project_base.html index 02405f4..d42954f 100644 --- a/ForgeImporters/forgeimporters/templates/project_base.html +++ b/ForgeImporters/forgeimporters/templates/project_base.html @@ -26,7 +26,7 @@ {% block content %}
- +
{% block project_fields %}{% endblock %}