Skip to content

Commit a5686e5

Browse files
authored
Merge pull request creativecommons#6 from creativecommons/category_filters
Added filtering ideas by skill and difficulty.
2 parents 00e8fe6 + 6326d50 commit a5686e5

File tree

10 files changed

+90
-11
lines changed

10 files changed

+90
-11
lines changed
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
_model: project-ideas
22
---
33
title: GSoC 2019: Project Ideas
4-
---
5-
body:
6-
<p class="text-muted">This is the project idea list for the <a href="/gsoc-2019">Google Summer of Code 2019</a> program. We have a mix of projects that are meant to be installed widely (such as plugins for other software) and projects that are more focused on improving user experience for users of Creative Commons licenses. Regardless of scope, these projects all have a broad and positive community impact.</p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_model: project-ideas
2+
---
3+
title: GSoC 2019: Project Ideas
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_model: project-ideas
2+
---
3+
title: GSoC 2019: Project Ideas
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_model: project-ideas
2+
---
3+
title: GSoC 2019: Project Ideas
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_model: project-ideas
2+
---
3+
title: GSoC 2019: Project Ideas
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_model: project-ideas
2+
---
3+
title: GSoC 2019: Project Ideas
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_model: project-ideas
2+
---
3+
title: GSoC 2019: Project Ideas

databags/project-filters.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"project-ideas": {
3+
"path": "/gsoc-2019/project-ideas",
4+
"nav_label": "All Projects",
5+
"field": null,
6+
"value": null
7+
},
8+
"difficulty-easy": {
9+
"path": "/gsoc-2019/project-ideas/difficulty-easy",
10+
"nav_label": "Difficulty: Easy",
11+
"field": "difficulty",
12+
"value": "Easy"
13+
},
14+
"difficulty-medium": {
15+
"path": "/gsoc-2019/project-ideas/difficulty-medium",
16+
"nav_label": "Difficulty: Medium",
17+
"field": "difficulty",
18+
"value": "Medium"
19+
},
20+
"difficulty-hard": {
21+
"path": "/gsoc-2019/project-ideas/difficulty-hard",
22+
"nav_label": "Difficulty: Hard",
23+
"field": "difficulty",
24+
"value": "Hard"
25+
},
26+
"skill-python": {
27+
"path": "/gsoc-2019/project-ideas/skill-python",
28+
"nav_label": "Skill: Python",
29+
"field": "skill",
30+
"value": "Python"
31+
},
32+
"skill-javascript": {
33+
"path": "/gsoc-2019/project-ideas/skill-javascript",
34+
"nav_label": "Skill: JavaScript",
35+
"field": "skill",
36+
"value": "JavaScript"
37+
},
38+
"skill-wordpress": {
39+
"path": "/gsoc-2019/project-ideas/skill-wordpress",
40+
"nav_label": "Skill: WordPress",
41+
"field": "skill",
42+
"value": "WordPress"
43+
}
44+
}

models/project-ideas.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ protected = yes
77
[fields.title]
88
label = Title
99
type = string
10-
11-
[fields.body]
12-
label = Body
13-
type = markdown

templates/project-ideas.html

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
11
{% extends "layout.html" %}
2-
{% block title %}{{ this.title }}{% endblock %}
2+
{% block title %}Project Ideas for GSoC 2019{% endblock %}
33

44
{% block body %}
5-
{{ this.body }}
5+
<p class="text-muted">This is the project idea list for the <a href="/gsoc-2019">Google Summer of Code 2019</a> program. We have a mix of projects that are meant to be installed widely (such as plugins for other software) and projects that are more focused on improving user experience for users of Creative Commons licenses. Regardless of scope, these projects all have a broad and positive community impact.</p>
66
<a name="ideas-top"></a>
77
<hr/>
8-
{% set ideas = site.query('/gsoc-2019/project-ideas/project-ideas-list').include_undiscoverable(true).all() %}
8+
<!-- We display all ideas by default. -->
9+
{% set ideas = site.query('/gsoc-2019/project-ideas/project-ideas-list').include_undiscoverable(true) %}
10+
<!-- The following code filters the ideas to display based on the current URL. These mappings are defined in the "databags" folder.
11+
Jinja does not support changing values of variables inside loops, so we have to use namespace objects.
12+
See "Scoping Behavior" here: http://jinja.pocoo.org/docs/2.10/templates/#assignments -->
13+
{% set ns = namespace(field=None, value=None) %}
14+
{% for slug, data in bag('project-filters').iteritems() %}
15+
{% if this._slug == slug %}
16+
{% set ns.field = data['field'] %}
17+
{% set ns.value = data['value'] %}
18+
{% endif %}
19+
{% endfor %}
20+
{% if ns.field == 'difficulty' %}
21+
{% set ideas = ideas.filter(F.difficulty == ns.value) %}
22+
{% endif %}
23+
{% if ns.field == 'skill' %}
24+
{% set ideas = ideas.filter(F.skills_recommended.contains(ns.value)) %}
25+
{% endif %}
926
<div class="mt-4">
1027
<div>
11-
<ul class="list-unstyled m3">
28+
{% for slug, data in bag('project-filters').iteritems() %}
29+
<a href="{{ data['path'] }}">
30+
<button type="button" class="btn btn-sm {% if this._path == data['path'] %}btn-dark{% else %}btn-primary{% endif %}" {% if this._path == data['path'] %}disabled{% endif %}>
31+
{{ data['nav_label'] }}
32+
</button>
33+
</a>
34+
{% endfor %}
35+
<ul class="list-unstyled m-3">
1236
{% for idea in ideas %}
1337
<li class="my-2"><a href="#{{ idea._slug }}">{{ idea.title }}</a></li>
1438
{% endfor %}

0 commit comments

Comments
 (0)