From b202889dce7b68e32c2ddd9d633e6f23587006d9 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 2 Oct 2023 19:48:35 +0100 Subject: [PATCH 1/2] Use original message with a few changes. --- templates/message.jinja | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/templates/message.jinja b/templates/message.jinja index 7871dc5..0d1b1db 100644 --- a/templates/message.jinja +++ b/templates/message.jinja @@ -2,24 +2,19 @@ #} Hi, -I wanted to get in touch regarding your photo of {{ name }}, which I came across on Flickr: +I'd like to use your photo to illustrate the article about {{ name }} on Wikipedia. {{ flickr_url }} -I am currently working on enhancing the Wikipedia article about {{ name }}, and I believe your image would be a valuable addition to the article. However, to use it on Wikipedia, we need to ensure that it's available under the Creative Commons Attribution (CC BY) license or the Attribution-ShareAlike (CC BY-SA) license. These licenses allow us to use the image with proper attribution. - {{ wiki_part1 }}{{ wiki_part2 | urlencode }} -If you're open to it, could you please consider changing the license of this photo to either CC BY or CC BY-SA? We would, of course, provide full credit on the image page, acknowledging your contribution. +Would you be willing to change the license of the photo to Creative Commons Attribution so it can be used on Wikipedia? I'll include a credit on the image page. + +Just to be clear on the license, it needs to be Attribution or Attribution-ShareAlike. If you select a license with a "NonCommercial" or "NoDerivs" restriction then the images can't be used on Wikipedia. To adjust the license settings, you can click on 'All rights reserved' on the right-hand side of the photo's page, just underneath the date. -Your generosity in allowing us to use this image would greatly enhance the quality of the Wikipedia article and contribute to the dissemination of knowledge about {{ name }}. - -Thank you for your consideration, and if you have any questions or require further information, please don't hesitate to contact me. - -Warm regards, +Thanks, Edward - edward@4angle.com From e4e9df88d7e10d5321efe199cf3ae757692c54c2 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 2 Oct 2023 19:48:50 +0100 Subject: [PATCH 2/2] First form can take name or URL Closes: #2 --- main.py | 32 +++++++++++++++++++++++--------- templates/combined.html | 8 ++++---- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index 154b71e..d4b4677 100755 --- a/main.py +++ b/main.py @@ -50,14 +50,29 @@ def exception_handler(e: werkzeug.exceptions.InternalServerError) -> tuple[str, @app.route("/") def start() -> str: """Start form.""" - wikipedia_url = flask.request.args.get("wikipedia") - if not wikipedia_url: + enwp = flask.request.args.get("enwp") + if not enwp: + return flask.render_template("combined.html") + enwp = enwp.strip() + if not enwp: return flask.render_template("combined.html") - start = wikipedia_url.find(enwiki) + len(enwiki) - wiki_part2 = unquote(wikipedia_url[start:]) + input_is = "url" if enwp.startswith(enwiki) else "title" - name = wiki_part2 + wikipedia_url: str + wiki_part1: str + wiki_part2: str + if input_is == "url": + start = enwp.find(enwiki) + len(enwiki) + wiki_part2 = unquote(enwp[start:]) + name = wiki_part2 + wiki_part1 = enwp[:start] + wikipedia_url = enwp + else: + name = enwp + wiki_part1 = enwiki + wiki_part2 = name.replace(" ", "_") + wikipedia_url = wiki_part1 + wiki_part2 if "_(" in name: name = name[: name.find("_(")] @@ -68,11 +83,9 @@ def start() -> str: return flask.render_template( "combined.html", name=name, - wikipedia_url=wikipedia_url, + enwp=enwp, ) - wiki_part1 = wikipedia_url[:start] - if "/in/" in flickr_url: flickr_url = flickr_url[: flickr_url.find("/in/")] @@ -90,6 +103,7 @@ def start() -> str: msg = flask.render_template( "message.jinja", flickr_url=flickr_url, + enwp=enwp, wikipedia_url=wikipedia_url, name=name, wiki_part1=wiki_part1, @@ -103,7 +117,7 @@ def start() -> str: return flask.render_template( "combined.html", name=name, - wikipedia_url=wikipedia_url, + enwp=enwp, flickr_url=flickr_url, subject=subject, lines=lines, diff --git a/templates/combined.html b/templates/combined.html index d458e7e..7609539 100644 --- a/templates/combined.html +++ b/templates/combined.html @@ -8,8 +8,8 @@

Flickr mail

- - + +
@@ -21,8 +21,8 @@

Search flickr

- -
+ +