Upgrade from bootstrap 4 to 5

This commit is contained in:
Edward Betts 2023-11-09 07:35:41 +01:00
parent fd281532e6
commit 4446cbed6e
4 changed files with 87 additions and 40 deletions

View file

@ -0,0 +1,27 @@
from .category import Category
from .mediawiki import mediawiki_query
from .type import CallParams
def process_cats(cats: list[dict[str, str]], site: str) -> list[Category]:
"""Process categories."""
return [Category(cat["title"], site) for cat in cats]
def get_categories(titles: list[str], site: str) -> list[tuple[str, list[Category]]]:
"""Get categories for pages with given titles."""
params: CallParams = {
"prop": "categories",
"clshow": "!hidden",
"cllimit": "max",
}
from_wiki = mediawiki_query(titles, params, site)
title_and_cats = []
for i in from_wiki:
if "categories" not in i:
continue
cats = process_cats(i["categories"], site)
if not cats:
continue
title_and_cats.append((i["title"], cats))
return title_and_cats

View file

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" href="{{ url_for('static', filename='javascript/bootstrap4/css/bootstrap.min.css') }}"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title> <title>
@ -27,8 +27,7 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
<script src="{{ url_for('static', filename='javascript/jquery/jquery.min.js') }}"></script> <script src="{{ url_for('static', filename='javascript/jquery/jquery.min.js') }}"></script>
{# <script src="{{ url_for('static', filename='javascript/popper.js/popper.min.js') }}"></script> #} <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<script src="{{ url_for('static', filename='javascript/bootstrap4/js/bootstrap.min.js') }}"></script>
{% block script %}{% endblock %} {% block script %}{% endblock %}
</body> </body>

View file

@ -6,16 +6,40 @@
<style> <style>
div.description { margin-left: 2em; color: rgb(96, 96, 96); } div.description { margin-left: 2em; color: rgb(96, 96, 96); }
span.description { color: rgb(96, 96, 96); } span.description { color: rgb(96, 96, 96); }
#artwork {
position: fixed; /* This keeps the map in place when the page is scrolled */
top: 56px;
left: 0; /* Positioned on the right side */
width: 50%; /* Half the screen width */
bottom: 0px;
z-index: -1;
}
#artwork img {
object-fit: contain; /* The image will be scaled to maintain its aspect ratio */
width: 100%;
height: 100%;
}
#main {
float: right; /* Floats the main content to the right */
width: 48%; /* Adjusted width of the main content */
height: auto; /* Height is set to auto, allowing it to expand naturally */
margin-right: 1%;
}
</style> </style>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="container-fluid mt-2"> <div id="artwork">
<div class="row"> <div class="w-100 h-100">
<div class="col-md"> <img src="{{ image.thumburl }}" />
<img src="{{ image.thumburl }}" class="w-100" />
</div> </div>
<div class="col-md"> </div>
<div id="main">
<h1>{{ self.title() }}</h1> <h1>{{ self.title() }}</h1>
{% if label_languages %} {% if label_languages %}
<p>Label from: <p>Label from:
@ -179,8 +203,6 @@ span.description { color: rgb(96, 96, 96); }
</form> </form>
{% endif %} {% endif %}
</div> </div>
</div>
</div>
{% endblock %} {% endblock %}
{% block script %} {% block script %}

View file

@ -5,19 +5,17 @@
{% endmacro %} {% endmacro %}
{% macro navbar_inner(name) %} {% macro navbar_inner(name) %}
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <div class="container-fluid">
<a class="navbar-brand" href="{{ url_for('browse_page') }}">Wikidata Art Depiction Explorer</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<a class="navbar-brand" href="{{ url_for('browse_page') }}">Wikidata Art Depiction Explorer</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto"> <ul class="navbar-nav me-auto">
<ul class="navbar-nav mr-auto">
{{ nav_item('browse_page', 'Browse') }} {{ nav_item('browse_page', 'Browse') }}
{{ nav_item('list_edits', 'Recent changes') }} {{ nav_item('list_edits', 'Recent changes') }}
{{ nav_item('random_artwork', 'Random artwork') }} {{ nav_item('random_artwork', 'Random artwork') }}
</ul> </ul>
</ul>
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item"> <li class="nav-item">
{% if g.user %} {% if g.user %}
@ -35,10 +33,11 @@
{% endif %} {% endif %}
</ul> </ul>
</div> </div>
</div>
{% endmacro %} {% endmacro %}
{% macro navbar() %} {% macro navbar() %}
<nav class="navbar navbar-toggleable-md navbar-expand-lg navbar-dark bg-dark"> <nav class="navbar navbar-expand-lg bg-dark" data-bs-theme="dark">
{{ navbar_inner() }} {{ navbar_inner() }}
</nav> </nav>
{% endmacro %} {% endmacro %}