Skip to content

Commit

Permalink
Merge branch 'upstream' into feat_NavigationControl
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-29 committed Dec 11, 2023
2 parents f4ae836 + 71705f0 commit 502c1f4
Show file tree
Hide file tree
Showing 17 changed files with 225 additions and 75 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
# if your default branches is not master, please change it here
ref: master

- name: Cache Data Files
if: inputs.save_data_in_github_cache
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ RUN npm config set registry https://registry.npm.taobao.org \
FROM develop-py AS data
ARG app
ARG nike_refresh_token
ARG email
ARG password
ARG secret_string
ARG client_id
ARG client_secret
ARG refresh_token
Expand All @@ -39,9 +38,9 @@ RUN DUMMY=${DUMMY}; \
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}; \
python3 run_page/garmin_sync.py ${secret_string} ; \
elif [ "$app" = "Garmin-CN" ] ; then \
python3 run_page/garmin_sync.py ${email} ${password} --is-cn ; \
python3 run_page/garmin_sync.py ${secret_string} --is-cn ; \
elif [ "$app" = "Strava" ] ; then \
python3 run_page/strava_sync.py ${client_id} ${client_secret} ${refresh_token};\
elif [ "$app" = "Nike_to_Strava" ] ; then \
Expand Down
47 changes: 31 additions & 16 deletions README-CN.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
## Note

1. clone or Fork before vercel 404 need to pull the latest code
2. python3(python) in README means python3 python
3. use v2.0 need change vercel setting from gatsby to vite
4. 2023.09.26 garmin need secret_string(and in Actions) get

```bash
python run_page/get_garmin_secret.py ${email} ${password}
# if cn
python run_page/get_garmin_secret.py ${email} ${password} --is-cn
```
```

![running_page](https://socialify.git.ci/yihong0618/running_page/image?description=1&font=Inter&forks=1&issues=1&language=1&logo=https%3A%2F%2Fraw.luolix.top%2Fshaonianche%2Fgallery%2Fmaster%2Frunning_page%2Frunning_page_logo_150*150.jpg&owner=1&pulls=1&stargazers=1&theme=Light)

Expand Down Expand Up @@ -85,7 +87,7 @@ R.I.P. 希望大家都能健康顺利的跑过终点,逝者安息。
| [Vint](https://github.com/VintLin) | <https://vinton.store/Running/> | Keep |
| [Muyids](https://github.com/muyids) | <https://muyids.github.io/running> | Garmin-cn |
| [Gao Hao](https://github.com/efish2002) | <https://efish2002.github.io/running_page/> | Garmin-cn |
| [Jinlei](https://github.com/iamjinlei0312) | <https://jinlei.run/> | AW-GPX |
| [Jinlei](https://github.com/iamjinlei0312) | <https://jinlei.run/> | 咕咚 |
| [Ray Wang](https://github.com/raywangsy) | <https://run.raywang.pro/> | Garmin |
| [RealTiny656](https://github.com/tiny656) | <https://tiny656.github.io/running_page/> | JoyRun |
| [EINDEX](https://github.com/eindex) | <https://workouts.eindex.me/> | Strava/Nike |
Expand Down Expand Up @@ -194,11 +196,10 @@ docker run -itd -p 80:80 running_page:latest
> 如果你是海外用户请更改 `IS_CHINESE = false` in `src/utils/const.ts`
```typescript
const MAPBOX_TOKEN ='pk.eyJ1IjoieWlob25nMDYxOCIsImEiOiJja2J3M28xbG4wYzl0MzJxZm0ya2Fua2p2In0.PNKfkeQwYuyGOTT_x9BJ4Q';
const MAPBOX_TOKEN =
'pk.eyJ1IjoieWlob25nMDYxOCIsImEiOiJja2J3M28xbG4wYzl0MzJxZm0ya2Fua2p2In0.PNKfkeQwYuyGOTT_x9BJ4Q';
```



## 个性化设置

> 在仓库目录下找到 `src/static/site-metadata.ts`,找到以下内容并修改成你自己想要的。
Expand Down Expand Up @@ -378,6 +379,7 @@ python3(python) run_page/joyrun_sync.py 13333xxxx xxxx
```

joyrun 导出 gpx 文件

