From d787f6871c0736f32cda652a9988da6d9aeb933f Mon Sep 17 00:00:00 2001 From: Haotian Chen <53367039+chen2438@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:08:46 +0800 Subject: [PATCH 01/10] feat: automatic sync upstream using Github Actions After forking the project, due to the limitations imposed by GitHub, you need to manually enable Workflows and Upstream Sync Action on the Actions page of the forked project. --- .github/workflows/sync.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/sync.yml diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000..ba6cad3 --- /dev/null +++ b/.github/workflows/sync.yml @@ -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 From d72c03fd34172c0e1d6ce4c400a2dbbbddde2970 Mon Sep 17 00:00:00 2001 From: ccbikai Date: Thu, 8 Aug 2024 21:44:42 +0800 Subject: [PATCH 02/10] feat: improve back-to-top icon integration Refactor back-to-top icon import for better performance and maintainability. --- src/layouts/base.astro | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/layouts/base.astro b/src/layouts/base.astro index e6af8b2..f434601 100644 --- a/src/layouts/base.astro +++ b/src/layouts/base.astro @@ -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' --- @@ -127,7 +126,7 @@ const backToTopIcon = 'src/assets/back-to-top.svg' - Back to Top + Back to Top From 8bec08657dd7589124f41ab983a3fcdaed255242 Mon Sep 17 00:00:00 2001 From: ccbikai Date: Fri, 9 Aug 2024 08:20:53 +0800 Subject: [PATCH 03/10] feat: enhance image layout and handling Improved image display by introducing a responsive grid layout for image lists, optimizing the first image's placement in odd-numbered lists to span across both columns. This change enhances visual appeal and usability, especially on larger screens. Additionally, refactored image retrieval logic to wrap images in a container, dynamically adjusting the class based on the number of images for tailored styling. --- src/assets/item.css | 12 ++++++++++++ src/lib/telegram/index.js | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/assets/item.css b/src/assets/item.css index 43da170..89f4fd5 100644 --- a/src/assets/item.css +++ b/src/assets/item.css @@ -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)); } diff --git a/src/lib/telegram/index.js b/src/lib/telegram/index.js index bd13182..dae0690 100644 --- a/src/lib/telegram/index.js +++ b/src/lib/telegram/index.js @@ -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 ` @@ -44,7 +44,8 @@ function getImages($, item, { staticProxy, id, index, title }) { ${title} ` - })?.get()?.join('') + })?.get() + return `
${images?.join('')}
` } function getVideo($, item, { staticProxy, index }) { From 5adc053b7cf33946936ccd7ea5e4ceffcaf3498b Mon Sep 17 00:00:00 2001 From: ccbikai Date: Fri, 9 Aug 2024 08:29:03 +0800 Subject: [PATCH 04/10] feat: add new link --- README.md | 1 + README.zh-cn.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index ebc2bb9..50508a2 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ English | [简体中文](./README.zh-cn.md) - [Steve Studio](https://tgc.surgeee.me/) - [LiFePO4:沙雕吐槽](https://lifepo4.top) - [Hotspot Hourly](https://hourly.top/) +- [大河马中文财经新闻分享](https://a.xiaomi318.com/) ### Platform diff --git a/README.zh-cn.md b/README.zh-cn.md index ec3cdc9..77b7bba 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -32,6 +32,7 @@ - [Steve Studio](https://tgc.surgeee.me/) - [LiFePO4:沙雕吐槽](https://lifepo4.top) - [Hotspot Hourly](https://hourly.top/) +- [大河马中文财经新闻分享](https://a.xiaomi318.com/) ### 平台 From 4f9a403c9018b708439721c3cd17b40a4a359e4a Mon Sep 17 00:00:00 2001 From: ccbikai Date: Fri, 9 Aug 2024 08:32:41 +0800 Subject: [PATCH 05/10] feat: expand whitelist for secure redirects Add telesco.pe to targetWhitelist to enhance security and allow for additional trusted redirect destinations. --- src/pages/static/[...url].js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/static/[...url].js b/src/pages/static/[...url].js index 8752418..e0354d7 100644 --- a/src/pages/static/[...url].js +++ b/src/pages/static/[...url].js @@ -4,6 +4,7 @@ const targetWhitelist = [ 'telegram.me', 'telegram.dog', 'cdn-telegram.org', + 'telesco.pe', ] export const prerender = false From 50fc7413a9ed87c23faca4a00bbb68a8474c460e Mon Sep 17 00:00:00 2001 From: ccbikai Date: Fri, 9 Aug 2024 12:03:02 +0800 Subject: [PATCH 06/10] feat: enhance UI and fix video handling - Hide video elements in widget for improved user experience - Update header background for better contrast - Prevent empty image containers from rendering - Remove unsupported video player elements - Add onclick attribute to links for enhanced functionality - Include Yandex.ru in target whitelist for expanded compatibility --- src/assets/item.css | 4 ++++ src/components/header.astro | 1 + src/lib/telegram/index.js | 5 +++-- src/pages/static/[...url].js | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/assets/item.css b/src/assets/item.css index 89f4fd5..d167a56 100644 --- a/src/assets/item.css +++ b/src/assets/item.css @@ -118,6 +118,10 @@ display: block !important; } + .tgme_widget_message_video_wrap { + display: none; + } + .tgme_widget_message_poll_options { display: block; diff --git a/src/components/header.astro b/src/components/header.astro index b8e3cc7..9ddb1d2 100644 --- a/src/components/header.astro +++ b/src/components/header.astro @@ -156,6 +156,7 @@ const staticProxy = getEnv(import.meta.env, Astro, 'STATIC_PROXY') ?? '/static/'