Initial commit
This commit is contained in:
commit
084c886933
55
main.py
Executable file
55
main.py
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
from urllib.parse import unquote
|
||||
|
||||
import flask
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
app.debug = True
|
||||
|
||||
enwiki = "en.wikipedia.org/wiki/"
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def start_form() -> str:
|
||||
"""Start form."""
|
||||
return flask.render_template("start_form.html")
|
||||
|
||||
|
||||
@app.route("/message")
|
||||
def show_message() -> str:
|
||||
"""Show message."""
|
||||
flickr_url = flask.request.args["flickr"]
|
||||
wikipedia_url = flask.request.args["wikipedia"]
|
||||
|
||||
start = wikipedia_url.find(enwiki) + len(enwiki)
|
||||
wiki_part1 = wikipedia_url[:start]
|
||||
|
||||
if len(sys.argv) > 4:
|
||||
name = sys.argv[4]
|
||||
else:
|
||||
wiki_part2 = unquote(wikipedia_url[start:])
|
||||
name = wiki_part2
|
||||
|
||||
if "_(" in name:
|
||||
name = name[: name.find("_(")]
|
||||
name = name.replace("_", " ")
|
||||
|
||||
if "/in/" in flickr_url:
|
||||
flickr_url = flickr_url[: flickr_url.find("/in/")]
|
||||
|
||||
msg = flask.render_template(
|
||||
"message.jinja",
|
||||
flickr_url=flickr_url,
|
||||
wikipedia_url=wikipedia_url,
|
||||
name=name,
|
||||
wiki_part1=wiki_part1,
|
||||
wiki_part2=wiki_part2,
|
||||
)
|
||||
|
||||
return flask.render_template("show_message.html", msg=msg)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0")
|
25
templates/message.jinja
Normal file
25
templates/message.jinja
Normal file
|
@ -0,0 +1,25 @@
|
|||
{# vim:ft=jinja
|
||||
#}
|
||||
Request to use your photo of {{ name }} on Wikipedia
|
||||
|
||||
Hi,
|
||||
|
||||
I wanted to get in touch regarding your photo of {{ name }}, which I came across on Flickr:
|
||||
|
||||
{{ 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.
|
||||
|
||||
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,
|
||||
|
||||
Edward
|
11
templates/show_message.html
Normal file
11
templates/show_message.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<pre>{{ msg }}</pre>
|
||||
</body>
|
||||
</html>
|
19
templates/start_form.html
Normal file
19
templates/start_form.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>URL Input Form</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Enter URLs</h1>
|
||||
<form action="{{ url_for("show_message") }}">
|
||||
<label for="flickr_url">Flickr URL:</label>
|
||||
<input type="text" id="flickr" name="flickr" required><br><br>
|
||||
|
||||
<label for="wikipedia_url">Wikipedia URL:</label>
|
||||
<input type="text" id="wikipedia" name="wikipedia" required><br><br>
|
||||
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in a new issue