## API
### 最近開いたページ
```
POST {{base_url}}/cgraphql?q=RecentPagesQuery
```
[[Python]]だと以下のような感じ。
```json
import http.client
import json
conn = http.client.HTTPSConnection("ゆあどめいん.atlassian.net")
payload = json.dumps([
{
"operationName": "RecentPagesQuery",
"variables": {
"filter": {
"products": [
"CONFLUENCE"
],
"objectTypes": [
"PAGE"
],
"cloudIds": [
"ひみつ"
]
},
"first": 15
},
"query": "query RecentPagesQuery($filter: ActivitiesArguments!, $first: Int) {\n activities {\n myActivities {\n viewed(filters: [{type: AND, arguments: $filter}], first: $first) {\n edges {\n cursor\n node {\n id\n object {\n id\n content {\n id\n title\n type\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n pageInfo {\n hasNextPage\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"
}
])
headers = {
'Authorization': 'Basic 秘密情報',
'Content-Type': 'application/json'
}
conn.request("POST", "/cgraphql?q=RecentPagesQuery", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```
### クイックサーチ
```python
import http.client
import json
conn = http.client.HTTPSConnection("ゆあどめいん.atlassian.net")
payload = json.dumps({
"query": "くえり",
"cloudId": "ひみつ",
"limit": 10,
"scopes": [
"confluence.page"
],
"filters": [],
"modelParams": [
{
"@type": "queryParams",
"queryVersion": 1
}
],
"experience": "confluence.nav-v3",
"cloudIds": []
})
headers = {
'Authorization': 'Basic 秘密情報',
'Content-Type': 'application/json'
}
conn.request("POST", "/gateway/api/xpsearch-aggregator/quicksearch/v1", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```
## [[Flow Launcherプラグイン]]
https://github.com/Flow-Launcher/Flow.Launcher.Plugin.HelloWorldPython を参考に最小構成でプラグインディレクトリ配下に作成してみる。
```
./Confluence Recent-0.1.0
├── Images
│ └── app.png
├── lib
├── main.py
├── plugin.json
└── requirements.txt
```
基本的にはサンプルのまま。以下いずれかがトリガーとなってプラグインに追加される。
- [[Flow Launcher]]の再起動
- `plugin.json`のUUID変更
## 実装
`query`に先のコードをぶっこむ。
また、pageIdを指定する[[URL]]は以下のようになる。
```
https://ゆあどめいん.atlassian.net/wiki/pages/viewpage.action?pageId=ぺーじID
```
> [!question] 通信処理が入るとクエリが入力されるたびに通信されないか?
> おそらく問題ない。`sleep(1)`を挟んで処理を見る限り、キー入力時に0.5s程度のdebounceがかかってそう。
- [ ] ==[[VSCode]]だと再起動しないとモジュールが有効にならない==
## 設定の追加
[[Flox]]を使う。
https://github.com/Garulf/Github-Quick-Launcher/blob/main/SettingsTemplate.yaml
- `query`ではなく`_query`