Browse Source

fix single bare page link

pull/32/head
FuXiaoHei 11 years ago
parent
commit
42b08ff261
  1. 1
      modules/middleware/repo.go
  2. 18
      public/js/app.js
  3. 2
      templates/repo/nav.tmpl
  4. 4
      templates/repo/single_bare.tmpl

1
modules/middleware/repo.go

@ -79,5 +79,6 @@ func RepoAssignment(redirect bool) martini.Handler {
ctx.Data["CloneLink"] = ctx.Repo.CloneLink ctx.Data["CloneLink"] = ctx.Repo.CloneLink
ctx.Data["RepositoryLink"] = ctx.Data["Title"] ctx.Data["RepositoryLink"] = ctx.Data["Title"]
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner
ctx.Data["IsRepositoryWatching"] = ctx.Repo.IsWatching
} }
} }

18
public/js/app.js

@ -72,18 +72,18 @@ var Gogits = {
prettyPrint(); prettyPrint();
var $lineNums = $pre.parent().siblings('.lines-num'); var $lineNums = $pre.parent().siblings('.lines-num');
if($lineNums.length > 0){ if ($lineNums.length > 0) {
var nums = $pre.find('ol.linenums > li').length; var nums = $pre.find('ol.linenums > li').length;
for(var i=0;i < nums;i++){ for (var i = 1; i <= nums; i++) {
$lineNums.append('<span id="L'+i+'" rel=".L'+i+'">'+(i+1)+'</span>'); $lineNums.append('<span id="L' + i + '" rel=".L' + i + '">' + i + '</span>');
} }
var last; var last;
$(document).on('click', '.lines-num span', function(){ $(document).on('click', '.lines-num span', function () {
var $e = $(this); var $e = $(this);
console.log($e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel'))); console.log($e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel')));
console.log('ol.linenums > ' + $e.attr('rel')); console.log('ol.linenums > ' + $e.attr('rel'));
if(last){ if (last) {
last.removeClass('active'); last.removeClass('active');
} }
last = $e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel')); last = $e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel'));
@ -98,12 +98,12 @@ var Gogits = {
var node = $(this); var node = $(this);
var val = encodeURIComponent(node.text().toLowerCase().replace(/[^\w\- ]/g, '').replace(/[ ]/g, '-')); var val = encodeURIComponent(node.text().toLowerCase().replace(/[^\w\- ]/g, '').replace(/[ ]/g, '-'));
var name = val; var name = val;
if(headers[val] > 0){ if (headers[val] > 0) {
name = val + '-' + headers[val]; name = val + '-' + headers[val];
} }
if(headers[val] == undefined){ if (headers[val] == undefined) {
headers[val] = 1; headers[val] = 1;
}else{ } else {
headers[val] += 1; headers[val] += 1;
} }
node = node.wrap('<div id="' + name + '" class="anchor-wrap" ></div>'); node = node.wrap('<div id="' + name + '" class="anchor-wrap" ></div>');
@ -183,6 +183,7 @@ function initUserSetting() {
} }
function initRepository() { function initRepository() {
(function () {
var $guide = $('.guide-box'); var $guide = $('.guide-box');
if ($guide.length) { if ($guide.length) {
var $url = $('#guide-clone-url'); var $url = $('#guide-clone-url');
@ -197,6 +198,7 @@ function initRepository() {
}).eq(0).trigger("click"); }).eq(0).trigger("click");
// todo copy to clipboard // todo copy to clipboard
} }
})();
} }
(function ($) { (function ($) {

2
templates/repo/nav.tmpl

@ -13,7 +13,7 @@
<span class="caret"></span> <span class="caret"></span>
</button> </button>
</div> </div>
<div class="btn-group" id="gogs-repo-watching"> <div class="btn-group {{if .IsRepositoryWatching}}watching{{end}}" id="gogs-repo-watching">
<button type="button" class="btn btn-default"><i class="fa fa-eye fa-lg fa-m"></i></button> <button type="button" class="btn btn-default"><i class="fa fa-eye fa-lg fa-m"></i></button>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span> <span class="caret"></span>

4
templates/repo/single_bare.tmpl

@ -6,8 +6,8 @@
<h3>Clone this repository</h3> <h3>Clone this repository</h3>
<div class="input-group col-md-8 col-md-offset-2 guide-buttons"> <div class="input-group col-md-8 col-md-offset-2 guide-buttons">
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" data-url="{{.CloneLink.SSH}}" type="button">SSH</button> <button class="btn btn-default" data-link="{{.CloneLink.SSH}}" type="button">SSH</button>
<button class="btn btn-default" data-url="{{.CloneLink.HTTPS}}" type="button">HTTPS</button> <button class="btn btn-default" data-link="{{.CloneLink.HTTPS}}" type="button">HTTPS</button>
</span> </span>
<input type="text" class="form-control" id="guide-clone-url" value="" readonly/> <input type="text" class="form-control" id="guide-clone-url" value="" readonly/>
<span class="input-group-btn"> <span class="input-group-btn">

Loading…
Cancel
Save