Skip to content

Commit

Permalink
Merge pull request #170 from cnpm/show-git-web-url
Browse files Browse the repository at this point in the history
Support gitlab git url to display and click. fixed #160
  • Loading branch information
dead-horse committed Jan 20, 2014
2 parents 161a860 + f3a4500 commit ccec2cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
5 changes: 5 additions & 0 deletions controllers/web/package.js
Expand Up @@ -14,6 +14,7 @@
* Module dependencies.
*/

var giturl = require('giturl');
var moment = require('moment');
var eventproxy = require('eventproxy');
var semver = require('semver');
Expand Down Expand Up @@ -80,6 +81,10 @@ exports.display = function (req, res, next) {
}
}

if (pkg.repository && pkg.repository.url) {
pkg.repository.weburl = giturl.parse(pkg.repository.url);
}

setLicense(pkg);

for (var k in download) {
Expand Down
7 changes: 4 additions & 3 deletions package.json
Expand Up @@ -30,6 +30,7 @@
"debug": "0.7.4",
"eventproxy": "0.2.6",
"forward": "0.0.4",
"giturl": "0.0.1",
"graceful": "0.0.5",
"gravatar": "1.0.6",
"humanize-number": "0.0.2",
Expand All @@ -40,7 +41,7 @@
"mkdirp": "0.3.5",
"moment": "2.5.0",
"ms": "0.6.2",
"mysql": "2.0.0",
"mysql": "2.0.1",
"nodemailer": "0.6.0",
"qn": "0.2.0",
"ready": "0.1.1",
Expand All @@ -60,8 +61,8 @@
"mocha": "*",
"mocha-lcov-reporter": "*",
"pedding": "0.0.3",
"should": "2.1.1",
"supertest": "0.8.3",
"should": "3.0.1",
"supertest": "0.9.0",
"travis-cov": "*"
},
"homepage": "https://github.com/cnpm/cnpmjs.org",
Expand Down
14 changes: 4 additions & 10 deletions view/web/package.html
Expand Up @@ -89,19 +89,13 @@ <h1>
%></td>
</tr>
<% } %>
<% if (package.repository && package.repository !== 'undefined') {
var gh = package.repository.url &&
package.repository.url.match(
/^(?:https?:\/\/|git(?::\/\/|@))(gist.github.com|github.com)[:\/](.*?)(?:.git)?$/)
if (gh) {
gh = 'https://' + gh[1] + '/' + gh[2]
}
%>
<% if (package.repository && package.repository !== 'undefined') { %>
<tr>
<th>Repository</td>
<td>
<% if (gh) { %><a href="<%= gh %>" target="_blank"><% } %>
<%= package.repository.url %><% if (gh) { %></a><% } %>
<a href="<%= package.repository.weburl || package.repository.url %>" target="_blank">
<%= package.repository.url %>
</a>
(<%= package.repository.type %>)
</td>
</tr>
Expand Down

0 comments on commit ccec2cb

Please sign in to comment.