From f7df9b1dabf9700a5a5bdc098d9f81e2b293030f Mon Sep 17 00:00:00 2001 From: zeroth Date: Fri, 13 Nov 2020 23:49:29 +0000 Subject: [PATCH] mediawiki pages html content to templates --- daapinterface.py | 43 +++++++++++++++++++++++++++++++++++---- templates/about-wiki.html | 6 ++++++ templates/casestudy.html | 12 +++++++++++ templates/upload.html | 14 ++++++------- 4 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 templates/casestudy.html diff --git a/daapinterface.py b/daapinterface.py index d9de650..ff4cefb 100644 --- a/daapinterface.py +++ b/daapinterface.py @@ -341,14 +341,20 @@ def searchtools(): ######################### ABOUT @app.route("/about") def about(): - url="https://daap.bannerrepeater.org/w/index.php?title=Project:About&action=render" + url="https://daap.bannerrepeater.org/w/index.php?title=About&action=render" # Make a GET request to fetch the raw HTML content html_content = requests.get(url).text # Parse the html content soup = BeautifulSoup(html_content, "lxml") - print(soup.prettify()) # print the parsed data of html + # print(soup.prettify()) # print the parsed data of html - text=soup.find("p") + text=soup.find("html") + # adapt the path to img with regex + # test = text.replace("wiki/File:","wiki/Special:Redirect/file/") + # text.replace_with(test) + + text=Markup(text) + return render_template('about-wiki.html', text=text) @@ -361,7 +367,36 @@ def tutorials(): ######################### UPLOAD @app.route("/upload") def upload(): - return render_template('upload.html') + url="https://daap.bannerrepeater.org/w/index.php?title=Upload&action=render" + # Make a GET request to fetch the raw HTML content + html_content = requests.get(url).text + # Parse the html content + soup = BeautifulSoup(html_content, "lxml") + # print(soup.prettify()) # print the parsed data of html + + text=soup.find("html") + + text=Markup(text) + return render_template('upload.html', text=text) + + +# #################### CASE STUDY +@app.route("/casestudy") +def casestudy(): + url="https://daap.bannerrepeater.org/w/index.php?title=Carolee_Schneemann_case_study&action=render" + # Make a GET request to fetch the raw HTML content + html_content = requests.get(url).text + # Parse the html content + soup = BeautifulSoup(html_content, "lxml") + # print(soup.prettify()) # print the parsed data of html + + text=soup.find("html") + + text=Markup(text) + return render_template('casestudy.html', text=text) + + + ######################### LOGIN diff --git a/templates/about-wiki.html b/templates/about-wiki.html index 2ab998e..e4b639c 100644 --- a/templates/about-wiki.html +++ b/templates/about-wiki.html @@ -3,4 +3,10 @@ {{ text }} + + {% endblock content %} \ No newline at end of file diff --git a/templates/casestudy.html b/templates/casestudy.html new file mode 100644 index 0000000..e4b639c --- /dev/null +++ b/templates/casestudy.html @@ -0,0 +1,12 @@ +{% extends "layout.html" %} +{% block content %} + +{{ text }} + + + +{% endblock content %} \ No newline at end of file diff --git a/templates/upload.html b/templates/upload.html index 003d9e6..413d549 100644 --- a/templates/upload.html +++ b/templates/upload.html @@ -1,15 +1,13 @@ {% extends "layout.html" %} {% block content %} -
-

UPLOAD

-

Upload page upcoming

-
-
-
-
-
+{{ text }} + {% endblock content %} \ No newline at end of file