> 导出的 gpx 在 GPX_OUT 目录,方便上传到其它软件
```bash
Expand Down Expand Up @@ -578,10 +580,15 @@ python3(python) run_page/garmin_sync.py xxxxxxxxxx --is-cn --only-run
获取 Nike 的 refresh_token

1. 登录 [Nike](https://www.nike.com) 官网
2. In Developer -> Application-> Storage -> https:unite.nike.com 中找到 refresh_token
**全部需要在大陆以外的全局 ip 下进行**

![example img](https://user-images.githubusercontent.com/67903793/282300381-4e7437d0-65a9-4eed-93d1-2b70e360215f.png)

1. 在这里登陆[website](https://unite.nike.com/s3/unite/mobile.html?androidSDKVersion=3.1.0&corsoverride=https%3A%2F%2Funite.nike.com&uxid=com.nike.sport.running.droid.3.8&backendEnvironment=identity&view=login&clientId=VhAeafEGJ6G8e9DxRUz8iE50CZ9MiJMG), 打开 F12 在浏览器抓 login -> XHR -> get the `refresh_token` from login api

![image](https://user-images.githubusercontent.com/15976103/94448123-23812b00-01dd-11eb-8143-4b0839c31d90.png) 3. 在项目根目录下执行:
2. 复制 `refresh_token` 之后可以添加在GitHub Secrets 中,也可以直接在命令行中使用

> Chrome 浏览器:按下 F12 打开浏览器开发者工具,点击 Application 选项卡,来到左侧的 Storage 面板,点击展开 Local storage,点击下方的 https://unite.nike.com。接着点击右侧的 com.nike.commerce.nikedotcom.web.credential Key,下方会分行显示我们选中的对象,可以看到 refresh_token ,复制 refresh_token 右侧的值。Safari 浏览器:在 Safari 打开 Nike 的网页后,右击页面,选择「检查元素」,打开浏览器开发者工具。点击「来源」选项卡,在左侧找到 XHR 文件夹,点击展开,在下方找到 login 文件并单击,在右侧同样可以看到 refresh_token ,复制 refresh_token 右侧的值。
```bash
python3(python) run_page/nike_sync.py ${nike refresh_token}
Expand Down Expand Up @@ -904,9 +911,17 @@ python3(python) run_page/gen_svg.py --from-db --type circular --use-localtime

4. 为 GitHub Actions 添加代码提交权限,访问仓库的 `Settings > Actions > General`页面,找到 `Workflow permissions` 的设置项,将选项配置为 `Read and write permissions`,支持 CI 将运动数据更新后提交到仓库中。


5. 如果想把你的 running_page 部署在 xxx.github.io 而不是 xxx.github.io/run_page,需要做三点

- 修改你的 fork 的 running_page 仓库改名为 xxx.github.io, xxx 是你 github 的 username
- 修改 gh-pages.yml 中的 Build 模块,删除 `${{ github.event.repository.name }}` 改为`run: PATH_PREFIX=/ pnpm build` 即可
- src/static/site-metadata.ts 中 `siteUrl: ''` 即可

</details>

## GitHub Actions

> Fork 的同学请一定不要忘了把 GitHub Token 改成自己的,否则会 push 到我的 repo 中,谢谢大家。
<details>
Expand Down Expand Up @@ -964,7 +979,6 @@ curl https://api.github.com/repos/yihong0618/running_page/actions/workflows -H "

</details>


## Github Cache

<details>
Expand Down Expand Up @@ -1033,17 +1047,18 @@ curl https://api.github.com/repos/yihong0618/running_page/actions/workflows -H "

# FAQ

- Strava 100 每 15 分钟的请求,1000 每日限制
- Strava 100 每 15 分钟的请求,1000 每日限制

<https://www.strava.com/settings/api>
<https://www.strava.com/settings/api>
<https://developers.strava.com/docs/#rate-limiting>

等待时间限制(这里是 strava 接口请求限制),不要关闭终端,这里会自动执行下一组上传数据
等待时间限制(这里是 strava 接口请求限制),不要关闭终端,这里会自动执行下一组上传数据

```
Strava API Rate Limit Exceeded. Retry after 100 seconds
Strava API Rate Limit Timeout. Retry in 799.491622 seconds
```

```
Strava API Rate Limit Exceeded. Retry after 100 seconds
Strava API Rate Limit Timeout. Retry in 799.491622 seconds
```
- vercel git

如果想 ignpre gh-pages 可以在 `settings` -> `build` -> `Ignored Build Step` -> `Custom` 输入命令:
Expand Down
47 changes: 30 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
## Note

1. clone or Fork before vercel 404 need to pull the latest code
2. python3(python) in README means python3 python
3. use v2.0 need change vercel setting from gatsby to vite
4. 2023.09.26 garmin need secret_string(and in Actions) get

