Skip to content

Commit aa540aa

Browse files
Reverted change to yml variable in chapters from id: to obj_id as id is a restricted jekylls name.
Changed sponsor_link: variable to link: Changed sponsor_logo: variable to logo: Changed sponsor_name: variable to name: Changed sponsor_address: variable to address: Changed sponsor_id: variable to obj_id: All those variable name changes are to unify naming among all objects so that we can use them in generators easily. Added comments to locations_variable_generator.html describing how it works. Completed logic in locations_variable_generator.html to be usable for events or chapters. Used post as a source of location data for map generation in post layout. Removed layout: variable from posts as it is now set globally in defaults in _config.yml / _config_def.yml. Changed "Go to event page" in the map's popup window to "Learn More" as it is universal and can be used for posts and events. Added default variable for chapters: is_chapter: true.
1 parent f7354c8 commit aa540aa

36 files changed

+90
-86
lines changed

_chapters/london_python_sprints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: default
3-
id: london_python_sprints
3+
obj_id: london_python_sprints
44
title: "London Python Sprints"
55
meetup_link: https://www.meetup.com/Python-Sprints/
66
address: London, United Kingdom

_chapters/madrid_test_sprints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: default
3-
id: madrid_test_sprints
3+
obj_id: madrid_test_sprints
44
title: "Madrid Test Sprints"
55
meetup_link: https://www.meetup.com/Python-Sprints/
66
address: Madrid, Spain

_chapters/szczecin_test_sprints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: default
3-
id: szczecin_test_sprints
3+
obj_id: szczecin_test_sprints
44
title: "Szczecin Test Sprints"
55
meetup_link: https://www.meetup.com/Python-Sprints/
66
address: Szczecin, Poland

_config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ defaults:
3838
values:
3939
layout: "post"
4040
is_post: true
41+
42+
-
43+
scope:
44+
path: ""
45+
type: "chapters"
46+
values:
47+
is_chapter: true
4148
-
4249
scope:
4350
path: ""

_config_dev.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ defaults:
3838
values:
3939
layout: "post"
4040
is_post: true
41+
42+
-
43+
scope:
44+
path: ""
45+
type: "chapters"
46+
values:
47+
is_chapter: true
48+
4149
-
4250
scope:
4351
path: ""
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="footer__sponsor-col col-md-12 col-lg-6">
2-
<a class="footer__sponsor-link" href="{{ include.item.sponsor_link }}">
3-
<img class="footer__img" src="{{ site.baseurl }}/{{ include.item.sponsor_logo }}">
2+
<a class="footer__sponsor-link" href="{{ include.item.link }}">
3+
<img class="footer__img" src="{{ site.baseurl }}/{{ include.item.logo }}">
44
</a>
55
</div>

_includes/locations_variable_generator.html

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
Create a javascript variable for use in the function adding map markers.
55

66
Accepts Liquid array object and converts it to a javascript list
7-
of dictionaries.
7+
of dictionaries (JSON). This will be used for chapters and events(posts) maps.
8+
If array of posts (events) is provided we get the event's address, latitude,
9+
longitude etc. from the FIRST sponsor object (if more than one are present
10+
for an event) Sponsor is a equivalent of a foreignkey for the event.
11+
One must remember though that sponsor is just a name not a reference to
12+
the sponsor object.
13+
This we find among sponsors using "where" filter as below.
14+
This is to avoid duplication of records in our yml section.
815

916
Parameters:
1017

@@ -25,23 +32,29 @@
2532

