Bladeren bron

Give an error when no text could be found inside a URL.

pull/24/head
Ben Kurtovic 10 jaren geleden
bovenliggende
commit
ca09caa15d
2 gewijzigde bestanden met toevoegingen van 9 en 1 verwijderingen
  1. +5
    -1
      copyvios/checker.py
  2. +4
    -0
      templates/index.mako

+ 5
- 1
copyvios/checker.py Bestand weergeven

@@ -41,7 +41,11 @@ def _get_results(query):
if urlparse(query.url).scheme not in ["http", "https"]: if urlparse(query.url).scheme not in ["http", "https"]:
query.error = "bad URI" query.error = "bad URI"
return return
query.result = page.copyvio_compare(query.url)
result = page.copyvio_compare(query.url)
if result.source_chain is page.EMPTY:
query.error = "no data"
return
query.result = result
query.result.cached = False query.result.cached = False
else: else:
conn = get_cache_db() conn = get_cache_db()


+ 4
- 0
templates/index.mako Bestand weergeven

@@ -7,6 +7,10 @@
<div id="info-box" class="red-box"> <div id="info-box" class="red-box">
<p>Unsupported URI scheme: <a href="${query.url | h}">${query.url | h}</a>.</p> <p>Unsupported URI scheme: <a href="${query.url | h}">${query.url | h}</a>.</p>
</div> </div>
% elif query.error == "no data":
<div id="info-box" class="red-box">
<p>Couldn't find any text in <a href="${query.url | h}">${query.url | h}</a>. <i>Note:</i> only HTML and plain text pages are supported, and content generated by JavaScript or found inside iframes is ignored.</p>
</div>
% elif not query.site: % elif not query.site:
<div id="info-box" class="red-box"> <div id="info-box" class="red-box">
<p>The given site (project=<b><span class="mono">${query.project | h}</span></b>, language=<b><span class="mono">${query.lang | h}</span></b>) doesn't seem to exist. It may also be closed or private. <a href="//${query.lang | h}.${query.project | h}.org/">Confirm its URL.</a></p> <p>The given site (project=<b><span class="mono">${query.project | h}</span></b>, language=<b><span class="mono">${query.lang | h}</span></b>) doesn't seem to exist. It may also be closed or private. <a href="//${query.lang | h}.${query.project | h}.org/">Confirm its URL.</a></p>


Laden…
Annuleren
Opslaan