-
-
Notifications
You must be signed in to change notification settings - Fork 147
feat: more categorization and support for select_keys #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ export interface Rule { | |||||||||||||||||||
| type: 'regex' | 'none'; | ||||||||||||||||||||
| regex?: string; | ||||||||||||||||||||
| ignore_case?: boolean; | ||||||||||||||||||||
| select_keys?: string[]; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export interface Category { | ||||||||||||||||||||
|
|
@@ -23,26 +24,68 @@ export interface Category { | |||||||||||||||||||
| children?: Category[]; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const COLOR_UNCAT = '#CCC'; | ||||||||||||||||||||
| const COLOR_GREEN = '#0F0', | ||||||||||||||||||||
| COLOR_SUPER_GREEN = '#54e346', | ||||||||||||||||||||
| COLOR_BRIGHT_GREEN = '#A8FC00', | ||||||||||||||||||||
| COLOR_UNCAT = '#CCC', | ||||||||||||||||||||
| COLOR_YELLOW = '#FCC400', | ||||||||||||||||||||
| COLOR_SLIGHTLY_YELLOW = '#f5ff65', | ||||||||||||||||||||
| COLOR_ORANGE = '#ffba47', | ||||||||||||||||||||
| COLOR_RED = '#F80'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // The default categories | ||||||||||||||||||||
| // Should be run through createMissingParents before being used in most cases. | ||||||||||||||||||||
| export const defaultCategories: Category[] = [ | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Work'], | ||||||||||||||||||||
| rule: { type: 'regex', regex: 'Google Docs|libreoffice|ReText' }, | ||||||||||||||||||||
| data: { color: '#0F0' }, | ||||||||||||||||||||
|
Comment on lines
-32
to
-34
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to keep this parent-category explicit imo. Even if without a rule, such that children inherit color and don't need to be set explicitly for each child. |
||||||||||||||||||||
| name: ['Work', 'Writing'], | ||||||||||||||||||||
| rule: { type: 'regex', regex: 'Google Docs|Google Sheets|libreoffice|ReText' }, | ||||||||||||||||||||
| data: { color: COLOR_GREEN }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Work', 'Writing'], | ||||||||||||||||||||
| rule: { | ||||||||||||||||||||
| type: 'regex', | ||||||||||||||||||||
| select_keys: ['app'], | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is set, but there is no way to change it in the UI? All
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's right. You can't set them via the UI, but you can import a config file which contains them. I think we should add
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But that's very confusing for the user. They have no indication there is even a I really don't want to add this specifier to the default rules without:
|
||||||||||||||||||||
| regex: 'LibreOffice|TextEdit|MacDown|Obsidian|TextEdit', | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| data: { color: COLOR_GREEN }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Work', 'General'], | ||||||||||||||||||||
| rule: { | ||||||||||||||||||||
| type: 'regex', | ||||||||||||||||||||
| regex: 'Preview|Finder|Todoist|1Password|Soulver|System Preferences|VNC Viewer|Streaks', | ||||||||||||||||||||
| select_keys: ['app'], | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| data: { color: COLOR_SLIGHTLY_YELLOW }, | ||||||||||||||||||||
|
Comment on lines
+52
to
+60
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Sorry, but I don't like this as a default category. It's too broad to be generally useful, imo. Better to leave underspecified stuff like this up to the user (or if one would keep it, it would belong better in the parent category 'Work', such that child-categories can override). |
||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Work', 'Programming'], | ||||||||||||||||||||
| rule: { | ||||||||||||||||||||
| type: 'regex', | ||||||||||||||||||||
| regex: 'GitHub|Stack Overflow|BitBucket|Gitlab|vim|Spyder|kate|Ghidra|Scite', | ||||||||||||||||||||
| regex: | ||||||||||||||||||||
| 'GitHub|Stack Overflow|BitBucket|Gitlab|vim|Spyder|kate|iTerm|Hyper|Alacritty|Script Editor|Ghidra|Scite|jetbrains-idea|jetbrains-pycharm', | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| data: { color: COLOR_SUPER_GREEN }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Work', 'Programming'], | ||||||||||||||||||||
| rule: { type: 'regex', select_keys: ['url'], regex: 'github.com' }, | ||||||||||||||||||||
| data: { color: COLOR_SUPER_GREEN }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
|
Comment on lines
+71
to
+75
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does having several category rules with the same name work correctly in the web UI? (editing etc) Seems redundant to specify
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does seem to work from my testing!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This rule will only work in those cases where there is a I think it will be very confusing to users which would expect this to work, given it's a default, but for most users it won't (and without a |
||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Work', 'Programming'], | ||||||||||||||||||||
| rule: { | ||||||||||||||||||||
| type: 'regex', | ||||||||||||||||||||
| select_keys: ['app'], | ||||||||||||||||||||
| regex: 'Code|Sublime Text|TextMate|iTerm|Script Editor|Base|Postico|Sequel Ace', | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| data: { color: COLOR_SUPER_GREEN }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Work', 'Programming', 'ActivityWatch'], | ||||||||||||||||||||
| rule: { type: 'regex', regex: 'ActivityWatch|aw-', ignore_case: true }, | ||||||||||||||||||||
| data: { color: COLOR_SUPER_GREEN }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { name: ['Work', 'Image'], rule: { type: 'regex', regex: 'Gimp|Inkscape' } }, | ||||||||||||||||||||
| { name: ['Work', 'Video'], rule: { type: 'regex', regex: 'Kdenlive' } }, | ||||||||||||||||||||
|
|
@@ -51,30 +94,39 @@ export const defaultCategories: Category[] = [ | |||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Media', 'Games'], | ||||||||||||||||||||
| rule: { type: 'regex', regex: 'Minecraft|RimWorld' }, | ||||||||||||||||||||
| data: { color: '#F80' }, | ||||||||||||||||||||
| data: { color: COLOR_RED }, | ||||||||||||||||||||
|
Comment on lines
-54
to
+97
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was orange, now red (intentional/improvement?)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Media', 'Video'], | ||||||||||||||||||||
| rule: { type: 'regex', regex: 'YouTube|Plex|VLC' }, | ||||||||||||||||||||
| data: { color: '#F33' }, | ||||||||||||||||||||
| data: { color: COLOR_RED }, | ||||||||||||||||||||
|
Comment on lines
-59
to
+102
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was a dimmer/desaturated red, now a darker/saturated red. Worse contrast with the black text. |
||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Media', 'Social Media'], | ||||||||||||||||||||
| rule: { | ||||||||||||||||||||
| type: 'regex', | ||||||||||||||||||||
| regex: 'reddit|Facebook|Twitter|Instagram|devRant', | ||||||||||||||||||||
| regex: 'reddit|Facebook|Twitter|Instagram|devRant|LinkedIn', | ||||||||||||||||||||
| ignore_case: true, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| data: { color: '#FCC400' }, | ||||||||||||||||||||
| data: { color: COLOR_YELLOW }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Media', 'Podcasts'], | ||||||||||||||||||||
| rule: { | ||||||||||||||||||||
| type: 'regex', | ||||||||||||||||||||
| regex: 'Podcasts', | ||||||||||||||||||||
| select_keys: ['app'], | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| data: { color: COLOR_BRIGHT_GREEN }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Media', 'Music'], | ||||||||||||||||||||
| rule: { | ||||||||||||||||||||
| type: 'regex', | ||||||||||||||||||||
| regex: 'Spotify|Deezer', | ||||||||||||||||||||
| regex: 'Spotify|Deezer|Amazon Music', | ||||||||||||||||||||
| ignore_case: true, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| data: { color: '#A8FC00' }, | ||||||||||||||||||||
| data: { color: COLOR_BRIGHT_GREEN }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Comms'], | ||||||||||||||||||||
|
|
@@ -85,10 +137,29 @@ export const defaultCategories: Category[] = [ | |||||||||||||||||||
| name: ['Comms', 'IM'], | ||||||||||||||||||||
| rule: { | ||||||||||||||||||||
| type: 'regex', | ||||||||||||||||||||
| regex: 'Messenger|Telegram|Signal|WhatsApp|Rambox|Slack|Riot|Element|Discord|Nheko', | ||||||||||||||||||||
| regex: | ||||||||||||||||||||
| 'Messenger|Messages|Discord|Telegram|Signal|WhatsApp|Rambox|Slack|Riot|Element|Discord|Textual|Nheko|Texts', | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| data: { color: COLOR_ORANGE }, | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why override the
Suggested change
|
||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Comms', 'Email'], | ||||||||||||||||||||
| rule: { type: 'regex', regex: 'Gmail|Thunderbird|mutt|alpine' }, | ||||||||||||||||||||
| data: { color: COLOR_ORANGE }, | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above.
Suggested change
|
||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Comms', 'Meetings'], | ||||||||||||||||||||
| rule: { type: 'regex', regex: 'Zoom|Calendar|Cron' }, | ||||||||||||||||||||
| data: { color: COLOR_SLIGHTLY_YELLOW }, | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| }, | ||||||||||||||||||||
| { | ||||||||||||||||||||
| name: ['Web Browsing'], | ||||||||||||||||||||
| rule: { | ||||||||||||||||||||
| type: 'regex', | ||||||||||||||||||||
| regex: 'Chrome|Safari|FireFox|Brave', | ||||||||||||||||||||
| select_keys: ['app'], | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { name: ['Comms', 'Email'], rule: { type: 'regex', regex: 'Gmail|Thunderbird|mutt|alpine' } }, | ||||||||||||||||||||
| { name: ['Uncategorized'], rule: { type: null }, data: { color: COLOR_UNCAT } }, | ||||||||||||||||||||
| ]; | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -197,6 +268,7 @@ function pickDeepest(categories: Category[]) { | |||||||||||||||||||
| return _.maxBy(categories, c => c.name.length); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // TODO this is only used colorize the categories, all categorization is done on the backend | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| export function matchString(str: string, categories: Category[] | null): Category | null { | ||||||||||||||||||||
| if (!categories) { | ||||||||||||||||||||
| console.log( | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Red is orange now? Previous red was
#F33.