+
\ No newline at end of file
diff --git a/.idea/kobalt.xml b/.idea/kobalt.xml
deleted file mode 100644
index 7f1760d..0000000
--- a/.idea/kobalt.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml
new file mode 100644
index 0000000..153a060
--- /dev/null
+++ b/.idea/libraries/bld.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/libraries/compile.xml b/.idea/libraries/compile.xml
new file mode 100644
index 0000000..99cc0c0
--- /dev/null
+++ b/.idea/libraries/compile.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/runtime.xml b/.idea/libraries/runtime.xml
new file mode 100644
index 0000000..d4069f2
--- /dev/null
+++ b/.idea/libraries/runtime.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/test.xml b/.idea/libraries/test.xml
new file mode 100644
index 0000000..57ed5ef
--- /dev/null
+++ b/.idea/libraries/test.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 115f0a1..2adb169 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index d5b3d2b..55adcb9 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,8 +2,8 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Run Tests.xml b/.idea/runConfigurations/Run Tests.xml
new file mode 100644
index 0000000..2d4326e
--- /dev/null
+++ b/.idea/runConfigurations/Run Tests.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/Source.xml b/.idea/scopes/Source.xml
deleted file mode 100644
index 942e059..0000000
--- a/.idea/scopes/Source.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
deleted file mode 100644
index e96534f..0000000
--- a/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 4a6654e..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-language: java
-
-jdk:
- - oraclejdk8
-
-before_install:
- - chmod +x kobaltw
-
-install: true
-
-cache:
- directories:
- - $HOME/.m2
- - $HOME/.kobalt
-
-before_cache:
- - rm -rf .kobalt/*
-
-script: ./kobaltw clean assemble test
\ No newline at end of file
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..f25500c
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,11 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "java",
+ "name": "Run Tests",
+ "request": "launch",
+ "mainClass": "net.thauvin.erik.pinboard.PinboardPosterTest"
+ }
+ ]
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..ba429d0
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,15 @@
+{
+ "java.project.sourcePaths": [
+ "src/main/java",
+ "src/main/resources",
+ "src/test/java",
+ "src/test/resources",
+ "src/bld/java",
+ "src/bld/resources"
+ ],
+ "java.configuration.updateBuildConfiguration": "automatic",
+ "java.project.referencedLibraries": [
+ "${HOME}/.bld/dist/bld-2.2.1.jar",
+ "lib/**/*.jar"
+ ]
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..9c318e1
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,61 @@
+# Changelog
+
+## [1.1.0](https://github.com/ethauvin/pinboard-poster/tree/1.1.0) (2023-09-28)
+
+[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/1.0.3...1.1.0)
+
+**Implemented enhancements:**
+
+- Add pin config builder [\#10](https://github.com/ethauvin/pinboard-poster/issues/10)
+
+**Fixed bugs:**
+
+- Fixed potential resource leak [\#11](https://github.com/ethauvin/pinboard-poster/issues/11)
+
+## [1.0.3](https://github.com/ethauvin/pinboard-poster/tree/1.0.3) (2021-03-22)
+
+[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/1.0.2...1.0.3)
+
+**Fixed bugs:**
+
+- 1.0.2 only compiled for Java 15 [\#4](https://github.com/ethauvin/pinboard-poster/issues/4)
+
+## [1.0.2](https://github.com/ethauvin/pinboard-poster/tree/1.0.2) (2021-03-22)
+
+[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/1.0.1...1.0.2)
+
+**Implemented enhancements:**
+
+- Use HttpLoggingInterceptor instead of manually logging. [\#3](https://github.com/ethauvin/pinboard-poster/issues/3)
+
+**Fixed bugs:**
+
+- executeMethod should trap IO execeptions [\#2](https://github.com/ethauvin/pinboard-poster/issues/2)
+
+## [1.0.1](https://github.com/ethauvin/pinboard-poster/tree/1.0.1) (2019-05-27)
+
+[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/1.0.0...1.0.1)
+
+**Implemented enhancements:**
+
+- Implement better error reporting. [\#1](https://github.com/ethauvin/pinboard-poster/issues/1)
+
+## [1.0.0](https://github.com/ethauvin/pinboard-poster/tree/1.0.0) (2018-06-26)
+
+[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/0.9.3...1.0.0)
+
+## [0.9.3](https://github.com/ethauvin/pinboard-poster/tree/0.9.3) (2017-11-09)
+
+[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/0.9.2...0.9.3)
+
+## [0.9.2](https://github.com/ethauvin/pinboard-poster/tree/0.9.2) (2017-11-08)
+
+[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/0.9.1...0.9.2)
+
+## [0.9.1](https://github.com/ethauvin/pinboard-poster/tree/0.9.1) (2017-05-18)
+
+[Full Changelog](https://github.com/ethauvin/pinboard-poster/compare/2ee3568e40114e19b0956ea7d12c071d5c49b0d5...0.9.1)
+
+
+
+\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..9926d00
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,27 @@
+Copyright (c) 2017-2025, Erik C. Thauvin (erik@thauvin.net)
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of this project nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
index ec04161..cdf7df5 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,18 @@
-# [Pinboard](https://pinboard.in) Poster for Kotlin/Java
+# [Pinboard](https://pinboard.in) Poster for Kotlin, Java and Android
-[](http://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/pinboard-poster/releases/latest) [](https://bintray.com/ethauvin/maven/pinboard-poster/_latestVersion)
-[](https://www.versioneye.com/user/projects/591c0293b81f680038a784b3) [](https://travis-ci.org/ethauvin/pinboard-poster) [](https://circleci.com/gh/ethauvin/pinboard-poster/tree/master)
+[](https://opensource.org/licenses/BSD-3-Clause)
+[](https://kotlinlang.org/)
+[](https://rife2.com/bld)
+[](https://github.com/ethauvin/pinboard-poster/releases/latest)
+[](https://central.sonatype.com/artifact/net.thauvin.erik/pinboard-poster)
+[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/pinboard-poster/)
-A small Kotlin/Java library for posting to [Pinboard](https://pinboard.in).
+
+[](https://sonarcloud.io/dashboard?id=ethauvin_pinboard-poster)
+[](https://github.com/ethauvin/pinboard-poster/actions/workflows/bld.yml)
+[](https://circleci.com/gh/ethauvin/pinboard-poster/tree/master)
+
+A small library for posting to [Pinboard](https://pinboard.in).
## Examples
@@ -13,71 +22,80 @@ A small Kotlin/Java library for posting to [Pinboard](https://pinboard.in).
val poster = PinboardPoster("user:TOKEN")
-poster.addPin("http://www.example.com/foo", "This is a test")
-poster.deletePin("http:///www.example.com/bar")
+poster.addPin("https://example.com/foo", "This is a test")
+poster.addPin("https://example.com", "This is a test", tags = arrayOf("foo", "bar"))
+poster.deletePin("https://example.com/bar")
```
-[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/src/main/kotlin/net/thauvin/erik/pinboard/PinboardPoster.kt#L219)
+
+[View Examples](https://github.com/ethauvin/pinboard-poster/blob/master/examples)
### Java
+
```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");
+poster.addPin("https://example.com/foo", "This is a test");
+poster.addPin(new PinConfig.Builder("https://example.com", "This is a test")
+ .tags("foo", "bar")
+ .build());
+poster.deletePin("https://example.com/bar");
```
-[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/src/main/java/net/thauvin/erik/pinboard/JavaExample.java)
+
+[View Examples](https://github.com/ethauvin/pinboard-poster/blob/master/examples)
Your API authentication token is available on the [Pinboard settings page](https://pinboard.in/settings/password).
-## Usage with Maven, Gradle and Kobalt
+## bld
-### Maven
+To use with [bld](https://rife2.com/bld), include the following dependency in your [build](https://github.com/ethauvin/pinboard-poster/blob/master/examples/bld/src/bld/java/net/thauvin/erik/pinboard/samples/ExampleBuild.java) file:
-To install and run from Maven, configure an artifact as follows:
+```java
+repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
-```xml
-
- net.thauvin.erik
- pinboard-poster
- 0.9.2
-
+scope(compile)
+ .include(dependency("net.thauvin.erik:pinboard-poster:1.2.0"));
```
+Be sure to use the [bld Kotlin extension](https://github.com/rife2/bld-kotlin) in your project.
-### Gradle
+[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/examples/bld/)
-To install and run from Gradle, add the following to the build.gradle file:
+## Gradle, Maven, etc.
+
+To install and run from Gradle, add the following to the `build.gradle` file:
```gradle
+repositories {
+ mavenCentral()
+}
+
dependencies {
- compile 'net.thauvin.erik:pinboard-poster:0.9.2'
+ compile 'net.thauvin.erik:pinboard-poster:1.2.0'
}
```
-### Kobalt
+[View Examples](https://github.com/ethauvin/pinboard-poster/blob/master/examples/gradle/)
-To install and run from Kobalt, add the following to the Build.kt file:
-
-```gradle
-dependencies {
- compile("net.thauvin.erik:pinboard-poster:0.9.2")
-}
-```
+Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/pinboard-poster).
## Adding
The `addPin` function support all of the [Pinboard API parameters](https://pinboard.in/api/#posts_add):
```kotlin
-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)
+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.
@@ -89,7 +107,7 @@ It returns `true` if the bookmark was added successfully, `false` otherwise.
The `deletePin` function support all of the [Pinboard API parameters](https://pinboard.in/api/#posts_delete):
```kotlin
-poster.deletePin(url = "http://www.example.com/")
+poster.deletePin(url = "https://www.example.com/")
```
It returns `true` if the bookmark was deleted successfully, `false` otherwise.
@@ -99,19 +117,24 @@ It returns `true` if the bookmark was deleted successfully, `false` otherwise.
The library used [`java.util.logging`](https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html) to log errors. Logging can be configured as follows:
#### Kotlin
+
```kotlin
with(poster.logger) {
addHandler(ConsoleHandler().apply { level = Level.FINE })
level = Level.FINE
+ useParentHandlers = false
}
```
+
#### Java
+
```java
final ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.FINE);
final Logger logger = poster.getLogger();
logger.addHandler(consoleHandler);
logger.setLevel(Level.FINE);
+logger.setUseParentHandlers(false);
```
or using a logging properties file.
@@ -133,7 +156,7 @@ PINBOARD_API_TOKEN=user\:TOKEN
val poster = PinboardPoster(Paths.get("local.properties"))
```
-To specify your own key:
+or by specifying your own key:
```ini
# my.properties
@@ -144,9 +167,20 @@ my.api.key=user\:TOKEN
val poster = PinboardPoster(Paths.get("my.properties"), "my.api.key")
```
+or even specifying your own property:
+
+```kotlin
+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 `PINBOARD_API_TOKEN` environment variable will be used, if any.
+If no arguments are passed to the constructor, the value of the `PINBOARD_API_TOKEN` environment variable will be used, if any.
```sh
export PINBOARD_API_TOKEN="user:TOKEN"
@@ -162,4 +196,22 @@ The API end point is automatically configured to `https://api.pinboard.in/v1/`.
```kotlin
poster.apiEndPoint = "https://www.example.com/v1"
-```
\ No newline at end of file
+```
+
+## Contributing
+
+If you want to contribute to this project, all you have to do is clone the GitHub
+repository:
+
+```console
+git clone git@github.com:ethauvin/pinboard-poster.git
+```
+
+Then use [bld](https://rife2.com/bld) to build:
+
+```console
+cd pinboard-poster
+./bld compile
+```
+
+The project has an [IntelliJ IDEA](https://www.jetbrains.com/idea/) project structure. You can just open it after all the dependencies were downloaded and peruse the code.
diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml
new file mode 100644
index 0000000..ace99d2
--- /dev/null
+++ b/bitbucket-pipelines.yml
@@ -0,0 +1,20 @@
+image: ubuntu:latest
+
+pipelines:
+ default:
+ - step:
+ name: Test with bld
+ script:
+ # Install latest Java & Kotlin via SDKMAN!
+ - apt-get update -qq && apt-get install -y curl zip
+ - curl -s "https://get.sdkman.io" | bash
+ - echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config
+ - echo sdkman_auto_selfupdate=true >> $HOME/.sdkman/etc/config
+ - source "$HOME/.sdkman/bin/sdkman-init.sh"
+ - sdk install java
+ - sdk install kotlin
+ - source "$HOME/.sdkman/bin/sdkman-init.sh"
+ # Download, compile and test with bld
+ - ./bld download
+ - ./bld compile
+ - ./bld test
diff --git a/bld b/bld
new file mode 100755
index 0000000..3c1df97
--- /dev/null
+++ b/bld
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.pinboard.PinboardPosterBuild "$@"
diff --git a/bld.bat b/bld.bat
new file mode 100644
index 0000000..1262822
--- /dev/null
+++ b/bld.bat
@@ -0,0 +1,4 @@
+@echo off
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.pinboard.PinboardPosterBuild %*
diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml
new file mode 100644
index 0000000..3f97ec1
--- /dev/null
+++ b/config/detekt/baseline.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ LongParameterList:PinConfig.kt$PinConfig$( var url: String, var description: String, var extended: String = "", var tags: Array<out String> = emptyArray(), var dt: ZonedDateTime = ZonedDateTime.now(), var replace: Boolean = true, var shared: Boolean = true, var toRead: Boolean = false )
+ LongParameterList:PinboardPoster.kt$PinboardPoster$( url: String, description: String, extended: String = "", vararg tags: String = emptyArray(), dt: ZonedDateTime = ZonedDateTime.now(), replace: Boolean = true, shared: Boolean = true, toRead: Boolean = false )
+ NestedBlockDepth:PinboardPoster.kt$PinboardPoster$private fun executeMethod(method: String, params: Map<String, String>): Boolean
+ ThrowsCount:PinboardPoster.kt$PinboardPoster$@Throws(IOException::class) internal fun parseMethodResponse(method: String, response: String)
+ TooManyFunctions:PinConfig.kt$PinConfig$Builder
+
+
diff --git a/examples/bld/.gitignore b/examples/bld/.gitignore
new file mode 100644
index 0000000..a2805aa
--- /dev/null
+++ b/examples/bld/.gitignore
@@ -0,0 +1,55 @@
+.gradle
+.DS_Store
+build
+lib/bld/**
+!lib/bld/bld-wrapper.jar
+!lib/bld/bld-wrapper.properties
+lib/compile/
+lib/runtime/
+lib/standalone/
+lib/test/
+
+# IDEA ignores
+
+# User-specific
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# SonarLint plugin
+.idea/sonarlint/
+
+# Editor-based Rest Client
+.idea/httpRequests
\ No newline at end of file
diff --git a/examples/bld/.idea/.gitignore b/examples/bld/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/examples/bld/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/examples/bld/.idea/.name b/examples/bld/.idea/.name
new file mode 100644
index 0000000..6782949
--- /dev/null
+++ b/examples/bld/.idea/.name
@@ -0,0 +1 @@
+pinboard-poster-examples-bld
\ No newline at end of file
diff --git a/examples/bld/.idea/app.iml b/examples/bld/.idea/app.iml
new file mode 100644
index 0000000..2d05353
--- /dev/null
+++ b/examples/bld/.idea/app.iml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/bld.iml b/examples/bld/.idea/bld.iml
new file mode 100644
index 0000000..e63e11e
--- /dev/null
+++ b/examples/bld/.idea/bld.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/bld.xml b/examples/bld/.idea/bld.xml
new file mode 100644
index 0000000..6600cee
--- /dev/null
+++ b/examples/bld/.idea/bld.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/inspectionProfiles/Project_Default.xml b/examples/bld/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..1e01b48
--- /dev/null
+++ b/examples/bld/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/bld.xml b/examples/bld/.idea/libraries/bld.xml
new file mode 100644
index 0000000..153a060
--- /dev/null
+++ b/examples/bld/.idea/libraries/bld.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/bld/.idea/libraries/compile.xml b/examples/bld/.idea/libraries/compile.xml
new file mode 100644
index 0000000..99cc0c0
--- /dev/null
+++ b/examples/bld/.idea/libraries/compile.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/runtime.xml b/examples/bld/.idea/libraries/runtime.xml
new file mode 100644
index 0000000..d4069f2
--- /dev/null
+++ b/examples/bld/.idea/libraries/runtime.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/libraries/test.xml b/examples/bld/.idea/libraries/test.xml
new file mode 100644
index 0000000..57ed5ef
--- /dev/null
+++ b/examples/bld/.idea/libraries/test.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/misc.xml b/examples/bld/.idea/misc.xml
new file mode 100644
index 0000000..f522a9e
--- /dev/null
+++ b/examples/bld/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/examples/bld/.idea/modules.xml b/examples/bld/.idea/modules.xml
new file mode 100644
index 0000000..55adcb9
--- /dev/null
+++ b/examples/bld/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/runConfigurations/Run Tests.xml b/examples/bld/.idea/runConfigurations/Run Tests.xml
new file mode 100644
index 0000000..e5f873f
--- /dev/null
+++ b/examples/bld/.idea/runConfigurations/Run Tests.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.idea/vcs.xml b/examples/bld/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/examples/bld/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/bld/.vscode/launch.json b/examples/bld/.vscode/launch.json
new file mode 100644
index 0000000..b183bbe
--- /dev/null
+++ b/examples/bld/.vscode/launch.json
@@ -0,0 +1,11 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "java",
+ "name": "Run Tests",
+ "request": "launch",
+ "mainClass": "net.thauvin.erik.pinboard.samples.JavaExampleTest"
+ }
+ ]
+}
diff --git a/examples/bld/.vscode/settings.json b/examples/bld/.vscode/settings.json
new file mode 100644
index 0000000..ba429d0
--- /dev/null
+++ b/examples/bld/.vscode/settings.json
@@ -0,0 +1,15 @@
+{
+ "java.project.sourcePaths": [
+ "src/main/java",
+ "src/main/resources",
+ "src/test/java",
+ "src/test/resources",
+ "src/bld/java",
+ "src/bld/resources"
+ ],
+ "java.configuration.updateBuildConfiguration": "automatic",
+ "java.project.referencedLibraries": [
+ "${HOME}/.bld/dist/bld-2.2.1.jar",
+ "lib/**/*.jar"
+ ]
+}
diff --git a/examples/bld/README.md b/examples/bld/README.md
new file mode 100644
index 0000000..ad5401c
--- /dev/null
+++ b/examples/bld/README.md
@@ -0,0 +1,18 @@
+## Kotlin Example
+To compile & run the Kotlin example:
+
+```console
+./bld compile
+
+./bld run
+```
+
+## Java Example
+
+To compile & run the Java example:
+
+```console
+./bld compile
+
+./bld run-java
+```
diff --git a/examples/bld/bld b/examples/bld/bld
new file mode 100755
index 0000000..1a39c97
--- /dev/null
+++ b/examples/bld/bld
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.pinboard.samples.ExampleBuild "$@"
diff --git a/examples/bld/bld.bat b/examples/bld/bld.bat
new file mode 100644
index 0000000..6357553
--- /dev/null
+++ b/examples/bld/bld.bat
@@ -0,0 +1,4 @@
+@echo off
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.pinboard.samples.ExampleBuild %*
diff --git a/examples/bld/lib/bld/bld-wrapper.jar b/examples/bld/lib/bld/bld-wrapper.jar
new file mode 100644
index 0000000..968a8ab
Binary files /dev/null and b/examples/bld/lib/bld/bld-wrapper.jar differ
diff --git a/examples/bld/lib/bld/bld-wrapper.properties b/examples/bld/lib/bld/bld-wrapper.properties
new file mode 100644
index 0000000..1f1009d
--- /dev/null
+++ b/examples/bld/lib/bld/bld-wrapper.properties
@@ -0,0 +1,7 @@
+bld.downloadExtensionJavadoc=false
+bld.downloadExtensionSources=true
+bld.downloadLocation=
+bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
+bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
+bld.sourceDirectories=
+bld.version=2.2.1
diff --git a/examples/bld/src/bld/java/net/thauvin/erik/pinboard/samples/ExampleBuild.java b/examples/bld/src/bld/java/net/thauvin/erik/pinboard/samples/ExampleBuild.java
new file mode 100644
index 0000000..6fc8142
--- /dev/null
+++ b/examples/bld/src/bld/java/net/thauvin/erik/pinboard/samples/ExampleBuild.java
@@ -0,0 +1,54 @@
+package net.thauvin.erik.pinboard.samples;
+
+import rife.bld.BaseProject;
+import rife.bld.BuildCommand;
+import rife.bld.extension.CompileKotlinOperation;
+import rife.bld.extension.kotlin.CompileOptions;
+import rife.bld.operations.RunOperation;
+
+import java.util.List;
+
+import static rife.bld.dependencies.Repository.*;
+import static rife.bld.dependencies.Scope.compile;
+
+public class ExampleBuild extends BaseProject {
+ public ExampleBuild() {
+ pkg = "net.thauvin.erik.pinboard.samples";
+ name = "Example";
+ version = version(0, 1, 0);
+
+ mainClass = pkg + ".KotlinExampleKt";
+
+ javaRelease = 11;
+ downloadSources = true;
+ autoDownloadPurge = true;
+
+ repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
+
+ scope(compile)
+ .include(dependency("net.thauvin.erik", "pinboard-poster", version(1, 2, 1, "SNAPSHOT")));
+ }
+
+ public static void main(String[] args) {
+ new ExampleBuild().start(args);
+ }
+
+ @Override
+ public void compile() throws Exception {
+ new CompileKotlinOperation()
+ .fromProject(this)
+ .compileOptions(new CompileOptions().verbose(true))
+ .execute();
+
+ // Also compile the Java source code
+ super.compile();
+ }
+
+ @BuildCommand(value = "run-java", summary = "Runs the Java example")
+ public void runJava() throws Exception {
+ new RunOperation()
+ .fromProject(this)
+ .mainClass(pkg + ".JavaExample")
+ .execute();
+ }
+}
diff --git a/examples/bld/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java b/examples/bld/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java
new file mode 100644
index 0000000..1ef224b
--- /dev/null
+++ b/examples/bld/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java
@@ -0,0 +1,47 @@
+package net.thauvin.erik.pinboard.samples;
+
+import net.thauvin.erik.pinboard.PinConfig;
+import net.thauvin.erik.pinboard.PinboardPoster;
+
+import java.nio.file.Paths;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class JavaExample {
+ public static void main(String[] args) {
+ final String url = "https://example.com/pinboard";
+ final PinboardPoster poster;
+
+ if (args.length == 1) {
+ // API Token is an argument
+ poster = new PinboardPoster(args[0]);
+ } else {
+ // API Token is in local.properties or PINBOARD_API_TOKEN environment variable
+ poster = new PinboardPoster(Paths.get("local.properties"));
+ }
+
+ // Set logging levels
+ final ConsoleHandler consoleHandler = new ConsoleHandler();
+ consoleHandler.setLevel(Level.FINE);
+ final Logger logger = poster.getLogger();
+ logger.addHandler(consoleHandler);
+ logger.setLevel(Level.FINE);
+ logger.setUseParentHandlers(false);
+
+ if (poster.validate()) {
+ // Add Pin
+ if (poster.addPin(new PinConfig.Builder(url, "Testing")
+ .extended("Extra")
+ .tags("test", "java")
+ .build())) {
+ System.out.println("Added: " + url);
+ }
+
+ // Delete Pin
+ if (poster.deletePin(url)) {
+ System.out.println("Deleted: " + url);
+ }
+ }
+ }
+}
diff --git a/examples/bld/src/main/kotlin/net/thauvin/erik/pinboard/samples/KotlinExample.kt b/examples/bld/src/main/kotlin/net/thauvin/erik/pinboard/samples/KotlinExample.kt
new file mode 100644
index 0000000..1b48e82
--- /dev/null
+++ b/examples/bld/src/main/kotlin/net/thauvin/erik/pinboard/samples/KotlinExample.kt
@@ -0,0 +1,37 @@
+package net.thauvin.erik.pinboard.samples
+
+import net.thauvin.erik.pinboard.PinboardPoster
+import java.nio.file.Paths
+import java.util.logging.ConsoleHandler
+import java.util.logging.Level
+
+fun main(args: Array) {
+ val url = "https://example.com/pinboard"
+
+ val poster = if (args.size == 1) {
+ // API Token is an argument
+ PinboardPoster(args[0])
+ } else {
+ // API Token is in local.properties or PINBOARD_API_TOKEN environment variable
+ PinboardPoster(Paths.get("local.properties"))
+ }
+
+ // Set logging levels
+ with(poster.logger) {
+ addHandler(ConsoleHandler().apply { level = Level.FINE })
+ level = Level.FINE
+ useParentHandlers = false
+ }
+
+ if (poster.validate()) {
+ // Add Pin
+ if (poster.addPin(url, "Testing", "Extended test", tags = arrayOf("test", "kotlin"))) {
+ println("Added: $url")
+ }
+
+ // Delete Pin
+ if (poster.deletePin(url)) {
+ println("Deleted: $url")
+ }
+ }
+}
diff --git a/examples/gradle/java/.editorconfig b/examples/gradle/java/.editorconfig
new file mode 100644
index 0000000..a6971e1
--- /dev/null
+++ b/examples/gradle/java/.editorconfig
@@ -0,0 +1,2 @@
+[*]
+insert_final_newline=true
diff --git a/examples/gradle/java/.gitignore b/examples/gradle/java/.gitignore
new file mode 100644
index 0000000..6322c7f
--- /dev/null
+++ b/examples/gradle/java/.gitignore
@@ -0,0 +1,29 @@
+**/.idea/dictionaries
+**/.idea/gradle.xml
+**/.idea/libraries
+**/.idea/tasks.xml
+**/.idea/workspace.xml
+*.sublime-*
+*.iws
+.classpath
+.DS_Store
+.gradle
+.kobalt
+.nb-gradle
+.project
+.settings
+/bin
+/build
+/deploy
+/dist
+/gen
+/gradle.properties
+/local.properties
+/out
+/proguard-project.txt
+/project.properties
+/target
+/test-output
+ehthumbs.db
+kobaltBuild
+Thumbs.db
\ No newline at end of file
diff --git a/examples/gradle/java/.idea/.gitignore b/examples/gradle/java/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/examples/gradle/java/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/examples/gradle/java/.idea/.name b/examples/gradle/java/.idea/.name
new file mode 100644
index 0000000..4f5dba1
--- /dev/null
+++ b/examples/gradle/java/.idea/.name
@@ -0,0 +1 @@
+pinboard-poster-examples-gradle-java
\ No newline at end of file
diff --git a/examples/gradle/java/.idea/compiler.xml b/examples/gradle/java/.idea/compiler.xml
new file mode 100644
index 0000000..fb7f4a8
--- /dev/null
+++ b/examples/gradle/java/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/gradle/java/.idea/inspectionProfiles/Project_Default.xml b/examples/gradle/java/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..1e01b48
--- /dev/null
+++ b/examples/gradle/java/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/gradle/java/.idea/jarRepositories.xml b/examples/gradle/java/.idea/jarRepositories.xml
new file mode 100644
index 0000000..a529ef2
--- /dev/null
+++ b/examples/gradle/java/.idea/jarRepositories.xml
@@ -0,0 +1,25 @@
+
+
+
+
+