Browse Source

Fix torrent W3C+UX
Puts links to torrents and magnets in tool bar
Fixes a lot of W3C errors

Cqoicebordel 10 years ago
parent
commit
c59d0c200e
2 changed files with 9 additions and 8 deletions
  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):
         magnetlink = result.xpath(magnet_xpath)[0].attrib['href']
         magnetlink = result.xpath(magnet_xpath)[0].attrib['href']
 
 
         torrentfile = result.xpath(torrent_xpath)[0].attrib['href']
         torrentfile = result.xpath(torrent_xpath)[0].attrib['href']
+        torrentfileurl = quote(torrentfile, safe="%/:=&?~#+!$,;'@()*")
 
 
         # append result
         # append result
         results.append({'url': href,
         results.append({'url': href,
@@ -112,7 +113,7 @@ def response(resp):
                         'filesize': filesize,
                         'filesize': filesize,
                         'files': files,
                         'files': files,
                         'magnetlink': magnetlink,
                         'magnetlink': magnetlink,
-                        'torrentfile': torrentfile,
+                        'torrentfile': torrentfileurl,
                         'template': 'torrent.html'})
                         'template': 'torrent.html'})
 
 
     # return results sorted by seeder
     # return results sorted by seeder

+ 7 - 7
searx/templates/oscar/result_templates/torrent.html

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