Skip to content

Commit

Permalink
[fix #582] make latitude and longitude two variables in _config.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
fmichonneau committed Oct 11, 2019
1 parent 35da433 commit fe27c43
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
10 changes: 4 additions & 6 deletions _extras/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ which must define the following values in its header:
and languages: "ar" is Arabic when used for a language, but
Argentina when used for a country.

* `latlng` is the latitude and longitude of the workshop site (so we
can put a pin on our map). You can use
[this site](https://getlatlong.net/) to find these
values. You can *not* put spaces around the comma separating the
latitude from the longitude.

* `latitude` and `longitude` are the latitude and longitude of the workshop
site (so we can put a pin on our map). You can use
[this site](https://getlatlong.net/) to find these values.

* `humandate` is the human-friendly start and end date for the
workshop. Please use three-letter month names and abbreviations
(e.g., `Jul` instead of `July`), since these values are displayed
Expand Down
2 changes: 1 addition & 1 deletion _layouts/workshop.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<meta name="country" content="{{page.country}}" />
<meta name="venue" content="{{page.venue}}" />
<meta name="address" content="{{page.address}}" />
<meta name="latlng" content="{{page.latlng}}" />
<meta name="latlng" content="{{page.latitude}},{{page.longitude}}" />
<meta name="language" content="{{page.language}}" />
<meta name="eventbrite" content="{{page.eventbrite}}" />
<meta name="instructor" content="{{page.instructor|join:'|'}}" />
Expand Down
5 changes: 3 additions & 2 deletions bin/_travis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
yaml_data['address']="Room 123"
yaml_data['country']="us"
yaml_data['language']="en"
yaml_data['latlng']="0,0"
yaml_data['latitude']="0"
yaml_data['longitude']="0"
yaml_data['humandate']="Jan 01-02, 2020"
yaml_data['humantime']="9:00 am - 4:30 pm"
yaml_data['startdate']= datetime.datetime.today()
Expand All @@ -29,4 +30,4 @@
writer.write("---\n") #blankbit is technically a yaml document
yaml.dump(yaml_data, writer)
writer.write("---\n")
writer.write(text)
writer.write(text)
33 changes: 23 additions & 10 deletions bin/workshop_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,29 @@ def check_date(this_date):


@look_for_fixme
def check_latitude_longitude(latlng):
def check_latitude(latitude):
"""
'latlng' must be a valid latitude and longitude represented as two
floating-point numbers separated by a comma.
'latitude' must be a valid latitude represented as a
floating-point number separated by a comma.
"""

try:
lat, lng = latlng.split(',')
lat = float(lat)
lng = float(lng)
return (-90.0 <= lat <= 90.0) and (-180.0 <= lng <= 180.0)
lat = float(latitude)
return (-90.0 <= lat <= 90.0)
except ValueError:
return False

def check_longitude(longitude):
"""
'longitude' must be a valid latitude represented as a
floating-point number separated by a comma.
"""

try:
lat = float(longitude)
return (-180.0 <= lat <= 180)
except ValueError:
return False

def check_instructors(instructors):
"""
Expand Down Expand Up @@ -281,9 +290,13 @@ def check_pass(value):
'enddate invalid. Must be of format year-month-day, i.e.,' +
' 2014-01-31'),

'latlng': (True, check_latitude_longitude,
'latlng invalid. Check that it is two floating point ' +
'numbers, separated by a comma'),
'latitude': (True, check_latitude,
'latitude invalid. Check that it is a floating point, ' +
'between -90 and 90'),

'longitude': (True, check_longitude,
'longitude invalid. Check that it is a floating point, ' +
'between -180 and 180'),

'instructor': (True, check_instructors,
'instructor list isn\'t a valid list of format ' +
Expand Down
9 changes: 5 additions & 4 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ venue: "FIXME" # brief name of host site without address (e.g., "Euphoric
address: "FIXME" # full street address of workshop (e.g., "Room A, 123 Forth Street, Blimingen, Euphoria")
country: "FIXME" # lowercase two-letter ISO country code such as "fr" (see https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes)
language: "FIXME" # lowercase two-letter ISO language code such as "fr" (see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
latlng: "FIXME" # decimal latitude and longitude of workshop venue (e.g., "41.7901128,-87.6007318" - use https://www.latlong.net/)
latitude: "45" # decimal latitude of workshop venue (use https://www.latlong.net/)
longitude: "-1" # decimal longitude of the workshop venue (use https://www.latlong.net)
humandate: "FIXME" # human-readable dates for the workshop (e.g., "Feb 17-18, 2020")
humantime: "FIXME" # human-readable times for the workshop (e.g., "9:00 am - 4:30 pm")
startdate: FIXME # machine-readable start date for the workshop in YYYY-MM-DD format like 2015-01-01
Expand Down Expand Up @@ -110,14 +111,14 @@ if the latitude and longitude of the workshop have been set. You
can use https://itouchmap.com/latlong.html to find the lat/long of an
address.
{% endcomment %}
{% if page.latlng %}
{% if page.latitude and page.longitude %}
<p id="where">
<strong>Where:</strong>
{{page.address}}.
Get directions with
<a href="//www.openstreetmap.org/?mlat={{page.latlng | replace:',','&mlon='}}&zoom=16">OpenStreetMap</a>
<a href="//www.openstreetmap.org/?mlat={{page.latitude}}&mlon={{page.longitude}}&zoom=16">OpenStreetMap</a>
or
<a href="//maps.google.com/maps?q={{page.latlng}}">Google Maps</a>.
<a href="//maps.google.com/maps?q={{page.latitude}},{{page.longitude}}">Google Maps</a>.
</p>
{% endif %}

Expand Down

0 comments on commit fe27c43

Please sign in to comment.