Skip to content

Commit 9631f4c

Browse files
committed
support link style without domain #3
1 parent 8cd1c54 commit 9631f4c

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,23 @@ for deployment.
3434
## Supported link type
3535

3636
```
37-
Links Style:
37+
Link Style 1:
3838
http(s)://{host_with_or_without_prefix}/{owner}/{repository}/blob/{SHA}/{path/to/file}#L{StartLineNumber}-L{EndLineNumber}
3939
40-
Example1:
40+
Link Style 2:
41+
/{owner}/{repository}/blob/{SHA}/{path/to/file}#L{StartLineNumber}-L{EndLineNumber}
42+
43+
Example-1 with style 1:
4144
http://localhost:8080/root/gitbucket/blob/19f0431a3fb4a9c3560dbf9b1d74f2073da7708f/GitBucketCoreModuleSpec.scala#L5-L10
4245
43-
Example2:
46+
Example-1 with style 2:
47+
/root/gitbucket/blob/19f0431a3fb4a9c3560dbf9b1d74f2073da7708f/GitBucketCoreModuleSpec.scala#L5-L10
48+
49+
Example-2 with style 1:
4450
http://localhost/root/gitbucket/blob/19f0431a3fb4a9c3560dbf9b1d74f2073da7708f/src/main/scala/GitBucketCoreModuleSpec.scala#L5-L10
51+
52+
Example-2 with style 2:
53+
/root/gitbucket/blob/19f0431a3fb4a9c3560dbf9b1d74f2073da7708f/src/main/scala/GitBucketCoreModuleSpec.scala#L5-L10
4554
```
4655

4756
## Note
@@ -51,14 +60,16 @@ Please use link with sha, not branch name such as `master`. Because `master` cha
5160
```
5261
Good url:
5362
http://localhost:8080/root/gitbucket/blob/19f0431a3fb4a9c3560dbf9b1d74f2073da7708f/GitBucketCoreModuleSpec.scala#L5-L10
63+
/root/gitbucket/blob/19f0431a3fb4a9c3560dbf9b1d74f2073da7708f/GitBucketCoreModuleSpec.scala#L5-L10
5464
55-
No Good url:
65+
Not Good url:
5666
http://localhost:8080/root/gitbucket/blob/master/GitBucketCoreModuleSpec.scala#L5-L10
67+
/root/gitbucket/blob/master/GitBucketCoreModuleSpec.scala#L5-L10
5768
```
5869

5970
## Version
6071

6172
Plugin version|GitBucket version
6273
:---|:---
63-
1.0.x |4.34.x -
74+
1.1.x |4.34.x -
6475
0.1.x |4.34.x -

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name := "gitbucket-embedding-plugin"
22
organization := "io.github.gitbucket"
3-
version := "1.0.2"
3+
version := "1.1.0"
44
scalaVersion := "2.13.6"
55
gitbucketVersion := "4.35.3"

src/main/resources/embedding/assets/entry.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $(function(){
33
const patternElement2 = '[/\\w!\\?\\+\\-_~=;\\.,\\*&@\\$\\%\\(\\)\'\\[\\]]+';
44
const matchPattern = new RegExp(
55
'^'+
6-
location.origin +
6+
'(' + location.origin + ')?' +
77
'(/' + patternElement1 + ')?' +
88
'/(' + patternElement1 + ')' +
99
'/(' + patternElement1 + ')' +
@@ -58,7 +58,7 @@ $(function(){
5858
}
5959

6060
function convertLinks(){
61-
const elements = $('.markdown-body p a');
61+
const elements = $('.markdown-body p');
6262
let element;
6363
let url;
6464
let mat;
@@ -67,15 +67,16 @@ $(function(){
6767
url = element.innerText;
6868
mat = url.match(matchPattern);
6969
if(mat !== null){
70-
// let urlPrefix = mat[1];
71-
// let owner = mat[2];
72-
let repo = mat[3];
73-
let commit = mat[4];
74-
let filepath = mat[5];
75-
let startLine = Number(mat[6]);
70+
// let origin = mat[1];
71+
// let urlPrefix = mat[2];
72+
// let owner = mat[3];
73+
let repo = mat[4];
74+
let commit = mat[5];
75+
let filepath = mat[6];
76+
let startLine = Number(mat[7]);
7677
let endLine = startLine;
77-
if(typeof mat[7] !== "undefined"){
78-
endLine = Number(mat[7]);
78+
if(typeof mat[8] !== "undefined"){
79+
endLine = Number(mat[8]);
7980
}
8081
let commitUrl = getCommitUrl(url, filepath);
8182
try{

src/main/scala/Plugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Plugin extends gitbucket.core.plugin.Plugin {
1313
new Version("0.1.2"),
1414
new Version("1.0.0"),
1515
new Version("1.0.1"),
16-
new Version("1.0.2"),
16+
new Version("1.1.0"),
1717
)
1818

1919
override val assetsMappings: Seq[(String, String)] = Seq("/embedding" -> "/embedding/assets")

0 commit comments

Comments
 (0)