pinpress 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +6 -0
- data/README.md +239 -128
- data/bin/pinpress +30 -102
- data/lib/pinpress.rb +97 -3
- data/lib/pinpress/constants.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ae77f99f46a0971c0032f10131cbb16cc3c0ae7
|
4
|
+
data.tar.gz: 8eddc0dc1ded71589b348fb1605deca5f2b3b00f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01127ec83ecfc6f1b72046c5d77ffa8594732d482650a80a89f1ed203fadfe05cba86f4fd2690baae900e808322a0599c0091b47fa93487969fcc583ef765ea6
|
7
|
+
data.tar.gz: aa9c8f7a7bd32b6dfa127165c6b62adc2370e2ec5ce92f88ff92228c289e38d2df3d39cebe0cbb4f350ed93186762af4dd5f45a188cf18a815b998b6426501d8
|
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ PinPress is a simple CLI to create templates (HTML, Markdown, or otherwise) of P
|
|
6
6
|
|
7
7
|
# Why?
|
8
8
|
|
9
|
-
Every
|
9
|
+
Every week, I create a [link mash for my blog](#link-mash-config-file); this link mash consists of URLs that I find interesting and want to share with my readers. Previously, I would save those interesting URLs to an Evernote note and, every week, manually create my link mash for use in Wordpress. `<barf/>`
|
10
10
|
|
11
11
|
When I began using [Pinboard](http://pinboard.in "Pinboard") to save interesting links, I knew I needed a better method. This tool is the result: **Pin** board + Word **press**.
|
12
12
|
|
@@ -16,7 +16,7 @@ In addition to Git (which, given you being on this site, I'll assume you have),
|
|
16
16
|
|
17
17
|
# Installation
|
18
18
|
|
19
|
-
```
|
19
|
+
```bash
|
20
20
|
gem install pinpress
|
21
21
|
```
|
22
22
|
|
@@ -24,7 +24,7 @@ gem install pinpress
|
|
24
24
|
|
25
25
|
Syntax and usage can be accessed by running `pinpress help`:
|
26
26
|
|
27
|
-
```
|
27
|
+
```bash
|
28
28
|
$ pinpress help
|
29
29
|
NAME
|
30
30
|
pinpress - A Pinboard application that allows for the creation of
|
@@ -50,7 +50,7 @@ COMMANDS
|
|
50
50
|
|
51
51
|
Note that each command's options can be revealed by adding the `--help` switch after the command. For example:
|
52
52
|
|
53
|
-
```
|
53
|
+
```bash
|
54
54
|
$ pinpress pins --help
|
55
55
|
NAME
|
56
56
|
pins - Get posts from Pinboard
|
@@ -67,15 +67,128 @@ COMMAND OPTIONS
|
|
67
67
|
|
68
68
|
# Initialization
|
69
69
|
|
70
|
-
```
|
70
|
+
```bash
|
71
71
|
$ pinpress init
|
72
72
|
```
|
73
73
|
|
74
74
|
Initialization will prompt you to enter your Pinboard API token. Once, entered, this (and other pertinent data) will be stored in `~/.pinpress`.
|
75
75
|
|
76
|
+
# Getting Pins
|
77
|
+
|
78
|
+
```bash
|
79
|
+
$ pinpress pins
|
80
|
+
```
|
81
|
+
|
82
|
+
This simple command will return all pins from the user's account and output them based on the [Pin Template](#pin-templates "Pin Templates") provided.
|
83
|
+
|
84
|
+
Pinpress also provides some flags that allow a user to define specific pins to grab:
|
85
|
+
|
86
|
+
* `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
|
87
|
+
* `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
|
88
|
+
* `-n`: the number of pins to return (e.g., 20)
|
89
|
+
* `-t`: a CSV list of tags (e.g., "tag1,tag2") that must exist for the returned pins
|
90
|
+
|
91
|
+
## Getting Pins From a Date Forward
|
92
|
+
|
93
|
+
```bash
|
94
|
+
$ pinpress pins -s 2014-01-01
|
95
|
+
```
|
96
|
+
|
97
|
+
...returns all pins from January 1, 2014 to the current day.
|
98
|
+
|
99
|
+
## Getting Pins Until a Date
|
100
|
+
|
101
|
+
```bash
|
102
|
+
$ pinpress pins -e 2014-01-01
|
103
|
+
```
|
104
|
+
|
105
|
+
...returns all pins up to January 1, 2014.
|
106
|
+
|
107
|
+
## Getting Pins Between a Date Range
|
108
|
+
|
109
|
+
```bash
|
110
|
+
$ pinpress pins -s 2014-01-01 -e 2014-01-31
|
111
|
+
```
|
112
|
+
|
113
|
+
## Getting Tagged Pins
|
114
|
+
|
115
|
+
```bash
|
116
|
+
$ pinpress pins -t "ruby,cli"
|
117
|
+
```
|
118
|
+
|
119
|
+
...returns all pins tagged "ruby" *and* "cli".
|
120
|
+
|
121
|
+
**Naturally, these flags can be combined in any number of ways.**
|
122
|
+
|
123
|
+
## Getting Pins Created Since Last Run
|
124
|
+
|
125
|
+
Every time you run `pinpress pins`, the current date is added to `~/.pinpress`. Because of this, running:
|
126
|
+
|
127
|
+
```bash
|
128
|
+
$ pinpress pins last
|
129
|
+
```
|
130
|
+
|
131
|
+
...will get all the pins created since that date (e.g., if you'd last run `pinpress pins` on 2014-01-01, this command would return all pins created from 2014-01-02 onward).
|
132
|
+
|
133
|
+
# Getting Tags
|
134
|
+
|
135
|
+
Pinpress can also work with tags in a Pinboard account:
|
136
|
+
|
137
|
+
```bash
|
138
|
+
$ pinpress tags
|
139
|
+
```
|
140
|
+
|
141
|
+
This simple command will return all tags from the user's account and output them based on the [Tag Template](#tag-templates "Tag Templates") provided.
|
142
|
+
|
143
|
+
Pinpress also provides some flags that allow a user to define specific tags to grab:
|
144
|
+
|
145
|
+
* `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
|
146
|
+
* `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
|
147
|
+
* `-t`: a CSV list of tags (e.g., "tag1,tag2") to examine for association (see [below](#getting-tags-that-have-been-used-with-other-tags)).
|
148
|
+
|
149
|
+
## Getting Tags From a Date Forward
|
150
|
+
|
151
|
+
```bash
|
152
|
+
$ pinpress tags -s 2014-01-01
|
153
|
+
```
|
154
|
+
|
155
|
+
...returns all tags used from January 1, 2014 to the current day. Note that for each tag returned, the data includes both the tag name and the number of times it was used.
|
156
|
+
|
157
|
+
## Getting Tags Until a Date
|
158
|
+
|
159
|
+
```bash
|
160
|
+
$ pinpress tags -e 2014-01-01
|
161
|
+
```
|
162
|
+
|
163
|
+
...returns all tags used up to January 1, 2014.
|
164
|
+
|
165
|
+
## Getting Tags Between a Date Range
|
166
|
+
|
167
|
+
```bash
|
168
|
+
$ pinpress tags -s 2014-01-01 -e 2014-01-31
|
169
|
+
```
|
170
|
+
|
171
|
+
## Getting Tags that Have Been Used With Other Tags
|
172
|
+
|
173
|
+
```bash
|
174
|
+
$ pinpress tags -t 'tag1,tag2' -s 2014-01-01
|
175
|
+
```
|
176
|
+
|
177
|
+
...returns all tags that have been used *alongside* `tag1` and `tag2`, starting on Jarnuary 1, 2014.
|
178
|
+
|
179
|
+
## Getting Tags Used Since Last Run
|
180
|
+
|
181
|
+
Every time you run `pinpress tags`, the current date is added to `~/.pinpress`. Because of this, running:
|
182
|
+
|
183
|
+
```bash
|
184
|
+
$ pinpress tags last
|
185
|
+
```
|
186
|
+
|
187
|
+
...will get all the tags used since that date (e.g., if you'd last run `pinpress tags` on 2014-01-01, this command would return all tags used from 2014-01-02 onward).
|
188
|
+
|
76
189
|
# Templates
|
77
190
|
|
78
|
-
|
191
|
+
Templates are used to define how data should be output to the terminal and are defined in `~/.pinpress`. They come in two forms: **Pin Templates** and **Tag Templates**.
|
79
192
|
|
80
193
|
## Pin Templates
|
81
194
|
|
@@ -85,13 +198,17 @@ Pin Templates define how a pin from Pinboard should be output.
|
|
85
198
|
|
86
199
|
Pin Templates are placed under the `pin_templates` section of the `~/.pinpress` config file -- as an example:
|
87
200
|
|
88
|
-
```
|
201
|
+
```yaml
|
89
202
|
pin_templates:
|
90
203
|
- name: pinpress_default
|
91
|
-
opener: "<ul
|
204
|
+
opener: "<ul>\n"
|
205
|
+
item: >
|
206
|
+
<li>
|
207
|
+
<b><a title="<%= description %>" href="<%= href %>" target="_blank">
|
208
|
+
<%= description %></a>.</b>
|
209
|
+
<%= extended %>
|
210
|
+
</li>
|
92
211
|
closer: "</ul>"
|
93
|
-
item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
|
94
|
-
description %></a>.</b> <%= extended %></li>\n"
|
95
212
|
```
|
96
213
|
|
97
214
|
A Pin Template can have several different sub-keys:
|
@@ -118,13 +235,13 @@ Additionally, a Pin Template can make use of several different tokens that are f
|
|
118
235
|
|
119
236
|
Pin Templates can be used in two ways: they can either be called dynamically:
|
120
237
|
|
121
|
-
```
|
238
|
+
```bash
|
122
239
|
$ pinpress pins template_name
|
123
240
|
```
|
124
241
|
|
125
242
|
...or a default template can be specified in `~/.pinpress`:
|
126
243
|
|
127
|
-
```
|
244
|
+
```yaml
|
128
245
|
---
|
129
246
|
pinpress:
|
130
247
|
config_location: "/Users/abach/.pinpress"
|
@@ -133,17 +250,46 @@ pinpress:
|
|
133
250
|
pin_templates:
|
134
251
|
- name: pinpress_default
|
135
252
|
opener: "<ul>\n"
|
253
|
+
item: >
|
254
|
+
<li>
|
255
|
+
<b><a href="<%= href %>">
|
256
|
+
<%= description %></a>.</b>
|
257
|
+
<%= extended %>
|
258
|
+
</li>
|
136
259
|
closer: "</ul>"
|
137
|
-
item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
|
138
|
-
description %></a>.</b> <%= extended %></li>\N"
|
139
260
|
```
|
140
261
|
|
141
|
-
|
262
|
+
So, knowing the above, both:
|
142
263
|
|
143
|
-
```
|
264
|
+
```bash
|
144
265
|
$ pinpress pins
|
145
266
|
```
|
146
267
|
|
268
|
+
...and:
|
269
|
+
|
270
|
+
```bash
|
271
|
+
$ pinpress pins pinpress_default
|
272
|
+
```
|
273
|
+
|
274
|
+
...will output pin data in the format specified by that template:
|
275
|
+
|
276
|
+
```html
|
277
|
+
<ul>
|
278
|
+
<li>
|
279
|
+
<b>
|
280
|
+
<a href="http://www.macstories.net/tutorials/launch-center-pro-guide/">
|
281
|
+
Automating iOS: A Comprehensive Guide to Launch Center Pro
|
282
|
+
</a>.
|
283
|
+
</b>
|
284
|
+
This the most amazing article I've seen in a long time. So many tips, tricks,
|
285
|
+
and automations to make productivity easier.
|
286
|
+
</li>
|
287
|
+
<!-- ... -->
|
288
|
+
</ul>
|
289
|
+
```
|
290
|
+
|
291
|
+
(Note that the nice indenting is for Github's sake; the actual output will conform to the formatting in `~/.pinpress`.)
|
292
|
+
|
147
293
|
## Tag Templates
|
148
294
|
|
149
295
|
Tag Templates are exactly like Pin Templates, but are used for tags.
|
@@ -152,37 +298,37 @@ Tag Templates are exactly like Pin Templates, but are used for tags.
|
|
152
298
|
|
153
299
|
They, too, are defined in `~/.pinpress`:
|
154
300
|
|
155
|
-
```
|
301
|
+
```yaml
|
156
302
|
tag_templates:
|
157
303
|
- name: pinpress_default
|
158
304
|
item: "<%= tag %> (<%= count %>),"
|
159
305
|
```
|
160
306
|
|
161
|
-
A
|
307
|
+
A Tag Template makes use of the same sub-keys as Pin Template:
|
162
308
|
|
163
309
|
* `name` (**required**): the name of the template
|
164
|
-
* `opener` (*optional*): the text that should exist above the
|
165
|
-
* `closer` (*optional*): the text that should exist below the
|
166
|
-
* `item` (**required**): the formatted text that should be output for every
|
310
|
+
* `opener` (*optional*): the text that should exist above the tag string
|
311
|
+
* `closer` (*optional*): the text that should exist below the tag string
|
312
|
+
* `item` (**required**): the formatted text that should be output for every tag
|
167
313
|
|
168
314
|
### Available Tokens
|
169
315
|
|
170
|
-
Additionally, a Pin Template can make use of
|
316
|
+
Additionally, like a Pin Template, a Tag Template can make use of a few tokens:
|
171
317
|
|
172
318
|
* `<%= tag %>`: the name of the tag
|
173
|
-
* `<%= count %>`: the number of times the tag has been used
|
319
|
+
* `<%= count %>`: the number of times the tag has been used (depending on the range used)
|
174
320
|
|
175
321
|
### Usage
|
176
322
|
|
177
323
|
Pin Templates can be used in two ways: they can either be called dynamically:
|
178
324
|
|
179
|
-
```
|
325
|
+
```bash
|
180
326
|
$ pinpress tags template_name
|
181
327
|
```
|
182
328
|
|
183
329
|
...or a default template can be specified in `~/.pinpress`:
|
184
330
|
|
185
|
-
```
|
331
|
+
```yaml
|
186
332
|
---
|
187
333
|
pinpress:
|
188
334
|
config_location: "/Users/abach/.pinpress"
|
@@ -195,134 +341,99 @@ tag_templates:
|
|
195
341
|
item: "<%= tag %> (<%= count %>),"
|
196
342
|
```
|
197
343
|
|
198
|
-
|
344
|
+
So, knowing the above, both:
|
199
345
|
|
200
|
-
```
|
346
|
+
```bash
|
201
347
|
$ pinpress tags
|
202
348
|
```
|
203
349
|
|
204
|
-
|
205
|
-
|
206
|
-
```
|
207
|
-
$ pinpress pins
|
208
|
-
# <ul>
|
209
|
-
# <li>
|
210
|
-
# <b><a title="Technical Debt, a case study : tags" href="http://marcgravell.blogspot.com/2014/04/technical-debt-case-study-tags.html?m=1" target="_blank">Technical Debt, a case study : tags</a>.</b> A look at how programmers solve complex problems iteratively.
|
211
|
-
# </li>
|
212
|
-
# <li>
|
213
|
-
# <b><a title="Using Drafts for Remote CLI" href="https://gist.github.com/hiilppp/10993803" target="_blank">Using Drafts for Remote CLI</a>.</b> As a text file is added to a directory to which this AppleScript is associated as Folder Action, the content of the received file is executed as shell script and the generated output sent to an iOS device.
|
214
|
-
# </li>
|
215
|
-
# </ul>
|
216
|
-
```
|
217
|
-
|
218
|
-
This simple command will return all pins from the user's account and output them based on the [Pin Template](https://github.com/bachya/PinPress#pin-templates "Pin Templates") provided.
|
219
|
-
|
220
|
-
Pinpress also provides some flags that allow a user to define specific pins to grab:
|
221
|
-
|
222
|
-
* `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
|
223
|
-
* `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
|
224
|
-
* `-n`: the number of pins to return (e.g., 20)
|
225
|
-
* `-t`: a CSV list of tags (e.g., "tag1,tag2") that must exist for the returned pins
|
226
|
-
|
227
|
-
Naturally, these switches can be combined in any number of ways.
|
228
|
-
|
229
|
-
## Getting Pins From a Date Forward
|
350
|
+
...and:
|
230
351
|
|
352
|
+
```bash
|
353
|
+
$ pinpress tags pinpress_default
|
231
354
|
```
|
232
|
-
$ pinpress pins -s 2014-01-01
|
233
|
-
```
|
234
|
-
|
235
|
-
...returns all pins from January 1, 2014 to the current day.
|
236
|
-
|
237
|
-
## Getting Pins Until a Date
|
238
|
-
|
239
|
-
```
|
240
|
-
$ pinpress pins -e 2014-01-01
|
241
|
-
```
|
242
|
-
|
243
|
-
...returns all pins up to January 1, 2014.
|
244
|
-
|
245
|
-
## Getting Pins Between a Date Range
|
246
|
-
|
247
|
-
```
|
248
|
-
$ pinpress pins -s 2014-01-01 -e 2014-01-31
|
249
|
-
```
|
250
|
-
|
251
|
-
## Getting Tagged Pins
|
252
|
-
|
253
|
-
```
|
254
|
-
$ pinpress pins -t "ruby,cli"
|
255
|
-
```
|
256
|
-
|
257
|
-
...returns all pins tagged "ruby" *and* "cli".
|
258
355
|
|
259
|
-
|
260
|
-
|
261
|
-
Pinpress can also work with tags in a Pinboard account:
|
356
|
+
...will output tag data in the format specified by that template:
|
262
357
|
|
358
|
+
```bash
|
359
|
+
link-mash (15),app (2),ios (3),productivity (1),launch-center-pro (1),drafts (2),
|
263
360
|
```
|
264
|
-
$ pinpress tags
|
265
|
-
# => cli (1),github (1),applescript (1),osx (1),link-mash (1),
|
266
|
-
```
|
267
|
-
|
268
|
-
This simple command will return all tags from the user's account and output them based on the [Tag Template](https://github.com/bachya/PinPress#tag-templates "Tag Templates") provided.
|
269
361
|
|
270
|
-
|
271
|
-
|
272
|
-
* `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
|
273
|
-
* `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
|
274
|
-
* `-t`: a CSV list of tags (e.g., "tag1,tag2") to examine for association (see [below](#getting-tags-that-have-been-used-with-other-tags)).
|
362
|
+
# Other Configuration Options
|
275
363
|
|
276
|
-
|
364
|
+
You can place special keys in the `pinpress` section of `~/.pinpress` to automate some actions:
|
277
365
|
|
278
|
-
```
|
279
|
-
|
280
|
-
|
366
|
+
```yaml
|
367
|
+
pinpress:
|
368
|
+
# ...other keys...
|
281
369
|
|
282
|
-
|
370
|
+
# The default `pins` template to use
|
371
|
+
default_pin_template
|
283
372
|
|
284
|
-
|
373
|
+
# The default `tags` template to use
|
374
|
+
default_tag_template
|
285
375
|
|
286
|
-
|
287
|
-
|
288
|
-
```
|
376
|
+
# The default tags to be used when getting pins or associated tags
|
377
|
+
default_tags: ['tag1', 'tag2']
|
289
378
|
|
290
|
-
|
379
|
+
# The tags to ignore when executing either `pins` or `tags`
|
380
|
+
ignored_tags: ['bad-tag', 'bad-tag2']
|
291
381
|
|
292
|
-
|
382
|
+
# The default number of results to return
|
383
|
+
default_num_results: 5
|
293
384
|
|
294
|
-
|
295
|
-
$ pinpress tags -s 2014-01-01 -e 2014-01-31
|
385
|
+
# ...other keys...
|
296
386
|
```
|
297
387
|
|
298
|
-
|
299
|
-
|
300
|
-
```
|
301
|
-
$ pinpress tags -t 'tag1,tag2' -s 2014-01-01
|
302
|
-
```
|
388
|
+
Do note:
|
303
389
|
|
304
|
-
|
390
|
+
* The `default_tags` key is overridden by the `-t` flag.
|
391
|
+
* The `default_num_results` key is overridden by the `-n` flag.
|
305
392
|
|
306
|
-
#
|
393
|
+
# Link Mash Config File
|
307
394
|
|
308
|
-
|
395
|
+
For your reference, here's my `~/.pinpress` (which is used to generate a [Link Mash on my blog](http://www.bachyaproductions.com/tag/link-mash/ "Bachya Productions Link Mash Archives")):
|
309
396
|
|
310
|
-
```
|
397
|
+
```yaml
|
398
|
+
---
|
311
399
|
pinpress:
|
312
|
-
|
313
|
-
default_pin_template
|
314
|
-
default_tag_template
|
315
|
-
default_tags: ['
|
316
|
-
ignored_tags: ['
|
317
|
-
|
318
|
-
|
400
|
+
config_location: "/Users/abach/.pinpress"
|
401
|
+
default_pin_template: pinpress_default
|
402
|
+
default_tag_template: pinpress_default
|
403
|
+
default_tags: ['link-mash']
|
404
|
+
ignored_tags: ['buffer']
|
405
|
+
log_level: WARN
|
406
|
+
version: 1.1.1
|
407
|
+
api_token: bachya:b819312cf9ccee799b87
|
408
|
+
pin_templates:
|
409
|
+
- name: pinpress_default
|
410
|
+
opener: >
|
411
|
+
<em>The weekly Link Mash is a curated selection of tools, stories, and
|
412
|
+
other links that I found during my travels on the web. All of my curated
|
413
|
+
links can be found on <a title="Bachya's Pinboard: Link Mash"
|
414
|
+
href="https://pinboard.in/u:bachya/t:link-mash/" target="_blank">
|
415
|
+
my Pinboard</a>; you can also find the Link Mash archives <a
|
416
|
+
href="http://www.bachyaproductions.com/tag/link-mash/">here</a>.
|
417
|
+
</em>
|
418
|
+
<ul>
|
419
|
+
item: >
|
420
|
+
<li>
|
421
|
+
<b><a title="<%= description %>" href="<%= href %>" target="_blank">
|
422
|
+
<%= description %></a>.</b>
|
423
|
+
<%= extended %>
|
424
|
+
</li>
|
425
|
+
closer: >
|
426
|
+
</ul>
|
427
|
+
<hr/>
|
428
|
+
<em>This Link Mash was generated by <a title="PinPress"
|
429
|
+
href="https://github.com/bachya/pinpress" target="_blank">PinPress</a>,
|
430
|
+
a simple tool to generate text templates from <a title="Pinboard"
|
431
|
+
href="https://pinboard.in" target="_blank">Pinboard</a> data.</em>"
|
432
|
+
tag_templates:
|
433
|
+
- name: pinpress_default
|
434
|
+
item: "<%= tag %>,"
|
319
435
|
```
|
320
436
|
|
321
|
-
Do note:
|
322
|
-
|
323
|
-
* The `default_tags` key can be overridden by the `-t` flag.
|
324
|
-
* The `default_num_results` key can be overridden by the `-n` flag.
|
325
|
-
|
326
437
|
# Known Issues & Future Releases
|
327
438
|
|
328
439
|
Check out the Pinpress roadmap via the [Trello Board](https://trello.com/b/lmuC8TT0/pinpress "Pinpress Trello Board").
|
@@ -331,11 +442,11 @@ Bugs, issues, and enhancement requests can be submitted on the [Issues Page](htt
|
|
331
442
|
|
332
443
|
# Bugs and Feature Requests
|
333
444
|
|
334
|
-
To report bugs with or suggest features/changes for
|
445
|
+
To report bugs with or suggest features/changes for PinPress, please use the [Issues Page](http://github.com/bachya/PinPress/issues).
|
335
446
|
|
336
447
|
Contributions are welcome and encouraged. To contribute:
|
337
448
|
|
338
|
-
* [Fork
|
449
|
+
* [Fork PinPress](http://github.com/bachya/PinPress/fork).
|
339
450
|
* Create a branch for your contribution (`git checkout -b new-feature`).
|
340
451
|
* Commit your changes (`git commit -am 'Added this new feature'`).
|
341
452
|
* Push to the branch (`git push origin new-feature`).
|
data/bin/pinpress
CHANGED
@@ -85,9 +85,9 @@ post do |global, command, options, args|
|
|
85
85
|
end
|
86
86
|
|
87
87
|
on_error do |exception|
|
88
|
-
messenger.error(exception.to_s)
|
89
|
-
exit!(1)
|
90
|
-
true
|
88
|
+
# messenger.error(exception.to_s)
|
89
|
+
# exit!(1)
|
90
|
+
# true
|
91
91
|
end
|
92
92
|
|
93
93
|
# ======================================================
|
@@ -124,64 +124,22 @@ command :pins do |c|
|
|
124
124
|
c.flag([:s], desc: 'The start date to pull pins from')
|
125
125
|
c.flag([:t], desc: 'The tags to use (e.g., "ruby,pinboard")')
|
126
126
|
|
127
|
-
c.
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
# Create a Pinboard client and set options based on
|
137
|
-
# PinPress flags.
|
138
|
-
opts = {}
|
139
|
-
opts.merge!(todt: Chronic.parse(options[:e])) if options[:e]
|
140
|
-
opts.merge!(fromdt: Chronic.parse(options[:s])) if options[:s]
|
141
|
-
|
142
|
-
if options[:n]
|
143
|
-
opts.merge!(results: options[:n])
|
144
|
-
elsif configuration.pinpress[:default_num_results]
|
145
|
-
opts.merge!(results: configuration.pinpress[:default_num_results])
|
146
|
-
end
|
147
|
-
|
148
|
-
if options[:t]
|
149
|
-
tags = options[:t].split(',')
|
150
|
-
elsif configuration.pinpress[:default_tags]
|
151
|
-
tags = configuration.pinpress[:default_tags]
|
152
|
-
end
|
153
|
-
|
154
|
-
ignored_tags = configuration.pinpress[:ignored_tags]
|
155
|
-
tags -= ignored_tags if ignored_tags
|
156
|
-
opts.merge!(tag: tags) if tags
|
157
|
-
|
158
|
-
begin
|
159
|
-
pins = client.posts(opts)
|
160
|
-
if !pins.empty?
|
161
|
-
print template.opener if template.opener
|
162
|
-
pins.each do |p|
|
163
|
-
href = p[:href]
|
164
|
-
description = p[:description]
|
165
|
-
extended = p[:extended]
|
166
|
-
tag = p[:tag]
|
167
|
-
time = p[:time]
|
168
|
-
replace = p[:replace]
|
169
|
-
shared = p[:shared]
|
170
|
-
toread = p[:toread]
|
171
|
-
|
172
|
-
print ERB.new(template.item).result(binding) if template.item
|
173
|
-
end
|
174
|
-
print template.closer if template.closer
|
175
|
-
else
|
176
|
-
messenger.warn('No matching pins...')
|
177
|
-
end
|
178
|
-
rescue StandardError => e
|
179
|
-
messenger.debug(e.to_s)
|
180
|
-
raise "Pinboard API failed; are you sure you've run " \
|
181
|
-
" `pinpress init` (and that your API key is correct)?"
|
127
|
+
c.desc 'Gets all pins from the last run date + 1'
|
128
|
+
c.command :last do |last|
|
129
|
+
last.action do |global_options, options, args|
|
130
|
+
last_run_date = configuration.pinpress[:last_pins_run]
|
131
|
+
if last_run_date
|
132
|
+
options[:s] = last_run_date + 1
|
133
|
+
puts PinPress.get_data(PinPress::Template::TEMPLATE_TYPE_PIN, args, options)
|
134
|
+
else
|
135
|
+
messenger.warn("`pinpress pins` hasn't been run before.")
|
182
136
|
end
|
183
137
|
end
|
184
138
|
end
|
139
|
+
|
140
|
+
c.action do |global_options, options, args|
|
141
|
+
puts PinPress.get_data(PinPress::Template::TEMPLATE_TYPE_PIN, args, options)
|
142
|
+
end
|
185
143
|
end
|
186
144
|
|
187
145
|
# ------------------------------------------------------
|
@@ -195,53 +153,23 @@ command :tags do |c|
|
|
195
153
|
c.flag([:t], desc: 'The tags to use (e.g., "ruby,pinboard")')
|
196
154
|
c.flag([:s], desc: 'The start date to pull pins from')
|
197
155
|
|
198
|
-
c.desc 'Gets
|
199
|
-
c.
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
opts.merge!(fromdt: Chronic.parse(options[:s])) if options[:s]
|
208
|
-
|
209
|
-
if options[:t]
|
210
|
-
tags = options[:t].split(',')
|
211
|
-
elsif configuration.pinpress[:default_tags]
|
212
|
-
tags = configuration.pinpress[:default_tags]
|
213
|
-
end
|
214
|
-
|
215
|
-
ignored_tags = configuration.pinpress[:ignored_tags]
|
216
|
-
tags -= ignored_tags if ignored_tags
|
217
|
-
opts.merge!(tag: tags) if tags
|
218
|
-
|
219
|
-
begin
|
220
|
-
pins = client.posts(opts)
|
221
|
-
pins.each { |p| tags += p[:tag] }
|
222
|
-
tags = tags.uniq.map { |t| { tag: t, count: tags.count(t) } }
|
223
|
-
|
224
|
-
if !tags.empty?
|
225
|
-
print template.opener if template.opener
|
226
|
-
tags.each do |t|
|
227
|
-
unless t[:tag] == opts[:tag]
|
228
|
-
tag = t[:tag]
|
229
|
-
count = t[:count]
|
230
|
-
end
|
231
|
-
|
232
|
-
print ERB.new(template.item).result(binding) if template.item
|
233
|
-
end
|
234
|
-
print template.closer if template.closer
|
235
|
-
else
|
236
|
-
message.warn('No matching tags...')
|
237
|
-
end
|
238
|
-
rescue StandardError => e
|
239
|
-
messenger.debug(e.to_s)
|
240
|
-
raise "Pinboard API failed; are you sure you've run " \
|
241
|
-
" `pinpress init` (and that your API key is correct)?"
|
156
|
+
c.desc 'Gets all tags from the last run date + 1'
|
157
|
+
c.command :last do |last|
|
158
|
+
last.action do |global_options, options, args|
|
159
|
+
last_run_date = configuration.pinpress[:last_tags_run]
|
160
|
+
if last_run_date
|
161
|
+
options[:s] = last_run_date + 1
|
162
|
+
puts PinPress.get_data(PinPress::Template::TEMPLATE_TYPE_TAG, args, options)
|
163
|
+
else
|
164
|
+
messenger.warn("`pinpress tags` hasn't been run before.")
|
242
165
|
end
|
243
166
|
end
|
244
167
|
end
|
168
|
+
|
169
|
+
c.desc 'Gets the unique tags based on the passed criteria'
|
170
|
+
c.action do |global_options, options, args|
|
171
|
+
puts PinPress.get_data(PinPress::Template::TEMPLATE_TYPE_TAG, args, options)
|
172
|
+
end
|
245
173
|
end
|
246
174
|
|
247
175
|
# ------------------------------------------------------
|
data/lib/pinpress.rb
CHANGED
@@ -24,7 +24,7 @@ module PinPress
|
|
24
24
|
# @return [void]
|
25
25
|
def self.execute_template(template_type, template_name)
|
26
26
|
template_hash = PinPress.get_template_by_name(template_type, template_name)
|
27
|
-
if
|
27
|
+
if template_hash
|
28
28
|
template = PinPress::TagTemplate.new(template_hash)
|
29
29
|
client = Pinboard::Client.new(token: configuration.pinpress[:api_token])
|
30
30
|
yield template, client
|
@@ -33,6 +33,100 @@ module PinPress
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
# Generates a string of items from pins.
|
37
|
+
# @param [Fixnum] template_type
|
38
|
+
# @param [PinPress::Template] template
|
39
|
+
# @param [Array] pins
|
40
|
+
# @return [String]
|
41
|
+
def self.generate_items(template_type, template, pins, opts)
|
42
|
+
output = ''
|
43
|
+
case template_type
|
44
|
+
when PinPress::Template::TEMPLATE_TYPE_PIN
|
45
|
+
pins.each do |p|
|
46
|
+
href = p[:href]
|
47
|
+
description = p[:description]
|
48
|
+
extended = p[:extended]
|
49
|
+
tag = p[:tag]
|
50
|
+
time = p[:time]
|
51
|
+
replace = p[:replace]
|
52
|
+
shared = p[:shared]
|
53
|
+
toread = p[:toread]
|
54
|
+
output += ERB.new(template.item).result(binding)
|
55
|
+
end
|
56
|
+
configuration.pinpress[:last_pins_run] = Date.today
|
57
|
+
when PinPress::Template::TEMPLATE_TYPE_TAG
|
58
|
+
tags = []
|
59
|
+
pins.each { |p| tags += p[:tag] }
|
60
|
+
tags = tags.uniq.map { |t| { tag: t, count: tags.count(t) } }
|
61
|
+
tags.each do |t|
|
62
|
+
unless t[:tag] == opts[:tag]
|
63
|
+
tag = t[:tag]
|
64
|
+
count = t[:count]
|
65
|
+
output += ERB.new(template.item).result(binding)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
configuration.pinpress[:last_tags_run] = Date.today
|
69
|
+
end
|
70
|
+
output
|
71
|
+
end
|
72
|
+
|
73
|
+
# Generic function to get data from Pinboard.
|
74
|
+
# @param [Fixnum] template_type
|
75
|
+
# @param [Array] args
|
76
|
+
# @param [Hash] options
|
77
|
+
# @return [String]
|
78
|
+
def self.get_data(template_type, args, options)
|
79
|
+
output = ''
|
80
|
+
|
81
|
+
# Two scenarios covered here:
|
82
|
+
# 1. If the user passes a valid name, grab that template.
|
83
|
+
# 2. If no name is passed, grabbed the default template
|
84
|
+
# If both of these conditions fail, an error message is shown.
|
85
|
+
# t_type = PinPress::Template::TEMPLATE_TYPE_PIN
|
86
|
+
# t_name = args.empty? ? nil : args[0]
|
87
|
+
t_name = args.empty? ? nil : args[0]
|
88
|
+
|
89
|
+
PinPress.execute_template(template_type, t_name) do |template, client|
|
90
|
+
opts = {}
|
91
|
+
opts.merge!(todt: Chronic.parse(options[:e])) if options[:e]
|
92
|
+
opts.merge!(fromdt: Chronic.parse(options[:s])) if options[:s]
|
93
|
+
|
94
|
+
if options[:n]
|
95
|
+
opts.merge!(results: options[:n])
|
96
|
+
elsif configuration.pinpress[:default_num_results]
|
97
|
+
opts.merge!(results: configuration.pinpress[:default_num_results])
|
98
|
+
end
|
99
|
+
|
100
|
+
if options[:t]
|
101
|
+
tags = options[:t].split(',')
|
102
|
+
elsif configuration.pinpress[:default_tags]
|
103
|
+
tags = configuration.pinpress[:default_tags]
|
104
|
+
end
|
105
|
+
|
106
|
+
ignored_tags = configuration.pinpress[:ignored_tags]
|
107
|
+
tags -= ignored_tags if ignored_tags
|
108
|
+
opts.merge!(tag: tags) if tags
|
109
|
+
|
110
|
+
begin
|
111
|
+
pins = client.posts(opts)
|
112
|
+
if pins.empty?
|
113
|
+
messenger.warn('No matching pins...')
|
114
|
+
else
|
115
|
+
output += template.opener if template.opener
|
116
|
+
output += PinPress.generate_items(template_type, template, pins, opts)
|
117
|
+
output += template.closer if template.closer
|
118
|
+
end
|
119
|
+
configuration.save
|
120
|
+
return output
|
121
|
+
rescue StandardError => e
|
122
|
+
p e.to_s
|
123
|
+
messenger.debug(e.to_s)
|
124
|
+
raise "Pinboard API failed; are you sure you've run " \
|
125
|
+
" `pinpress init` (and that your API key is correct)?"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
36
130
|
# Determines whether a template exists.
|
37
131
|
# @param [Fixnum] template_type
|
38
132
|
# @param [<String, Symbol>] template_name
|
@@ -110,7 +204,7 @@ module PinPress
|
|
110
204
|
tag_templates = configuration.tag_templates
|
111
205
|
|
112
206
|
messenger.section('AVAILABLE PIN TEMPLATES:')
|
113
|
-
if
|
207
|
+
if pin_templates
|
114
208
|
pin_templates.each_with_index do |template, index|
|
115
209
|
messenger.info("#{ index + 1 }. #{ template[:name] }")
|
116
210
|
end
|
@@ -119,7 +213,7 @@ module PinPress
|
|
119
213
|
end
|
120
214
|
|
121
215
|
messenger.section('AVAILABLE TAG TEMPLATES:')
|
122
|
-
if
|
216
|
+
if tag_templates
|
123
217
|
tag_templates.each_with_index do |template, index|
|
124
218
|
messenger.info("#{ index + 1 }. #{ template[:name] }")
|
125
219
|
end
|
data/lib/pinpress/constants.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pinpress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Bach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|