Pinboard Poster for Kotlin/Java https://github.com/ethauvin/pinboard-poster
Find a file
2018-06-26 14:38:40 -07:00
.circleci Added Kobalt back to CircleCI. 2018-06-20 10:57:18 -07:00
.idea Added issueManagement to pom. 2018-06-21 11:28:51 -07:00
gradle/wrapper Fixed Gradle wrappers. 2018-06-20 00:47:22 -07:00
kobalt Pre-1.0.0 release prep. 2018-06-20 15:39:27 -07:00
lib Initial commit. 2017-05-17 00:41:35 -07:00
samples Removed unused imports. 2018-06-22 17:42:25 -07:00
src Fixed kDoc. 2018-06-26 13:55:16 -07:00
.gitattributes Initial commit. 2017-05-17 00:41:35 -07:00
.gitignore Added Kobalt test wrapper. 2017-11-04 12:05:47 -07:00
.travis.yml Fixed CIs. 2018-06-20 00:42:56 -07:00
build.gradle.kts Fixed isRelease flag. 2018-06-26 14:38:40 -07:00
gradlew Made wrappers executable. 2018-06-20 00:54:05 -07:00
gradlew.bat Fixed Gradle wrappers. 2018-06-20 00:47:22 -07:00
kobaltw Made kobaltw executable via: 'git update-index --chmod=+x koblatw' 2017-10-29 22:51:03 -07:00
kobaltw.bat Initial commit. 2017-05-17 00:41:35 -07:00
LICENCE.txt Updated copyright. 2018-01-16 14:31:06 -08:00
pinboard-poster.iml Pre-1.0.0 release prep. 2018-06-20 15:39:27 -07:00
pom.xml Added issueManagement to pom. 2018-06-21 11:28:51 -07:00
README.md Pre-1.0.0 release. 2018-06-22 17:16:54 -07:00
settings.gradle Added stable publsihing feature. 2018-06-22 17:13:28 -07:00

Pinboard Poster for Kotlin/Java

License (3-Clause BSD) release Download
Known Vulnerabilities Build Status CircleCI

A small Kotlin/Java library for posting to Pinboard.

Examples

Kotlin


val poster = PinboardPoster("user:TOKEN")

poster.addPin("http://www.example.com/foo", "This is a test")
poster.deletePin("http:///www.example.com/bar")

View Example

Java


final PinboardPoster poster = new PinBboardPoster("user:TOKEN");

poster.addPin("http://www.example.com/foo", "This is a test");
poster.deletePin("http:///www.example.com/bar");

View Example

Your API authentication token is available on the Pinboard settings page.

Usage with Maven, Gradle and Kobalt

Maven

To install and run from Maven, configure an artifact as follows:

<dependency>
    <groupId>net.thauvin.erik</groupId>
    <artifactId>pinboard-poster</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

To install and run from Gradle, add the following to the build.gradle file:

dependencies {
    compile 'net.thauvin.erik:pinboard-poster:1.0.0'
}

View Example
View Kotlin DSL Example

Kobalt

To install and run from Kobalt, add the following to the Build.kt file:

dependencies {
    compile("net.thauvin.erik:pinboard-poster:1.0.0")
}

View Example

Adding

The addPin function support all of the Pinboard API parameters:

poster.addPin(url = "http://www.example.com",
              description = "This is the title",
              extended = "This is the extended description.",
              tags = "tag1 tag2 tag3",
              dt = "2010-12-11T19:48:02Z",
              replace = true,
              shared = true,
              toRead = false)

url and description are required.

It returns true if the bookmark was added successfully, false otherwise.

Deleting

The deletePin function support all of the Pinboard API parameters:

poster.deletePin(url = "http://www.example.com/")

It returns true if the bookmark was deleted successfully, false otherwise.

Logging

The library used java.util.logging to log errors. Logging can be configured as follows:

Kotlin

with(poster.logger) {
    addHandler(ConsoleHandler().apply { level = Level.FINE })
    level = Level.FINE
}

Java

final ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.FINE);
final Logger logger = poster.getLogger();
logger.addHandler(consoleHandler);
logger.setLevel(Level.FINE);

or using a logging properties file.

API Authentication Token

The token can also be located in a properties file or environment variable.

Local Property

For example, using the default PINBOARD_API_TOKEN key value from a local.properties file:

# local.properties
PINBOARD_API_TOKEN=user\:TOKEN
val poster = PinboardPoster(Paths.get("local.properties"))

or by specifying your own key:

# my.properties
my.api.key=user\:TOKEN
val poster = PinboardPoster(Paths.get("my.properties"), "my.api.key")

or even specifying your own property:

val p = Properties()
p.setProperty("api.key", "user:TOKEN")

val poster = PinboardPoster(p, "api.key")

In all cases, the value of the PINBOARD_API_TOKEN environment variable is used by default if the specified property is invalid or not found.

Environment Variable

If no arguments are passed to the constructor, the value of the PINBOARD_API_TOKEN environment variable will be used, if any.

export PINBOARD_API_TOKEN="user:TOKEN"
val poster = PinboardPoster()

API End Point

The API end point is automatically configured to https://api.pinboard.in/v1/. Since Pinboard uses the del.ico.us API, the library could potentially be used with another compatible service. To configure the API end point, use:

poster.apiEndPoint = "https://www.example.com/v1"