Skip to content

Commit

Permalink
feat(random_image): customize resource identifier param name (#530)
Browse files Browse the repository at this point in the history
* feat: customize resource identifier param name

Co-authored-by: Takagi <[email protected]>

* refactor(random_image): move cfg position

---------

Co-authored-by: Takagi <[email protected]>
  • Loading branch information
ShiinaKin and LIlGG authored Jun 12, 2024
1 parent e4e986f commit aeddf4c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,13 @@ spec:
label: 文章使用随机封面图
value: false
help: 文章是否使用随机图的设置随机获取图片
- $formkit: text
if: "$get(rimage_cover_open).value == true"
name: rimage_custom_param_name
label: 随机图 API 资源标识变量
validation: "required"
value: postid
help: 随机图 API 资源标识变量,默认为 postid,可根据随机图 API 的需要自行设置。
- $formkit: checkbox
name: rimage_cover_sheet_open
id: rimage_cover_sheet_open
Expand Down
2 changes: 1 addition & 1 deletion templates/macro/content-thumb.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h1 th:text="${post.spec.title}"></h1>
/>
<img
th:if="${#strings.isEmpty(post.spec.cover)} and ${theme.config.random_image.rimage_cover_open} and ${#annotations.getOrDefault(post, 'randomImage', true)} and ${not #strings.isEmpty(theme.config.random_image.rimage_url)}"
th:with="randomUrl = |${theme.config.random_image.rimage_url}?postid=${post.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
th:with="randomUrl = |${theme.config.random_image.rimage_url}?${theme.config.random_image.rimage_custom_param_name}=${post.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
th:src="${theme.config.random_image.rimage_cover_lqip == 'loading' ? #theme.assets('/images/load/orange.progress-bar-stripe-loader.svg') : (randomUrl + (#strings.isEmpty(theme.config.random_image.rimage_cover_lqip_params) ? '' : '&' + theme.config.random_image.rimage_cover_lqip_params))}"
th:data-srcset="|
${randomUrl}&th=640 640w,
Expand Down
2 changes: 1 addition & 1 deletion templates/macro/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/>
<img
th:if="${#strings.isEmpty(post.spec.cover)} and ${theme.config.random_image.rimage_cover_open} and ${#annotations.getOrDefault(post, 'randomImage', true)} and ${not #strings.isEmpty(theme.config.random_image.rimage_url)}"
th:with="randomUrl = |${theme.config.random_image.rimage_url}?postid=${post.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
th:with="randomUrl = |${theme.config.random_image.rimage_url}?${theme.config.random_image.rimage_custom_param_name}=${post.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
th:src="${theme.config.random_image.rimage_cover_lqip == 'loading' ? #theme.assets('/images/load/orange.progress-bar-stripe-loader.svg') : (randomUrl + (#strings.isEmpty(theme.config.random_image.rimage_cover_lqip_params) ? '' : '&' + theme.config.random_image.rimage_cover_lqip_params))}"
th:data-srcset="|
${randomUrl}&th=150 150w,
Expand Down
2 changes: 1 addition & 1 deletion templates/macro/page-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!--/* 随机图 */-->
<th:block
th:if="${#strings.isEmpty(frontCover) && randomCoverAvailable}"
th:with="randomImage = |${theme.config.random_image.rimage_url}?${_templateId}id=${id != null ? id : extension.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
th:with="randomImage = |${theme.config.random_image.rimage_url}?${_templateId}id=${id != null ? id : extension.metadata.name}&${theme.config.random_image.rimage_custom_param_name}=${id != null ? id : extension.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
>
<img
th:src="${theme.config.random_image.rimage_cover_lqip == 'loading' ? #theme.assets('/images/load/orange.progress-bar-stripe-loader.svg') : (randomImage + (#strings.isEmpty(theme.config.random_image.rimage_cover_lqip_params) ? '' : '&' + theme.config.random_image.rimage_cover_lqip_params))}"
Expand Down
4 changes: 2 additions & 2 deletions templates/module/post-pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/>
<img
th:if="${#strings.isEmpty(postCursor.previous.spec.cover)} and ${theme.config.random_image.rimage_cover_open} and ${#annotations.getOrDefault(post, 'randomImage', true)} and ${not #strings.isEmpty(theme.config.random_image.rimage_url)}"
th:with="randomUrl = |${theme.config.random_image.rimage_url}?postid=${postCursor.previous.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
th:with="randomUrl = |${theme.config.random_image.rimage_url}?${theme.config.random_image.rimage_custom_param_name}=${postCursor.previous.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
th:src="${theme.config.random_image.rimage_cover_lqip == 'loading' ? #theme.assets('/images/load/orange.progress-bar-stripe-loader.svg') : (randomUrl + (#strings.isEmpty(theme.config.random_image.rimage_cover_lqip_params) ? '' : '&' + theme.config.random_image.rimage_cover_lqip_params))}"
th:data-srcset="|
${randomUrl}&th=400 400w,
Expand Down Expand Up @@ -75,7 +75,7 @@ <h3 th:text="${postCursor.previous.spec.title}"></h3>
/>
<img
th:if="${#strings.isEmpty(postCursor.next.spec.cover)} and ${theme.config.random_image.rimage_cover_open} and ${#annotations.getOrDefault(post, 'randomImage', true)} and ${not #strings.isEmpty(theme.config.random_image.rimage_url)}"
th:with="randomUrl = |${theme.config.random_image.rimage_url}?postid=${postCursor.next.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
th:with="randomUrl = |${theme.config.random_image.rimage_url}?${theme.config.random_image.rimage_custom_param_name}=${postCursor.next.metadata.name}&type=url&itype=${theme.config.random_image.rimage_cover_itype}${theme.config.random_image.rimage_cover_itype != 'image' ? '&id=' + theme.config.random_image.rimage_cover_id : ''}${#strings.isEmpty(theme.config.random_image.rimage_other_params) ? '' : '&' + theme.config.random_image.rimage_other_params}|"
th:src="${theme.config.random_image.rimage_cover_lqip == 'loading' ? #theme.assets('/images/load/orange.progress-bar-stripe-loader.svg') : (randomUrl + (#strings.isEmpty(theme.config.random_image.rimage_cover_lqip_params) ? '' : '&' + theme.config.random_image.rimage_cover_lqip_params))}"
th:data-srcset="|
${randomUrl}&th=400 400w,
Expand Down

0 comments on commit aeddf4c

Please sign in to comment.