Skip to content

Commit

Permalink
Merge branch 'upstream' into v2.0
Browse files Browse the repository at this point in the history
* upstream:
  chore: my data
  doc: v2.0 doc
  fix: by comments
  chore:gnore ./dist (yihong0618#494)
  fix: gpx encode error maybe
  fix: v2.0 can not zoom (yihong0618#492)
  fix: gh-pages to Actions and fix the path bug (yihong0618#490)
  doc: fix v2.0 doc and actions change (yihong0618#488)
  chore:upgrade node version and pnpm (yihong0618#474)
  fix: fix fullscreen css (yihong0618#487)
  doc: drop vercel cache build doc for newbie
  chore: merge example data
  fix: using session to download keep route
  feat: add a new runner's page (yihong0618#482)
  Add correction on instruction of build github pages. (yihong0618#476)
  fix: set gh page default to true for newbie.......
  Add sync strava data args comment: `--only-run` (yihong0618#471)
  fix: 同一天有多个运动时选中地图路线显示错误问题 (yihong0618#468)

# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/run_data_sync.yml
#	README-CN.md
#	README.md
#	assets/github.svg
#	assets/github_2022.svg
#	assets/grid.svg
#	scripts/gpx_to_strava_sync.py
#	scripts/gpxtrackposter/track.py
#	src/pages/index.tsx
#	src/static/activities.json
  • Loading branch information
ben-29 committed Sep 23, 2023
2 parents 5eca9d1 + 3e342dc commit 2070b02
Show file tree
Hide file tree
Showing 26 changed files with 4,370 additions and 3,308 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@ jobs:
python-version: ['3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
id: setup_python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
# from pdm
- name: Set Variables and install dep
id: set_variables
run: |
sudo apt-get install libxml2-dev libxslt-dev python3-dev
echo "PY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_OUTPUT
echo "PIP_CACHE=$(pip cache dir)" >> $GITHUB_OUTPUT
cache: 'pip'
cache-dependency-path: 'requirements-dev.txt'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Check formatting (black)
run: black . --check
67 changes: 44 additions & 23 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,23 @@ on:
type: string
default: track_data

permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
build_and_deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand Down Expand Up @@ -57,29 +70,37 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
node-version: '18'

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false

- run: |
yarn install
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: |
yarn build
env:
PATH_PREFIX: /
- name: Install dependencies
run: pnpm install
- name: Build
run: PATH_PREFIX=/${{ github.event.repository.name }} pnpm build

- name: GitHub Pages
uses: crazy-max/ghaction-github-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Git branch where site will be deployed
target_branch: gh-pages
# Create incremental commit instead of doing push force
keep_history: true
# Build directory to deploy
build_dir: build
# Write the given domain name to the CNAME file
#fqdn: custom.domain.name # optional
# Prevent Jekyll from building the site
jekyll: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload dist repository
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
57 changes: 29 additions & 28 deletions .github/workflows/run_data_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ on:
branches:
- master
paths:
- scripts/nike_sync.py
- scripts/nike_to_strava_sync.py
- scripts/strava_sync.py
- scripts/gen_svg.py
- scripts/garmin_sync.py
- scripts/keep_sync.py
- scripts/gpx_sync.py
- scripts/tcx_sync.py
- scripts/garmin_to_strava_sync.py
- run_page/nike_sync.py
- run_page/nike_to_strava_sync.py
- run_page/strava_sync.py
- run_page/gen_svg.py
- run_page/garmin_sync.py
- run_page/keep_sync.py
- run_page/gpx_sync.py
- run_page/tcx_sync.py
- run_page/garmin_to_strava_sync.py
- requirements.txt

env:
Expand All @@ -36,7 +36,7 @@ env:
IGNORE_RANGE: 0 # Unit meter
SAVE_DATA_IN_GITHUB_CACHE: false # if you deploy in the vercal, check the README
DATA_CACHE_PREFIX: "track_data"
BUILD_GH_PAGES: false
BUILD_GH_PAGES: true # If you do not need GitHub Page please set it to `false`

jobs:
sync:
Expand Down Expand Up @@ -85,48 +85,49 @@ jobs:
- name: Run sync Nike script
if: env.RUN_TYPE == 'nike'
run: |
python scripts/nike_sync.py ${{ secrets.NIKE_REFRESH_TOKEN }}
python run_page/nike_sync.py ${{ secrets.NIKE_REFRESH_TOKEN }}
- name: Run sync Nike to Strava(Run with nike data backup and show with strava)
if: env.RUN_TYPE == 'nike_to_strava'
run: |
python scripts/nike_to_strava_sync.py ${{ secrets.NIKE_REFRESH_TOKEN }} ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }}
python run_page/nike_to_strava_sync.py ${{ secrets.NIKE_REFRESH_TOKEN }} ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }}
- name: Run sync Keep script
if: env.RUN_TYPE == 'keep'
run: |
python scripts/keep_sync.py ${{ secrets.KEEP_MOBILE }} ${{ secrets.KEEP_PASSWORD }} --with-gpx
python run_page/keep_sync.py ${{ secrets.KEEP_MOBILE }} ${{ secrets.KEEP_PASSWORD }} --with-gpx
- name: Run sync Strava script
if: env.RUN_TYPE == 'strava'
run: |
python scripts/strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }}
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs).
# python scripts/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run --is-cn

- name: Run sync Codoon script
if: env.RUN_TYPE == 'codoon'
run: |
python scripts/codoon_sync.py ${{ secrets.CODOON_MOBILE }} ${{ secrets.CODOON_PASSWORD }}
python run_page/codoon_sync.py ${{ secrets.CODOON_MOBILE }} ${{ secrets.CODOON_PASSWORD }}
# for garmin if you want generate `tcx` you can add --tcx command in the args.
- name: Run sync Garmin script
if: env.RUN_TYPE == 'garmin'
run: |
python scripts/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }}
python run_page/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }}
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs).
# python scripts/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run
# python run_page/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run

