diff --git a/add_links/mediawiki_oauth.py b/add_links/wikidata_oauth.py similarity index 100% rename from add_links/mediawiki_oauth.py rename to add_links/wikidata_oauth.py diff --git a/web_view.py b/web_view.py index b93f1bd..436307a 100755 --- a/web_view.py +++ b/web_view.py @@ -11,7 +11,7 @@ import werkzeug from requests_oauthlib import OAuth1Session from werkzeug.wrappers.response import Response -from add_links import api, core, mediawiki_api, mediawiki_oauth +from add_links import api, core, mediawiki_api, wikidata_oauth from add_links.match import NoMatch, get_diff, get_match app = flask.Flask(__name__) @@ -83,7 +83,7 @@ def search_no_link(q: str) -> tuple[int, list[Hit]]: @app.before_request def global_user() -> None: """Make username available everywhere.""" - flask.g.user = mediawiki_oauth.get_username() + flask.g.user = wikidata_oauth.get_username() @app.route("/") @@ -268,7 +268,7 @@ def article_page(url_title: str) -> str | Response: hit_title = flask.request.form["hit"] try: do_save(from_title, hit_title) - except mediawiki_oauth.LoginNeeded: + except wikidata_oauth.LoginNeeded: return flask.redirect(flask.url_for("start_oauth")) return flask.redirect( flask.url_for("article_page", url_title=url_title, after=hit_title) @@ -283,15 +283,10 @@ def article_page(url_title: str) -> str | Response: by_title = {hit["title"]: hit for hit in hits} - found = None if article_title in by_title: hit = by_title[article_title] - try: - found = get_diff(from_title, hit["title"], None) - except NoMatch: - pass - - if not found: + found = get_diff(from_title, hit["title"], None) + else: after = flask.request.args.get("after") if after: print(after) @@ -321,7 +316,7 @@ def article_page(url_title: str) -> str | Response: def do_save(title: str, hit_title: str) -> str: """Update page on Wikipedia.""" - token = mediawiki_oauth.get_token() + token = wikidata_oauth.get_token() found = get_match(title, hit_title, None)