Skip to content

Commit 88505b5

Browse files
committed
Member maps - fix, document
- modified the script to better handle the frontmatter - generated new member-locations.js (with the above script) - Modified the readme (add conventions, link to wiki)
1 parent 220ce9b commit 88505b5

File tree

4 files changed

+61
-318
lines changed

4 files changed

+61
-318
lines changed

Gemfile.lock

Lines changed: 0 additions & 271 deletions
This file was deleted.

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
Website for the SwissBIAS network: Swiss BioImage Analysts' network
33
See also the associated [wiki](https://github.com/SwissBIAS/SwissBIAS.github.io/wiki)
44

5-
65
## How to contribute
76
We decided to keep some control over what’s published by merging Pull Requests. So ***please fork, modify, PR*** and then we’ll merge your changes. Please see this [guide to create a Pull Request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request). \
8-
If you would prefer to generate a dummy website to make sure it looks exactly as you want before pushing it, you can create your locally served website. To do so, follow the instructions provided [here](https://github.com/imagej/imagej.github.io/blob/main/_pages/editing/advanced.md).
7+
If you would prefer to generate a dummy website to make sure it looks exactly as you want before pushing it, you can create your locally served website. To do so, follow the instructions provided for the _imagej.github.io_ pages about [Jekyll and Git](https://github.com/imagej/imagej.github.io/blob/main/_pages/editing/advanced.md).
98

10-
## Adding and editing member information
9+
## Quickstart: Adding and editing member information
1110
Each member have their own markdown file, stored in the `/_members` directory.
12-
It consist of a YAML frontmatter and markdown text, like this, for the file `simon.noerrelykke.md`:
11+
It consists of a YAML [frontmatter](https://jekyllrb.com/docs/front-matter/) (between the triple-dashed lines) and document body written in Github flavored [markdown](https://guides.github.com/features/mastering-markdown/). Bellow is an example, for the file `simon.noerrelykke.md`:
1312

14-
```
13+
```markdown
1514
---
1615
first_name: Simon F.
1716
last_name: Noerrelykke
1817
short_name: simon
18+
city: Zurich
1919
affiliation: ETH Zurich
2020
position: Image Analyst
2121
tags: [matlab, fiji]
@@ -27,20 +27,22 @@ He heads [IDA](http://let-your-data-speak.com/) - the Image and Data Analysis gr
2727

2828
To create a new member file, copy an existing file, rename as `firstName.lastName.md`, change all text that needs changing, and save it in `/_members` (commit it).
2929

30-
Edits can be done directly in your browser in GitHub --- larger changes to structure must be done locally, then pushed to GitHub.
30+
> Front Matter conventions:
31+
> * The `city` attribute should only be used for Swiss cities and left empty otherwise. To add a new city not yet present on [the map](https://swissbias.github.io/members/), check out [detailed documentation](https://github.com/SwissBIAS/SwissBIAS.github.io/wiki/How-to-add-yourself-to-the-webpage#the-city-attribute)
32+
> * The `affiliation` attribute can hold only one institution/company. Use its main name and put the detailed description in the document body.
33+
34+
**Small edits** can be done directly in your browser in GitHub.
35+
**Larger changes** to structure must be done locally, then pushed to GitHub (see the [above section](#how-to-contribute).
3136

3237
That is it!
3338
The new member will automatically be added to the list of all members and have their own page with the text they provided, e.g. `https://www.swissbias.ch/members/simon.noerrelykke`.
3439

35-
[Here is a guide to markdown on Github](https://guides.github.com/features/mastering-markdown/).
36-
37-
3840
## Adding pages
3941
To add a webpage, create it as markdown or html and place it in `_pages` (become and editor or create a pull request for this).
4042
You can link to it from another page or add it to the navigation menu (be conservative -- navigation bars quickly become crowded).
4143

4244
## Navigation bars
43-
There are several possible navigation bars, read the documention for whatever Jekyll theme we are using, e.g. [minimal-mistakes](https://github.com/mmistakes/minimal-mistakes).
45+
There are several possible navigation bars, read the documentation for whatever Jekyll theme we are using, e.g. [minimal-mistakes](https://github.com/mmistakes/minimal-mistakes).
4446
Pages are added to the top bar by editing the file `navigation.yml` in the `/_data` folder.
4547

4648
# The configuration file

_plugins/member-cities.rb

100644100755
Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,30 @@
1111
require 'json'
1212
require 'net/http'
1313

14+
Encoding.default_external = Encoding::UTF_8
15+
Encoding.default_internal = Encoding::UTF_8
16+
1417

1518
def get_front_matter_attributes(filepath, attributenames= %w[city affiliation])
1619
res = {}
20+
n = 0
1721

18-
File.open(filepath, 'r').each_line { |line|
19-
parts = line.split(':')
20-
if parts
21-
attribute = attributenames.delete(parts[0].strip)
22-
if attribute
23-
res[attribute] = parts[1].strip
22+
File.open(filepath, 'r:UFT-8').each_line { |line|
23+
if line.strip == '---'
24+
n += 1
25+
else
26+
puts "read #{line}"
27+
parts = line.split(':')
28+
if parts
29+
attribute = attributenames.delete(parts[0].strip)
30+
if attribute
31+
res[attribute] = parts[1].strip
32+
end
2433
end
2534
end
26-
break unless attributenames
35+
break unless (attributenames and n < 2)
2736
}
37+
puts "#{res}\n\n"
2838
res
2939
end
3040

@@ -34,15 +44,15 @@ def fetch_coordinates(city, base_url, query_options)
3444
response = Net::HTTP.get(query)
3545
result = JSON.parse(response)[0]
3646
output = [result['lat'].to_f, result['lon'].to_f]
37-
puts("Fetched " + city + ": [" + output.join(" ") + "]")
47+
puts "Fetched #{city}: [ #{output.join(" ")} + ]"
3848
output
3949
end
4050

4151

4252
def generate_location_json(pattern, url, options, outpath)
4353
ca = {}
4454
Dir.glob(pattern).each { |mdpath|
45-
puts("processing file " + mdpath)
55+
puts "processing file #{mdpath}"
4656
fm = get_front_matter_attributes(mdpath)
4757
city = fm['city']
4858
city = "Unknown" if city.nil? || city.empty?
@@ -64,7 +74,7 @@ def generate_location_json(pattern, url, options, outpath)
6474
File.open(outpath, 'w+') {|f|
6575
f.write "// Generated with #{$PROGRAM_NAME}.\nfunction get_member_locations() {\nreturn " + JSON.pretty_generate(ca) + ";}"
6676
}
67-
puts("Wrote " + outpath)
77+
puts "Wrote #{outpath}"
6878
end
6979

7080

@@ -75,4 +85,4 @@ def generate_location_json(pattern, url, options, outpath)
7585
coordinate_api_options = ",+switzerland&format=json&limit=1"
7686

7787
generate_location_json(pages_path_pattern, coordinate_api_base_url, coordinate_api_options, javascript_output_path)
78-
puts("Done.")
88+
puts "Done."

0 commit comments

Comments
 (0)