Skip to content

Commit 5815042

Browse files
committed
First version for DNt 3.x
1 parent 2336669 commit 5815042

9 files changed

+27
-66
lines changed

README.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
11

22
# DEVONthink Search
33

4-
Powerful tool for seaching in DEVONthink. [中文说明](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/blob/master/README_CN.md)
4+
Powerful tool for seaching in DEVONthink, for DEVONthink 3.x.
55

6-
There are two editions:
7-
8-
- **DEVONthink Search**, for DEVONthink Personal
9-
- [Download](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/releases/download/3.0/DEVONthink.Search.alfredworkflow)
10-
- Search results aren't perfect, as the workflow searches with `Spotlight Index` generated by DEVONthink.
11-
- It's necessary to enable `Create Spotlight Index` in Database Property. (Enabled by default)
12-
- It **only** support the following `dnt` keyword and single database.
13-
- **DEVONthink Pro Search**, for DEVONthink Pro/Pro Office
14-
- [Download](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/releases)
15-
- Search results are the same as in DEVONthink, sorted by keywords matching score.
16-
- It's not necessary to enable `Create Spotlight Index`.
17-
- The information displayed in the search results is more abundant.
18-
19-
![Comparison](https://user-images.githubusercontent.com/3690653/48790858-3f872c00-ed2b-11e8-8ae6-683ce19cc597.png)
20-
21-
- The subtext of result in `DEVONthink Search` is the download url or the path of Spotlight Index.
22-
- The subtext of result in `DEVONthink Pro Search` consists of the database name and group name which contained the file. It will show tags when you press `⌘Command`.
6+
For DEVONthink 2.x, you can use the versions of this workflow before V7.0. Switch to [Branch DEVONthink 2.x](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/tree/DEVONthink2.x) to access the README document and source code.
237

8+
[Download](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/releases) [中文说明](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/blob/master/README_CN.md)
249

2510
## Usage
2611

27-
- Type `dnt + keywords` to search in all opened databases.
28-
- Type `dnts + keywords` to search in **Search Window** of DNtp.
12+
- Type `dnt + keywords` to search in all opened databases in Alfred.
13+
- Type `dnts + keywords` to search in DEVONthink window.
2914
- Type `dnd` to choose which datebase to search
3015
- Press `Enter`, then type in `keywords` to search in the chosen database.
3116
- Press `⌘Command + Enter` to list all tags in the database, then choose a tag and press `Enter` to list all documents which have the tag.

README_CN.md

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
# DEVONthink Search
22

3-
强大的 DEVONthink 搜索工具。
3+
强大的 DEVONthink 搜索工具,适用于 DEVONthink 3.x 的各个版本
44

5-
分为两个版本:
5+
DEVONthink 2.x 请使用 7.0 之前的版本,说明文档及代码请查看[相应分支](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/tree/DEVONthink2.x)
66

7-
- DEVONthink Search, 适用于 DEVONthink Personal。
8-
- [点击下载](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/releases/download/3.0/DEVONthink.Search.alfredworkflow)
9-
- 搜索准确度一般,因为是利用生成的 Spotlight Index 进行搜索。
10-
- 需要开启数据库属性中的 `Create Spotlight Index` (默认开启)。
11-
- 仅支持下文中的 `dnt + 关键词` 搜索方式。
12-
- DEVONthink Pro Search, 适用于 DEVONthink Pro / Pro Office。
13-
- [点击下载](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/releases)
14-
- 搜索结果与 DEVONthink 中搜索结果一致,按照关键词匹配得分排列。
15-
- 无需开启数据库属性中的 `Create Spotlight Index`
16-
- 搜索结果中显示的信息更丰富。
17-
18-
![对比](https://user-images.githubusercontent.com/3690653/48790858-3f872c00-ed2b-11e8-8ae6-683ce19cc597.png)
19-
20-
**说明:**
21-
22-
- DEVONthink Search 搜索结果的子文本(subtext)为下载该文件的 URL 或相应的 Spotlight Index 文件路径。
23-
- DEVONthink Pro Search 搜索结果的子文本(subtext)为该文件在 DEVONthink 中所在的数据库+文件夹路径。按下 `⌘Command` 则显示为标签信息。
7+
[这里下载](https://github.com/mpco/AlfredWorkflow-DEVONthink-Search/releases)
248

259
## 用法
2610

27-
- 输入 `dnt + 关键词` 在所有数据库中进行搜索
28-
- 输入 `dnts + 关键词`DNtp 的 **Search Window** 中进行搜索
11+
- 输入 `dnt + 关键词` 在 Alfred 中搜索所有数据库
12+
- 输入 `dnts + 关键词`DEVONthink 的窗口中进行搜索
2913
- 输入 `dnd` 选择需要搜索的数据库
3014
-`回车` 确认,接着输入 `关键词` 以进行搜索。
3115
-`⌘Command + 回车` 列出该数据库中的所有标签(Tag)。选择某个标签,然后按下回车键,可列出所有附有该标签的文档。
@@ -48,8 +32,6 @@
4832

4933
## 配置
5034

51-
**仅适用于 DEVONthink Pro Search**
52-
5335
### `ignoredDbUuidList`:屏蔽某些数据库
5436

5537
使用 `dnt``dnm` 在所有数据库中进行搜索,但是我们可能需要屏蔽某些数据库。例如,我建立了一个**存档**数据库以保存一些文件,但平时一般不需要打开或查看。在 Alfred Workflow 环境变量 `ignoredDbUuidList` 中加入以**英文逗号**分隔的多个数据库 UUID 即可屏蔽这些数据库。设置后,依旧可以通过 `dnd` 指定在被屏蔽的数据库中进行搜索。

getDbList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
function run() {
3-
var DNt = Application("DEVONthink Pro");
3+
var DNt = Application("DEVONthink 3");
44
var allDB = DNt.databases
55
var allResult = []
66
for (var db in allDB) {

getRecordListByTags.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
ignoredDbUuidList = os.getenv('ignoredDbUuidList', "").split(",")
1717
ignoredDbUuidList = [dbUuid.strip() for dbUuid in ignoredDbUuidList]
1818
ignoredDbUuidListStr = "\",\"".join(ignoredDbUuidList)
19-
getInfoAppleScript = """'tell application "DEVONthink Pro"
19+
getInfoAppleScript = """'tell application "DEVONthink 3"
2020
set allDb to every database
2121
set allResult to ""
2222
set ignoredDbUuidList to {"%s"}
@@ -50,7 +50,7 @@
5050
selectedTag = os.getenv('selectedTag', "")
5151
tagStr = selectedTag
5252
selectedDbUuid = os.getenv('selectedDbUUID', "")
53-
getInfoAppleScript = """'tell application "DEVONthink Pro"
53+
getInfoAppleScript = """'tell application "DEVONthink 3"
5454
set theDB to (get database with uuid "%s")
5555
set theList to lookup records with tags {"%s"} in theDB
5656
set theResult to ""

getTagsList.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
selectedDbUUID = os.getenv('selectedDbUUID', "")
1414

15-
cmdScript = "osascript -e 'tell application \"DEVONthink Pro\" to get name of tag group of (get database with uuid \"{}\")' -s s".format(selectedDbUUID)
15+
cmdScript = "osascript -e 'tell application \"DEVONthink 3\" to get name of tag group of (get database with uuid \"{}\")' -s s".format(selectedDbUUID)
1616
cmdList = shlex.split(cmdScript)
1717
cmdResult = subprocess.check_output(cmdList)
1818
tagList = ast.literal_eval(

icon.png

-60.4 KB
Loading

info.plist

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@
188188
<key>createdby</key>
189189
<string>Charles Ma</string>
190190
<key>description</key>
191-
<string>Powerful tool for searching in DEVONthink Pro / Pro Office</string>
191+
<string>Powerful tool for searching in DEVONthink 3</string>
192192
<key>disabled</key>
193193
<false/>
194194
<key>name</key>
195-
<string>DEVONthink Pro Search</string>
195+
<string>DEVONthink Search</string>
196196
<key>objects</key>
197197
<array>
198198
<dict>
@@ -206,13 +206,7 @@
206206
<string>echo '{query}' | perl -CIOED -p -e 's/(\p{Block=CJK_Unified_Ideographs}+)/ ~\1 /g' | pbcopy
207207
208208
AScommand=$(cat&lt;&lt;EOF
209-
tell application "DEVONthink Pro" to activate
210-
tell application "System Events"
211-
keystroke "f" using {command down, shift down}
212-
tell application "System Events" to keystroke "v" using command down
213-
delay 0.1
214-
key code 36
215-
end tell
209+
tell application "DEVONthink 3" to activatetell application "System Events" keystroke "n" using {command down, option down} keystroke "f" using {command down, option down} tell application "System Events" to keystroke "v" using command down delay 0.1 key code 36end tell
216210
EOF)
217211
218212
osascript -e "$AScommand"</string>
@@ -234,13 +228,13 @@ osascript -e "$AScommand"</string>
234228
<key>config</key>
235229
<dict>
236230
<key>argumenttype</key>
237-
<integer>1</integer>
231+
<integer>0</integer>
238232
<key>keyword</key>
239233
<string>dnts</string>
240234
<key>subtext</key>
241235
<string></string>
242236
<key>text</key>
243-
<string>Search in DEVONthink Search Window</string>
237+
<string>Search in DEVONthink Window</string>
244238
<key>withspace</key>
245239
<true/>
246240
</dict>
@@ -300,7 +294,7 @@ osascript -e "$AScommand"</string>
300294
<key>subtext</key>
301295
<string>{var:selectedDbName}</string>
302296
<key>title</key>
303-
<string>Search in DEVONthink Pro</string>
297+
<string>Search in DEVONthink 3</string>
304298
<key>type</key>
305299
<integer>0</integer>
306300
<key>withspace</key>
@@ -370,7 +364,7 @@ osascript -e "$AScommand"</string>
370364
<key>script</key>
371365
<string>function run(argv) {
372366
var query = argv[0];
373-
const DNt = Application('DEVONthink Pro');
367+
const DNt = Application('DEVONthink 3');
374368
DNt.activate()
375369
DNt.openWindowFor({ record: DNt.getRecordWithUuid(query) })
376370
}</string>
@@ -557,7 +551,7 @@ open "x-devonthink-item://${1}?reveal=1"</string>
557551
<key>escaping</key>
558552
<integer>68</integer>
559553
<key>script</key>
560-
<string>on run set theQuery to "{query}" tell application "DEVONthink Pro" load workspace theQuery activate end tellend run</string>
554+
<string>on run set theQuery to "{query}" tell application "DEVONthink 3" load workspace theQuery activate end tellend run</string>
561555
<key>scriptargtype</key>
562556
<integer>0</integer>
563557
<key>scriptfile</key>
@@ -648,7 +642,7 @@ open "x-devonthink-item://${1}?reveal=1"</string>
648642
<key>escaping</key>
649643
<integer>68</integer>
650644
<key>script</key>
651-
<string>on run set theQuery to "{query}" tell application "DEVONthink Pro" save workspace theQuery end tellend run</string>
645+
<string>on run set theQuery to "{query}" tell application "DEVONthink 3" save workspace theQuery end tellend run</string>
652646
<key>scriptargtype</key>
653647
<integer>0</integer>
654648
<key>scriptfile</key>
@@ -786,7 +780,7 @@ open "x-devonthink-item://${1}?reveal=1"</string>
786780
<string>filterOutGroup</string>
787781
</array>
788782
<key>version</key>
789-
<string>6.1</string>
783+
<string>7.0</string>
790784
<key>webaddress</key>
791785
<string>https://github.com/mpco/AlfredWorkflow-DEVONthink-Search</string>
792786
</dict>

search.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function run(argv) {
2424
// const cjkRegex = /(\p{Unified_Ideograph}+)/ug
2525
const cjkRegex = /([\u4e00-\u9fff]+)/g
2626
const query = argv[0].replace(/^\s+|\s+$/g, '').replace(cjkRegex, "~$1");
27-
var DNt = Application("DEVONthink Pro");
27+
var DNt = Application("DEVONthink 3");
2828
var allDB = DNt.databases
2929
// if selectedDbUUID exists, only search in selected db.
3030
if (typeof selectedDbUUID !== 'undefined') {
@@ -68,7 +68,7 @@ function run(argv) {
6868
item["type"] = "default"
6969
// group 的 path() 为空,但是 item["arg"] 为空时 Alfred 不可执行后续动作
7070
// 故以应用路径代替
71-
item["arg"] = "/Applications/DEVONthink Pro.app"
71+
item["arg"] = "/Applications/DEVONthink 3.app"
7272
item["title"] = "[Group] " + itemName
7373
if (itemLocation == "/Tags/") {
7474
item["title"] = "[Tag] " + itemName

workspace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import shlex
66
import subprocess
77

8-
cmdScript = "osascript -e 'tell application \"DEVONthink Pro\" to get workspaces' -s s"
8+
cmdScript = "osascript -e 'tell application \"DEVONthink 3\" to get workspaces' -s s"
99
cmdList = shlex.split(cmdScript)
1010
cmdResult = subprocess.check_output(cmdList)
1111
workspaceList = ast.literal_eval(

0 commit comments

Comments
 (0)