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

refactor: rename img-url to media-url and site.img_cdn to site.cdn #1651

Merged

Conversation

MrMurdock11
Copy link
Collaborator

@MrMurdock11 MrMurdock11 commented Apr 5, 2024

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (refactoring and improving code)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Description

We discussed the variable changes in this PR.

Copy link
Owner

@cotes2020 cotes2020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

site.cdn is not just for images, so the documentation and code comments have to be changed accordingly.

Also I think the parameter of _includes/media-url.html should be changed from img_path to subpath.

@kungfux
Copy link
Collaborator

kungfux commented Apr 6, 2024

Also I think the parameter of _includes/media-url.html should be changed from img_path to subpath.

I'm not sure if it worst to rename parameters here as I would like to propose to refactor configuration to improve the support of image/video/audio embed. Just so you know. Here is a draft idea:

# Media files configuration
media:
  # Use CDN for media files e.g. "https://cdn.example.com"
  # If defined, CDN URL will be added to all image (site avatar & posts images) paths starting with '/'
  cdn: "https://chirpy-img.netlify.app"
  # Default path bases for images/videos/audios e.g. "/assets/images"
  # Can be extended by img_path/video_path/audio_path variables from post front matter
  # like site.base_paths.img_path + post.img_path
  base_path:
    img: "/assets/images"
    video: &video_base_path "/assets/video"
    audio: &audio_base_path "/assets/audio"

pwa:
  cache:
    enabled: true
    deny_paths:
      - *video_base_path
      - *audio_base_path

@cotes2020
Copy link
Owner

@kungfux Even if you add media.base_path to _config.yml, it still doesn't replace the existing page.xxx_path functionality.

So if you want to extend subpath support for video, you can just add page.video_path, and the same goes for audio.

@kungfux
Copy link
Collaborator

kungfux commented Apr 6, 2024

@cotes2020 That's correct and I wish to have it. The base path just makes it handy to omit specifying the full path every time.

So, the question is: do we want to accomplish some renaming here first or work on the whole solution right away instead. I have shared the idea just to avoid repeating work on the same things. Thanks.

@cotes2020
Copy link
Owner

cotes2020 commented Apr 6, 2024

... do we want to accomplish some renaming here first or work on the whole solution right away instead.

I think it's fine. Let's see what @MrMurdock11 thinks.

@MrMurdock11
Copy link
Collaborator Author

@cotes2020 I agree with @kungfux. I think we can do this now. My preparation process with renaming and new parameters for @kungfux's config is easier to release as a PR with a detailed description of what it's all for

@cotes2020
Copy link
Owner

Do you mean that the following configuration is feasible? @MrMurdock11

# Media files configuration
media:
  # ...
  # Default path bases for images/videos/audios e.g. "/assets/images"
  # Can be extended by img_path/video_path/audio_path variables from post front matter
  # like site.base_paths.img_path + post.img_path
  base_path:
    img: "/assets/images"
    video: &video_base_path "/assets/video"
    audio: &audio_base_path "/assets/audio"

# ...

@MrMurdock11
Copy link
Collaborator Author

MrMurdock11 commented Apr 9, 2024

@cotes2020 If you mean anchors in yaml, that's a hypothesis I really want to test, I like it. If it is feasible, the file configuration may simplify in some cases.

image

Based on the documentation, we can assume that it will work. But this needs to be tested directly in the project.
P.S.: This functionality supports from YAML v1.0

@cotes2020
Copy link
Owner

Hi @MrMurdock11 Mr, I'm not discussing anchors in yaml, but I'm worried that you're going to add a structure like media.base_path.{img|video|audio} to _config.yml, because it's unnecessary as it doesn't replace the functionality of the existing page.img_path (front-matter in the header of the post) and adds complexity to the configuration.

@MrMurdock11
Copy link
Collaborator Author

@cotes2020 After discussing @kungfux's suggestion offline, I realized that the root of his solution is a bug with caching large amounts of audio/video files. After analyzing the code base, I came to the conclusion that you are right and there is no point in complicating the configuration file in this case, because we can add code to avoid this bug in the future. Below is the code that should fix this.

// ./sw.js

