games.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. {% import 'templates/video.html' as video %}
  2. {% import 'templates/tags.html' as tags %}
  3. {% macro render_name(name, game, first, show_details) %}
  4. {%- if show_details -%}
  5. {% set link = game.wikilink %}
  6. {%- else -%}
  7. {% set link = "/" + game.slug %}
  8. {%- endif -%}
  9. <dt {% if first %}id="{{ show_id(name) }}"{% endif %} class="searchable">
  10. <a href="{{ link }}">{{ name }}</a>
  11. {% if first %}
  12. {{ tags.render_tag_groups('genres', game.meta['genres']) }}
  13. {{ tags.render_tag_groups('subgenres', game.meta['subgenres']) }}
  14. {{ tags.render_tag_groups('themes', game.meta['themes']) }}
  15. {% if show_details %}
  16. <a class="add-link" href="/add_original.html?data=/{{ game.slug }}/data.json" target="_blank"><i class="far fa-edit"></i>Edit</a>
  17. {% endif %}
  18. {% endif %}
  19. </dt>
  20. {% endmacro %}
  21. {% macro show_id(name) -%}
  22. {{ name | lower | replace(' ', '-') }}
  23. {%- endmacro %}
  24. {% macro show_tags(game) -%}
  25. {%- if 'multiplayer' in game %}
  26. {{ game.tags.append('multiplayer') }}
  27. {% endif -%}
  28. {{ game.tags | join(' ') }}
  29. {%- endmacro %}
  30. {% macro show_keywords_names(names) -%}
  31. {% for n in names -%}
  32. {% if n is not string -%}
  33. {% for i in n -%}
  34. {{ i | normalize -}}{{ ' ' -}}
  35. {% endfor -%}
  36. {% else -%}
  37. {{ n | normalize -}}
  38. {% endif -%}
  39. {{ ' ' -}}
  40. {% endfor -%}
  41. {%- endmacro %}
  42. {% macro show_keywords(game, names, meta) -%}
  43. {{ game.name | normalize -}}{{ ' ' -}}
  44. {{ game.tags | join(' ') | normalize -}}{{ ' ' -}}
  45. {{ game.info | normalize -}}{{ ' ' -}}
  46. {%- if game.new %}
  47. {{ 'new updated added ' -}}
  48. {% endif %}
  49. {%- if 'multiplayer' in game -%}
  50. {{ 'multiplayer ' }}
  51. {%- endif -%}
  52. {{ show_keywords_names(names) }}
  53. {{ show_keywords_names(meta.names_ascii) }}
  54. {%- endmacro %}
  55. {% macro render_clone(names, meta, game, show_details, expand_gallery) %}
  56. <div itemscope="" itemtype="http://schema.org/SoftwareSourceCode">
  57. {%- set show_gallery = show_details and ('images' in game or 'video' in game) -%}
  58. <dd class="searchable
  59. {% if game.new -%}
  60. new
  61. {%- elif game.is_updated -%}
  62. updated
  63. {%- endif -%}"
  64. data-name="{{ game.name }}"
  65. data-parent="
  66. {%- if names.0 is string -%}
  67. {% set name = names.0 %}
  68. {%- else -%}
  69. {% set name = names.0.0 %}
  70. {%- endif -%}
  71. {{ show_id(name) }}"
  72. data-tags="{{ show_tags(game) }}"
  73. data-index="{{ show_keywords(game, names, meta) }}"
  74. data-updated="{{ game.updated }}"
  75. >
  76. <span class="{% if show_gallery %}toggler {% if expand_gallery %}visible{% endif %}{% else %}notoggler{% endif %}">&#x25b6;</span>
  77. {%- if 'url' in game -%}
  78. <a href="{{ game['url'] }}" itemprop="url"><span itemprop="name">{{ game['name'] }}</span></a>
  79. {%- else -%}
  80. <span itemprop="name">{{ game['name'] }}</span>
  81. {%- endif %}
  82. {%- if game.new -%}
  83. <span class="badge-new">NEW</span>
  84. {%- elif game.is_updated -%}
  85. <span class="badge-updated">UPDATED</span>
  86. {%- endif -%}
  87. {%- if 'feed' in game %}
  88. <a href="{{ game['feed'] }}" class="feed-icon" title="Feed"><span class="fas fa-rss"></span></a>
  89. {%- endif %}
  90. {%- if 'repo' in game %}
  91. (
  92. <a itemprop="codeRepository" href="{{ game['repo'] }}">repo
  93. {%- if 'repoiconname' in game %}
  94. <span class="repoicon {{ game['repoiconstyle'] }} fa-{{ game['repoiconname'] }}" title="{{ game['repotitle'] }}"></span>
  95. {%- endif %}
  96. {%- if 'repobadge' in game %}{{ game['repobadge'] }}{%- endif %}
  97. </a>
  98. )
  99. {%- endif %}
  100. {{ tags.render_tag_groups('type', game['type'] | title) if show_details }}
  101. {{ tags.render_tag_groups('status', game['status'] | title) if game['type'] != 'tool' }}
  102. {{ tags.render_tag_groups('development', game['development'] | title) }}
  103. {{ tags.render_tag_groups('langs', game['langs']) }}
  104. {{ tags.render_tag_groups('frameworks', game['frameworks']) if show_details }}
  105. {{ tags.render_tag_groups('content', game['content'] | title) if show_details }}
  106. {{ tags.render_tag_groups('licenses', game['licenses']) }}
  107. {{ tags.render_tag_groups('multiplayer', game['multiplayer']) if 'multiplayer' in game and show_details }}
  108. {% if show_details %}
  109. <a class="add-link" href="/add_game.html?data=_clones/{{ game['name'] | slugify }}.json" target="_blank"><i class="far fa-edit"></i>Edit</a>
  110. {% endif %}
  111. {%- if 'info' in game and show_details %}
  112. <div itemprop="description">{{ game['info'] }}</div>
  113. {% endif %}
  114. {% if show_gallery %}
  115. <div class="gallery" style="display: none;"></div>
  116. {% if game['images'] | length > 0 -%}
  117. <script class="gallery-json" data-game="{{ game['name'] }}" type="text/json">
  118. {{- game['images'] | join(', ') -}}
  119. </script>
  120. {% endif %}
  121. <script class="gallery-raw" type="text/plain">
  122. {% if 'video' in game %}
  123. {% if 'youtube' in game['video'] %}{{ video.render_youtube(game['name'], game['video']['youtube']) }}{% endif %}
  124. {% if 'vimeo' in game['video'] %}{{ video.render_vimeo(game['name'], game['video']['vimeo']) }}{% endif %}
  125. {% if 'moddb' in game['video'] %}{{ video.render_moddb(game['name'], game['video']['moddb']) }}{% endif %}
  126. {% if 'indiedb' in game['video'] %}{{ video.render_indiedb(game['name'], game['video']['indiedb']) }}{% endif %}
  127. {%- endif %}
  128. {% for imageUrl in game.get('images', []) %}
  129. <a
  130. href="{{ imageUrl }}"
  131. data-fancybox="gallery-{{ game['name'] }}"
  132. >
  133. <img class="thumb fa-solid fa-image" src="{{ imageUrl }}" itemprop="image" alt="{{ game['name'] }}">
  134. </a>
  135. {% endfor %}
  136. </script>
  137. {% endif %}
  138. </dd>
  139. </div>
  140. {% endmacro %}
  141. {% macro render(game, show_details) %}
  142. <div class="game-spacer"></div>
  143. {% for name in game.names %}
  144. {{ render_name(name, game, loop.index0 == 0, show_details) }}
  145. {% endfor %}
  146. {% for clone in game.clones %}
  147. {{ render_clone(game.names, game.meta, clone, show_details, show_details) }}
  148. {% endfor %}
  149. {% endmacro %}