Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
j4ckofalltrades committed Aug 6, 2023
0 parents commit 7697056
Show file tree
Hide file tree
Showing 42 changed files with 3,408 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
.idea/**
/src/DistributionTool
dev.jduabe.obsideck
.vscode/**
package.json
.history
__exclude
.editorconfig
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/dev.jduabe.obsideck.sdPlugin/libs"]
path = src/dev.jduabe.obsideck.sdPlugin/libs
url = https://github.com/elgatosf/streamdeck-javascript-sdk
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Jordan Duabe @j4ckofalltrades <me@jduabe.dev>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<div align="center">
<br/>
<a href="https://github.com/j4ckofalltrades/obsideck">
<img height="128" src="src/dev.jduabe.obsideck.sdPlugin/assets/plugin.png" alt="Logo">
</a>
</div>

<br/>

# Obsideck

A Stream Deck plugin that runs commands in Obsidian (via the Local Rest API plugin).

## Getting Started

1. Install the [Local REST API plugin](https://github.com/coddingtonbear/obsidian-local-rest-api) for Obsidian.
2. Download and install this Stream Deck plugin from the [Release](./Release) directory.

## Configuration

![](src/dev.jduabe.obsideck.sdPlugin/previews/1-preview.png)

The `Run Command` action has the following __required__ properties:

- URL
- API Key
- Command ID

The `URL` and `API Key` properties can be found in the plugins' settings in Obsidian.

The list of available commands can be obtained by calling the `/commands` endpoint or through the plugin's [docs](https://coddingtonbear.github.io/obsidian-local-rest-api).

Note: The API plugin uses HTTPS by default.

```bash
curl -X 'GET' \
'http://127.0.0.1:27123/commands/' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer api_key'

# Sample response
{
"commands": [
{
"id": "app:open-help",
"name": "Open Help"
}
]
}
```
Binary file added Release/dev.jduabe.obsideck.streamDeckPlugin
Binary file not shown.
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>

<head>
<title>dev.jduabe.obsideck</title>
<meta charset="utf-8" />
<style>
canvas {
background-color: transparent;
}
</style>
</head>

<body>
<!-- Stream Deck Libs -->
<script src="libs/js/constants.js"></script>
<script src="libs/js/prototypes.js"></script>
<script src="libs/js/timers.js"></script>
<script src="libs/js/utils.js"></script>
<script src="libs/js/events.js"></script>
<script src="libs/js/api.js"></script>
<script src="libs/js/stream-deck.js"></script>
<script src="libs/js/action.js"></script>

<!-- Plugin Source -->
<script src="app.js"></script>
</body>

</html>
35 changes: 35 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// <reference path="libs/js/action.js" />
/// <reference path="libs/js/stream-deck.js" />

var settings = {};
var runCommandAction = new Action("dev.jduabe.obsideck.runcommand");

runCommandAction.onWillAppear((event) => {
$SD.getSettings(event.context);
});

runCommandAction.onDidReceiveSettings(({ payload }) => {
settings = payload.settings;
});

runCommandAction.onKeyUp(({ context }) => {
const apiKey = settings.apiKey;
const commandId = settings.commandId;
const url = settings.url;

fetch(`${url}/commands/${encodeURIComponent(commandId)}/`, {
method: "POST",
headers: {
"Accept": "*/*",
"Authorization": "Bearer " + apiKey,
}
})
.then(response => {
if (response.ok) {
$SD.showOk(context);
} else {
$SD.showAlert(context);
}
})
.catch(err => $SD.showAlert(context));
});
Binary file added src/dev.jduabe.obsideck.sdPlugin/assets/action.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dev.jduabe.obsideck.sdPlugin/assets/category.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dev.jduabe.obsideck.sdPlugin/assets/key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/inspector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<meta name="viewport"
content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,minimal-ui,viewport-fit=cover" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>dev.jduabe.obsideck Property Inspector</title>
<link rel="stylesheet" href="libs/css/sdpi.css" />
</head>

<body>
<form id="property-inspector">
<div class="sdpi-wrapper" id="mainWrapper">
<div class="sdpi-item">
<div class="sdpi-item-label">URL</div>
<input class="sdpi-item-value" id="url" name="url" required value="" type="text"
placeholder="fully qualified url e.g. http://127.0.0.1:27123" />
</div>

<div class="sdpi-item">
<div class="sdpi-item-label">API Key</div>
<input class="sdpi-item-value" id="apiKey" name="apiKey" required value="" type="password" />
</div>

<div class="sdpi-item">
<div class="sdpi-item-label">Command ID</div>
<input class="sdpi-item-value" id="commandId" name="commandId" required value="" type="text" />
</div>
</div>
</form>

<!-- Stream Deck Libs -->
<script src="libs/js/constants.js"></script>
<script src="libs/js/prototypes.js"></script>
<script src="libs/js/timers.js"></script>
<script src="libs/js/utils.js"></script>
<script src="libs/js/events.js"></script>
<script src="libs/js/api.js"></script>
<script src="libs/js/property-inspector.js"></script>
<script src="libs/js/dynamic-styles.js"></script>

<!-- Property Inspector Source -->
<script src="inspector.js"></script>
</body>

</html>
17 changes: 17 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/inspector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// <reference path="libs/js/property-inspector.js" />
/// <reference path="libs/js/utils.js" />

$PI.onConnected((jsn) => {
const form = document.querySelector('#property-inspector');
const { actionInfo: { payload: { settings } } } = jsn;

Utils.setFormValue(settings, form);

form.addEventListener(
'input',
Utils.debounce(150, () => {
const value = Utils.getFormValue(form);
$PI.setSettings(value);
})
);
});
1 change: 1 addition & 0 deletions src/dev.jduabe.obsideck.sdPlugin/libs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.history
5 changes: 5 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/libs/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"useTabs": true,
"singleQuote": true,
"printWidth": 100
}
4 changes: 4 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/libs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# streamdeck-javascript-sdk

A library for plugins used for connecting to Stream Deck. This does not require a build step and declares variables in
the global scope directly in the class files.
3 changes: 3 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/libs/assets/caret.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/libs/assets/caret_closed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/libs/assets/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/libs/assets/elg_calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/libs/assets/rcheck.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/dev.jduabe.obsideck.sdPlugin/libs/assets/tick.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7697056

Please sign in to comment.