Pinboard Poster for Kotlin/Java https://github.com/ethauvin/pinboard-poster
Find a file
2023-11-24 00:31:30 -08:00
.circleci Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
.github/workflows Added pinboard token to workflow 2023-11-23 23:21:09 -08:00
.idea Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
.vscode Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
config/detekt Added pin config builder. Closes #10 2023-09-27 17:25:00 -07:00
examples Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
lib Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
src Cleaned up tests 2023-11-24 00:31:30 -08: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 Version 1.1 2023-09-27 19:42:51 -07:00
.gitignore Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
.gitlab-ci.yml Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
bitbucket-pipelines.yml Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
bld Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
bld.bat Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
CHANGELOG.md Version 1.1 2023-09-27 19:42:51 -07:00
LICENSE.txt Updated dependencies 2023-09-27 17:25:00 -07:00
pom.xml Moved from Gradle to bld 2023-11-23 23:15:24 -08:00
README.md Fixed GitHub CI badge 2023-11-23 23:25:18 -08:00
sonar-project.properties Moved from Gradle to bld 2023-11-23 23:15:24 -08:00

Pinboard Poster for Kotlin, Java and Android

License (3-Clause BSD) Kotlin Release Maven Central Nexus Snapshot

Quality Gate Status GitHub CI CircleCI

A small library for posting to Pinboard.

Examples

Kotlin


val poster = PinboardPoster("user:TOKEN")

poster.addPin("https://www.example.com/foo", "This is a test")
poster.addPin("https://examples.com", "This is a test", tags = arrayOf("foo", "bar"))
poster.deletePin("https:///www.example.com/bar")

View Examples

Java


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

poster.addPin("https://www.example.com/foo", "This is a test");
poster.addPin(new PinConfig.Builder()
                .url("https://example.com")
                .description("This is a test")
                .tags("foo", "bar")
                .build());
poster.deletePin("https:///www.example.com/bar");

View Examples

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

bld

To use with bld, include the following dependency in your build file:

repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);

scope(compile)
    .include(dependency("net.thauvin.erik:pinboard-poster:1.1.0"));

Be sure to use the bld Kotlin extension in your project.

View Example

Gradle, Maven, etc.

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

repositories {
    mavenCentral()
}

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

View Examples

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

Adding

The addPin function support all of the Pinboard API parameters:

import java.time.ZonedDateTime

poster.addPin(
    url = "https://www.example.com",
    description = "This is the title",
    extended = "This is the extended description.",
    tags = arrayOf("tag1", "tag2", "tag3"),
    dt = ZonedDateTime.now(),
    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 = "https://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"