-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use jinja2 instead of manual HTML templating (#2)
* Add jinja as a dependency for litestar * Switch manual HTML templating to jinja2 * Replace 412 status code with 404 There are no preconditions set in the headers so using this status code here makes no sense. * Update running instructions * Add JavaScript to hide columns * Update method of finding common anime * Use lower instead of casefold Casefold is a more expensive algorithm since it's unicode aware and there's no purpose in supporting that when everything else uses lower()
- Loading branch information
Showing
4 changed files
with
92 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Anilist common anime tool</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content="{{ description }}"> | ||
</head> | ||
<body> | ||
<table> | ||
<button data-column="romaji">Toggle Romaji</button> | ||
<button data-column="english">Toggle English</button> | ||
<button data-column="native">Toggle Native</button> | ||
<thead> | ||
<tr> | ||
<th>Media ID</th> | ||
<th>Romaji</th> | ||
<th>English</th> | ||
<th>Native</th> | ||
</tr> | ||
</thead> | ||
<colgroup> | ||
<col> | ||
<col id="romaji"> | ||
<col id="english"> | ||
<col id="native"> | ||
</colgroup> | ||
<tbody> | ||
{% for entry in entries %} | ||
<tr> | ||
<td>{{ entry['id'] }}</td> | ||
<td><a href="{{ entry['siteUrl'] }}">{{ entry['title']['romaji'] }}</a></td> | ||
<td><a href="{{ entry['siteUrl'] }}">{{ entry['title']['english'] }}</a></td> | ||
<td><a href="{{ entry['siteUrl'] }}">{{ entry['title']['native'] }}</a></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</body> | ||
<script> | ||
const toggles = document.querySelectorAll('button'); | ||
|
||
const toggle_setting = (setting) => { | ||
if (localStorage.getItem(setting)) { | ||
localStorage.removeItem(setting); | ||
document.getElementById(setting).style.removeProperty('visibility'); | ||
} else { | ||
localStorage.setItem(setting, '1') | ||
document.getElementById(setting).style.setProperty('visibility', 'collapse'); | ||
} | ||
} | ||
|
||
toggles.forEach(button => { | ||
button.addEventListener('click', () => toggle_setting(button.dataset.column)) | ||
}) | ||
|
||
for (const column of ['romaji', 'english', 'native']) | ||
if (localStorage.getItem(column)) | ||
document.getElementById(column).style.setProperty('visibility', 'collapse'); | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters