incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [2/3] git commit: [#6456] Added class for parsing GC project data
Date Fri, 19 Jul 2013 14:55:19 GMT
[#6456] Added class for parsing GC project data

Also, some minor touchups on the template

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


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 <cjohns@slashdotmedia.com>
Authored: Fri Jul 19 14:22:24 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
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 %}
 
 <form id="project-import-form" method="POST" action="process">
-    <input type="hidden" name="source" value="{{request.params.source}}" />
+    <input type="hidden" id="neighborhood" name="neighborhood" value="Projects"/>
 
     <fieldset id="project-fields">
         {% block project_fields %}{% endblock %}


Mime
View raw message