Skip to content

Commit d613f53

Browse files
feat: update publication sync and year grouping
1 parent 71a8b71 commit d613f53

3 files changed

Lines changed: 43 additions & 19 deletions

File tree

.github/workflows/sync_papers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Sync Papers from Feishu
22

33
on:
44
schedule:
5-
- cron: "*/10 * * * *" # every 10 minutes (TESTING — revert to daily later)
5+
- cron: "0 18 * * *" # daily at 18:00 UTC = 02:00 Beijing time
66
workflow_dispatch: # allow manual trigger
77

88
jobs:

assets/js/publications.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
title: ['论文标题', 'title', '标题', '题目', '论文', 'paper', 'name'],
1313
authors: ['作者信息', '作者', 'author', '参与者'],
1414
venue: ['期刊/会议', '期刊', '会议', 'venue', 'conference', 'journal', 'publish', '发表', '来源'],
15+
publishedAt: ['论文发表日期', '发表日期', 'publication date', 'published at', 'published', 'date'],
1516
pdf: ['arXiv主页', 'arxiv', 'pdf', '链接', 'link', 'url'],
1617
code: ['Github仓库链接', 'github', 'code', '代码', 'repo', '仓库'],
1718
project: ['刊印链接', 'project', '项目页', '主页', '刊印'],
@@ -51,14 +52,28 @@
5152
.join(', ');
5253
}
5354

54-
function yearFromVenue(venue) {
55-
var m = String(venue || '').match(/\b(20\d{2})\b/);
56-
return m ? m[1] : '';
55+
function yearFromPublishedAt(value) {
56+
if (value === null || value === undefined || value === '') return '';
57+
58+
if (typeof value === 'number' || /^\d+$/.test(String(value).trim())) {
59+
var ts = Number(value);
60+
if (!Number.isNaN(ts) && ts > 0) {
61+
return String(new Date(ts).getUTCFullYear());
62+
}
63+
}
64+
65+
var text = String(value).trim();
66+
var m = text.match(/\b(20\d{2})\b/);
67+
if (m) return m[1];
68+
69+
var parsed = new Date(text);
70+
return Number.isNaN(parsed.getTime()) ? '' : String(parsed.getUTCFullYear());
5771
}
5872

5973
function normalise(raw, map) {
6074
var venue = map.venue ? (raw[map.venue] || '') : '';
6175
var authors = map.authors ? (raw[map.authors] || '') : '';
76+
var publishedAt = map.publishedAt ? (raw[map.publishedAt] || '') : '';
6277
var tags = [];
6378

6479
if (map.tags && raw[map.tags]) {
@@ -76,7 +91,7 @@
7691
title: map.title ? (raw[map.title] || '') : '',
7792
authors: cleanAuthors(typeof authors === 'string' ? authors : extractUrl(authors)),
7893
venue: typeof venue === 'string' ? venue : extractUrl(venue),
79-
year: yearFromVenue(venue),
94+
year: yearFromPublishedAt(publishedAt),
8095
pdf: map.pdf ? extractUrl(raw[map.pdf]) : '',
8196
code: map.code ? extractUrl(raw[map.code]) : '',
8297
project: map.project ? extractUrl(raw[map.project]) : '',
@@ -87,7 +102,7 @@
87102

88103
function buildMap(keys) {
89104
var map = {};
90-
['title', 'authors', 'venue', 'pdf', 'code', 'project', 'tags', 'thumbnail'].forEach(function (f) {
105+
['title', 'authors', 'venue', 'publishedAt', 'pdf', 'code', 'project', 'tags', 'thumbnail'].forEach(function (f) {
91106
map[f] = detectKey(keys, f);
92107
});
93108
return map;

0 commit comments

Comments
 (0)