Compare commits

..

No commits in common. "fc0d6f114a5a13b4a6258d4f2fd75969b7ba3a60" and "128d84fce9816b3172425ec643c03f3ed74e70c2" have entirely different histories.

2 changed files with 6 additions and 11 deletions

View file

@ -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:
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)