Merge branch 'dev' into classic-theme
Cette révision appartient à :
révision
c0059bdb09
5 fichiers modifiés avec 49 ajouts et 7 suppressions
|
@ -84,7 +84,7 @@
|
||||||
<a href="{{.Magnet}}" title="{{ T("magnet_link") }}">
|
<a href="{{.Magnet}}" title="{{ T("magnet_link") }}">
|
||||||
<div class="icon-magnet"></div>
|
<div class="icon-magnet"></div>
|
||||||
</a>
|
</a>
|
||||||
<a href="{{.TorrentLink}}" title="{{ T("torrent_file") }}" {{if !torrentFileExists(.Hash)}}class="hidden"{{end}}>
|
<a href="{{.TorrentLink}}" title="{{ T("torrent_file") }}" {{if !torrentFileExists(.Hash, .TorrentLink)}}class="hidden"{{end}}>
|
||||||
<div class="icon-floppy"></div>
|
<div class="icon-floppy"></div>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -133,8 +133,8 @@
|
||||||
<a href="{{Torrent.Magnet}}" class="form-input btn-green download" style="float:left;height: auto;margin-right: 0.5em;">
|
<a href="{{Torrent.Magnet}}" class="form-input btn-green download" style="float:left;height: auto;margin-right: 0.5em;">
|
||||||
<div class="icon-magnet"></div>{{ T("magnet_link")}}
|
<div class="icon-magnet"></div>{{ T("magnet_link")}}
|
||||||
</a>
|
</a>
|
||||||
<a href="{{Torrent.TorrentLink}}" class="form-input download{{ if !torrentFileExists(Torrent.Hash)}} hidden{{end}}" style="float:left;height: auto;">
|
<a href="{{Torrent.TorrentLink}}" class="form-input download{{ if !torrentFileExists(Torrent.Hash, Torrent.TorrentLink)}} hidden{{end}}" style="float:left;height: auto;">
|
||||||
<div class="icon-floppy"></div>{{ T("torrent_file")}}
|
<div class="icon-floppy"></div> {{ T("torrent_file")}}
|
||||||
</a>
|
</a>
|
||||||
{{ if User.ID > 0}}
|
{{ if User.ID > 0}}
|
||||||
<a id="reportPopup" href="#" class="form-input">{{ T("report_btn") }}</a>
|
<a id="reportPopup" href="#" class="form-input">{{ T("report_btn") }}</a>
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<a href="{{torrent.Magnet}}" title="{{ T("magnet_link") }}">
|
<a href="{{torrent.Magnet}}" title="{{ T("magnet_link") }}">
|
||||||
<div class="icon-magnet"></div>
|
<div class="icon-magnet"></div>
|
||||||
</a>
|
</a>
|
||||||
<a href="{{torrent.TorrentLink}}" title="{{ T("torrent_file") }}" {{if !torrentFileExists(torrent.Hash)}}class="hidden"{{end}}>
|
<a href="{{torrent.TorrentLink}}" title="{{ T("torrent_file") }}" {{if !torrentFileExists(torrent.Hash, torrent.TorrentLink)}}class="hidden"{{end}}>
|
||||||
<div class="icon-floppy"></div>
|
<div class="icon-floppy"></div>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -50,6 +50,7 @@ func templateFunctions(vars jet.VarMap) jet.VarMap {
|
||||||
vars.Set("genActivityContent", genActivityContent)
|
vars.Set("genActivityContent", genActivityContent)
|
||||||
vars.Set("contains", contains)
|
vars.Set("contains", contains)
|
||||||
vars.Set("kilo_strcmp", kilo_strcmp)
|
vars.Set("kilo_strcmp", kilo_strcmp)
|
||||||
|
vars.Set("kilo_strfind", kilo_strfind)
|
||||||
return vars
|
return vars
|
||||||
}
|
}
|
||||||
func getRawQuery(currentURL *url.URL) string {
|
func getRawQuery(currentURL *url.URL) string {
|
||||||
|
@ -296,8 +297,10 @@ func contains(arr interface{}, comp string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func torrentFileExists(hash string) bool {
|
func torrentFileExists(hash string, TorrentLink string) bool {
|
||||||
|
if(len(TorrentLink) > 30 && !kilo_strfind(TorrentLink, ".pantsu.cat", 8)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
Openfile, err := os.Open(fmt.Sprintf("%s%c%s.torrent", config.Get().Torrents.FileStorage, os.PathSeparator, hash))
|
Openfile, err := os.Open(fmt.Sprintf("%s%c%s.torrent", config.Get().Torrents.FileStorage, os.PathSeparator, hash))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
|
@ -329,3 +332,17 @@ func kilo_strcmp(str1 string, str2 string, end int, start int) bool {
|
||||||
|
|
||||||
return strings.Compare(str1[start:end], str2[start:end]) == 0
|
return strings.Compare(str1[start:end], str2[start:end]) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func kilo_strfind(str1 string, searchfor string, start int) bool {
|
||||||
|
//Search a string inside another with start parameter
|
||||||
|
//start parameter indicates where we start searching
|
||||||
|
|
||||||
|
len1 := len(str1)
|
||||||
|
|
||||||
|
if start >= len1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return strings.Contains(str1[start:len1], searchfor)
|
||||||
|
}
|
||||||
|
|
|
@ -599,7 +599,7 @@ func testTorrentFileExists(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
value := torrentFileExists(test.hash)
|
value := torrentFileExists(test.hash, "")
|
||||||
if value != test.Expected {
|
if value != test.Expected {
|
||||||
t.Errorf("Unexpected value from the function TorrentFileExists, got '%t', wanted '%t' for '%s'", value, test.Expected, test.hash)
|
t.Errorf("Unexpected value from the function TorrentFileExists, got '%t', wanted '%t' for '%s'", value, test.Expected, test.hash)
|
||||||
}
|
}
|
||||||
|
@ -630,6 +630,31 @@ func Testkilo_strcmp(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Testkilo_strfind(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_strfind(test.TestString, test.TestString2, 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 {
|
func mockupTemplateT(t *testing.T) publicSettings.TemplateTfunc {
|
||||||
conf := config.Get().I18n
|
conf := config.Get().I18n
|
||||||
|
|
Référencer dans un nouveau ticket