Merge branch 'main' into dev

This commit is contained in:
ccbikai
2024-08-11 09:56:33 +08:00
9 changed files with 82 additions and 8 deletions

40
.github/workflows/sync.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: Upstream Sync
permissions:
contents: write
on:
schedule:
- cron: "0 0 * * *" # every day
workflow_dispatch:
jobs:
sync_latest_from_upstream:
name: Sync latest commits from upstream repo
runs-on: ubuntu-latest
if: ${{ github.event.repository.fork }}
steps:
# Step 1: run a standard checkout action
- name: Checkout target repo
uses: actions/checkout@v3
# Step 2: run the sync action
- name: Sync upstream changes
id: sync
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
with:
upstream_sync_repo: ccbikai/BroadcastChannel
upstream_sync_branch: main
target_sync_branch: main
target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set
# Set test_mode true to run tests instead of the true action!!
test_mode: false
- name: Sync check
if: failure()
run: |
echo "[Error] 由于上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次。"
echo "[Error] Due to a change in the workflow file of the upstream repository, GitHub has automatically suspended the scheduled automatic update. You need to manually sync your fork."
exit 1

View File

@@ -32,6 +32,11 @@ English | [简体中文](./README.zh-cn.md)
- [Steve Studio](https://tgc.surgeee.me/)
- [LiFePO4:沙雕吐槽](https://lifepo4.top)
- [Hotspot Hourly](https://hourly.top/)
- [大河马中文财经新闻分享](https://a.xiaomi318.com/)
- [\_My. Tricks 🎩 Collection](https://channel.mykeyvans.com)
- [小报童专栏精选](https://xiaobaotong.genaiprism.site/)
- [Fake news](https://fake-news.csgo.ovh/)
- [miyi23's Geekhub资源分享](https://gh.miyi23.top/)
### Platform

View File

@@ -32,6 +32,11 @@
- [Steve Studio](https://tgc.surgeee.me/)
- [LiFePO4:沙雕吐槽](https://lifepo4.top)
- [Hotspot Hourly](https://hourly.top/)
- [大河马中文财经新闻分享](https://a.xiaomi318.com/)
- [\_My. 技巧 🎩 集锦](https://channel.mykeyvans.com)
- [小报童专栏精选](https://xiaobaotong.genaiprism.site/)
- [Fake news](https://fake-news.csgo.ovh/)
- [miyi23's Geekhub资源分享](https://gh.miyi23.top/)
### 平台

View File

@@ -1,6 +1,18 @@
.content {
word-break: break-word;
.image-list-container {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: masonry;
&.image-list-odd {
:first-child {
grid-column: 1 / 3;
}
}
}
img {
width: calc(100% - var(--box-margin));
}
@@ -106,6 +118,10 @@
display: block !important;
}
.tgme_widget_message_video_wrap {
display: none;
}
.tgme_widget_message_poll_options {
display: block;

View File

@@ -156,6 +156,7 @@ const staticProxy = getEnv(import.meta.env, Astro, 'STATIC_PROXY') ?? '/static/'
<style>
#site-intro {
color: var(--secondary-color);
background-color: var(--code-background-color);
word-break: break-word;
& :global(.emoji) {

View File

@@ -4,6 +4,7 @@ import '../assets/style.css'
import '../assets/global.css'
import { SEO } from 'astro-seo'
import { getEnv } from '../lib/env'
import backToTopIcon from '../assets/back-to-top.svg'
const { SITE_URL } = Astro.locals
const { channel } = Astro.props
@@ -42,8 +43,6 @@ const seoParams = {
const HEADER_INJECT = getEnv(import.meta.env, Astro, 'HEADER_INJECT')
const FOOTER_INJECT = getEnv(import.meta.env, Astro, 'FOOTER_INJECT')
const backToTopIcon = 'src/assets/back-to-top.svg'
---
<!doctype html>
@@ -127,7 +126,7 @@ const backToTopIcon = 'src/assets/back-to-top.svg'
</div>
</div>
<a href="#wrapper" id="back-to-top" aria-label="Back to top">
<img src={backToTopIcon} alt="Back to Top" />
<img {...backToTopIcon} alt="Back to Top" />
</a>
<Fragment set:html={FOOTER_INJECT} />
</body>

View File

@@ -33,7 +33,7 @@ function getImageStickers($, item, { staticProxy, index }) {
}
function getImages($, item, { staticProxy, id, index, title }) {
return $(item).find('.tgme_widget_message_photo_wrap')?.map((_index, photo) => {
const images = $(item).find('.tgme_widget_message_photo_wrap')?.map((_index, photo) => {
const url = $(photo).attr('style').match(/url\(["'](.*?)["']/)?.[1]
const popoverId = `modal-${id}-${_index}`
return `
@@ -41,10 +41,11 @@ function getImages($, item, { staticProxy, id, index, title }) {
<img src="${staticProxy + url}" alt="${title}" loading="${index > 15 ? 'eager' : 'lazy'}" />
</button>
<button class="image-preview-button modal" id="${popoverId}" popovertarget="${popoverId}" popovertargetaction="hide" popover>
<img class="modal-img" src="${staticProxy + url}" alt="${title}" loading="${index > 15 ? 'eager' : 'lazy'}" />
<img class="modal-img" src="${staticProxy + url}" alt="${title}" loading="lazy" />
</button>
`
})?.get()?.join('')
})?.get()
return images.length ? `<div class="image-list-container ${images.length % 2 === 0 ? 'image-list-even' : 'image-list-odd'}">${images?.join('')}</div>` : ''
}
function getVideo($, item, { staticProxy, index }) {
@@ -99,7 +100,7 @@ function getReply($, item, { channel }) {
function modifyHTMLContent($, content, { index } = {}) {
$(content).find('.emoji')?.attr('style', '')
$(content).find('a')?.each((_index, a) => {
$(a)?.attr('title', $(a)?.text())
$(a)?.attr('title', $(a)?.text())?.attr('onclick', '')
})
$(content).find('tg-spoiler')?.each((_index, spoiler) => {
const id = `spoiler-${index}-${_index}`
@@ -140,6 +141,7 @@ function getPost($, item, { channel, staticProxy, index = 0 }) {
// $(item).find('.tgme_widget_message_sticker_wrap')?.html(),
$(item).find('.tgme_widget_message_poll')?.html(),
$.html($(item).find('.tgme_widget_message_document_wrap')),
$.html($(item).find('.tgme_widget_message_video_player.not_supported')),
$.html($(item).find('.tgme_widget_message_location_wrap')),
getLinkPreview($, item, { staticProxy, index }),
].filter(Boolean).join('').replace(/(url\(["'])((https?:)?\/\/)/g, (match, p1, p2, _p3) => {

View File

@@ -25,9 +25,13 @@ export async function GET(Astro) {
content: sanitizeHtml(item.content, {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'video', 'audio']),
allowedAttributes: {
...sanitizeHtml.defaults.allowedAttributes,
video: ['src', 'width', 'height', 'poster'],
audio: ['src', 'controls'],
img: ['src', 'width', 'height', 'loading'],
img: ['src', 'srcset', 'alt', 'title', 'width', 'height', 'loading', 'class'],
},
exclusiveFilter(frame) {
return frame.tag === 'img' && frame.attribs?.class?.includes('modal-img')
},
}),
})),

View File

@@ -4,6 +4,8 @@ const targetWhitelist = [
'telegram.me',
'telegram.dog',
'cdn-telegram.org',
'telesco.pe',
'yandex.ru',
]
export const prerender = false