| @@ -75,10 +75,10 @@ def _hook_check(query): | |||||
| return format_api_error("bad_site", info) | return format_api_error("bad_site", info) | ||||
| elif not query.result: | elif not query.result: | ||||
| if query.oldid: | if query.oldid: | ||||
| info = u"The given revision ID doesn't seem to exist: {0}" | |||||
| info = u"The revision ID couldn't be found: {0}" | |||||
| return format_api_error("bad_oldid", info.format(query.oldid)) | return format_api_error("bad_oldid", info.format(query.oldid)) | ||||
| else: | else: | ||||
| info = u"The given page doesn't seem to exist: {0}" | |||||
| info = u"The page couldn't be found: {0}" | |||||
| return format_api_error("bad_title", info.format(query.page.title)) | return format_api_error("bad_title", info.format(query.page.title)) | ||||
| result = query.result | result = query.result | ||||
| @@ -105,17 +105,17 @@ def _get_results(query, follow=True): | |||||
| query.error = "bad action" | query.error = "bad action" | ||||
| def _get_page_by_revid(site, revid): | def _get_page_by_revid(site, revid): | ||||
| res = site.api_query(action="query", prop="info|revisions", revids=revid, | |||||
| rvprop="content|timestamp", inprop="protection|url", | |||||
| rvslots="main") | |||||
| try: | try: | ||||
| res = site.api_query(action="query", prop="info|revisions", revids=revid, | |||||
| rvprop="content|timestamp", inprop="protection|url", | |||||
| rvslots="main") | |||||
| page_data = res["query"]["pages"].values()[0] | page_data = res["query"]["pages"].values()[0] | ||||
| title = page_data["title"] | title = page_data["title"] | ||||
| # Only need to check that these exist: | # Only need to check that these exist: | ||||
| revision = page_data["revisions"][0] | revision = page_data["revisions"][0] | ||||
| revision["slots"]["main"]["*"] | revision["slots"]["main"]["*"] | ||||
| revision["timestamp"] | revision["timestamp"] | ||||
| except (KeyError, IndexError): | |||||
| except (exceptions.APIError, KeyError, IndexError): | |||||
| return None | return None | ||||
| page = site.get_page(title) | page = site.get_page(title) | ||||
| @@ -41,11 +41,11 @@ | |||||
| </div> | </div> | ||||
| % elif query.oldid and not result: | % elif query.oldid and not result: | ||||
| <div id="info-box" class="red-box"> | <div id="info-box" class="red-box"> | ||||
| <p>The given revision ID doesn't seem to exist: <a href="https://${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>.</p> | |||||
| <p>The revision ID couldn't be found: <a href="https://${query.site.domain | h}/w/index.php?oldid=${query.oldid | h}">${query.oldid | h}</a>.</p> | |||||
| </div> | </div> | ||||
| % elif query.title and not result: | % elif query.title and not result: | ||||
| <div id="info-box" class="red-box"> | <div id="info-box" class="red-box"> | ||||
| <p>The given page doesn't seem to exist: <a href="${query.page.url}">${query.page.title | h}</a>.</p> | |||||
| <p>The page couldn't be found: <a href="${query.page.url}">${query.page.title | h}</a>.</p> | |||||
| </div> | </div> | ||||
| % endif | % endif | ||||
| %endif | %endif | ||||