- name: Run sync Garmin CN script
if: env.RUN_TYPE == 'garmin_cn'
run: |
python scripts/garmin_sync.py ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} --is-cn
python run_page/garmin_sync.py ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} --is-cn
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs).
# python scripts/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run --is-cn
# python run_page/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run --is-cn

- name: Run sync Only GPX script
if: env.RUN_TYPE == 'only_gpx'
run: |
python scripts/gpx_sync.py
python run_page/gpx_sync.py
- name: Run sync Only FIT script
if: env.RUN_TYPE == 'only_fit'
Expand All @@ -141,35 +142,35 @@ jobs:
- name: Run sync Strava to Garmin(Run with strava(or others upload to strava) data backup in Garmin)
if: env.RUN_TYPE == 'strava_to_garmin'
run: |
python scripts/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }}
python run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }}
- name: Run sync Strava to Garmin-cn(Run with strava(or others upload to strava) data backup in Garmin-cn)
if: env.RUN_TYPE == 'strava_to_garmin_cn'
run: |
python scripts/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn
python run_page/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn
- name: Run sync Garmin-cn to Strava(Run with Garmin data backup in Strava)
if: env.RUN_TYPE == 'garmin_to_strava_cn'
run: |
python scripts/garmin_to_strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} --is-cn
python run_page/garmin_to_strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} --is-cn
- name: Run sync Garmin to Strava(Run with Garmin data backup in Strava)
if: env.RUN_TYPE == 'garmin_to_strava'
run: |
python scripts/garmin_to_strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }}
python run_page/garmin_to_strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }}
- name: Run sync Tulipsport script
if: env.RUN_TYPE == 'tulipsport'
run: |
python scripts/tulipsport_sync.py ${{ secrets.TULIPSPORT_TOKEN }} --with-gpx
python run_page/tulipsport_sync.py ${{ secrets.TULIPSPORT_TOKEN }} --with-gpx
- name: Make svg GitHub profile
if: env.RUN_TYPE != 'pass'
run: |
python scripts/gen_svg.py --from-db --title "${{ env.TITLE }}" --type github --athlete "${{ env.ATHLETE }}" --special-distance 10 --special-distance2 20 --special-color yellow --special-color2 red --output assets/github.svg --use-localtime --min-distance 0.5
python scripts/gen_svg.py --from-db --title "${{ env.TITLE_GRID }}" --type grid --athlete "${{ env.ATHLETE }}" --output assets/grid.svg --special-color yellow --special-color2 red --special-distance 20 --special-distance2 40 --use-localtime --min-distance "${{ env.MIN_GRID_DISTANCE }}"
python scripts/gen_svg.py --from-db --type circular --use-localtime
python scripts/gen_svg.py --from-db --year $(date +"%Y") --language zh_CN --title "$(date +"%Y") Workouts" --type github --athlete "${{ env.ATHLETE }}" --special-distance 10 --special-distance2 20 --special-color yellow --special-color2 red --output assets/github_$(date +"%Y").svg --use-localtime --min-distance 0.5
python run_page/gen_svg.py --from-db --title "${{ env.TITLE }}" --type github --athlete "${{ env.ATHLETE }}" --special-distance 10 --special-distance2 20 --special-color yellow --special-color2 red --output assets/github.svg --use-localtime --min-distance 0.5
python run_page/gen_svg.py --from-db --title "${{ env.TITLE_GRID }}" --type grid --athlete "${{ env.ATHLETE }}" --output assets/grid.svg --special-color yellow --special-color2 red --special-distance 20 --special-distance2 40 --use-localtime --min-distance "${{ env.MIN_GRID_DISTANCE }}"
python run_page/gen_svg.py --from-db --type circular --use-localtime
python run_page/gen_svg.py --from-db --year $(date +"%Y") --language zh_CN --title "$(date +"%Y") Workouts" --type github --athlete "${{ env.ATHLETE }}" --special-distance 10 --special-distance2 20 --special-color yellow --special-color2 red --output assets/github_$(date +"%Y").svg --use-localtime --min-distance 0.5
- name: Push new runs
if: env.SAVE_DATA_IN_GITHUB_CACHE != 'true'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ yarn-error.log

