Commits

Janto Dreijer committed ff236be

rough heuristics to determine repo type and location

Comments (0)

Files changed (2)

 		d = dict(
 			name=self.name,
 			pypi_name="",
+			info_source=self.info_source,
+
 			shortdesc="",
 			description="",
+
 			homepage="",
+			download_url="",
+
 			revision="",
 			people="",
-			info_source=self.info_source,
-			download_link="",
 			)
 		doap_result = get_url(
 			"http://pypi.python.org/pypi?:action=doap&name=%s" % self.name,
 			d["people"] = ", ".join(d["people"])
 			d["pypi_name"] = d["name"]
 
-			download_page = d.get("download-page", "") or ("http://pypi.python.org/pypi/%(name)s" % d)
-			d["download_link"] = make_link(download_page)
+			d["download_url"] = d.get("download-page", "") or ("http://pypi.python.org/pypi/%(name)s" % d)
 
 		d["short_name"] = d["name"].split(".")[-1]
 
+		# determine repository type and url
+
+		urls = [
+			self.repo_url,
+			d["download_url"],
+			d["homepage"],
+		]
+		repo_command = "svn checkout"
+		for url in urls:
+
+			if "svn" in url:
+				repo_command = "svn checkout"
+				self.repo_url = url
+				break
+			if "launchpad" in url:
+				repo_command = "bzr branch"
+				self.repo_url = url
+				break
+			if "bitbucket" in url or "hg" in url:
+				repo_command = "hg clone"
+				self.repo_url = url
+				break
+			if "git" in self.repo_url:
+				repo_command = "git clone"
+				self.repo_url = url
+				break
+		d["repo_command"] = repo_command
+
 		return d
 
 	def to_html(self):

code/templates.py

 </p>
 
 <p>
-{% if download_link %}
-<img src="/static/images/download_32.png" width="16" border="0" /> Download:  {{ download_link }} <br />
+{% if download_url %}
+<img src="/static/images/download_32.png" width="16" border="0" />
+Download:  <a href="{{ download_url }}">{{ download_url }}</a> <br />
 {% endif %}
 {% if homepage %}
 Homepage: <a href="{{ homepage }}">{{ homepage }}</a> <br />
 <h4>Source code</h4>
 <p>
 You can get the latest sources from the repository using
-<pre>svn checkout <a href="{{ repo_url }}">{{ repo_url }}</a></pre>
+<pre>{{ repo_command }} <a href="{{ repo_url }}">{{ repo_url }}</a></pre>
 </p>
 {% endif %}
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.