From e06f833e213d907d0dbe61ccb18ed215a4cd1bc8 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 4 Jul 2023 18:46:35 +0800 Subject: [PATCH 1/3] fix: missing published date in some wechat articles * some wechat articles do not have `create_time` in the dom javascript so use the `publish_time` node in the dom content --- .../src/websites/weixin-qq-handler.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/content-handler/src/websites/weixin-qq-handler.ts b/packages/content-handler/src/websites/weixin-qq-handler.ts index cab4040c8..4ae9f6ae8 100644 --- a/packages/content-handler/src/websites/weixin-qq-handler.ts +++ b/packages/content-handler/src/websites/weixin-qq-handler.ts @@ -17,11 +17,16 @@ export class WeixinQqHandler extends ContentHandler { if (publishTime) { const dateTimeFormat = 'yyyy-LL-dd HH:mm' // convert the publish time to a string in the format of "2023-01-01 00:00" in GMT+8 - const publishTimeInGMT8 = DateTime.fromFormat(publishTime, dateTimeFormat) - .setZone('Asia/Shanghai') - .toFormat(dateTimeFormat) - // replace the publish time in the dom - dom.querySelector('#publish_time')?.replaceWith(publishTimeInGMT8) + const publishTimeISO = DateTime.fromFormat( + publishTime, + dateTimeFormat + ).toISO() + + // create a meta node to store the publish time with timezone + const metaNode = dom.createElement('meta') + metaNode.setAttribute('name', 'date') + metaNode.setAttribute('content', publishTimeISO) + dom.querySelector('head')?.appendChild(metaNode) } // This replace the class name of the article info to preserve the block dom From 9a92fc68704c79e0669ab5212c17a2eb51e209cb Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 4 Jul 2023 18:58:21 +0800 Subject: [PATCH 2/3] fix: * published/saved date not editable on web * these two dates are not fully shown --- .../templates/homeFeed/EditItemModals.tsx | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/web/components/templates/homeFeed/EditItemModals.tsx b/packages/web/components/templates/homeFeed/EditItemModals.tsx index a147990e4..06c316c19 100644 --- a/packages/web/components/templates/homeFeed/EditItemModals.tsx +++ b/packages/web/components/templates/homeFeed/EditItemModals.tsx @@ -1,23 +1,20 @@ +import dayjs, { Dayjs } from 'dayjs' +import { useCallback, useState } from 'react' +import { updatePageMutation } from '../../../lib/networking/mutations/updatePageMutation' +import { ArticleAttributes } from '../../../lib/networking/queries/useGetArticleQuery' +import { LibraryItem } from '../../../lib/networking/queries/useGetLibraryItemsQuery' +import { showErrorToast, showSuccessToast } from '../../../lib/toastHelpers' +import { CloseButton } from '../../elements/CloseButton' +import { FormInput } from '../../elements/FormElements' +import { Box, HStack, SpanBox, VStack } from '../../elements/LayoutPrimitives' import { ModalButtonBar, ModalContent, ModalOverlay, ModalRoot, } from '../../elements/ModalPrimitives' -import { Box, HStack, SpanBox, VStack } from '../../elements/LayoutPrimitives' -import { Button } from '../../elements/Button' import { StyledText } from '../../elements/StyledText' - -import { FormInput } from '../../elements/FormElements' -import { useCallback, useState } from 'react' -import { LibraryItem } from '../../../lib/networking/queries/useGetLibraryItemsQuery' import { StyledTextArea } from '../../elements/StyledTextArea' -import { updatePageMutation } from '../../../lib/networking/mutations/updatePageMutation' -import { showErrorToast, showSuccessToast } from '../../../lib/toastHelpers' -import dayjs, { Dayjs } from 'dayjs' -import { ArticleAttributes } from '../../../lib/networking/queries/useGetArticleQuery' -import { CloseButton } from '../../elements/CloseButton' - type EditLibraryItemModalProps = { onOpenChange: (open: boolean) => void item: LibraryItem @@ -227,7 +224,7 @@ function EditItemModal(props: EditItemModalProps): JSX.Element { > { // remove focus from modal ;(document.activeElement as HTMLElement).blur() @@ -244,10 +241,10 @@ function EditItemModal(props: EditItemModalProps): JSX.Element { > - SAVED AT: + SAVED AT { const dateStr = event.target.value @@ -264,8 +261,8 @@ function EditItemModal(props: EditItemModalProps): JSX.Element { Date: Tue, 4 Jul 2023 19:02:47 +0800 Subject: [PATCH 3/3] comment --- packages/content-handler/src/websites/weixin-qq-handler.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/content-handler/src/websites/weixin-qq-handler.ts b/packages/content-handler/src/websites/weixin-qq-handler.ts index 4ae9f6ae8..35006cd50 100644 --- a/packages/content-handler/src/websites/weixin-qq-handler.ts +++ b/packages/content-handler/src/websites/weixin-qq-handler.ts @@ -16,13 +16,12 @@ export class WeixinQqHandler extends ContentHandler { const publishTime = dom.querySelector('#publish_time')?.textContent if (publishTime) { const dateTimeFormat = 'yyyy-LL-dd HH:mm' - // convert the publish time to a string in the format of "2023-01-01 00:00" in GMT+8 const publishTimeISO = DateTime.fromFormat( publishTime, dateTimeFormat ).toISO() - // create a meta node to store the publish time with timezone + // create a meta node to store the publish time in ISO format const metaNode = dom.createElement('meta') metaNode.setAttribute('name', 'date') metaNode.setAttribute('content', publishTimeISO)