# Build directory
/build
/dist
.DS_Store
.sass-cache/
_posts/
Expand Down
1 change: 1 addition & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requirements.txt
2 changes: 0 additions & 2 deletions .yarnrc

This file was deleted.

59 changes: 31 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ FROM python:3.10.5-slim AS develop-py
WORKDIR /root/running_page
COPY ./requirements.txt /root/running_page/requirements.txt
RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install -i https://mirrors.aliyun.com/pypi/simple/ pip -U \
&& pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
&& pip3 install -r requirements.txt

FROM node:16 AS develop-node
&& apt-get install -y --no-install-recommends git \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install -i https://mirrors.aliyun.com/pypi/simple/ pip -U \
&& pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
&& pip3 install -r requirements.txt

FROM node:18 AS develop-node
WORKDIR /root/running_page
COPY ./package.json /root/running_page/package.json
COPY ./yarn.lock /root/running_page/yarn.lock
COPY ./pnpm-lock.yaml /root/running_page/pnpm-lock.yaml
RUN npm config set registry https://registry.npm.taobao.org \
&& yarn install
&&npm install -g corepack \
&&corepack enable \
&&pnpm install



FROM develop-py AS data
Expand All @@ -32,29 +35,29 @@ WORKDIR /root/running_page
COPY . /root/running_page/
ARG DUMMY=unknown
RUN DUMMY=${DUMMY}; \
echo $app ; \
if [ "$app" = "NRC" ] ; then \
python3 scripts/nike_sync.py ${nike_refresh_token}; \
elif [ "$app" = "Garmin" ] ; then \
python3 scripts/garmin_sync.py ${email} ${password}; \
elif [ "$app" = "Garmin-CN" ] ; then \
python3 scripts/garmin_sync.py ${email} ${password} --is-cn ; \
elif [ "$app" = "Strava" ] ; then \
python3 scripts/strava_sync.py ${client_id} ${client_secret} ${refresh_token};\
elif [ "$app" = "Nike_to_Strava" ] ; then \
python3 scripts/nike_to_strava_sync.py ${nike_refresh_token} ${client_id} ${client_secret} ${refresh_token};\
else \
echo "Unknown app" ; \
fi
RUN python3 scripts/gen_svg.py --from-db --title "my running page" --type grid --athlete "$YOUR_NAME" --output assets/grid.svg --min-distance 10.0 --special-color yellow --special-color2 red --special-distance 20 --special-distance2 40 --use-localtime \
&& python3 scripts/gen_svg.py --from-db --title "my running page" --type github --athlete "$YOUR_NAME" --special-distance 10 --special-distance2 20 --special-color yellow --special-color2 red --output assets/github.svg --use-localtime --min-distance 0.5 \
&& python3 scripts/gen_svg.py --from-db --type circular --use-localtime
echo $app ; \
if [ "$app" = "NRC" ] ; then \
python3 run_page/nike_sync.py ${nike_refresh_token}; \
elif [ "$app" = "Garmin" ] ; then \
python3 run_page/garmin_sync.py ${email} ${password}; \
elif [ "$app" = "Garmin-CN" ] ; then \
python3 run_page/garmin_sync.py ${email} ${password} --is-cn ; \
elif [ "$app" = "Strava" ] ; then \
python3 run_page/strava_sync.py ${client_id} ${client_secret} ${refresh_token};\
elif [ "$app" = "Nike_to_Strava" ] ; then \
python3 run_page/nike_to_strava_sync.py ${nike_refresh_token} ${client_id} ${client_secret} ${refresh_token};\
else \
echo "Unknown app" ; \
fi
RUN python3 run_page/gen_svg.py --from-db --title "my running page" --type grid --athlete "$YOUR_NAME" --output assets/grid.svg --min-distance 10.0 --special-color yellow --special-color2 red --special-distance 20 --special-distance2 40 --use-localtime \
&& python3 run_page/gen_svg.py --from-db --title "my running page" --type github --athlete "$YOUR_NAME" --special-distance 10 --special-distance2 20 --special-color yellow --special-color2 red --output assets/github.svg --use-localtime --min-distance 0.5 \
&& python3 run_page/gen_svg.py --from-db --type circular --use-localtime


FROM develop-node AS frontend-build
WORKDIR /root/running_page
COPY --from=data /root/running_page /root/running_page
RUN yarn build-prefix
RUN pnpm run build

FROM nginx:alpine AS web
COPY --from=frontend-build /root/running_page/public /usr/share/nginx/html/
Expand Down
2 changes: 2 additions & 0 deletions assets/github_2023.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2070b02

Please sign in to comment.