Reorganise code
This commit is contained in:
parent
a5f8070179
commit
253096bf59
21 changed files with 0 additions and 0 deletions
30
confarchive/templates/add_venue.html
Normal file
30
confarchive/templates/add_venue.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}New venue{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Conference archive</h1>
|
||||
<p><a href="{{ url_for("index") }}">home</a></p>
|
||||
|
||||
<h2>New venue</h2>
|
||||
|
||||
<p>City: {{ city.name }}, {{ city.country.name }}</p>
|
||||
|
||||
<form>
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Name</label>
|
||||
<input type="text" class="form-control" id="name" name="name">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="wikidata_qid" class="form-label">Wikidata QID</label>
|
||||
<input type="text" class="form-control" id="wikidata_qid" name="wikidata_qid">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
41
confarchive/templates/base.html
Normal file
41
confarchive/templates/base.html
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@1.2.0/css/fork-awesome.min.css" integrity="sha256-XoaMnoYC5TH6/+ihMEnospgm0J1PM/nioxbOUdnM8HY=" crossorigin="anonymous">
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: monospace;
|
||||
margin: 40px auto;
|
||||
max-width: 900px;
|
||||
line-height: 1.6;
|
||||
font-size: 18px;
|
||||
color: #444;
|
||||
padding: 0 10px
|
||||
}
|
||||
h1, h2, h3{line-height:1.2}
|
||||
.text-nowrap { white-space:nowrap; }
|
||||
.text-end { text-align: right; }
|
||||
// img { max-width: 100%; height: auto; }
|
||||
</style>
|
||||
|
||||
<title>{% block title %}Xanadu{% endblock %}</title>
|
||||
|
||||
{% block style %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% include "navbar.html" %}
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
{% endblock %}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
194
confarchive/templates/conference.html
Normal file
194
confarchive/templates/conference.html
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block style %}
|
||||
<style>
|
||||
.images {
|
||||
position: absolute;
|
||||
right: -200px;
|
||||
top: 0;
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.image {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% set show_images = True %}
|
||||
|
||||
{% block title %}{{ item.title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="container">
|
||||
{% if show_images %}
|
||||
<div class="images">
|
||||
{% for person in item.people %}
|
||||
{% set photo = person.photo_filename() %}
|
||||
{% if photo %}
|
||||
<div class="image-container">
|
||||
<a href="{{ url_for("person", person_id=person.id) }}">
|
||||
{{ person.name }}<br>
|
||||
<img class="image" src="{{ url_for("static", filename=photo) }}" alt="{{ person.name}}" title="{{ person.name}}">
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row">
|
||||
<h1>{{ item.title }}</h1>
|
||||
<p><a href="{{ url_for("index") }}">home</a></p>
|
||||
|
||||
<div>
|
||||
{% if item.series %}
|
||||
<div>series: {{ item.series.name }}
|
||||
{% if item.series.wikidata_qid %}
|
||||
<a href="https://www.wikidata.org/wiki/{{ item.series.wikidata_qid }}">Wikidata</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div>start: {{ item.start }}</div>
|
||||
<div>end: {{ item.end }}</div>
|
||||
{% if days %}
|
||||
<div>days: {{ item.days }}</div>
|
||||
{% endif %}
|
||||
{# <div>short name: {{ item.short_name }}</div> #}
|
||||
{% if item.venue %}
|
||||
{% set country = item.venue.city.country %}
|
||||
<div>
|
||||
venue: {{ item.venue.name }}
|
||||
{% if item.venue.wikidata_qid %}
|
||||
<a href="https://www.wikidata.org/wiki/{{ item.venue.wikidata_qid }}">Wikidata</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
city: {{ item.venue.city.name }}
|
||||
{% if item.venue.city.wikidata_qid %}
|
||||
<a href="https://www.wikidata.org/wiki/{{ item.venue.city.wikidata_qid }}">Wikidata</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>country: {{ country.name }} {{ country.flag }}</div>
|
||||
{% endif %}
|
||||
{% if item.wikidata_qid %}
|
||||
<div>wikidata: <a href="https://www.wikidata.org/wiki/{{ item.wikidata_qid }}">{{ item.wikidata_qid }}</a></div>
|
||||
{% endif %}
|
||||
|
||||
{% if item.url %}
|
||||
<div>Website: <a href="{{ item.url }}">{{ item.url }}</a></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if is_admin() %}
|
||||
<form method="POST">
|
||||
<div>
|
||||
<label for="title">title</label>
|
||||
<input type="text" name="title" id="title" value="{{ item.title }}">
|
||||
</div>
|
||||
<div>
|
||||
<label for="short_name">short name</label>
|
||||
<input type="text" name="short_name" id="short_name" value="{{ item.short_name }}">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
<h3>Talks</h3>
|
||||
|
||||
<p>{{ item.events.count() }} talks</p>
|
||||
{% for event in item.events %}
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<p>
|
||||
🎤
|
||||
<a href="{{ url_for("event_page", event_id=event.id) }}">{{ event.title }}</a><br>
|
||||
|
||||
Speakers:
|
||||
{% for p in event.people %}
|
||||
👤
|
||||
<a href="{{ url_for("person", person_id=p.id) }}">{{ p.name }}</a>
|
||||
{% endfor %}<br>
|
||||
|
||||
{% if event.event_date %}
|
||||
📅 {{ event.event_date.strftime("%a, %d %b %Y at %H:%M") }}
|
||||
{% else %}
|
||||
event date missing
|
||||
{% endif %}
|
||||
|
||||
<a class="event-detail-toggle" href="#">show details</a><br>
|
||||
|
||||
|
||||
|
||||
</p>
|
||||
<div class="event-detail" id="event_{{event.id }}" style="display:none">
|
||||
{% if event.url %}
|
||||
<p><a href="{{ event.url }}">talk on conference website</a></p>
|
||||
{% endif %}
|
||||
|
||||
{% if event.abstract %}
|
||||
<p class="card-text">
|
||||
{% if "<" in event.abstract %}
|
||||
{{ event.abstract | safe }}
|
||||
{% else %}
|
||||
{{ event.abstract }}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if event.description %}
|
||||
<p class="card-text">
|
||||
{% if "<" in event.description %}
|
||||
{{ event.description | safe }}
|
||||
{% else %}
|
||||
{{ event.description }}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script>
|
||||
// Get all elements with the class "event-detail-toggle"
|
||||
var toggleLinks = document.querySelectorAll(".event-detail-toggle");
|
||||
|
||||
// Loop through each toggle link and attach a click event handler
|
||||
toggleLinks.forEach(function(link) {
|
||||
link.addEventListener("click", function(e) {
|
||||
e.preventDefault(); // Prevent the default link behavior
|
||||
|
||||
// Find the parent div of the clicked link
|
||||
var parentDiv = this.closest("div");
|
||||
|
||||
// Find the element with class "event-detail" inside the parent div
|
||||
var detailElement = parentDiv.querySelector(".event-detail");
|
||||
|
||||
// Toggle the display of the detail element
|
||||
if (detailElement.style.display === "none" || detailElement.style.display === "") {
|
||||
detailElement.style.display = "block";
|
||||
this.textContent = "hide detail"; // Change the link text
|
||||
} else {
|
||||
detailElement.style.display = "none";
|
||||
this.textContent = "show detail"; // Change the link text
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
39
confarchive/templates/country_list.html
Normal file
39
confarchive/templates/country_list.html
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Countries{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Conference archive</h1>
|
||||
<p><a href="{{ url_for("index") }}">home</a></p>
|
||||
|
||||
<h2>Countries</h2>
|
||||
|
||||
{% for item in items %}
|
||||
<div>
|
||||
<h4>{{ item.name }}</h4>
|
||||
<p><a href="https://www.wikidata.org/wiki/{{ item.wikidata_qid }}">Wikidata: {{ item.wikidata_qid }}</a></p>
|
||||
<div>
|
||||
<ul>
|
||||
{% for city in item.cities %}
|
||||
<li>
|
||||
{{ city.name }}
|
||||
(<a href="https://www.wikidata.org/wiki/{{ item.wikidata_qid }}">{{ item.wikidata_qid }}</a>)
|
||||
—
|
||||
{% if city.venues %}
|
||||
{% for venue in city.venues %}
|
||||
{{ venue.name }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<a href="{{ url_for("add_venue", city_id=city.id) }}">add venue in city</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
57
confarchive/templates/event.html
Normal file
57
confarchive/templates/event.html
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ item.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>{{ item.title }}</h1>
|
||||
<p><a href="{{ url_for("index") }}">home</a></p>
|
||||
|
||||
|
||||
<div class="card my-2">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
{% if item.url %}
|
||||
<a href="{{ item.url }}">{{ item.title }}</a>
|
||||
{% else %}
|
||||
{{ item.title }}
|
||||
{% endif %}
|
||||
</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">
|
||||
<a href="{{ url_for("conference_page", short_name=item.conference.short_name) }}">{{ item.conference.title }}</a>
|
||||
</h6>
|
||||
|
||||
{% if item.abstract %}
|
||||
<p class="card-text">
|
||||
{% if "<" in item.abstract %}
|
||||
{{ item.abstract | safe }}
|
||||
{% else %}
|
||||
{{ item.abstract }}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if item.description %}
|
||||
<p class="card-text">
|
||||
{% if "<" in item.description %}
|
||||
{{ item.description | safe }}
|
||||
{% else %}
|
||||
{{ item.description }}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
<p class="card-text">
|
||||
Speakers:
|
||||
{% for p in item.people %}
|
||||
<a href="{{ url_for("person", person_id=p.id) }}">{{ p.name }}</a>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
25
confarchive/templates/github.html
Normal file
25
confarchive/templates/github.html
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Conference archive</h1>
|
||||
|
||||
<p>{{ items | count }} matches found</p>
|
||||
{% for person, qid, wd_name, desc in items %}
|
||||
<div>
|
||||
<a href="{{ url_for("person", person_id=person.id) }}">{{ person.name }}</a>
|
||||
##
|
||||
<a href="https://www.wikidata.org/wiki/{{ qid }}">{{ wd_name }} ({{ qid }})</a>
|
||||
##
|
||||
{{ desc }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block style %}
|
||||
<style>
|
||||
.searchmatch { background: lightgreen }
|
||||
</style>
|
||||
{% endblock %}
|
||||
59
confarchive/templates/index.html
Normal file
59
confarchive/templates/index.html
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h1>Conference archive</h1>
|
||||
|
||||
<div style="margin-bottom:1rem">
|
||||
👥
|
||||
{{ "{:,d}".format(count.conference) }} conferences<br/>
|
||||
🌍
|
||||
{{ "{:,d}".format(count.country) }} countries<br/>
|
||||
📍
|
||||
{{ "{:,d}".format(count.venue) }} venues<br/>
|
||||
🎤
|
||||
{{ "{:,d}".format(count.event) }} talks<br/>
|
||||
👤
|
||||
{{ "{:,d}".format(count.person) }} speakers
|
||||
<a href="{{ url_for("top_speakers_page") }}">top speakers</a><br/>
|
||||
</div>
|
||||
|
||||
<h2>Conferences</h2>
|
||||
|
||||
{% for item in items %}
|
||||
{% if loop.first or item.start.year != loop.previtem.start.year %}
|
||||
<h3>{{ item.start.year }}</h3>
|
||||
{% endif %}
|
||||
|
||||
<div style="margin-bottom:1.5rem">
|
||||
👥
|
||||
<a href="{{ url_for("conference_page", short_name=item.short_name) }}">{{ item.title }}</a>
|
||||
📅
|
||||
{{ item.start.strftime("%d %b %Y") }}
|
||||
<br/>
|
||||
{% if item.venue %}
|
||||
📍
|
||||
{{ item.venue.name }}
|
||||
–
|
||||
{{ item.venue.city.name }},
|
||||
{{ item.venue.city.country.name }}
|
||||
{{ item.venue.city.country.flag }}
|
||||
<br/>
|
||||
{% endif %}
|
||||
{#
|
||||
{% if item.series %}
|
||||
📃 Series: {{ item.series.name }}
|
||||
<br/>
|
||||
{% endif %}
|
||||
#}
|
||||
|
||||
{{ (item.end - item.start).days + 1 }} days,
|
||||
{{ item.events.count() }} talks,
|
||||
{{ item.people_detail.count() }} speakers<br/>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
16
confarchive/templates/login.html
Normal file
16
confarchive/templates/login.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Conference archive</h1>
|
||||
|
||||
<div>Admin login.</div>
|
||||
|
||||
<form method="POST">
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" name="password"/>
|
||||
<button>login</button>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
49
confarchive/templates/merge_people.html
Normal file
49
confarchive/templates/merge_people.html
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Conference archive</h1>
|
||||
|
||||
<form action="{{ url_for("merge") }}">
|
||||
<div class="mb-3">
|
||||
<label for="q" class="form-label">speaker name</label>
|
||||
<input type="text" class="form-control" name="q" id="q" value="{{ search_for }}">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
|
||||
<p>Found {{ q.count() }} people matching '{{ search_for }}'</p>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="q" value="{{search_for }}"/>
|
||||
|
||||
|
||||
{% for item in q %}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="person_id" value="{{ item.id }}" id="person{{ item.id }}">
|
||||
<label class="form-check-label" for="person{{ item.id }}">
|
||||
<a href="{{ url_for("person", person_id=item.id) }}">{{ item.name }}</a>
|
||||
|
||||
{% if item.wikidata_qid %}
|
||||
—
|
||||
<a href="https://www.wikidata.org/wiki/{{ item.wikidata_qid }}">{{ item.wikidata_qid }} on Wikidata</a>
|
||||
{% endif %}
|
||||
</label>
|
||||
<input class="form-check-input" type="radio" name="name" value="{{ item.id }}" id="name{{ item.id }}">
|
||||
<label class="form-check-label" for="name{{ item.id }}">use this name</label><br>
|
||||
|
||||
{% for conf in item.conferences %} 👥{{ conf.title }}{% endfor %}
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
<button type="submit" class="btn btn-primary">Merge</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
12
confarchive/templates/navbar.html
Normal file
12
confarchive/templates/navbar.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<p>
|
||||
<form action="{{ url_for("search_people") }}">
|
||||
<a href="{{ url_for("index") }}">conferences</a>
|
||||
| <a href="{{ url_for("top_speakers_page") }}">speakers</a>
|
||||
| <a href="{{ url_for("list_series") }}">series</a>
|
||||
|
||||
<input type="text" class="form-control" placeholder="speaker name" name="q" id="q">
|
||||
<button type="submit" class="btn btn-primary">search</button>
|
||||
</form>
|
||||
|
||||
|
||||
</p>
|
||||
208
confarchive/templates/person.html
Normal file
208
confarchive/templates/person.html
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ item.name }}{% endblock %}
|
||||
|
||||
{% block style %}
|
||||
<style>
|
||||
.image-container {
|
||||
float: right;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.image {
|
||||
max-width: 100%;
|
||||
}
|
||||
.text-nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<div>
|
||||
|
||||
{% set photo = item.photo_filename() %}
|
||||
{% if photo %}
|
||||
<div class="image-container">
|
||||
<img class="image" src="{{ url_for("static", filename=photo) }}">
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<h1>{{ item.name }}</h1>
|
||||
|
||||
<p>
|
||||
👥 {{ plural(item.conference_count, "conference") }}<br/>
|
||||
🎤 {{ plural(item.event_count, "talk") }}<br/>
|
||||
{% set start, end = item.active_years() %}
|
||||
📅 Years active: {{ start.year }} to {{end.year }}
|
||||
{% if item.wikidata_qid %}
|
||||
<br/>
|
||||
📊 Wikidata: <a href="https://www.wikidata.org/wiki/{{ item.wikidata_qid }}">{{ item.wikidata_qid }}</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% if is_admin() %}
|
||||
{% set search_for = item.name + ' ' + " haswbstatement:P31=Q5" %}
|
||||
<p><a href="https://www.wikidata.org/w/index.php?search={{ search_for | urlencode }}&title=Special%3ASearch&ns0=1&ns120=1">Search for {{ item.name }} on Wikidata</a></p>
|
||||
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Name</label>
|
||||
<input type="text" class="form-control" name="name" id="name" value="{{ item.name }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="wikidata_qid" class="form-label">Wikidata QID</label>
|
||||
<input type="text" class="form-control" name="wikidata_qid" id="wikidata_qid" value="{{ item.wikidata_qid or "" }}">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
|
||||
<form method="POST" action="{{ url_for("delete_person", person_id=item.id) }}">
|
||||
<button type="submit" class="btn btn-primary">delete</button>
|
||||
</form>
|
||||
|
||||
<div><a href="{{ url_for("split_person", person_id=item.id) }}">split person</a></div>
|
||||
|
||||
{% if show_wikidata_matches %}
|
||||
{% if wikidata_hits %}
|
||||
<p>Possible Wikidata matches</p>
|
||||
<ul>
|
||||
{% for hit in wikidata_hits %}
|
||||
<li>
|
||||
<a href="https://www.wikidata.org/wiki/{{ hit.qid }}">{{ hit.qid }}</a>
|
||||
{{ hit.label }} — {{ hit.description }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% elif not item.wikidata_qid %}
|
||||
<p>No similar names found on Wikidata</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% set bio_source = item.bio_source() %}
|
||||
{% if bio_source %}
|
||||
<h2>Biography</h2>
|
||||
<blockquote>
|
||||
<div>{{ bio_source.bio | safe }}</div>
|
||||
<div>— biography from
|
||||
<a href="{{ url_for("conference_page", short_name=bio_source.conference.short_name) }}">{{ bio_source.conference.title }}</a><br>
|
||||
<a href="{{ bio_source.url }}">{{ bio_source.url }}</a>
|
||||
</div>
|
||||
</blockquote>
|
||||
{% else %}
|
||||
<p>No biography available.</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<h2>Conferences</h2>
|
||||
<p>{{ item.conferences_association.count() }} known conferences</p>
|
||||
{% for apperance in item.conference_by_time() %}
|
||||
{% set conf = apperance.conference %}
|
||||
|
||||
<div>
|
||||
<h3>👥
|
||||
<a href="{{ url_for("conference_page", short_name=conf.short_name) }}">{{ conf.title }}</a>
|
||||
<small>📅 {{ conf.start.strftime("%d %b %Y") }}</small>
|
||||
|
||||
</h3>
|
||||
{% if 0 and apperance.bio %}<p>Biography: {{ apperance.bio | safe }}</p>{% endif %}
|
||||
</div>
|
||||
|
||||
{% for event in apperance.events %}
|
||||
<div>
|
||||
🎤
|
||||
<a href="{{ url_for("event_page", event_id=event.id) }}">{{ event.title }}</a><br>
|
||||
|
||||
<span class="text-nowrap">
|
||||
{% if event.event_date %}
|
||||
{{ event.event_date.strftime("%d %b %Y") }}
|
||||
{% else %}
|
||||
event date missing
|
||||
{% endif %}
|
||||
|
||||
<a class="event-detail-toggle" href="#">show details</a>
|
||||
</span>
|
||||
<div class="event-detail" id="event_{{event.id }}" style="display:none">
|
||||
|
||||
<p>
|
||||
{% if event.url %}
|
||||
<a href="{{ event.url }}">talk on conference website</a>
|
||||
{% endif %}
|
||||
<p>
|
||||
|
||||
{% if event.abstract %}
|
||||
<div>
|
||||
{% if "<" in event.abstract %}
|
||||
{{ event.abstract | safe }}
|
||||
{% else %}
|
||||
{{ event.abstract }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if event.description %}
|
||||
<div>
|
||||
{% if "<" in event.description %}
|
||||
{{ event.description | safe }}
|
||||
{% else %}
|
||||
{{ event.description }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if event.people_detail.count() > 1 %}
|
||||
<div>
|
||||
Other people:
|
||||
{% for p in event.people %}
|
||||
{% if p.id != item.id %}
|
||||
<a href="{{ url_for(request.endpoint, person_id=p.id) }}">{{ p.name }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
{% endfor %}
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script>
|
||||
// Get all elements with the class "event-detail-toggle"
|
||||
var toggleLinks = document.querySelectorAll(".event-detail-toggle");
|
||||
|
||||
// Loop through each toggle link and attach a click event handler
|
||||
toggleLinks.forEach(function(link) {
|
||||
link.addEventListener("click", function(e) {
|
||||
e.preventDefault(); // Prevent the default link behavior
|
||||
|
||||
// Find the parent div of the clicked link
|
||||
var parentDiv = this.closest("div");
|
||||
|
||||
// Find the element with class "event-detail" inside the parent div
|
||||
var detailElement = parentDiv.querySelector(".event-detail");
|
||||
|
||||
// Toggle the display of the detail element
|
||||
if (detailElement.style.display === "none" || detailElement.style.display === "") {
|
||||
detailElement.style.display = "block";
|
||||
this.textContent = "hide detail"; // Change the link text
|
||||
} else {
|
||||
detailElement.style.display = "none";
|
||||
this.textContent = "show detail"; // Change the link text
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
14
confarchive/templates/person/split.html
Normal file
14
confarchive/templates/person/split.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Split speaker – Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ item.name }}</h1>
|
||||
|
||||
<form method="POST">
|
||||
<div><textarea name="names" rows="5" cols="60">{{ item.name }}</textarea></div>
|
||||
<button>split</button>
|
||||
</form>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
38
confarchive/templates/reports.html
Normal file
38
confarchive/templates/reports.html
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Conference archive</h1>
|
||||
|
||||
<h2>Reports</h2>
|
||||
|
||||
<div>Talks: {{ "{:,d}".format(event_count) }}</div>
|
||||
<div>Talks with no event date: {{ "{:,d}".format(missing_event_date_count) }}</div>
|
||||
<div>Speakers: {{ "{:,d}".format(speaker_count) }}</div>
|
||||
<div>Speakers with no bio: {{ "{:,d}".format(no_bio_count) }}</div>
|
||||
<div>Speakers with one bio: {{ "{:,d}".format(one_bio_count) }}</div>
|
||||
<div>Speakers with more than one bio: {{ "{:,d}".format(multiple_bio_count) }}</div>
|
||||
<div>Conferences without a venue: {{ "{:,d}".format(no_venue_count) }}</div>
|
||||
|
||||
<h2>Talks with missing dates</h2>
|
||||
|
||||
{% for event in missing_event_date %}
|
||||
<div>{{ event.title }}<br>
|
||||
{{ event.conference.title }}<br>
|
||||
GUID: {{ event.guid or "missing" }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<h2>Speakers with a shorter recent biography</h2>
|
||||
|
||||
<p>{{ shorter_recent_bio | count }} found</p>
|
||||
|
||||
{% for person, recent_bio_length, longest in shorter_recent_bio %}
|
||||
<div>
|
||||
<a href="{{ url_for("person", person_id=person.id) }}">{{ person.name }}</a>
|
||||
recent bio: {{ recent_bio_length }} vs {{ longest }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
39
confarchive/templates/search_events.html
Normal file
39
confarchive/templates/search_events.html
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Conference archive</h1>
|
||||
|
||||
<form action="{{ url_for("events_page") }}">
|
||||
<div class="mb-3">
|
||||
<label for="q" class="form-label">event</label>
|
||||
<input type="text" class="form-control" name="q" id="q" value="{{ search_for }}">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
|
||||
<p>Found {{ q.count() }} events matching '{{ search_for }}'</p>
|
||||
|
||||
{% for item in q %}
|
||||
<div>
|
||||
🎤
|
||||
<a href="{{ url_for("event_page", event_id=item.id) }}">{{ item.title }}</a>
|
||||
—
|
||||
<a href="{{ url_for("conference_page", short_name=item.conference.short_name) }}">{{ item.conference.title }}</a>
|
||||
—
|
||||
{{ item.event_date.strftime("%d %b %Y at %H:%M") if item.event_date else "date missing" }}
|
||||
—
|
||||
{% for p in item.people %}
|
||||
<a href="{{ url_for("person", person_id=p.id) }}">{{ p.name }}</a>
|
||||
{% endfor %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
97
confarchive/templates/search_everything.html
Normal file
97
confarchive/templates/search_everything.html
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Conference archive</h1>
|
||||
<p><a href="{{ url_for("index") }}">home</a></p>
|
||||
|
||||
<form action="{{ url_for("search_everything") }}">
|
||||
<div class="mb-3">
|
||||
<input type="text" class="form-control" name="q" id="q" value="{{ search_for }}">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
|
||||
{% if search_for %}
|
||||
|
||||
<h3>Talks</h3>
|
||||
|
||||
<p>Found {{ events.count() }} events matching '{{ search_for }}'</p>
|
||||
|
||||
{% for event in events %}
|
||||
<div>
|
||||
<p>
|
||||
🎤
|
||||
<a href="{{ url_for("event_page", event_id=event.id) }}">{{ event.title }}</a><br>
|
||||
Speakers:
|
||||
{% for p in event.people %}
|
||||
👤
|
||||
<a href="{{ url_for("person", person_id=p.id) }}">{{ p.name }}</a>
|
||||
{% endfor %}<br>
|
||||
|
||||
👥 <a href="{{ url_for("conference_page", short_name=event.conference.short_name) }}">{{ event.conference.title }}</a><br>
|
||||
|
||||
{% if event.event_date %}
|
||||
📅 {{ event.event_date.strftime("%a, %d %b %Y at %H:%M") }}
|
||||
{% else %}
|
||||
event date missing
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% if event.abstract %}
|
||||
<p class="card-text">
|
||||
{% if "<" in event.abstract %}
|
||||
{{ event.abstract | safe }}
|
||||
{% else %}
|
||||
{% for line in event.abstract.splitlines() %}
|
||||
{{ line }}<br>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if event.description and event.description != event.abstract %}
|
||||
<p class="card-text">
|
||||
{% if "<" in event.description %}
|
||||
{{ event.description | safe }}
|
||||
{% else %}
|
||||
{% for line in event.description.splitlines() %}
|
||||
{{ line }}<br>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<h3>People</h3>
|
||||
<p>
|
||||
Found {{ people.count() }} people matching '{{ search_for }}'
|
||||
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
|
||||
{% for item in people %}
|
||||
<li>
|
||||
<a href="{{ url_for("person", person_id=item.id) }}">{{ item.name }}</a>
|
||||
{% if item.wikidata_qid %}
|
||||
—
|
||||
<a href="https://www.wikidata.org/wiki/{{ item.wikidata_qid }}">{{ item.wikidata_qid }} on Wikidata</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
44
confarchive/templates/search_people.html
Normal file
44
confarchive/templates/search_people.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Conference archive</h1>
|
||||
<p><a href="{{ url_for("index") }}">home</a></p>
|
||||
|
||||
<form action="{{ url_for("search_people") }}">
|
||||
<div class="mb-3">
|
||||
<label for="q" class="form-label">speaker name</label>
|
||||
<input type="text" class="form-control" name="q" id="q" value="{{ search_for }}">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
|
||||
<p>
|
||||
{% set count = q.count() %}
|
||||
Found {{ count }} people matching '{{ search_for }}'
|
||||
|
||||
{% if is_admin() and count %}
|
||||
<a href="{{ url_for("merge", q=search_for) }}">merge</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
|
||||
{% for item in q %}
|
||||
<li>
|
||||
<a href="{{ url_for("person", person_id=item.id) }}">{{ item.name }}</a>
|
||||
{% if item.wikidata_qid %}
|
||||
—
|
||||
<a href="https://www.wikidata.org/wiki/{{ item.wikidata_qid }}">{{ item.wikidata_qid }} on Wikidata</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
38
confarchive/templates/series/list.html
Normal file
38
confarchive/templates/series/list.html
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Series – Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Conference archive</h1>
|
||||
|
||||
<p>{{ items.count() }} series found</p>
|
||||
{% for item in items %}
|
||||
<h3>{{ item.name }}</h3>
|
||||
{% for conf in item.conferences %}
|
||||
|
||||
<div style="margin-bottom:1.5rem">
|
||||
👥
|
||||
<a href="{{ url_for("conference_page", short_name=conf.short_name) }}">{{ conf.title }}</a>
|
||||
📅
|
||||
{{ conf.start.strftime("%d %b %Y") }}
|
||||
<br/>
|
||||
{% if conf.venue %}
|
||||
📍
|
||||
{{ conf.venue.name }}
|
||||
–
|
||||
{{ conf.venue.city.name }},
|
||||
{{ conf.venue.city.country.name }}
|
||||
{{ conf.venue.city.country.flag }}
|
||||
<br/>
|
||||
{% endif %}
|
||||
|
||||
{{ (conf.end - conf.start).days + 1 }} days,
|
||||
{{ conf.events.count() }} talks,
|
||||
{{ conf.people_detail.count() }} speakers<br/>
|
||||
</div>
|
||||
|
||||
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
36
confarchive/templates/top_events.html
Normal file
36
confarchive/templates/top_events.html
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Conference archive</h1>
|
||||
<p><a href="{{ url_for("index") }}">home</a></p>
|
||||
|
||||
<h3>Top events</h3>
|
||||
|
||||
<form action="{{ url_for("events_page") }}">
|
||||
<div class="mb-3">
|
||||
<label for="q" class="form-label">event</label>
|
||||
<input type="text" class="form-control" name="q" id="q">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
|
||||
<ul>
|
||||
{% for event_title, count in top_events %}
|
||||
<li>
|
||||
<a href="{{ url_for("events_page", q=event_title) }}">{{ event_title }}</a>
|
||||
({{ count }})
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
103
confarchive/templates/top_speakers.html
Normal file
103
confarchive/templates/top_speakers.html
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block style %}
|
||||
<style>
|
||||
.person {
|
||||
display: flex;
|
||||
align-items: top;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.info {
|
||||
flex: 1; /* Allow text to take remaining space */
|
||||
padding-right: 10px; /* Add spacing between text and image */
|
||||
}
|
||||
|
||||
img.photo {
|
||||
max-width: 120px; /* Set max width for images */
|
||||
height: auto; /* Maintain image aspect ratio */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% set show_images = False %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
|
||||
{% if show_images %}
|
||||
|
||||
<div class="left-images">
|
||||
{% for person, photo in left_photos %}
|
||||
<div class="image-container" id="image-{{person.id}}">
|
||||
<a href="{{ url_for("person", person_id=person.id) }}">
|
||||
<img class="image" src="{{ url_for("static", filename=photo) }}" alt="{{ person.name}}" title="{{ person.name}}">
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="right-images">
|
||||
{% for person, photo in right_photos %}
|
||||
<div class="image-container">
|
||||
<a href="{{ url_for("person", person_id=person.id) }}">
|
||||
<img id="image-{{person.id}}" class="image" src="{{ url_for("static", filename=photo) }}" alt="{{ person.name}}" title="{{ person.name}}">
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<h1>Conference archive</h1>
|
||||
|
||||
<form action="{{ url_for("search_people") }}">
|
||||
<div class="mb-3">
|
||||
<label for="q" class="form-label">speaker name</label>
|
||||
<input type="text" class="form-control" name="q" id="q">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
|
||||
<h3>Speaker/conference frequency distribution</h3>
|
||||
|
||||
<p>Distribution of speakers by conference count.</p>
|
||||
{% for conf_count, speaker_count in speaker_counts %}
|
||||
<div>
|
||||
{{ plural(conf_count, "conference") }}:
|
||||
{{ plural(speaker_count, "speaker") }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<h3>Top speakers</h3>
|
||||
<ul>
|
||||
|
||||
{% for person, count in top_speakers %}
|
||||
{% if loop.first or loop.previtem[1] != count %}
|
||||
<h4>{{ count }} conferences</h4>
|
||||
{% endif %}
|
||||
<div class="person">
|
||||
{% set photo = person.photo_filename() %}
|
||||
<span class="info" id="person-{{ person.id }}">
|
||||
👤
|
||||
<a href="{{ url_for("person", person_id=person.id) }}">{{ person.name }}</a><br>
|
||||
({{ count }} conferences, {{ person.event_count }} talks)
|
||||
{% if person.photo_filename() %}📷{% endif %}
|
||||
{% if person.wikidata_qid %}
|
||||
<a href="https://www.wikidata.org/wiki/{{ person.wikidata_qid }}">Wikidata</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% if photo %}
|
||||
<img class="photo" src="{{ url_for("static", filename=photo) }}" alt="{{ person.name }}">
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
33
confarchive/templates/wikidata.html
Normal file
33
confarchive/templates/wikidata.html
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Conference archive{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Conference archive</h1>
|
||||
|
||||
{% for person, count, wikidata_hits in items %}
|
||||
<div>
|
||||
<h4><a href="{{ url_for("person", person_id=person.id) }}">{{ person.name }}</a> ({{ count }})</h4>
|
||||
<ul>
|
||||
{% for hit in wikidata_hits %}
|
||||
<li>
|
||||
<a href="https://www.wikidata.org/wiki/{{ hit.qid }}">{{ hit.qid }}</a>
|
||||
{{ hit.label }} — {{ hit.description }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block style %}
|
||||
<style>
|
||||
.searchmatch { background: lightgreen }
|
||||
</style>
|
||||
{% endblock %}
|
||||
506
confarchive/view.py
Executable file
506
confarchive/view.py
Executable file
|
|
@ -0,0 +1,506 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
|
||||
import flask
|
||||
from sqlalchemy import func, or_, update
|
||||
from werkzeug.wrappers import Response
|
||||
|
||||
from confarchive import database, model, wikidata, query, utils
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
app.debug = True
|
||||
|
||||
app.config.from_object("config.default")
|
||||
database.init_app(app)
|
||||
|
||||
|
||||
@app.route("/person/<int:person_id>", methods=["GET", "POST"])
|
||||
def person(person_id: int) -> str | Response:
|
||||
item = model.Person.query.get(person_id)
|
||||
if flask.request.method == "POST" and check_admin_mode():
|
||||
qid = flask.request.form["wikidata_qid"] or None
|
||||
item.name = flask.request.form["name"]
|
||||
|
||||
if qid and qid != item.wikidata_qid:
|
||||
item.wikidata_qid = qid
|
||||
wd_item = wikidata.get_item(qid)
|
||||
if "P18" in wd_item["claims"]:
|
||||
claim_p18 = wd_item["claims"]["P18"]
|
||||
wikidata_photo = [
|
||||
utils.drop_start(s["mainsnak"]["datavalue"]["value"], "-")
|
||||
for s in claim_p18
|
||||
]
|
||||
for filename in wikidata_photo:
|
||||
print(filename)
|
||||
wikidata.get_photo(filename)
|
||||
item.wikidata_photo = wikidata_photo
|
||||
|
||||
database.session.commit()
|
||||
assert flask.request.endpoint
|
||||
return flask.redirect(
|
||||
flask.url_for(flask.request.endpoint, person_id=person_id)
|
||||
)
|
||||
|
||||
wikidata_hits: list[dict[str, str]] = []
|
||||
if False and item.wikidata_qid is None:
|
||||
q = item.name + " haswbstatement:P31=Q5"
|
||||
search_hits = wikidata.search(q)
|
||||
print(len(search_hits))
|
||||
for search_hit in search_hits:
|
||||
qid = search_hit["title"]
|
||||
wd_item = wikidata.get_item(qid)
|
||||
if "en" in wd_item["labels"]:
|
||||
label = wd_item["labels"]["en"]["value"]
|
||||
else:
|
||||
label = "[no english label]"
|
||||
|
||||
if "en" in wd_item["descriptions"]:
|
||||
description = wd_item["descriptions"]["en"]["value"]
|
||||
else:
|
||||
description = "[no english description]"
|
||||
|
||||
wikidata_hits.append(
|
||||
{
|
||||
"qid": qid,
|
||||
"label": label,
|
||||
"description": description,
|
||||
}
|
||||
)
|
||||
|
||||
return flask.render_template(
|
||||
"person.html",
|
||||
item=item,
|
||||
Event=model.Event,
|
||||
plural=utils.plural,
|
||||
wikidata_hits=wikidata_hits,
|
||||
is_admin=check_admin_mode,
|
||||
)
|
||||
|
||||
|
||||
@app.route("/person/<int:person_id>/split", methods=["GET", "POST"])
|
||||
def split_person(person_id: int) -> str | Response:
|
||||
"""Split person."""
|
||||
item = model.Person.query.get(person_id)
|
||||
assert not item.wikidata_qid
|
||||
if flask.request.method == "GET":
|
||||
return flask.render_template(
|
||||
"person/split.html",
|
||||
item=item,
|
||||
)
|
||||
|
||||
names = flask.request.form["names"].strip().splitlines()
|
||||
print(names)
|
||||
assert len(names) > 1
|
||||
|
||||
item.name = names[0]
|
||||
for cp in item.conferences_association:
|
||||
cp.named_as = names[0]
|
||||
|
||||
for num, name in enumerate(names[1:], start=2):
|
||||
person = model.Person(name=name)
|
||||
database.session.add(person)
|
||||
|
||||
for cp0 in item.conferences_association:
|
||||
cp = model.ConferencePerson(
|
||||
person=person, named_as=name, conference_id=cp0.conference_id
|
||||
)
|
||||
database.session.add(cp)
|
||||
|
||||
for event0 in item.events_association:
|
||||
ep = model.EventPerson(
|
||||
person=person, event_id=event0.event_id, position=num
|
||||
)
|
||||
database.session.add(ep)
|
||||
|
||||
database.session.commit()
|
||||
|
||||
return flask.redirect(flask.url_for("person", person_id=person_id))
|
||||
|
||||
|
||||
@app.route("/event/<int:event_id>")
|
||||
def event_page(event_id: int) -> str:
|
||||
item = model.Event.query.get(event_id)
|
||||
return flask.render_template("event.html", item=item)
|
||||
|
||||
|
||||
@app.route("/conference/<short_name>", methods=["GET", "POST"])
|
||||
def conference_page(short_name: str) -> str | Response:
|
||||
item = model.Conference.query.filter_by(short_name=short_name).one_or_none()
|
||||
if item is None:
|
||||
flask.abort(404)
|
||||
|
||||
if flask.request.method == "POST" and check_admin_mode():
|
||||
item.short_name = flask.request.form["short_name"]
|
||||
item.title = flask.request.form["title"]
|
||||
database.session.commit()
|
||||
|
||||
assert flask.request.endpoint
|
||||
return flask.redirect(
|
||||
flask.url_for(flask.request.endpoint, short_name=item.short_name)
|
||||
)
|
||||
|
||||
return flask.render_template(
|
||||
"conference.html",
|
||||
item=item,
|
||||
person_image_filename=person_image_filename,
|
||||
is_admin=check_admin_mode,
|
||||
)
|
||||
|
||||
|
||||
@app.route("/people")
|
||||
def search_people() -> str:
|
||||
search_for = flask.request.args["q"]
|
||||
assert search_for
|
||||
search_for = search_for.strip()
|
||||
q = model.Person.query.filter(model.Person.name.ilike(f"%{search_for}%")).order_by(
|
||||
model.Person.name
|
||||
)
|
||||
return flask.render_template(
|
||||
"search_people.html", q=q, search_for=search_for, is_admin=check_admin_mode
|
||||
)
|
||||
|
||||
|
||||
@app.route("/merge", methods=["GET", "POST"])
|
||||
def merge() -> str | Response:
|
||||
"""Merge speakers."""
|
||||
assert check_admin_mode()
|
||||
|
||||
if flask.request.method == "GET":
|
||||
search_for = flask.request.args["q"]
|
||||
assert search_for
|
||||
search_for = search_for.strip()
|
||||
q = query.search_for_people(search_for)
|
||||
return flask.render_template("merge_people.html", q=q, search_for=search_for)
|
||||
|
||||
assert flask.request.method == "POST"
|
||||
search_for = flask.request.form["q"]
|
||||
|
||||
item_ids_str = flask.request.form.getlist("person_id")
|
||||
item_ids: list[int] = [int(i) for i in item_ids_str]
|
||||
|
||||
merge_to_id: int = min(item_ids)
|
||||
other_ids = [i for i in item_ids if i != merge_to_id]
|
||||
|
||||
name_from_person_id = int(flask.request.form["name"])
|
||||
|
||||
print(other_ids, "->", merge_to_id)
|
||||
|
||||
conference_people = model.ConferencePerson.query.filter(
|
||||
model.ConferencePerson.person_id.in_(other_ids)
|
||||
)
|
||||
|
||||
with database.session.begin():
|
||||
merge_to = model.Person.query.get(merge_to_id)
|
||||
existing_conferences = {conf.id for conf in merge_to.conferences}
|
||||
to_delete = [
|
||||
cp for cp in conference_people if cp.conference_id in existing_conferences
|
||||
]
|
||||
for cp in to_delete:
|
||||
database.session.delete(cp)
|
||||
|
||||
if merge_to_id != name_from_person_id:
|
||||
name_from_person = model.Person.query.get(name_from_person_id)
|
||||
merge_to.name = name_from_person.name
|
||||
|
||||
print("update ConferencePerson")
|
||||
database.session.execute(
|
||||
update(model.ConferencePerson)
|
||||
.where(model.ConferencePerson.person_id.in_(other_ids))
|
||||
.values(person_id=merge_to_id)
|
||||
)
|
||||
|
||||
print("update EventPerson")
|
||||
database.session.execute(
|
||||
update(model.EventPerson)
|
||||
.where(model.EventPerson.person_id.in_(other_ids))
|
||||
.values(person_id=merge_to_id)
|
||||
)
|
||||
|
||||
print("delete people")
|
||||
for person_id in other_ids:
|
||||
item = model.Person.query.get(person_id)
|
||||
database.session.delete(item)
|
||||
|
||||
endpoint = flask.request.endpoint
|
||||
assert endpoint
|
||||
return flask.redirect(flask.url_for(endpoint, q=search_for))
|
||||
|
||||
|
||||
@app.route("/events")
|
||||
def events_page() -> str:
|
||||
"""Events page."""
|
||||
search_for = flask.request.args.get("q")
|
||||
if search_for:
|
||||
q = query.search_for_events(search_for)
|
||||
return flask.render_template("search_events.html", q=q, search_for=search_for)
|
||||
else:
|
||||
return flask.render_template("top_events.html", top_events=query.top_events())
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def index() -> str:
|
||||
"""Start page."""
|
||||
q = model.Conference.query.order_by(model.Conference.start.desc())
|
||||
|
||||
count = {
|
||||
"conference": model.Conference.query.count(),
|
||||
"event": model.Event.query.count(),
|
||||
"person": model.Person.query.count(),
|
||||
"country": model.Country.query.count(),
|
||||
"venue": model.Venue.query.count(),
|
||||
}
|
||||
|
||||
return flask.render_template("index.html", items=q, count=count)
|
||||
|
||||
|
||||
@app.route("/series")
|
||||
def list_series() -> str:
|
||||
"""Page showing list of conference series."""
|
||||
items = model.Series.query
|
||||
|
||||
return flask.render_template("series/list.html", items=items)
|
||||
|
||||
|
||||
@app.route("/speakers")
|
||||
def top_speakers_page() -> str:
|
||||
"""Top speakers page."""
|
||||
top = query.top_speakers().having(func.count() > 4)
|
||||
|
||||
return flask.render_template(
|
||||
"top_speakers.html",
|
||||
top_speakers=top,
|
||||
speaker_counts=query.speaker_counts(),
|
||||
plural=utils.plural,
|
||||
person_image_filename=person_image_filename,
|
||||
)
|
||||
|
||||
|
||||
@app.route("/country")
|
||||
def country_list() -> str:
|
||||
"""Country list."""
|
||||
return flask.render_template("country_list.html", items=model.Country.query)
|
||||
|
||||
|
||||
@app.route("/city/<int:city_id>/venue/new", methods=["GET", "POST"])
|
||||
def add_venue(city_id: int) -> str | Response:
|
||||
"""Add new venue."""
|
||||
city = model.City.query.get(city_id)
|
||||
if flask.request.method != "POST":
|
||||
return flask.render_template("add_venue.html", city=city)
|
||||
|
||||
name = flask.request.form["name"]
|
||||
wikidata_qid = flask.request.form["wikidata_qid"]
|
||||
venue = model.Venue(name=name, city=city, wikidata_qid=wikidata_qid)
|
||||
database.session.add(venue)
|
||||
database.session.commit()
|
||||
|
||||
endpoint = flask.endpoint
|
||||
return flask.redirect(flask.url_for(endpoint))
|
||||
|
||||
|
||||
@app.route("/wikidata")
|
||||
def link_to_wikidata() -> str:
|
||||
items = []
|
||||
top = (
|
||||
query.top_speakers()
|
||||
.filter(model.Person.name.like("% %"), model.Person.wikidata_qid.is_(None))
|
||||
.having(func.count() > 2)
|
||||
)
|
||||
for person, num in top:
|
||||
search_hits = wikidata.search(person.name + " haswbstatement:P31=Q5")
|
||||
if not search_hits:
|
||||
continue
|
||||
|
||||
if len(search_hits) > 14:
|
||||
continue
|
||||
|
||||
hits = []
|
||||
|
||||
for search_hit in search_hits:
|
||||
qid = search_hit["title"]
|
||||
item = wikidata.get_item(qid)
|
||||
if "en" in item["labels"]:
|
||||
label = item["labels"]["en"]["value"]
|
||||
else:
|
||||
label = "[no english label]"
|
||||
|
||||
if "en" in item["descriptions"]:
|
||||
description = item["descriptions"]["en"]["value"]
|
||||
else:
|
||||
description = "[no english description]"
|
||||
|
||||
hits.append(
|
||||
{
|
||||
"qid": qid,
|
||||
"label": label,
|
||||
"description": description,
|
||||
}
|
||||
)
|
||||
|
||||
items.append((person, num, hits))
|
||||
|
||||
return flask.render_template("wikidata.html", items=items)
|
||||
|
||||
|
||||
@app.route("/search")
|
||||
def search_everything() -> str:
|
||||
search_for = flask.request.args.get("q")
|
||||
if not search_for:
|
||||
return flask.render_template("search_everything.html")
|
||||
|
||||
search_for = search_for.strip()
|
||||
like = f"%{search_for}%"
|
||||
|
||||
people = model.Person.query.filter(model.Person.name.ilike(like)).order_by(
|
||||
model.Person.name
|
||||
)
|
||||
|
||||
events = model.Event.query.filter(
|
||||
or_(model.Event.abstract.ilike(like), model.Event.description.ilike(like))
|
||||
).order_by(model.Event.event_date)
|
||||
|
||||
return flask.render_template(
|
||||
"search_everything.html", people=people, events=events, search_for=search_for
|
||||
)
|
||||
|
||||
|
||||
@app.route("/person/<int:person_id>/delete", methods=["POST"])
|
||||
def delete_person(person_id: int) -> str | Response:
|
||||
assert app.config["ADMIN_MODE"]
|
||||
|
||||
item = model.Person.query.get(person_id)
|
||||
|
||||
for cp in item.conferences_association:
|
||||
database.session.delete(cp)
|
||||
|
||||
for ep in item.events_association:
|
||||
database.session.delete(ep)
|
||||
database.session.delete(item)
|
||||
|
||||
database.session.commit()
|
||||
|
||||
return flask.redirect(flask.url_for("index"))
|
||||
|
||||
|
||||
def person_image_filename(person_id: int) -> str:
|
||||
"""Filename for speaker photo."""
|
||||
person = model.Person.query.get(person_id)
|
||||
return os.path.join("wikidata_photo", "thumb", person.wikidata_photo[0])
|
||||
|
||||
for filename in person.wikidata_photo:
|
||||
face_crop = "face_1_" + filename
|
||||
full = os.path.join("static", "wikidata_photo", "face_cropped", face_crop)
|
||||
if os.path.exists(full):
|
||||
return os.path.join("wikidata_photo", "face_cropped", face_crop)
|
||||
|
||||
return os.path.join("wikidata_photo", "thumb", person.wikidata_photo[0])
|
||||
|
||||
|
||||
@app.route("/login", methods=["GET", "POST"])
|
||||
def login() -> str | Response:
|
||||
"""Login page."""
|
||||
if flask.request.method == "GET":
|
||||
return flask.render_template("login.html")
|
||||
password = flask.request.form["password"]
|
||||
if password != app.config["ADMIN_PASSWORD"]:
|
||||
endpoint = flask.endpoint
|
||||
return flask.redirect(endpoint)
|
||||
|
||||
flask.session["admin_password"] = password
|
||||
return flask.redirect(flask.url_for("index"))
|
||||
|
||||
|
||||
def check_admin_mode() -> bool:
|
||||
"""User is an admin."""
|
||||
return bool(flask.session.get("admin_password") == app.config["ADMIN_PASSWORD"])
|
||||
|
||||
|
||||
@app.route("/github_wikidata")
|
||||
def github_wikidata() -> str:
|
||||
"""Look for speakers on Wikidata based on the GitHub property."""
|
||||
items = []
|
||||
for line in open("found_wikidata_github"):
|
||||
person_id, person_name, qid, wd_name, github, desc = eval(line)
|
||||
person = model.Person.query.get(person_id)
|
||||
if person.wikidata_qid:
|
||||
continue
|
||||
items.append((person, qid, wd_name, desc))
|
||||
|
||||
items.sort(key=lambda i: len(i[0].name))
|
||||
|
||||
return flask.render_template("github.html", items=items)
|
||||
|
||||
|
||||
@app.route("/reports")
|
||||
def reports_page() -> str:
|
||||
"""Page showing statistics."""
|
||||
event_count = model.Event.query.count()
|
||||
|
||||
missing_event_date_count = model.Event.query.filter(
|
||||
model.Event.event_date.is_(None)
|
||||
).count()
|
||||
|
||||
speaker_count = model.Person.query.count()
|
||||
no_bio_count = (
|
||||
model.Person.query.join(model.ConferencePerson)
|
||||
.filter(model.ConferencePerson.bio.is_(None))
|
||||
.group_by(model.Person)
|
||||
.count()
|
||||
)
|
||||
one_bio_count = (
|
||||
model.Person.query.join(model.ConferencePerson)
|
||||
.group_by(model.Person)
|
||||
.filter(model.ConferencePerson.bio.isnot(None))
|
||||
.having(func.count() == 1)
|
||||
.count()
|
||||
)
|
||||
|
||||
multiple_bio = (
|
||||
model.Person.query.join(model.ConferencePerson)
|
||||
.group_by(model.Person)
|
||||
.filter(model.ConferencePerson.bio.isnot(None))
|
||||
.having(func.count() > 1)
|
||||
)
|
||||
|
||||
shorter_recent_bio = []
|
||||
for person in multiple_bio:
|
||||
bio_with_date = sorted(
|
||||
[
|
||||
(cp.conference.start, cp.bio)
|
||||
for cp in person.conferences_association
|
||||
if cp.bio
|
||||
],
|
||||
reverse=True,
|
||||
)
|
||||
|
||||
if len(bio_with_date) < 2:
|
||||
continue
|
||||
|
||||
most_recent_bio = bio_with_date[0][1]
|
||||
len_recent_bio = len(most_recent_bio)
|
||||
longest = max(len(bio) for start, bio in bio_with_date[1:])
|
||||
|
||||
if longest > len_recent_bio * 2:
|
||||
shorter_recent_bio.append((person, len_recent_bio, longest))
|
||||
|
||||
return flask.render_template(
|
||||
"reports.html",
|
||||
event_count=event_count,
|
||||
speaker_count=speaker_count,
|
||||
no_bio_count=no_bio_count,
|
||||
one_bio_count=one_bio_count,
|
||||
multiple_bio_count=multiple_bio.count(),
|
||||
shorter_recent_bio=shorter_recent_bio,
|
||||
missing_event_date_count=missing_event_date_count,
|
||||
missing_event_date=model.Event.query.filter(
|
||||
model.Event.event_date.is_(None)
|
||||
).order_by(model.Event.title),
|
||||
no_venue_count=model.Conference.query.filter(
|
||||
model.Conference.venue_id.is_(None), model.Conference.online.isnot(True)
|
||||
).count(),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5002)
|
||||
Loading…
Add table
Add a link
Reference in a new issue