Skip to content

Commit 6d5d109

Browse files
committed
First Commit
0 parents  commit 6d5d109

File tree

7 files changed

+790
-0
lines changed

7 files changed

+790
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### OSX ###
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
Icon
6+
7+
# Thumbnails
8+
._*
9+
10+
# Files that might appear on external disk
11+
.Spotlight-V100
12+
.Trashes

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# HatebuList.alfredworkflow
2+
3+
このワークフローでは[はてなブックマークのマイブックマーク全文検索API](http://developer.hatena.ne.jp/ja/documents/bookmark/apis/fulltext_search)を使っています。
4+
また[はてなのWSSE認証](http://developer.hatena.ne.jp/ja/documents/auth/apis/wsse)を使うため、APIキーを取得する必要があります。
5+
6+
https://www.hatena.ne.jp/**ユーザー名**/config/mail/upload
7+
上記URLのページで表示された、投稿メールアドレスの**"@"以前の文字列**がAPIキーとなります。
8+
また、ユーザー名とAPIキーは``~/.hatebulist``のファイルを作り、そこに保存しています。
9+
10+
APIキーを取得したら、``hl_setting <USERNAME> <APIKEY>``を実行してください。
11+
12+
[Download](https://github.com/geckotang/alfredworkflow/raw/master/HatebuList.alfredworkflow)
13+
14+
## Commands
15+
16+
- ``hl_setting <USERNAME> <APIKEY>``
17+
- ``hl <KEYWORD>``

hl.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
require_once('workflows.php');
3+
$wf = new Workflows();
4+
date_default_timezone_set('Asia/Tokyo');
5+
6+
function trimAll($str) {
7+
return str_replace(array("\r\n","\n","\r"), " ", $str);
8+
}
9+
10+
function get_userinfo() {
11+
$filename = "~/.hatebulist";
12+
$str = exec('cat '.$filename, $output);
13+
$userinfo_array = explode(" ", $output[0]);
14+
return array(
15+
'user_name' => $userinfo_array[0],
16+
'api_key' => $userinfo_array[1]
17+
);
18+
}
19+
20+
$user = get_userinfo();
21+
$user_name = $user['user_name'];
22+
$api_key = $user['api_key'];
23+
24+
#http://d.hatena.ne.jp/i_ogi/20100214/wsse
25+
$url = "http://b.hatena.ne.jp/".$user_name."/search/json?q=".$query."&sort=date&limit=20";
26+
$nonce = md5(mt_rand());
27+
$created = date(DATE_ISO8601);
28+
$x_wsse = sprintf('UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',
29+
$user_name,
30+
base64_encode(sha1($nonce . $created . $api_key, true)),
31+
base64_encode($nonce),
32+
$created);
33+
$context = stream_context_create(
34+
array('http' => array('header' => "X-WSSE: $x_wsse"))
35+
);
36+
$file = file_get_contents($url, 0, $context);
37+
$json = json_decode($file);
38+
$dataList = $json;
39+
40+
foreach($dataList->bookmarks as $data) {
41+
$entry = $data->entry;
42+
$title = $entry->title;
43+
$count = $entry->count;
44+
$snippet = trimAll($entry->snippet);
45+
$wf_url = $entry->url;
46+
$wf_title = $title;
47+
$wf_description = $snippet;
48+
$wf->result(
49+
time(),
50+
$wf_url,
51+
$wf_title,
52+
$wf_description,
53+
'icon.png'
54+
);
55+
}
56+
57+
echo $wf->toxml();
58+
?>

hl_setting.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
require("workflows.php");
3+
$wf = new Workflows();
4+
5+
$filename = "~/.hatebulist";
6+
system('echo '.$query.' > '.$filename);
7+
$wf->result(time(), $query, $query, $query."を登録します", "icon.png");
8+
9+
echo $wf->toxml();
10+
?>

icon.png

8.46 KB
Loading

info.plist

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>bundleid</key>
6+
<string>com.geckotang.hatebulist</string>
7+
<key>category</key>
8+
<string>Internet</string>
9+
<key>connections</key>
10+
<dict>
11+
<key>3147245F-3884-41EF-9C55-1F02506C87FE</key>
12+
<array>
13+
<dict>
14+
<key>destinationuid</key>
15+
<string>FB7F05D1-FC13-4199-9204-01832CD35D02</string>
16+
<key>modifiers</key>
17+
<integer>0</integer>
18+
<key>modifiersubtext</key>
19+
<string></string>
20+
</dict>
21+
</array>
22+
<key>7AFAFE77-C9B7-44AA-BF76-FD77C31A5DA5</key>
23+
<array>
24+
<dict>
25+
<key>destinationuid</key>
26+
<string>6FE55463-DC32-470F-947C-F26B953A7184</string>
27+
<key>modifiers</key>
28+
<integer>0</integer>
29+
<key>modifiersubtext</key>
30+
<string></string>
31+
</dict>
32+
</array>
33+
</dict>
34+
<key>createdby</key>
35+
<string>@GeckoTang</string>
36+
<key>description</key>
37+
<string>はてブのマイブックマークの全文を検索する</string>
38+
<key>disabled</key>
39+
<false/>
40+
<key>name</key>
41+
<string>HatebuList</string>
42+
<key>objects</key>
43+
<array>
44+
<dict>
45+
<key>config</key>
46+
<dict>
47+
<key>plusspaces</key>
48+
<false/>
49+
<key>url</key>
50+
<string>{query}</string>
51+
<key>utf8</key>
52+
<true/>
53+
</dict>
54+
<key>type</key>
55+
<string>alfred.workflow.action.openurl</string>
56+
<key>uid</key>
57+
<string>6FE55463-DC32-470F-947C-F26B953A7184</string>
58+
<key>version</key>
59+
<integer>0</integer>
60+
</dict>
61+
<dict>
62+
<key>config</key>
63+
<dict>
64+
<key>argumenttype</key>
65+
<integer>0</integer>
66+
<key>escaping</key>
67+
<integer>0</integer>
68+
<key>keyword</key>
69+
<string>hl</string>
70+
<key>runningsubtext</key>
71+
<string>読み込み中...</string>
72+
<key>script</key>
73+
<string>$query = urlencode( "{query}" );
74+
require_once("hl.php");</string>
75+
<key>subtext</key>
76+
<string>全文検索したいキーワードを入力</string>
77+
<key>title</key>
78+
<string>マイブックマークから全文検索</string>
79+
<key>type</key>
80+
<integer>1</integer>
81+
<key>withspace</key>
82+
<true/>
83+
</dict>
84+
<key>type</key>
85+
<string>alfred.workflow.input.scriptfilter</string>
86+
<key>uid</key>
87+
<string>7AFAFE77-C9B7-44AA-BF76-FD77C31A5DA5</string>
88+
<key>version</key>
89+
<integer>0</integer>
90+
</dict>
91+
<dict>
92+
<key>config</key>
93+
<dict>
94+
<key>argumenttype</key>
95+
<integer>0</integer>
96+
<key>escaping</key>
97+
<integer>0</integer>
98+
<key>keyword</key>
99+
<string>hl_setting</string>
100+
<key>runningsubtext</key>
101+
<string>...</string>
102+
<key>script</key>
103+
<string>$query = "{query}";
104+
require_once("hl_setting.php");</string>
105+
<key>subtext</key>
106+
<string>例)ユーザー名 APIキー</string>
107+
<key>title</key>
108+
<string>ユーザー名とAPIキーを設定</string>
109+
<key>type</key>
110+
<integer>1</integer>
111+
<key>withspace</key>
112+
<true/>
113+
</dict>
114+
<key>type</key>
115+
<string>alfred.workflow.input.scriptfilter</string>
116+
<key>uid</key>
117+
<string>3147245F-3884-41EF-9C55-1F02506C87FE</string>
118+
<key>version</key>
119+
<integer>0</integer>
120+
</dict>
121+
<dict>
122+
<key>config</key>
123+
<dict>
124+
<key>lastpathcomponent</key>
125+
<false/>
126+
<key>onlyshowifquerypopulated</key>
127+
<true/>
128+
<key>output</key>
129+
<integer>0</integer>
130+
<key>removeextension</key>
131+
<false/>
132+
<key>sticky</key>
133+
<false/>
134+
<key>text</key>
135+
<string>{query}を登録しました。</string>
136+
<key>title</key>
137+
<string>Hatebu List</string>
138+
</dict>
139+
<key>type</key>
140+
<string>alfred.workflow.output.notification</string>
141+
<key>uid</key>
142+
<string>FB7F05D1-FC13-4199-9204-01832CD35D02</string>
143+
<key>version</key>
144+
<integer>0</integer>
145+
</dict>
146+
</array>
147+
<key>readme</key>
148+
<string>はてなブックマークのマイブックマークから全文検索し、簡単にアクセスするためのワークフローです。
149+
150+
まず、はてブのユーザー名とAPIキーをAlfredに登録します。
151+
152+
```
153+
hl_setting ユーザ名 APIキー
154+
```
155+
でユーザー情報をAlfredに登録してください。
156+
157+
APIキーは投稿メールアドレスの"@"や"+"以前の文字列になります。
158+
https://www.hatena.ne.jp/ユーザー名/config/mail/upload
159+
にアクセスして確認して下さい。
160+
登録後は
161+
162+
```
163+
hl 検索したい単語
164+
```
165+
166+
で検索することができます。</string>
167+
<key>uidata</key>
168+
<dict>
169+
<key>3147245F-3884-41EF-9C55-1F02506C87FE</key>
170+
<dict>
171+
<key>ypos</key>
172+
<real>130</real>
173+
</dict>
174+
<key>6FE55463-DC32-470F-947C-F26B953A7184</key>
175+
<dict>
176+
<key>ypos</key>
177+
<real>10</real>
178+
</dict>
179+
<key>7AFAFE77-C9B7-44AA-BF76-FD77C31A5DA5</key>
180+
<dict>
181+
<key>ypos</key>
182+
<real>10</real>
183+
</dict>
184+
<key>FB7F05D1-FC13-4199-9204-01832CD35D02</key>
185+
<dict>
186+
<key>ypos</key>
187+
<real>130</real>
188+
</dict>
189+
</dict>
190+
<key>webaddress</key>
191+
<string>https://github.com/geckotang/alfredworkflow</string>
192+
</dict>
193+
</plist>

0 commit comments

Comments
 (0)