diff --git a/etc/TODO.md b/etc/TODO.md index 24a245c1fecfc32aefba8565f50fcf13f008a6f3..89d2a13bbccec7e8a80f0a8adf4ee5dde6b7e598 100644 --- a/etc/TODO.md +++ b/etc/TODO.md @@ -5,4 +5,5 @@ * https://www.linode.com/docs/guides/task-queue-celery-rabbitmq/ * https://suzannewang.com/celery-rabbitmq-tutorial/ - +## Jinja +* https://jinja.palletsprojects.com/en/2.11.x/templates/ diff --git a/templates/fragment_pagination.html b/templates/fragment_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..e54202b7bf1202d66980f55fa1d1bf7984a64a91 --- /dev/null +++ b/templates/fragment_pagination.html @@ -0,0 +1,43 @@ +{% macro pagination_for_url( url_for_pagination ) -%} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( url_for_pagination, country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( url_for_pagination, country_id=who_country.id, page=page_num) }}"> + {{ page_num }} + </a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( url_for_pagination, country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {%- endmacro %} \ No newline at end of file diff --git a/templates/layout.html b/templates/layout.html index 12a19b081a643dfdaec4ab9964257d38f9eeac86..5fb0b177fb79a6a4b2bfb065a4cddb38a212217d 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -14,24 +14,29 @@ <title>{{page_info.title}}</title> <style> .pagination-page-info { - padding: .6em; - padding-left: 0; + padding: .6em .6em .6em 0em; + /* padding-left: 0; */ width: 40em; - margin: .5em; - margin-left: 0; + margin: .5em .5em .5em 0em; + /*margin-left: 0;*/ font-size: 12px; } .pagination-page-info b { color: black; background: #6aa6ed; - padding-left: 2px; - padding: .1em .25em; + /*padding-left: 2px;*/ + padding: .1em .25em .1em .25em; font-size: 150%; } .jumbotron { padding: 1rem 1rem; margin-bottom: 1rem; } + .my-page-item-ellipsis-page-link { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } </style> </head> <body> diff --git a/templates/who/who_country_all.html b/templates/who/who_country_all.html index 4d6657865c1aacbc2133665c4b49f1bd633ed168..55f1d0969f7c7911cf05e5768e8dbea4bc1122e1 100644 --- a/templates/who/who_country_all.html +++ b/templates/who/who_country_all.html @@ -1,5 +1,7 @@ {% extends 'layout.html' %} +{% include 'fragment_pagination.html' %} + {% block navigation_breadcrumb %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> diff --git a/templates/who/who_date_reported_all.html b/templates/who/who_date_reported_all.html index 7830d00712facd8df6c1a964047c07346afcea10..fc0bd1041718efc8ab1cc18ee1568b89019520d0 100644 --- a/templates/who/who_date_reported_all.html +++ b/templates/who/who_date_reported_all.html @@ -1,5 +1,7 @@ {% extends 'layout.html' %} +{% include 'fragment_pagination.html' %} + {% block navigation_breadcrumb %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> diff --git a/templates/who/who_date_reported_one.html b/templates/who/who_date_reported_one.html index f8df7c0c2c9d3daac1bd92a9fffdc98b7ae21f87..e215ebdca44577d58e6de0f3daf027ab52daac76 100644 --- a/templates/who/who_date_reported_one.html +++ b/templates/who/who_date_reported_one.html @@ -1,5 +1,7 @@ {% extends 'layout.html' %} +{% include 'fragment_pagination.html' %} + {% block navigation_breadcrumb %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> diff --git a/templates/who/who_imported.html b/templates/who/who_imported.html index a9618e12b0544a4a283e3013f0c228217c016d5f..e87f3082e77c57f6e4cd6a34f6e46034ac167e8f 100644 --- a/templates/who/who_imported.html +++ b/templates/who/who_imported.html @@ -1,5 +1,7 @@ {% extends 'layout.html' %} +{% include 'fragment_pagination.html' %} + {% block navigation_breadcrumb %} {% endblock %} diff --git a/templates/who/who_region_all.html b/templates/who/who_region_all.html index ae7d7fb185113428759e1d486e01a61784907d67..2e26937e06262dc76cf4cbf08710251d6056d016 100644 --- a/templates/who/who_region_all.html +++ b/templates/who/who_region_all.html @@ -1,5 +1,7 @@ {% extends 'layout.html' %} +{% include 'fragment_pagination.html' %} + {% block navigation_breadcrumb %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> diff --git a/templates/who/who_region_countries.html b/templates/who/who_region_countries.html index de979be0267864c92d9d8a341c05ad6c719802e9..71bb6c57212e8f504eb2fc39d3280b43d339435c 100644 --- a/templates/who/who_region_countries.html +++ b/templates/who/who_region_countries.html @@ -1,5 +1,7 @@ {% extends 'layout.html' %} +{% include 'fragment_pagination.html' %} + {% block navigation_breadcrumb %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> diff --git a/templates/who/who_region_country.html b/templates/who/who_region_country.html index 79fa117baa47d2f96ef7898c0b425b5025a5ba48..ddfc9839751ded792ea884970251219aa44571d9 100644 --- a/templates/who/who_region_country.html +++ b/templates/who/who_region_country.html @@ -1,5 +1,7 @@ {% extends 'layout.html' %} +{% include 'fragment_pagination.html' %} + {% block navigation_breadcrumb %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> @@ -52,6 +54,8 @@ </ul> {% endif %} + {{ pagination_for_url(url_for_pagination) }} + <table class="table table-hover table-striped"> <thead> <tr> @@ -60,54 +64,29 @@ <th scope="col">cases_new</th> <th scope="col">deaths_cumulative</th> <th scope="col">cases_cumulative</th> + <th scope="col">country_code</th> + <th scope="col">country</th> + <th scope="col">region</th> </tr> </thead> <tbody> {% for who_global_data in page_data.items %} <tr> - <td>{{ who_global_data.date_reported }}</td> + <th><a href="/who/date_reported/{{ who_global_data.date_reported_id }}">{{ who_global_data.date_reported }}</a></th> <td>{{ who_global_data.deaths_new }}</td> <td>{{ who_global_data.cases_new }}</td> <td>{{ who_global_data.deaths_cumulative }}</td> <td>{{ who_global_data.cases_cumulative }}</td> + <td>{{ who_global_data.country.country_code }}</td> + <td>{{ who_global_data.country.country }}</td> + <td>{{ who_global_data.country.region.region }}</td> </tr> {% endfor %} </tbody> </table> + {{ pagination_for_url(url_for_pagination) }} - <!-- previous page --> - <ul class="pagination"> - {% if page_data.has_prev %} - <li class="page-item"> - <a class="page-link" href="{{ url_for('url_who_region_country', country_id=who_country.id , page=page_data.prev_num) }}">Previous</a> - </li> - {% endif %} - <!-- all page numbers --> - {% for page_num in page_data.iter_pages() %} - {% if page_num %} - {% if page_num != page_data.page %} - <li class="page-item"> - <a class="page-link" href="{{ url_for('url_who_region_country', country_id=who_country.id ,page=page_num) }}">{{ page_num }}</a> - </li> - {% else %} - <li class="page-item active"> - <a class="page-link" href="#">{{ page_num }}</a> - </li> - {% endif %} - {% else %} - <li class="page-item"> - <span class="ellipsis page-link" style="white-space; nowrap; overflow: hidden; text-overflow: ellipsis">…</span> - </li> - {% endif %} - {% endfor %} - <!-- next page --> - {% if page_data.has_next %} - <li class="page-item"> - <a class="page-link" href="{{ url_for('url_who_region_country', country_id=who_country.id , page=page_data.next_num) }}">Next</a> - </li> - {% endif %} - </ul> {% endblock %}