浏览代码

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

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

4
 
4
 
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
5
 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
6
 <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
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
 <p class="result-content">{{ icon('transfer') }} {{ _('Seeder') }} <span class="badge">{{ result.seed }}</span> &bull; {{ _('Leecher') }} <span class="badge">{{ result.leech }}</span>
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
     <span class="badge">
12
     <span class="badge">
11
         {% if result.filesize < 1024 %}{{ result.filesize }} Byte
13
         {% if result.filesize < 1024 %}{{ result.filesize }} Byte
12
         {% elif result.filesize < 1024*1024 %}{{ '{0:0.2f}'.format(result.filesize/1024) }} kb
14
         {% elif result.filesize < 1024*1024 %}{{ '{0:0.2f}'.format(result.filesize/1024) }} kb
14
         {% elif result.filesize < 1024*1024*1024*1024 %}{{ '{0:0.2f}'.format(result.filesize/1024/1024/1024) }} GB
16
         {% elif result.filesize < 1024*1024*1024*1024 %}{{ '{0:0.2f}'.format(result.filesize/1024/1024/1024) }} GB
15
         {% else %}{{ '{0:0.2f}'.format(result.filesize/1024/1024/1024/1024) }} TB{% endif %}
17
         {% else %}{{ '{0:0.2f}'.format(result.filesize/1024/1024/1024/1024) }} TB{% endif %}
16
     </span>{% endif %}
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
 <div class="clearfix"></div>
25
 <div class="clearfix"></div>
26
 
26