cleanup: wiki urls could have been simpler

This commit is contained in:
Herr Ritschwumm
2016-01-30 10:45:14 +01:00
parent e50fe604c2
commit 3543073150
2 changed files with 7 additions and 9 deletions

View File

@@ -14,6 +14,7 @@ import org.eclipse.jgit.patch._
import org.eclipse.jgit.api.errors.PatchFormatException
import scala.collection.JavaConverters._
import RepositoryService.RepositoryInfo
import RepositoryService.RepositoryUrls
object WikiService {
@@ -38,11 +39,8 @@ object WikiService {
*/
case class WikiPageHistoryInfo(name: String, committer: String, message: String, date: Date)
def httpUrl(repoBase:RepoBase, repository: RepositoryInfo) =
repository.urls(repoBase).httpUrl.replaceFirst("\\.git\\Z", ".wiki.git")
def sshUrl(repoBase:RepoBase, repository: RepositoryInfo, userName: String) =
repository.urls(repoBase).sshUrl(userName).replaceFirst("\\.git\\Z", ".wiki.git")
def urls(repoBase:RepoBase, repository: RepositoryInfo):RepositoryUrls =
new RepositoryUrls(repoBase, repository.owner, repository.name + ".wiki")
}
trait WikiService {

View File

@@ -67,8 +67,8 @@
<div class="small">
<strong>Clone this wiki locally</strong>
</div>
@helper.html.copy("repository-url-copy", httpUrl(repoBase, repository)){
<input type="text" value="@httpUrl(repoBase, repository)" id="repository-url" class="form-control input-sm" readonly>
@helper.html.copy("repository-url-copy", urls(repoBase, repository).httpUrl){
<input type="text" value="@urls(repoBase, repository).httpUrl" id="repository-url" class="form-control input-sm" readonly>
}
@if(settings.ssh && loginAccount.isDefined){
<div class="small">
@@ -133,11 +133,11 @@ $(function(){
@if(settings.ssh && loginAccount.isDefined){
$('#repository-url-http').click(function(){
$('#repository-url').val('@httpUrl(repoBase, repository)');
$('#repository-url').val('@urls(repoBase, repository).httpUrl');
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
});
$('#repository-url-ssh').click(function(){
$('#repository-url').val('@sshUrl(repoBase, repository, loginAccount.get.userName)');
$('#repository-url').val('@urls(repoBase, repository).sshUrl(loginAccount.get.userName)');
$('#repository-url-copy').attr('data-clipboard-text', $('#repository-url').val());
});
}