Skip to content

Commit

Permalink
Added genres cloud to html template
Browse files Browse the repository at this point in the history
  • Loading branch information
nikuda committed Oct 8, 2016
1 parent 7ccbd47 commit b7801b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
27 changes: 14 additions & 13 deletions _ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,19 @@ def parse_tags(entry, fields):
return tags


def parse_global_tags(site, games, tag):
for game in games:
if tag in game:
if not getattr(site, tag, False):
setattr(site, tag, {})
def parse_global_tags(site, item, tag):
if tag in item:
if not getattr(site, tag, False):
setattr(site, tag, {})

if isinstance(game[tag], basestring):
game[tag] = [game[tag]]
if isinstance(item[tag], basestring):
item[tag] = [item[tag]]

for t in game[tag]:
tagObj = getattr(site, tag, False)
if not tagObj.get(t, False):
tagObj[t] = {'tag_count': 0}
tagObj[t]['tag_count'] += 1
for t in item[tag]:
tagObj = getattr(site, tag, False)
if not tagObj.get(t, False):
tagObj[t] = {'tag_count': 0}
tagObj[t]['tag_count'] += 1

setattr(site, tag, OrderedDict(sorted(getattr(site, tag, {}).items())))

Expand All @@ -85,7 +84,8 @@ def parse_items(site, item, key):
game_tags = ['status', 'development', 'license', 'lang', 'framework']
parse_fn = partial(parse_item, entry_tags=game_tags, meta=meta, meta_tags=meta_tags)

parse_global_tags(site, item[key], 'lang')
for game in item[key]:
parse_global_tags(site, game, 'lang')
getattr(site, key).append((names(item), meta, map(parse_fn, item[key])))


Expand Down Expand Up @@ -114,6 +114,7 @@ def parse_data(site):
raise error

for item in data:
parse_global_tags(site, item.get('meta', {}), 'genre')
parse_items(site, item, 'clones')
parse_items(site, item, 'reimplementations')

Expand Down
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ <h4>Languages</h4>
{% endfor %}
</section>

<section class="tag-group">
<h4>Genres</h4>

{% for tag, tag_props in site.genre.iteritems() %}
{{ render_tag('genre', tag, tag_props['tag_count']) }}
{% endfor %}
</section>

<h2>List of complete clones</h2>
<article>Some of these games aren&#39;t reimplementations but evolution of original ones, which were eventually open sourced.</article>
<dl>
Expand Down

0 comments on commit b7801b0

Please sign in to comment.