Change to platform userAgent.

This commit is contained in:
hikaruworld
2014-08-13 17:08:46 +09:00
committed by ymorika
parent f52bd2bcc0
commit 7b37d6b571
3 changed files with 8 additions and 8 deletions

View File

@@ -145,7 +145,7 @@ case class Context(settings: SystemSettingsService.SystemSettings, loginAccount:
val currentPath = request.getRequestURI.substring(request.getContextPath.length)
val baseUrl = settings.baseUrl(request)
val host = new java.net.URL(baseUrl).getHost
val userAgent = request.getHeader("User-Agent") match {
val platform = request.getHeader("User-Agent") match {
case agent if agent.contains("Mac") => "mac"
case agent if agent.contains("Linux") => "linux"
case agent if agent.contains("Win") => "windows"

View File

@@ -329,11 +329,11 @@ object RepositoryService {
def sshUrl(port: Int, userName: String) = s"ssh://${userName}@${host}:${port}/${owner}/${name}.git"
def sshOpenRepoUrl(userAgent: String, port: Int, userName: String) = openRepoUrl(userAgent, sshUrl(port, userName))
def sshOpenRepoUrl(platform: String, port: Int, userName: String) = openRepoUrl(platform, sshUrl(port, userName))
def httpOpenRepoUrl(userAgent: String) = openRepoUrl(userAgent, httpUrl)
def httpOpenRepoUrl(platform: String) = openRepoUrl(platform, httpUrl)
def openRepoUrl(userAgent: String, openUrl: String) = s"github-${userAgent}://openRepo/${openUrl}"
def openRepoUrl(platform: String, openUrl: String) = s"github-${platform}://openRepo/${openUrl}"
/**
* Creates instance with issue count and pull request count.

View File

@@ -84,9 +84,9 @@
</div>
}
@id.map { id =>
@if(context.userAgent != "linux"){
@if(context.platform != "linux"){
<div style="margin-top: 10px;">
<a href="@repository.httpOpenRepoUrl(context.userAgent)" id="repository-clone-url" class="btn btn-small" style="width: 147px;"><i class="icon-download-alt"></i>Clone in Desktop</a>
<a href="@repository.httpOpenRepoUrl(context.platform)" id="repository-clone-url" class="btn btn-small" style="width: 147px;"><i class="icon-download-alt"></i>Clone in Desktop</a>
</div>
}
<div style="margin-top: 10px;">
@@ -180,14 +180,14 @@ $(function(){
$('#repository-url-http').click(function(){
$('#repository-url-proto').text('HTTP');
$('#repository-url').val('@repository.httpUrl');
$('#repository-clone-url').attr('href', '@repository.httpOpenRepoUrl(context.userAgent)')
$('#repository-clone-url').attr('href', '@repository.httpOpenRepoUrl(context.platform)')
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
});
$('#repository-url-ssh').click(function(){
$('#repository-url-proto').text('SSH');
$('#repository-url').val('@repository.sshUrl(settings.sshPort.getOrElse(service.SystemSettingsService.DefaultSshPort), loginAccount.get.userName)');
$('#repository-clone-url').attr('href', '@repository.sshOpenRepoUrl(context.userAgent, settings.sshPort.getOrElse(service.SystemSettingsService.DefaultSshPort), loginAccount.get.userName)');
$('#repository-clone-url').attr('href', '@repository.sshOpenRepoUrl(context.platform, settings.sshPort.getOrElse(service.SystemSettingsService.DefaultSshPort), loginAccount.get.userName)');
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
});
}