```bash
python run_page/get_garmin_secret.py ${email} ${password}
# if cn
python run_page/get_garmin_secret.py ${email} ${password} --is-cn
```
```

<p align="center">
<img width="150" src="https://raw.githubusercontent.com/shaonianche/gallery/master/running_page/running_page_logo.png" />
Expand Down Expand Up @@ -81,7 +83,7 @@ English | [简体中文](https://github.com/yihong0618/running_page/blob/master/
| [Vint](https://github.com/VintLin) | <https://vinton.store/Running/> | Keep |
| [Muyids](https://github.com/muyids) | <https://muyids.github.io/running> | Garmin-cn |
| [Gao Hao](https://github.com/efish2002) | <https://efish2002.github.io/running_page/> | Garmin-cn |
| [Jinlei](https://github.com/iamjinlei0312) | <https://jinlei.run/> | AW-GPX |
| [Jinlei](https://github.com/iamjinlei0312) | <https://jinlei.run/> | 咕咚 |
| [RealTiny656](https://github.com/tiny656) | <https://tiny656.github.io/running_page/> | JoyRun |
| [EINDEX](https://github.com/eindex) | <https://workouts.eindex.me/> | Strava/Nike |
| [Melt](https://github.com/fpGHwd) | <https://running.autove.dev/> | Strava |
Expand All @@ -104,9 +106,9 @@ English | [简体中文](https://github.com/yihong0618/running_page/blob/master/
4. Mapbox for map display
5. Supports most sports apps such as nike strava...

> automatically backup gpx data for easy backup and uploading to other software.
> automatically backup gpx data for easy backup and uploading to other software.
> Note: If you don't want to make the data public, you can choose strava's fuzzy processing, or private repositories.
> Note: If you don't want to make the data public, you can choose strava's fuzzy processing, or private repositories.
## Support

Expand Down Expand Up @@ -176,7 +178,8 @@ Open your browser and visit localhost:80
> Suggested changes to your own [Mapbox token](https://www.mapbox.com/)
```typescript
const MAPBOX_TOKEN ='pk.eyJ1IjoieWlob25nMDYxOCIsImEiOiJja2J3M28xbG4wYzl0MzJxZm0ya2Fua2p2In0.PNKfkeQwYuyGOTT_x9BJ4Q';
const MAPBOX_TOKEN =
'pk.eyJ1IjoieWlob25nMDYxOCIsImEiOiJja2J3M28xbG4wYzl0MzJxZm0ya2Fua2p2In0.PNKfkeQwYuyGOTT_x9BJ4Q';
```

## Custom your page
Expand Down Expand Up @@ -290,7 +293,7 @@ python3(python) run_page/fit_sync.py
- If you only want `tcx` files add args --tcx
- If you only want `fit` files add args --fit
- If you are using Garmin as a data source, it is recommended that you pull the code to your local environment to run and obtain the Garmin secret.
**The Python version must be >=3.8**
**The Python version must be >=3.8**

#### Get Garmin Secret

Expand Down Expand Up @@ -335,7 +338,7 @@ python3(python) run_page/garmin_sync.py xxxxxxxxxxxxxx(secret_string) --only-run
- If you only want `tcx` files add args --tcx
- If you only want `fit` files add args --fit
- If you are using Garmin as a data source, it is recommended that you pull the code to your local environment to run and obtain the Garmin secret.
**The Python version must be >=3.10**
**The Python version must be >=3.10**

#### Get Garmin CN Secret

Expand Down Expand Up @@ -378,12 +381,13 @@ python3(python) run_page/garmin_sync.py xxxxxxxxxxxxxx(secret_string) --is-cn -
Get Nike's `refresh_token`

1. Login [Nike](https://www.nike.com) website
2. In Develop -> Application-> Storage -> https:unite.nike.com look for `refresh_token`
**ALL need to do outside GFW**

<br>
![example img](https://user-images.githubusercontent.com/67903793/282300381-4e7437d0-65a9-4eed-93d1-2b70e360215f.png)

1. Login from this [website](https://unite.nike.com/s3/unite/mobile.html?androidSDKVersion=3.1.0&corsoverride=https%3A%2F%2Funite.nike.com&uxid=com.nike.sport.running.droid.3.8&backendEnvironment=identity&view=login&clientId=VhAeafEGJ6G8e9DxRUz8iE50CZ9MiJMG), open F12 -> XHR -> get the `refresh_token` from login api.

![image](https://user-images.githubusercontent.com/15976103/94448123-23812b00-01dd-11eb-8143-4b0839c31d90.png)
2. copy this `refresh_token` and use it in GitHub Secrets or in command line

3. Execute in the root directory:

Expand Down Expand Up @@ -717,6 +721,14 @@ For more display effects, see:

4. make sure you have write permissions in Workflow permissions settings.



5. If you want to deploy your running_page to xxx.github.io instead of xxx.github.io/running_page, you need to do three things:

- Rename your forked running_page repository to `xxx.github.io`, where xxx is your GitHub username
- Modify the Build module in gh-pages.yml, remove `${{ github.event.repository.name }}` and change to `run: PATH_PREFIX=/ pnpm build`
- In `src/static/site-metadata.ts`, set siteUrl: ''

</details>

## GitHub Actions
Expand Down Expand Up @@ -851,17 +863,18 @@ Just enjoy it~

- Strava Api limit

<https://www.strava.com/settings/api>
<https://developers.strava.com/docs/#rate-limiting>
<https://www.strava.com/settings/api>
<https://developers.strava.com/docs/#rate-limiting>

```
Strava API Rate Limit Exceeded. Retry after 100 seconds
Strava API Rate Limit Timeout. Retry in 799.491622 seconds
```
```
Strava API Rate Limit Exceeded. Retry after 100 seconds
Strava API Rate Limit Timeout. Retry in 799.491622 seconds
```

- vercel git ignpre gh-pages:

you can change settings -> build -> Ignored Build Step -> Custom command

```bash
if [ "$VERCEL_GIT_COMMIT_REF" != "gh-pages" ]; then exit 1; else exit 0;
```
7 changes: 3 additions & 4 deletions run_page/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
JSON_FILE = os.path.join(parent, "src", "static", "activities.json")
SYNCED_FILE = os.path.join(parent, "imported.json")

# TODO: Move into nike_sync
BASE_URL = "https://api.nike.com/sport/v3/me"
TOKEN_REFRESH_URL = "https://unite.nike.com/tokenRefresh"
NIKE_CLIENT_ID = "HlHa2Cje3ctlaOqnxvgZXNaAs7T9nAuH"
# TODO: Move into nike_sync NRC THINGS


BASE_TIMEZONE = "Asia/Shanghai"


Expand Down
6 changes: 3 additions & 3 deletions run_page/gpxtrackposter/github_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def draw(self, dr: svgwrite.Drawing, size: XY, offset: XY):
f"{year}",
insert=offset.tuple(),
fill=self.poster.colors["text"],
alignment_baseline="hanging",
dominant_baseline="hanging",
style=year_style,
)
)
Expand All @@ -90,7 +90,7 @@ def draw(self, dr: svgwrite.Drawing, size: XY, offset: XY):
f"{year_length} {km_or_mi}",
insert=(offset.tuple()[0] + 165, offset.tuple()[1] + 5),
fill=self.poster.colors["text"],
alignment_baseline="hanging",
dominant_baseline="hanging",
style=year_length_style,
)
)
Expand Down Expand Up @@ -137,4 +137,4 @@ def draw(self, dr: svgwrite.Drawing, size: XY, offset: XY):
dr.add(rect)
github_rect_day += datetime.timedelta(1)
rect_x += 3.5
offset.y += 3.5 * 9 + year_size + 1.5
offset.y += 3.5 * 9 + year_size + 1.0
4 changes: 3 additions & 1 deletion run_page/gpxtrackposter/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ def load_from_db(self, activity):
self.start_time_local = start_time
self.end_time = start_time + activity.elapsed_time
self.length = float(activity.distance)
if not IGNORE_BEFORE_SAVING:
if IGNORE_BEFORE_SAVING:
summary_polyline = filter_out(activity.summary_polyline)
else:
summary_polyline = activity.summary_polyline
polyline_data = polyline.decode(summary_polyline) if summary_polyline else []
self.polylines = [[s2.LatLng.from_degrees(p[0], p[1]) for p in polyline_data]]
self.run_id = activity.run_id
Expand Down
6 changes: 5 additions & 1 deletion run_page/gpxtrackposter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ def project(
scale = size.x / d_x if size.x / size.y <= d_x / d_y else size.y / d_y
offset = offset + 0.5 * (size - scale * XY(d_x, -d_y)) - scale * XY(min_x, min_y)
lines = []
# If len > $zoom_threshold, choose 1 point out of every $step to reduce size of the SVG file
zoom_threshold = 400
for latlngline in latlnglines:
line = []
for latlng in latlngline:
step = int(len(latlngline) / zoom_threshold) + 1
for i in range(0, len(latlngline), step):
latlng = latlngline[i]
if bbox.contains(latlng):
line.append((offset + scale * latlng2xy(latlng)).tuple())
else:
Expand Down
Loading

0 comments on commit 502c1f4

Please sign in to comment.