- if (purge || event.request.method !== 'GET' || !verifyUrl(url)) {
+ if (purge || response.status !== 200 || event.request.method !== 'GET' || !verifyUrl(url)) {
  return response;
}

Based on this, I'll make the corrections you mentioned at the beginning and create a separate PR to fix this problem.

@MrMurdock11 MrMurdock11 force-pushed the feature/rename-img-url-and-img-cdn branch from 7c96393 to 0b1221b Compare April 12, 2024 14:09
@MrMurdock11
Copy link
Collaborator Author

MrMurdock11 commented Apr 12, 2024

site.cdn is not just for images, so the documentation and code comments have to be changed accordingly.

Also I think the parameter of _includes/media-url.html should be changed from img_path to subpath.

What do u think do we need to rename img_path: '/posts/20180809' to media_(sub)path: '/posts/20180809' for page scope?

Co-authored-by: MrMurdock11 MrMurdock11@users.noreply.github.com
Co-authored-by: kungfux kungfux@users.noreply.github.com
@cotes2020
Copy link
Owner

What do u think do we need to rename img_path: '/posts/20180809' to media_(sub)path: '/posts/20180809' for page scope?

OK, I think both names are fine (page.media_path / page.media_subpath). It's your call. :)

@MrMurdock11
Copy link
Collaborator Author

@cotes2020 @kungfux I've pushed my changes. If you have time, please check

_layouts/home.html Outdated Show resolved Hide resolved
_posts/2019-08-08-write-a-new-post.md Outdated Show resolved Hide resolved
_posts/2019-08-08-write-a-new-post.md Outdated Show resolved Hide resolved
Copy link
Owner

@cotes2020 cotes2020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MrMurdock11 MrMurdock11 merged commit 347c88a into cotes2020:master Apr 12, 2024
5 checks passed
@cotes2020
Copy link
Owner

Since this is a BREAKING CHANGE, I'll fix the commit message with force-push.

cotes2020 pushed a commit that referenced this pull request Apr 12, 2024
- Changed variable `img_cdn` to `cdn` in site configuration file.
- Changed the variable defining the relative path of the image in the post from `img_url` to `media_subpath`
@MrMurdock11 MrMurdock11 deleted the feature/rename-img-url-and-img-cdn branch April 13, 2024 10:56
mill413 pushed a commit to mill413/mill413.github.io that referenced this pull request Apr 21, 2024
- Changed variable `img_cdn` to `cdn` in site configuration file.
- Changed the variable defining the relative path of the image in the post from `img_url` to `media_subpath`
github-actions bot pushed a commit that referenced this pull request May 11, 2024
## [7.0.0](v6.5.5...v7.0.0) (2024-05-11)

### ⚠ BREAKING CHANGES

* optimize the resource hints (#1717)
* rename media-url file and related parameters (#1651)
* rename comment setting parameter (#1563)
* **analytics:** add post pageviews for GoatCounter (#1543)

### Features

* add cloudflare web analytics ([#1723](#1723)) ([c17fba4](c17fba4))
* add support for embed video files ([#1558](#1558)) ([9592146](9592146))
* add support for giscus strict title matching ([#1614](#1614)) ([700fd5b](700fd5b))
* **analytics:** add post pageviews for GoatCounter ([#1543](#1543)) ([b641b3f](b641b3f))
* **analytics:** add Umami and Matomo tracking codes ([#1658](#1658)) ([61bdca2](61bdca2))
* change site verification settings ([#1561](#1561)) ([e436387](e436387))
* **deps:** move `MathJax` configuration to a separate file ([#1670](#1670)) ([44f552c](44f552c))
* display theme version in footer ([#1611](#1611)) ([8349314](8349314))
* **i18n:** allow `page.lang` to override `site.lang` ([#1586](#1586)) ([547b95c](547b95c))
* make post description customizable ([#1602](#1602)) ([f865336](f865336))
* **media:** support audio and video tag with multi sources ([#1618](#1618)) ([23be416](23be416))

### Bug Fixes

* make TOC title and entries visible at the same time ([#1711](#1711)) ([e0950fc](e0950fc))
* mode toggle not outlined when receiving keyboard focus ([#1690](#1690)) ([cd37f63](cd37f63))
* prevent footnote back arrow from becoming an emoji ([#1716](#1716)) ([8608147](8608147))
* **pwa:** skip range requests in service worker ([#1672](#1672)) ([76d58fe](76d58fe))
* search result prompt is empty ([#1583](#1583)) ([8a2afae](8a2afae))
* use `https` for Weibo sharing URL ([#1612](#1612)) ([8e5fbb7](8e5fbb7))

### Improvements

* improve <hr> visibility in dark mode ([#1565](#1565)) ([4ddd5c4](4ddd5c4))
* lean bootstrap javascript ([#1734](#1734)) ([ddb48ed](ddb48ed))
* rename comment setting parameter ([#1563](#1563)) ([f8390d4](f8390d4))
* replace jQuery with Vanilla JS ([#1681](#1681)) ([fe7afa3](fe7afa3))
* simplify mode toggle script ([#1692](#1692)) ([d4a6d64](d4a6d64))
* tree shaking Bootstrap CSS ([#1736](#1736)) ([363a3d9](363a3d9))

### Changes

* optimize the resource hints ([#1717](#1717)) ([dcb0add](dcb0add))
* rename media-url file and related parameters ([#1651](#1651)) ([9f8aeaa](9f8aeaa))
kimbob13 pushed a commit to kimbob13/kimbob13.github.io that referenced this pull request May 25, 2024
- Changed variable `img_cdn` to `cdn` in site configuration file.
- Changed the variable defining the relative path of the image in the post from `img_url` to `media_subpath`
kimbob13 pushed a commit to kimbob13/kimbob13.github.io that referenced this pull request May 25, 2024
## [7.0.0](cotes2020/jekyll-theme-chirpy@v6.5.5...v7.0.0) (2024-05-11)

### ⚠ BREAKING CHANGES

* optimize the resource hints (cotes2020#1717)
* rename media-url file and related parameters (cotes2020#1651)
* rename comment setting parameter (cotes2020#1563)
* **analytics:** add post pageviews for GoatCounter (cotes2020#1543)

### Features

* add cloudflare web analytics ([cotes2020#1723](cotes2020#1723)) ([c17fba4](cotes2020@c17fba4))
* add support for embed video files ([cotes2020#1558](cotes2020#1558)) ([9592146](cotes2020@9592146))
* add support for giscus strict title matching ([cotes2020#1614](cotes2020#1614)) ([700fd5b](cotes2020@700fd5b))
* **analytics:** add post pageviews for GoatCounter ([cotes2020#1543](cotes2020#1543)) ([b641b3f](cotes2020@b641b3f))
* **analytics:** add Umami and Matomo tracking codes ([cotes2020#1658](cotes2020#1658)) ([61bdca2](cotes2020@61bdca2))
* change site verification settings ([cotes2020#1561](cotes2020#1561)) ([e436387](cotes2020@e436387))
* **deps:** move `MathJax` configuration to a separate file ([cotes2020#1670](cotes2020#1670)) ([44f552c](cotes2020@44f552c))
* display theme version in footer ([cotes2020#1611](cotes2020#1611)) ([8349314](cotes2020@8349314))
* **i18n:** allow `page.lang` to override `site.lang` ([cotes2020#1586](cotes2020#1586)) ([547b95c](cotes2020@547b95c))
* make post description customizable ([cotes2020#1602](cotes2020#1602)) ([f865336](cotes2020@f865336))
* **media:** support audio and video tag with multi sources ([cotes2020#1618](cotes2020#1618)) ([23be416](cotes2020@23be416))

### Bug Fixes

* make TOC title and entries visible at the same time ([cotes2020#1711](cotes2020#1711)) ([e0950fc](cotes2020@e0950fc))
* mode toggle not outlined when receiving keyboard focus ([cotes2020#1690](cotes2020#1690)) ([cd37f63](cotes2020@cd37f63))
* prevent footnote back arrow from becoming an emoji ([cotes2020#1716](cotes2020#1716)) ([8608147](cotes2020@8608147))
* **pwa:** skip range requests in service worker ([cotes2020#1672](cotes2020#1672)) ([76d58fe](cotes2020@76d58fe))
* search result prompt is empty ([cotes2020#1583](cotes2020#1583)) ([8a2afae](cotes2020@8a2afae))
* use `https` for Weibo sharing URL ([cotes2020#1612](cotes2020#1612)) ([8e5fbb7](cotes2020@8e5fbb7))

### Improvements

* improve <hr> visibility in dark mode ([cotes2020#1565](cotes2020#1565)) ([4ddd5c4](cotes2020@4ddd5c4))
* lean bootstrap javascript ([cotes2020#1734](cotes2020#1734)) ([ddb48ed](cotes2020@ddb48ed))
* rename comment setting parameter ([cotes2020#1563](cotes2020#1563)) ([f8390d4](cotes2020@f8390d4))
* replace jQuery with Vanilla JS ([cotes2020#1681](cotes2020#1681)) ([fe7afa3](cotes2020@fe7afa3))
* simplify mode toggle script ([cotes2020#1692](cotes2020#1692)) ([d4a6d64](cotes2020@d4a6d64))
* tree shaking Bootstrap CSS ([cotes2020#1736](cotes2020#1736)) ([363a3d9](cotes2020@363a3d9))

### Changes

* optimize the resource hints ([cotes2020#1717](cotes2020#1717)) ([dcb0add](cotes2020@dcb0add))
* rename media-url file and related parameters ([cotes2020#1651](cotes2020#1651)) ([9f8aeaa](cotes2020@9f8aeaa))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants