Skip to content

Commit

Permalink
Merge tag 'v2.0'
Browse files Browse the repository at this point in the history
* tag 'v2.0':
  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)
  feat: change to SPA and vite (yihong0618#472)
  feat: Typescript! (yihong0618#461)
  doc: todo for 2.0

# Conflicts:
#	.github/workflows/run_data_sync.yml
#	README-CN.md
#	README.md
#	assets/github.svg
#	assets/github_2022.svg
#	gatsby-config.js
#	gatsby-node.js
#	run_page/gpx_to_strava_sync.py
#	run_page/gpxtrackposter/track.py
#	run_page/kml2polyline.py
#	run_page/update_activities_file.py
#	run_page/xingzhe_sync.py
#	src/components/Layout/index.tsx
#	src/components/LocationStat/LocationSummary.tsx
#	src/components/LocationStat/PeriodStat.tsx
#	src/components/LocationStat/index.tsx
#	src/components/RunMap/index.tsx
#	src/components/RunTable/RunRow.tsx
#	src/components/RunTable/index.tsx
#	src/components/YearStat/index.tsx
#	src/hooks/useActivities.js
#	src/hooks/useSiteMetadata.js
#	src/pages/index.tsx
#	src/static/activities.json
#	src/static/run_countries.ts
#	src/utils/const.ts
#	src/utils/utils.ts
  • Loading branch information
ben-29 committed Sep 23, 2023
2 parents ae61646 + 3e342dc commit 9544179
Show file tree
Hide file tree
Showing 96 changed files with 4,883 additions and 11,746 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// eslint-disable-next-line no-undef
module.exports = {
parser: '@typescript-eslint/parser',
env: {
browser: true,
es2021: true,
Expand All @@ -24,5 +25,9 @@ module.exports = {
rules: {
'prettier/prettier': 'off',
'react/prop-types': 'off',
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
globals: {
NodeJS: true,
},
};
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: |
PATH_PREFIX=/${{ github.event.repository.name }} yarn build --prefix-paths
- run: |
cp -r assets/ public/static
- 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: public
# 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
54 changes: 27 additions & 27 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 Down Expand Up @@ -85,17 +85,17 @@ 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'
Expand All @@ -107,27 +107,27 @@ jobs:
- 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 @@ -142,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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
node_modules
yarn-error.log

/public
# Build directory
/build
/dist
.DS_Store
.sass-cache/
_posts/
Expand All @@ -19,3 +19,4 @@ _site/
.idea

config.yaml
.venv/
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:14 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
12 changes: 7 additions & 5 deletions README-CN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## note: use v2.0 need change vercel setting from gatsby to vercel

# [打造个人户外运动主页](http://workouts.ben29.xyz)

![screenshot](https://user-images.githubusercontent.com/6956444/163125711-24d0ad99-490d-4c04-b89f-5b7fe776eb38.png)
Expand Down Expand Up @@ -35,25 +37,25 @@
<summary>获取您的咕咚数据</summary>

```python
python3(python) scripts/codoon_sync.py ${your mobile or email} ${your password}
python3(python) run_page/codoon_sync.py ${your mobile or email} ${your password}
```

示例:

```python
python3(python) scripts/codoon_sync.py 13333xxxx xxxx
python3(python) run_page/codoon_sync.py 13333xxxx xxxx
```

> 注:我增加了 Codoon 可以导出 gpx 功能, 执行如下命令,导出的 gpx 会加入到 GPX_OUT 中,方便上传到其它软件
```python
python3(python) scripts/codoon_sync.py ${your mobile or email} ${your password} --with-gpx
python3(python) run_page/codoon_sync.py ${your mobile or email} ${your password} --with-gpx
```

示例:

```python
python3(python) scripts/codoon_sync.py 13333xxxx xxxx --with-gpx
python3(python) run_page/codoon_sync.py 13333xxxx xxxx --with-gpx
```

> 注:因为登录 token 有过期时间限制,我增加了 refresh_token&user_id 登陆的方式, refresh_token 及 user_id 在您登陆过程中会在控制台打印出来
Expand All @@ -63,7 +65,7 @@ python3(python) scripts/codoon_sync.py 13333xxxx xxxx --with-gpx
示例:

```python
python3(python) scripts/codoon_sync.py 54bxxxxxxx fefxxxxx-xxxx-xxxx --from-auth-token
python3(python) run_page/codoon_sync.py 54bxxxxxxx fefxxxxx-xxxx-xxxx --from-auth-token
```

</details>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## note: use v2.0 need change vercel setting from gatsby to vercel

# [Create a personal workouts home page](http://workouts.ben29.xyz)

![screenshot](https://user-images.githubusercontent.com/6956444/163125711-24d0ad99-490d-4c04-b89f-5b7fe776eb38.png)
Expand Down
2 changes: 1 addition & 1 deletion 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.
1 change: 1 addition & 0 deletions assets/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const yearStats = import.meta.glob('./year_*.svg', { import: 'ReactComponent' })
2 changes: 1 addition & 1 deletion assets/year_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 9544179

Please sign in to comment.