You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

resources.html 4.2KB

1 年之前
1 年之前
1 年之前
1 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. {% extends 'base.html' %}
  2. {% block content %}
  3. <!-- <div class="cell-margin">
  4. <div class="mb-8">
  5. <h2>
  6. {% block title %}
  7. {% autoescape false %}
  8. {{ type + 's' | replace(" ","<br>") }}
  9. {% endautoescape %}
  10. {% endblock %}
  11. </h2>
  12. <p>
  13. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget viverra magna. Nam in ante ultricies
  14. purus feugiat vestibulum et ac erat. Donec in sagittis ante. Maecenas non mauris et eros commodo fringilla.
  15. Integer accumsan ullamcorper diam, non rhoncus tellus molestie ut. Maecenas finibus pretium dolor ac sagittis.
  16. </p>
  17. </div>
  18. </div> -->
  19. {% macro filter_dropdown(id, filter, plural='') %}
  20. <select name="{{ id }}">
  21. <option value="" {% if request.args.get(id, '' )=='' %} selected {% endif %}>
  22. {% if plural != '' %}
  23. {{ plural }}
  24. {% else %}
  25. <span class="capitalize bg-red-400">{{ id }}s</span>
  26. {% endif%}
  27. </option>
  28. {% for thing in filter %}
  29. <option value="{{ thing[0] }}" {% if request.args.get(id)==thing[0]|string %} selected {% endif %}>
  30. {{ thing[1] }}
  31. </option>
  32. {% endfor %}
  33. </select>
  34. {% endmacro%}
  35. {% macro filter_dropdown_nokey(id, filter, plural='') %}
  36. <select name="{{ id }}">
  37. <option value="" {% if request.args.get(id, '' )=='' %} selected {% endif %}>
  38. {% if plural != '' %}
  39. {{ plural }}
  40. {% else %}
  41. <span class="capitalize">{{ id }}s</span>
  42. {% endif%}
  43. </option>
  44. {% for thing in filter %}
  45. <option value="{{ thing }}" {% if request.args.get(id)==thing|string %} selected {% endif %}>
  46. {{ thing }}
  47. </option>
  48. {% endfor %}
  49. </select>
  50. {% endmacro%}
  51. <div class="border-b-2 border-black grid lg:grid-cols-[52rem,30rem] content-start">
  52. <div class="mx-4 lg:ml-[13rem] text my-4 lg:my-8 meta lg:max-w-[30rem]">
  53. {{ intro_text|safe }}
  54. </div>
  55. </div>
  56. <form action="{{ url_for(request.endpoint )}}" method="GET" hx-trigger="change" hx-push-url="true">
  57. <input type="hidden" name="view" value="{{ view }}">
  58. <div
  59. class="flex p-4 lg:p-0 flex-col items-start lg:items-center lg:flex-row lg:flex-wrap gap-2 lg:gap-4 min-h-[2rem] mb-8 border-b-2 border-black ">
  60. <div class="-m-4 mb-4 lg:m-0">
  61. {{ view_switch() }}
  62. </div>
  63. {% if practices_filter%}
  64. {{ filter_dropdown('practice', practices_filter, 'Practices') }}
  65. {% endif %}
  66. {% if year_filter %}
  67. {{ filter_dropdown_nokey('year', year_filter, 'Year') }}
  68. {% endif %}
  69. {% if typology_filter %}
  70. {{ filter_dropdown_nokey('typology', typology_filter, 'Typologies') }}
  71. {% endif %}
  72. {% if languages_filter %}
  73. {{ filter_dropdown_nokey('scriptingLanguage', languages_filter, 'Scripting languages') }}
  74. {% endif %}
  75. {% if licenses_filter %}
  76. {{ filter_dropdown_nokey('license', licenses_filter, 'Licenses') }}
  77. {% endif %}
  78. {% if status_filter %}
  79. {{ filter_dropdown_nokey('status', status_filter, 'Maintenance status') }}
  80. {% endif %}
  81. {% if not practices_filter and not year_filter and not typology_filter and not languages_filter and not
  82. licenses_filter and not status_filter %}
  83. {% else %}
  84. <a href="{{ url_for(request.endpoint) }}?view={{ view }}">Reset</a>
  85. {% endif %}
  86. </div>
  87. <div>
  88. {% if view == 'list' %}
  89. {% for resource in resources %}
  90. {{ resource_list(resource, loop) }}
  91. {% endfor %}
  92. {% else %}
  93. {% for resource in resources %}
  94. {{ resource_with_related(resource, loop) }}
  95. {% endfor %}
  96. {% endif %}
  97. </div>
  98. {% macro render_pagination(pagination) %}
  99. <!-- <div class=page-items>
  100. {{ pagination.first }} - {{ pagination.last }} of {{ pagination.total }}
  101. </div> -->
  102. <div class="pagination p-4">
  103. <span class="mr-2">Page</span>
  104. {% for page in pagination.iter_pages() %}
  105. {% if page %}
  106. {% if page != pagination.page %}
  107. <a href="{{ url_for(request.endpoint, page=page) }}{% for key in request.args %}{% if key != 'page' %}&{{ key }}={{ request.args.get(key) }}{% endif %}{% endfor %}"
  108. class="mx-1">{{
  109. page }}</a>
  110. {% else %}
  111. <strong class="mx-1">{{ page }}</strong>
  112. {% endif %}
  113. {% else %}
  114. <span class="ellipsis">…</span>
  115. {% endif %}
  116. {% endfor %}
  117. </div>
  118. {% endmacro %}
  119. {{ render_pagination(resources) }}
  120. </form>
  121. {% endblock %}