Skip to content

Commit f57aa03

Browse files
committed
fix and feat: support more activatives. #50 #51
fix: issue #50 fix: issue #51 feat: support more activatives.
1 parent baa1bf0 commit f57aa03

File tree

6 files changed

+70
-60
lines changed

6 files changed

+70
-60
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@ ZoTracer is a [Zotero](https://www.zotero.org/) plugin that not only tracks and
3232
## Features
3333

3434
- **Comprehensive Activity Tracking**
35-
- Record research activities like reading, writing, and citing
36-
- Track literature management operations (adding, editing, organizing)
37-
- Monitor tab and reader usage
35+
36+
- Track the complete research process: reading, note-taking, and citation
37+
- Precisely monitor literature management operations (collection, editing, organization)
38+
- Real-time tracking of tab usage and reading behavior
39+
40+
- **Quick Location Based on Activity History**
41+
42+
- Intuitive activity data visualization interface
43+
- Flexible chronological and activity-based sorting
44+
- One-click access to literature associated with historical activities
45+
3846
- **Structured Data Export for Specific Workflows**
39-
- Support custom export formats and fields
40-
- Seamless integration with other tools and platforms (e.g., to [Flomo](https://flomoapp.com/))
41-
- Facilitate data analysis and visualization
42-
- **AI-Supported Contextual Annotation (Coming Soon)**
43-
- Intelligent identification and extraction of key information
44-
- Automatic generation of tag and summary suggestions
45-
- Personalized recommendations based on reading history
47+
- Seamless integration with mainstream knowledge management tools (e.g., [Flomo](https://flomoapp.com/))
4648

4749
## Quick Start
4850

addon/content/activityLog.js

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,20 @@ const ZoTracerActivityLog = {
376376
// Group activities by article title
377377
const groupedByArticle = {};
378378
activities.forEach(activity => {
379-
const title = activity.articleTitle || 'Other Activities';
380-
if (!groupedByArticle[title]) {
381-
groupedByArticle[title] = {
379+
const articleKey = activity.articleKey || 'Other Activities';
380+
const articleTitle = activity.articleTitle || 'Other Activities';
381+
if (!groupedByArticle[articleKey]) {
382+
groupedByArticle[articleKey] = {
382383
activities: [],
383-
lastModified: new Date(0)
384+
lastModified: new Date(0),
385+
articleTitle
384386
};
385387
}
386-
groupedByArticle[title].activities.push(activity);
388+
groupedByArticle[articleKey].activities.push(activity);
387389
const activityDate = new Date(activity.timestamp);
388-
if (activityDate > groupedByArticle[title].lastModified) {
389-
groupedByArticle[title].lastModified = activityDate;
390+
if (activityDate > groupedByArticle[articleKey].lastModified) {
391+
groupedByArticle[articleKey].lastModified = activityDate;
392+
groupedByArticle[articleKey].articleTitle = articleTitle;
390393
}
391394
});
392395

@@ -395,7 +398,7 @@ const ZoTracerActivityLog = {
395398
.sort(([, a], [, b]) => b.lastModified - a.lastModified);
396399

397400
// Create article groups
398-
sortedArticles.forEach(([title, data]) => {
401+
sortedArticles.forEach(([articleKey, data]) => {
399402
const articleGroup = document.createElement('div');
400403
articleGroup.className = 'article-group';
401404

@@ -407,8 +410,8 @@ const ZoTracerActivityLog = {
407410
headerContent.className = 'article-header-content';
408411

409412
const titleEl = document.createElement('a');
410-
titleEl.className = 'article-title';
411-
titleEl.textContent = title;
413+
titleEl.className = 'article-title';
414+
titleEl.textContent = data.articleTitle;
412415
titleEl.href = '#';
413416
titleEl.onclick = (event) => {
414417
event.preventDefault();
@@ -491,18 +494,18 @@ const ZoTracerActivityLog = {
491494
this.sortTimeAsc = false;
492495
this.sortCountAsc = false;
493496

494-
timeButton.textContent = `按时间排序 ${this.sortTimeAsc ? '▲' : '▼'}`;
495-
countButton.textContent = `按活动数排序 ${this.sortCountAsc ? '▲' : '▼'}`;
497+
timeButton.textContent = `Order by Time ${this.sortTimeAsc ? '▲' : '▼'}`;
498+
countButton.textContent = `Order by Count ${this.sortCountAsc ? '▲' : '▼'}`;
496499

497500
timeButton.addEventListener('click', () => {
498501
this.sortTimeAsc = !this.sortTimeAsc;
499-
timeButton.textContent = `按时间排序 ${this.sortTimeAsc ? '▲' : '▼'}`;
502+
timeButton.textContent = `Order by Time ${this.sortTimeAsc ? '▲' : '▼'}`;
500503
this.sortActivities('time', this.sortTimeAsc);
501504
});
502505

503506
countButton.addEventListener('click', () => {
504507
this.sortCountAsc = !this.sortCountAsc;
505-
countButton.textContent = `按活动数排序 ${this.sortCountAsc ? '▲' : '▼'}`;
508+
countButton.textContent = `Order by Count ${this.sortCountAsc ? '▲' : '▼'}`;
506509
this.sortActivities('count', this.sortCountAsc);
507510
});
508511
},
@@ -543,19 +546,19 @@ const ZoTracerActivityLog = {
543546
// Group activities by article
544547
const groupedByArticle = {};
545548
filteredActivities.forEach(activity => {
546-
const title = activity.articleTitle || 'Other Activities';
547-
if (!groupedByArticle[title]) {
548-
groupedByArticle[title] = [];
549+
const articleKey = activity.articleKey || 'Other Activities';
550+
if (!groupedByArticle[articleKey]) {
551+
groupedByArticle[articleKey] = [];
549552
}
550-
groupedByArticle[title].push(activity);
553+
groupedByArticle[articleKey].push(activity);
551554
});
552555

553556
let flomoContent = '';
554557

555558
// Format content for each article
556-
for (const [title, activities] of Object.entries(groupedByArticle)) {
559+
for (const [articleKey, activities] of Object.entries(groupedByArticle)) {
557560
// Add article title as a memo title
558-
flomoContent += `# 📖 ${title}\n\n`;
561+
flomoContent += `# 📖 ${activities[0].articleTitle}\n\n`;
559562

560563
for (const activity of activities) {
561564
// Get activity type and determine icon
@@ -888,10 +891,10 @@ const ZoTracerActivityLog = {
888891
}
889892
});
890893

891-
// Sort collections by activity count and get top 4
894+
// Sort collections by activity count and get top n
892895
const topCollections = Array.from(collectionStats.entries())
893896
.sort((a, b) => b[1] - a[1])
894-
.slice(0, 4);
897+
.slice(0, 5);
895898

896899
// Get collection names
897900
const collectionsWithNames = await Promise.all(
@@ -1008,6 +1011,7 @@ const ZoTracerActivityLog = {
10081011
'highlight_annotation': 0,
10091012
'underline_annotation': 0,
10101013
'add_note': 0,
1014+
'select_tab': 0,
10111015
'add_item': 0
10121016
};
10131017

@@ -1027,13 +1031,15 @@ const ZoTracerActivityLog = {
10271031
'Highlight Annotation',
10281032
'Underline Annotation',
10291033
'Add Notes',
1030-
'Add Items'
1034+
'Select Tab',
1035+
'Add Item'
10311036
];
10321037
const data = [
10331038
activityTypes['highlight_annotation'],
10341039
activityTypes['underline_annotation'],
10351040
activityTypes['add_note'],
1036-
activityTypes['add_item']
1041+
activityTypes['select_tab'],
1042+
activityTypes['add_item'],
10371043
];
10381044

10391045
this.activityRadarChart = new Chart(ctx, {

addon/content/activityLog.xhtml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@
2222
<html:optgroup label="Annotations">
2323
<html:option value="highlight_annotation">Highlight</html:option>
2424
<html:option value="underline_annotation">Underline</html:option>
25-
<!-- <html:option value="modify_annotation">Modify Annotation</html:option> -->
25+
<html:option value="modify_annotation">Modify Annotation</html:option>
2626
</html:optgroup>
2727
<html:optgroup label="Notes">
2828
<html:option value="add_note">Add Note</html:option>
2929
</html:optgroup>
3030
<html:optgroup label="Items">
3131
<html:option value="add_item">Add Item</html:option>
32-
<!-- <html:option value="modify_item">Modify Item</html:option>
32+
<html:option value="index_item">Index Item</html:option>
33+
<html:option value="modify_item">Modify Item</html:option>
3334
<html:option value="trash_item">Trash Item</html:option>
3435
<html:option value="delete_item">Delete Item</html:option>
35-
<html:option value="index_item">Index Item</html:option>
36-
<html:option value="refresh_item">Refresh Item</html:option> -->
36+
<html:option value="refresh_item">Refresh Item</html:option>
3737
</html:optgroup>
38-
<!-- <html:optgroup label="Files and Tabs">
38+
<html:optgroup label="Files and Tabs">
3939
<html:option value="open_file">Open File</html:option>
40-
<html:option value="add_tab">Add Tab</html:option>
4140
<html:option value="select_tab">Select Tab</html:option>
41+
<html:option value="add_tab">Add Tab</html:option>
4242
<html:option value="close_tab">Close Tab</html:option>
43-
</html:optgroup> -->
43+
</html:optgroup>
4444
</html:select>
4545
</html:div>
4646
<html:div class="filter-group">
@@ -127,12 +127,12 @@
127127
<html:div class="activity-header">
128128
<html:h2>Activity Details</html:h2>
129129
<html:div class="sort-controls">
130-
<html:button class="sort-button" id="sortByTime">按时间排序</html:button>
131-
<html:button class="sort-button" id="sortByCount">按活动数排序</html:button>
130+
<html:button class="sort-button" id="sortByTime">Order by Time</html:button>
131+
<html:button class="sort-button" id="sortByCount">Order by Count</html:button>
132132
<html:div class="dropdown">
133-
<html:button class="sort-button" id="exportButton">导出数据</html:button>
133+
<html:button class="sort-button" id="exportButton">Export Data</html:button>
134134
<html:div class="dropdown-content">
135-
<html:a href="#" id="syncToFlomo">同步到 flomo</html:a>
135+
<html:a href="#" id="syncToFlomo">Sync to Flomo</html:a>
136136
</html:div>
137137
</html:div>
138138
</html:div>

doc/README-zhCN.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,25 @@ ZoTracer 是一个 [Zotero](https://www.zotero.org/) 插件,它不仅能追踪
3131

3232
## 功能特性
3333

34-
- **全面的活动追踪**
35-
- 记录阅读、写作和引用等研究活动
36-
- 追踪文献管理操作(添加、编辑、组织)
37-
- 监控标签页和阅读器使用情况
34+
- **全方位活动追踪**
35+
36+
- 追踪学术研究全过程:阅读、笔记、文献引用等
37+
- 精确追踪文献管理操作(收录、编辑、分类整理)
38+
- 实时监控标签页使用及文献阅读行为
39+
40+
- **基于活动历史的快速定位**
41+
42+
- 直观清晰的活动数据可视化界面
43+
- 灵活的时序排序与活跃度排序功能
44+
- 一键定位历史活动关联文献
45+
3846
- **特定工作流的结构化数据导出**
39-
- 支持自定义导出格式和字段
40-
- 与其他工具和平台无缝集成 (例如, [Flomo](https://flomoapp.com/))
41-
- 便于数据分析和可视化
42-
- **AI 辅助的上下文注释(即将推出)**
43-
- 智能识别和提取关键信息
44-
- 自动生成标签和摘要建议
45-
- 基于阅读历史的个性化推荐
47+
48+
- 无缝对接主流知识管理工具(如 [Flomo](https://flomoapp.com/)
4649

4750
## 快速开始
4851

49-
1.[ZoTracer.xpi](https://github.com/etShaw-zh/zotracer/releases) 下载插件
52+
1.[ZoTracer.xpi](https://github.com/etShaw-zh/zotracer/releases) 下载插件的xpi文件
5053
2. 通过 Zotero 的插件管理器安装插件
5154
3. 您的研究活动将被自动追踪
5255
4. 通过插件界面访问活动日志

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zotracer",
33
"version": "1.0.5",
4-
"description": "ZoTracer is a Zotero plugin that tracks your research activities, creating a timeline of actions like saving or opening references. Analyze your study habits and streamline your research process with ease. ZoTracer 是一款 Zotero 插件,用于记录您的文献活动,如保存或打开文献,生成时间线。轻松分析学习习惯,优化研究流程。",
4+
"description": "Tracks your research activities, creates detailed timelines, and exports notes to platforms like Flomo.",
55
"config": {
66
"addonName": "ZoTracer",
77
"addonID": "[email protected]",

src/modules/database.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ export class DatabaseManager {
139139
}
140140

141141
public async getActivitiesSimple() {
142-
const query = `SELECT * FROM user_activities where activityType
143-
in ('highlight_annotation', 'underline_annotation', 'add_note', 'add_item', 'modify_annotation') ORDER BY timestamp DESC`;
142+
const query = `SELECT * FROM user_activities WHERE articleKey IS NOT NULL ORDER BY timestamp DESC`;
144143
return await this.db.queryAsync(query);
145144
}
146145

0 commit comments

Comments
 (0)