2633
But it should be enough to use site.chapters or site.posts etc.
2734
{% endcomment %}
28-
29-
30-
3135
<script>
3236
var locations = [
3337
{% for location in include.locations_array %}
34-
{"title": "{{ location.title }}",
35-
"meetupURL": "{{ location.meetup_link }}",
36-
"URL": "{{ location.url }}",
37-
{% if location.address %}
38-
"address": "{{ location.address }}",
38+
{% if location.is_post %}
39+
{% assign host_sponsor_id = location.sponsors | first %}
40+
{% assign host_sponsor = site.sponsors | where:"obj_id", host_sponsor_id | first %}
41+
{% capture prefix %}
42+
"address": "{{ host_sponsor.address }}",
43+
"lat": {{ host_sponsor.lat }},
44+
"lng": {{ host_sponsor.lng }},
45+
{% endcapture %}
3946
{% else %}
40-
{% assign sponsor = location.sponsors %}
41-
"address": "{{ sponsor.address }}",
47+
{% capture prefix %}
48+
"address": "{{ location.address }}",
49+
"lat": {{ location.lat }},
50+
"lng": {{ location.lng }},
51+
{% endcapture %}
4252
{% endif %}
43-
"lat": {{ location.lat }},
44-
"lng": {{ location.lng }}
53+
{
54+
{{ prefix }}
55+
"title": "{{ location.title }}",
56+
"meetupURL": "{{ location.meetup_link }}",
57+
"URL": "{{ location.url }}",
4558
},
4659
{% endfor %}
4760
];
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="footer__sponsor-col col-md-12 col-lg-6">
2-
<a class="footer__sponsor-link" href="{{ include.item.sponsor_link }}">
2+
<a class="footer__sponsor-link" href="{{ include.item.link }}">
33
<img class="footer__img"
4-
src="{{ site.baseurl }}/{{ include.item.sponsor_logo }}"
4+
src="{{ site.baseurl }}/{{ include.item.logo }}"
55
alt="Sponsor logo">
66
</a>
77
</div>

_layouts/post.html

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,10 @@ <h1 class="post__content-title">Event's location</h1>
105105
{% comment %}
106106
Create a javascript variable for use in the function adding map markers.
107107
{% endcomment %}
108-
{% assign locations_test = "" | split: ',' %}
109-
{% assign first_location = site.chapters | first %}
110-
{% assign locations_test = locations_test | push: first_location %}
111-
112-
{% comment %}
113-
{% assign last_location = site.chapters | last %}
114-
{% assign locations_test = locations_test | push: last_location %}
115-
{% endcomment %}
116-
117-
{% include locations_variable_generator.html locations_array = locations_test %}
108+
{% assign locations = "" | split: ',' %}
109+
{% assign location = page %}
110+
{% assign locations = locations | push: location %}
111+
{% include locations_variable_generator.html locations_array = locations %}
118112
<script async defer
119113
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB0NCzoIqGkYFdpRl-LmgWTKpxPBkqxxO0&callback=initMap">
120114
</script>
@@ -125,15 +119,15 @@ <h1 class="post__content-title">Event's sponsors</h1>
125119
</div>
126120
</div>
127121
{% for sponsor in page.sponsors %}
128-
{% assign sponsor_obj = site.sponsors | where:"sponsor_id", sponsor | first %}
122+
{% assign sponsor_obj = site.sponsors | where:"obj_id", sponsor | first %}
129123
<div class="row flex-nowrap">
130124
<div class="post__sponsor-col col-md-12">
131125
<div class="row">
132126
<div class="post__logo-col col-sm-3 col-12">
133-
<h3 class="post__sponsor-name">{{ sponsor_obj.sponsor_name }}</h3>
134-
<a class="post__sponsor-container post__sponsor-link" href="{{ sponsor_obj.sponsor_link }}">
127+
<h3 class="post__sponsor-name">{{ sponsor_obj.name }}</h3>
128+
<a class="post__sponsor-container post__sponsor-link" href="{{ sponsor_obj.link }}">
135129
<img class="post__sponsor-img"
136-
src="{{ site.baseurl }}/{{ sponsor_obj.sponsor_logo }}"
130+
src="{{ site.baseurl }}/{{ sponsor_obj.logo }}"
137131
alt="Sponsor logo">
138132
</a>
139133
</div >

_sponsors/bloomberg.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
sponsor_id: bloomberg
3-
sponsor_name: "Bloomberg"
4-
sponsor_logo: static/images/sponsors/bloomberg.png
5-
sponsor_link: https://www.bloomberg.com/careers/
6-
sponsor_address: "3 Queen Victoria St<br/>London, EC4N 4TQ, UK"
2+
obj_id: bloomberg
3+
name: "Bloomberg"
4+
logo: static/images/sponsors/bloomberg.png
5+
link: https://www.bloomberg.com/careers/
6+
address: "3 Queen Victoria St<br/>London, EC4N 4TQ, UK"
77
lat: 51.520363
88
lng: -0.086270
99
permanent: true

0 commit comments

Comments
 (0)