summaryrefslogtreecommitdiffstats
path: root/modules/markup/markdown
diff options
context:
space:
mode:
authormrsdizzie <info@mrsdizzie.com>2019-04-12 01:53:34 -0400
committerLauris BH <lauris@nix.lv>2019-04-12 08:53:34 +0300
commit3ff0a126e12109b6c3aceaa229dd1bf229b6ad4b (patch)
treed3201fa81e7b6dc01d238ec7b833456e47463d6c /modules/markup/markdown
parent3186ef554cdbf54e1a3328ffcb35ea18105d7cb1 (diff)
downloadgitea-3ff0a126e12109b6c3aceaa229dd1bf229b6ad4b.tar.gz
gitea-3ff0a126e12109b6c3aceaa229dd1bf229b6ad4b.zip
Improve issue autolinks (#6273)
* Improve issue autolinks Update autolinks to match what github does here: Issue in same repo: #1 Issue in different repo: org/repo#1 Fixes #6264 * Use setting.AppURL when parsing URL Using setting.AppURL here is a more reliable way of parsing the current URL and what other functions in this file seem to use. * Make ComposeMetas always return a valid context * Add per repository markdown renderers for better context * Update for use of context metas Now that we include the user and repo name inside context metas, update various code and tests for this new logic
Diffstat (limited to 'modules/markup/markdown')
-rw-r--r--modules/markup/markdown/markdown_test.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go
index 5aa9c3d7d2..8ba51e6a1b 100644
--- a/modules/markup/markdown/markdown_test.go
+++ b/modules/markup/markdown/markdown_test.go
@@ -19,6 +19,12 @@ const AppURL = "http://localhost:3000/"
const Repo = "gogits/gogs"
const AppSubURL = AppURL + Repo + "/"
+// these values should match the Repo const above
+var localMetas = map[string]string{
+ "user": "gogits",
+ "repo": "gogs",
+}
+
func TestRender_StandardLinks(t *testing.T) {
setting.AppURL = AppURL
setting.AppSubURL = AppSubURL
@@ -100,7 +106,8 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
<p>Ideas and codes</p>
<ul>
-<li>Bezier widget (by <a href="` + AppURL + `r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="http://localhost:3000/ocornut/imgui/issues/786" rel="nofollow">#786</a></li>
+<li>Bezier widget (by <a href="` + AppURL + `r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="http://localhost:3000/ocornut/imgui/issues/786" rel="nofollow">ocornut/imgui#786</a></li>
+<li>Bezier widget (by <a href="` + AppURL + `r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="http://localhost:3000/gogits/gogs/issues/786" rel="nofollow">#786</a></li>
<li>Node graph editors <a href="https://github.com/ocornut/imgui/issues/306" rel="nofollow">https://github.com/ocornut/imgui/issues/306</a></li>
<li><a href="` + baseURLContent + `/memory_editor_example" rel="nofollow">Memory Editor</a></li>
<li><a href="` + baseURLContent + `/plot_var_example" rel="nofollow">Plot var helper</a></li>
@@ -188,6 +195,7 @@ var sameCases = []string{
Ideas and codes
- Bezier widget (by @r-lyeh) ` + AppURL + `ocornut/imgui/issues/786
+- Bezier widget (by @r-lyeh) ` + AppURL + `gogits/gogs/issues/786
- Node graph editors https://github.com/ocornut/imgui/issues/306
- [[Memory Editor|memory_editor_example]]
- [[Plot var helper|plot_var_example]]`,
@@ -243,7 +251,7 @@ func TestTotal_RenderWiki(t *testing.T) {
answers := testAnswers(util.URLJoin(AppSubURL, "wiki/"), util.URLJoin(AppSubURL, "wiki", "raw/"))
for i := 0; i < len(sameCases); i++ {
- line := RenderWiki([]byte(sameCases[i]), AppSubURL, nil)
+ line := RenderWiki([]byte(sameCases[i]), AppSubURL, localMetas)
assert.Equal(t, answers[i], line)
}
@@ -270,7 +278,7 @@ func TestTotal_RenderString(t *testing.T) {
answers := testAnswers(util.URLJoin(AppSubURL, "src", "master/"), util.URLJoin(AppSubURL, "raw", "master/"))
for i := 0; i < len(sameCases); i++ {
- line := RenderString(sameCases[i], util.URLJoin(AppSubURL, "src", "master/"), nil)
+ line := RenderString(sameCases[i], util.URLJoin(AppSubURL, "src", "master/"), localMetas)
assert.Equal(t, answers[i], line)
}