瀏覽代碼

Fix torrent W3C+UX

Puts links to torrents and magnets in tool bar
Fixes a lot of W3C errors
Cqoicebordel 10 年之前
父節點
當前提交
c59d0c200e
共有 2 個檔案被更改,包括 9 行新增8 行删除
  1. 2
    1
      searx/engines/kickass.py
  2. 7
    7
      searx/templates/oscar/result_templates/torrent.html

+ 2
- 1
searx/engines/kickass.py 查看文件

@@ -102,6 +102,7 @@ def response(resp):
102 102
         magnetlink = result.xpath(magnet_xpath)[0].attrib['href']
103 103
 
104 104
         torrentfile = result.xpath(torrent_xpath)[0].attrib['href']
105
+        torrentfileurl = quote(torrentfile, safe="%/:=&?~#+!$,;'@()*")
105 106
 
106 107
         # append result
107 108
         results.append({'url': href,
@@ -112,7 +113,7 @@ def response(resp):
112 113
                         'filesize': filesize,
113 114
                         'files': files,
114 115
                         'magnetlink': magnetlink,
115
-                        'torrentfile': torrentfile,
116
+                        'torrentfile': torrentfileurl,
116 117
                         'template': 'torrent.html'})
117 118
 
118 119
     # return results sorted by seeder

+ 7
- 7
searx/templates/oscar/result_templates/torrent.html 查看文件

@@ -4,9 +4,11 @@
4 4
 
5 5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
6 6
 <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
7
+{% if result.magnetlink %}<small> &bull; <a href="{{ result.magnetlink }}" class="magnetlink">{{ icon('magnet') }} {{ _('magnet link') }}</a></small>{% endif %}
8
+{% if result.torrentfile %}<small> &bull; <a href="{{ result.torrentfile }}" class="torrentfile">{{ icon('download-alt') }} {{ _('torrent file') }}</a></small>{% endif %}
7 9
 
8 10
 <p class="result-content">{{ icon('transfer') }} {{ _('Seeder') }} <span class="badge">{{ result.seed }}</span> &bull; {{ _('Leecher') }} <span class="badge">{{ result.leech }}</span>
9
-{% if result.filesize %}</br>{{ icon('floppy-disk') }} {{ _('Filesize') }} 
11
+{% if result.filesize %}<br />{{ icon('floppy-disk') }} {{ _('Filesize') }} 
10 12
     <span class="badge">
11 13
         {% if result.filesize < 1024 %}{{ result.filesize }} Byte
12 14
         {% elif result.filesize < 1024*1024 %}{{ '{0:0.2f}'.format(result.filesize/1024) }} kb
@@ -14,13 +16,11 @@
14 16
         {% elif result.filesize < 1024*1024*1024*1024 %}{{ '{0:0.2f}'.format(result.filesize/1024/1024/1024) }} GB
15 17
         {% else %}{{ '{0:0.2f}'.format(result.filesize/1024/1024/1024/1024) }} TB{% endif %}
16 18
     </span>{% endif %}
17
-{% if result.files %}</br>{{ icon('file') }} {{ _('Number of Files') }} <span class="badge">{{ result.files }}</span>{% endif %}</p>
18
-<p class="result-content">
19
-    <a href="{{ result.magnetlink }}" class="magnetlink">{{ icon('magnet') }} {{ _('magnet link') }}</a>
20
-    {% if result.torrentfile %}</br><a href="{{ result.torrentfile }}" class="torrentfile">{{ icon('download-alt') }} {{ _('torrent file') }}</a>{% endif %}
21
-</p>
19
+{% if result.files %}<br />{{ icon('file') }} {{ _('Number of Files') }} <span class="badge">{{ result.files }}</span>{% endif %}
20
+
21
+{% if result.content %}<br />{{ result.content|safe }}{% endif %}
22 22
 
23
-{% if result.content %}<p class="result-content">{{ result.content|safe }}</p>{% endif %}
23
+</p>
24 24
 
25 25
 <div class="clearfix"></div>
26 26