diff --git a/templates/layouts/partials/menu/admin.jet.html b/templates/layouts/partials/menu/admin.jet.html index eae3d1ec..661cd071 100644 --- a/templates/layouts/partials/menu/admin.jet.html +++ b/templates/layouts/partials/menu/admin.jet.html @@ -1,10 +1,10 @@
{{ T("moderation")}} - {{ T("torrents")}} + {{ T("torrents")}} {{ T("users")}} {{ T("comments")}} - {{ T("oauth_clients_list")}} - {{ T("announcements")}} + {{ T("oauth_clients_list")}} + {{ T("announcements")}} {{ T("torrent_reports")}} {{ T("torrent_reassign")}}
diff --git a/templates/template_functions.go b/templates/template_functions.go index 441884e9..fecce525 100644 --- a/templates/template_functions.go +++ b/templates/template_functions.go @@ -49,6 +49,7 @@ func templateFunctions(vars jet.VarMap) jet.VarMap { vars.Set("genUploaderLink", genUploaderLink) vars.Set("genActivityContent", genActivityContent) vars.Set("contains", contains) + vars.Set("kilo_strcmp", kilo_strcmp) return vars } func getRawQuery(currentURL *url.URL) string { @@ -304,3 +305,27 @@ func torrentFileExists(hash string) bool { defer Openfile.Close() return true } + +func kilo_strcmp(str1 string, str2 string, end int, start int) bool { + //Compare two strings but has length arguments + + len1 := len(str1) + len2 := len(str2) + + if end == -1 && len1 != len2 { + return false + } + + if end == -1 || end > len1 { + end = len1 + } + if end > len2 { + end = len2 + } + + if start >= end { + return false + } + + return strings.Compare(str1[start:end], str2[start:end]) == 0 +} diff --git a/templates/template_functions_test.go b/templates/template_functions_test.go index a38fbd65..035506a5 100644 --- a/templates/template_functions_test.go +++ b/templates/template_functions_test.go @@ -606,6 +606,31 @@ func testTorrentFileExists(t *testing.T) { } } +func Testkilo_strcmp(t *testing.T) { + var tests = []struct { + TestString string + TestString2 string + Expected bool + }{ + { + TestString: "kilo", + TestString2: "kilo", + Expected: true, + }, + { + TestString: "kilo", + TestString2: "loki", // Clearly not the same level + Expected: false, + }, + } + for _, test := range tests { + value := kilo_strcmp(test.TestString, test.TestString2, -1, 0) + if value != test.Expected { + t.Errorf("Unexpected value from the function languageName, got '%t', wanted '%t'", value, test.Expected, test.TestString, test.TestString) + } + } + } + func mockupTemplateT(t *testing.T) publicSettings.TemplateTfunc { conf := config.Get().I18n conf.Directory = path.Join("..", conf.Directory) @@ -626,3 +651,4 @@ func mockupTemplateT(t *testing.T) publicSettings.TemplateTfunc { } return T } +