Pinboard Poster for Kotlin/Java https://github.com/ethauvin/pinboard-poster
Find a file
2021-03-21 21:58:15 -07:00
.circleci Added jdk14 to CIs. 2021-03-21 18:27:31 -07:00
.github/workflows Upgraded to Gradle 6.6 and Kotlin 1.4.0. 2020-08-18 11:39:40 -07:00
.idea Implemented using HttpLoggingInterceptor instead of manual logging. Closes #3. 2020-08-19 16:29:46 -07:00
config/detekt Upgraded to Gradle 6.6 and Kotlin 1.4.0. 2020-08-18 11:39:40 -07:00
gradle/wrapper Moved from JCenter to Maven Central. 2021-03-21 17:54:34 -07:00
lib Initial commit. 2017-05-17 00:41:35 -07:00
samples Cleanup. 2021-03-21 21:22:09 -07:00
src Updated copyright. 2021-03-21 18:41:09 -07:00
.editorconfig Added editor config. 2018-07-11 15:25:07 -07:00
.gitattributes Initial commit. 2017-05-17 00:41:35 -07:00
.github_changelog_generator Updated version numbers to 1.0.2 since the new pinboard API is not quite ready. 2021-03-21 21:08:30 -07:00
.gitignore Updated versions. 2021-03-21 18:19:44 -07:00
.gitlab-ci.yml Upgraded to Gradle 6.6 and Kotlin 1.4.0. 2020-08-18 11:39:40 -07:00
.travis.yml Added jdk14 to CIs. 2021-03-21 18:27:31 -07:00
bitbucket-pipelines.yml Upgraded to Gradle 6.6 and Kotlin 1.4.0. 2020-08-18 11:39:40 -07:00
build.gradle.kts Fixed typo. 2021-03-21 21:09:47 -07:00
CHANGELOG.md Updated version numbers to 1.0.2 since the new pinboard API is not quite ready. 2021-03-21 21:08:30 -07:00
gradlew Upgraded to Gradle 6.6 and Kotlin 1.4.0. 2020-08-18 11:39:40 -07:00
gradlew.bat Upgraded to Gradle 6.6 and Kotlin 1.4.0. 2020-08-18 11:39:40 -07:00
LICENSE.txt Updated copyright. 2021-03-21 18:41:09 -07:00
pinboard-poster.iml Upgraded to Gradle 6.6 and Kotlin 1.4.0. 2020-08-18 11:39:40 -07:00
pom.xml Updated version numbers to 1.0.2 since the new pinboard API is not quite ready. 2021-03-21 21:08:30 -07:00
preflightcheck.sh Removed Kobalt. 2020-08-19 21:15:58 -07:00
README.md Fixed maven central badge. 2021-03-21 21:42:37 -07:00
settings.gradle.kts Upgraded to Gradle 6.6 and Kotlin 1.4.0. 2020-08-18 11:39:40 -07:00
updatewrappers.sh Version 1.0.1 2019-04-06 00:09:16 -07:00

Pinboard Poster for Kotlin/Java

License (3-Clause BSD) Release Maven Central

Known Vulnerabilities Quality Gate Status Build Status CircleCI

A small Kotlin/Java/Android 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 Gradle, Maven, etc.

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

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

View Example
View Kotlin DSL Example

Instructions for using with Maven, Ivy, etc. can be found on Maven Central.

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"