Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for externalised sorting per language #748

Merged
merged 9 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ jobs:
with:
persist-credentials: false

- name: Build site
- name: Install dependencies
run: |
sudo apt-get install -y build-essential libicu-dev
python -m pip install --upgrade pip
pip install pycld2 pyicu-binary

- name: Build glossary data files and site
run: make gh-site

- name: Remove _data fromm .gitignore
- name: Remove _data from .gitignore
run: "grep -v '_data' .gitignore > tmpfile && mv tmpfile .gitignore"

- name: inspect content of folder
run: ls -alh _gh-site && ls -alh _gh-site/_data
- name: Inspect content of folder
run: ls -alh _gh-site && ls -alh _gh-site/_data && ls -alh _gh-site/_data/en

- name: Deploy to site
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'carpentries/glosario' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yaml-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.11]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ assets/css/to_delete.css
.DS_Store
_config.yml
_data/
count.py
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,42 @@ all : commands
commands :
@grep -h -E '^##' ${MAKEFILE_LIST} | sed -e 's/## //g' | column -t -s ':'

# Create copy of glossary file for GitHub Pages site.
_data/glossary.yml : ./glossary.yml
@mkdir -p _data
@cp $< $@

## sort : sort the glossary file and build _data glossary file per language
sort-glossary : _data/glossary.yml
@yamllint glossary.yml
@python utils/sort-glossary.py

## site : rebuild GitHub Pages site locally.
site : _data/glossary.yml
site :
$(MAKE) sort-glossary
rm -rf .jekyll-cache .jekyll-metadata _site
bundle exec jekyll build

## gh-site : builds the website for GitHub pages (part of the GH Actions workflow)
gh-site : _data/glossary.yml
$(MAKE) sort-glossary
@rm -rf _gh-site
@mkdir -p _gh-site
@cp -r `ls -A | grep -v '.git' | grep -v '_gh-site' | grep -v '_site'` _gh-site
@mkdir -p _gh-site/_data
@cp $< _gh-site/$<

## serve : serve GitHub Pages site locally.
serve : _data/glossary.yml
serve :
$(MAKE) sort-glossary
rm -rf _site
bundle exec jekyll serve -I

## clean : clean up unneeded files.
clean :
@rm -rf _site
@find . -name '*~' -exec rm {} \;
@rm -f _data/glossary.yml
@rm -rf _data/*

## check : check glossary consistency.
check :
Expand All @@ -37,8 +50,3 @@ check :
## checkall : check glossary consistency including missing terms in all languages.
checkall :
@python utils/check-glossary.py -A _config.yml glossary.yml

# Create copy of glossary file for GitHub Pages site.
_data/glossary.yml : ./glossary.yml
@mkdir -p _data
@cp $< $@
6 changes: 4 additions & 2 deletions _includes/glossary.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% assign gloss = site.data.glossary %}
{% assign language = page.permalink | replace: '/', '' %}

{% assign gloss = site.data.[language].glossary %}

{% assign direction = 'ltr' %}
{% if page.direction %}
{% assign direction = page.direction %}
Expand All @@ -13,7 +15,7 @@
- 'actual' is a list of slugs sorted by terms.
{%- endcomment -%}
{%- capture defined -%}{%- for item in gloss -%}{%- if item[language] -%}{{item[language].term | downcase}}IN_ITEM{{item.slug}}BETWEEN_ITEMS{%- endif -%}{%- endfor -%}{%- endcapture -%}
{%- assign sorted = defined | split: 'BETWEEN_ITEMS' | sort -%}
{%- assign sorted = defined | split: 'BETWEEN_ITEMS' -%}
{%- capture ordered -%}{%- for item in sorted -%}{{item | split: 'IN_ITEM' | last}}BETWEEN_ITEMS{%- endfor -%}{%- endcapture -%}
{%- assign actual = ordered | split: 'BETWEEN_ITEMS' -%}

Expand Down
Loading
Loading