-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4450397
Showing
8 changed files
with
279 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Release Obsidian Plugin | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '14.x' | ||
- name: Get Version | ||
id: version | ||
run: | | ||
echo "::set-output name=tag::$(git describe --abbrev=0)" | ||
# Build the plugin | ||
- name: Build | ||
id: build | ||
run: | | ||
npm install | ||
npm run build --if-present | ||
# Package the required files into a zip | ||
- name: Package | ||
run: | | ||
mkdir ${{ github.event.repository.name }} | ||
cp main.js manifest.json README.md ${{ github.event.repository.name }} | ||
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }} | ||
# Create the release on github | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
VERSION: ${{ github.ref }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
# Upload the packaged release file | ||
- name: Upload zip file | ||
id: upload-zip | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./${{ github.event.repository.name }}.zip | ||
asset_name: ${{ github.event.repository.name }}-${{ steps.version.outputs.tag }}.zip | ||
asset_content_type: application/zip | ||
# Upload the main.js | ||
- name: Upload main.js | ||
id: upload-main | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./main.js | ||
asset_name: main.js | ||
asset_content_type: text/javascript | ||
# Upload the manifest.json | ||
- name: Upload manifest.json | ||
id: upload-manifest | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./manifest.json | ||
asset_name: manifest.json | ||
asset_content_type: application/json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Intellij | ||
*.iml | ||
.idea | ||
|
||
# npm | ||
node_modules | ||
package-lock.json | ||
|
||
# build | ||
main.js | ||
*.js.map | ||
data.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Hotkeys for specific files | ||
|
||
Plugin for [Obsidian](https://obsidian.md) | ||
|
||
## How to use | ||
With this plugin, you can open specific files with a hotkey. You can set the files in the settings. A command will be generated for each file, then you can set your hotkey in the default hotkeys section in Obsidian. Already added commands will disappear after a reload of Obsidian. | ||
|
||
## Compatibility | ||
Custom plugins are only available for Obsidian v0.9.7+. | ||
|
||
## Installing | ||
|
||
### From Obsidian | ||
1. Open settings -> Third party plugin | ||
2. Disable Safe mode | ||
3. Click Browse community plugins | ||
4. Search for "Hotkeys for specific files" | ||
5. Install it | ||
6. Activate it under Installed plugins | ||
|
||
|
||
### From GitHub | ||
1. Download the [latest release](https://github.com/Vinzent03/obsidian-hotkeys-for-specific-files/releases/latest) | ||
2. Move `manifest.json` and `main.js` to `<vault>/.obsidian/plugins/obsidian-hotkeys-for-specific-files` | ||
3. Reload Obsidian (Str + r) | ||
4. Go to settings and disable safe mode | ||
5. Enable `Hotkeys for specific files` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { App, Plugin, PluginSettingTab, Setting } from 'obsidian'; | ||
interface MyPluginSettings { | ||
files: string[]; | ||
} | ||
|
||
const DEFAULT_SETTINGS: MyPluginSettings = { | ||
files: [] | ||
}; | ||
export default class MyPlugin extends Plugin { | ||
settings: MyPluginSettings; | ||
async onload() { | ||
await this.loadSettings(); | ||
console.log('loading ' + this.manifest.name); | ||
this.addSettingTab(new SettingsTab(this.app, this)); | ||
this.setCommands(this); | ||
|
||
} | ||
onunload() { | ||
console.log('unloading ' + this.manifest.name); | ||
} | ||
|
||
async loadSettings() { | ||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); | ||
} | ||
|
||
async saveSettings() { | ||
await this.saveData(this.settings); | ||
} | ||
setCommands(app: MyPlugin) { | ||
for (const fileName of this.settings.files) { | ||
app.addCommand({ | ||
id: fileName, | ||
name: `Open ${fileName.substring(0, fileName.lastIndexOf("."))}`, | ||
callback: () => app.app.workspace.openLinkText(fileName, "") | ||
}); | ||
} | ||
} | ||
} | ||
|
||
class SettingsTab extends PluginSettingTab { | ||
plugin: MyPlugin; | ||
constructor(app: App, plugin: MyPlugin) { | ||
super(app, plugin); | ||
this.plugin = plugin; | ||
} | ||
|
||
display(): void { | ||
// remove empty entries | ||
this.plugin.settings.files = this.plugin.settings.files.filter(file => file != null && file != ""); | ||
this.plugin.saveSettings(); | ||
|
||
let { containerEl } = this; | ||
containerEl.empty(); | ||
containerEl.createEl("h2", { text: this.plugin.manifest.name }); | ||
let index = 0; | ||
new Setting(containerEl) | ||
.setName("Add new commands (required after changes)") | ||
.setDesc("To remove already added commands, you have to reload Obsidian (or disable and enable this plugin) ") | ||
.addButton(cb => cb.setButtonText("Add").onClick(() => { | ||
this.plugin.setCommands(this.plugin); | ||
}).setClass("mod-cta")); | ||
new Setting(containerEl) | ||
.setName("Create new text field") | ||
.addButton(cb => cb.setButtonText("Create").onClick(() => { | ||
this.addTextField(index); | ||
index++; | ||
}).setClass("mod-cta")); | ||
for (let i = 0; i <= this.plugin.settings.files.length; i++) { | ||
this.addTextField(index, this.plugin.settings.files[index]); | ||
index++; | ||
} | ||
} | ||
addTextField(index: number, text: string = "") { | ||
new Setting(this.containerEl) | ||
.setName("File to open with command") | ||
.setDesc("With file extension!") | ||
.addText(cb => cb | ||
.setPlaceholder("Directory/file.md") | ||
.setValue(this.plugin.settings.files[index]) | ||
.setValue(text) | ||
.onChange((value) => { | ||
this.plugin.settings.files[index] = value; | ||
this.plugin.saveSettings(); | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"id": "obsidian-hotkeys-for-specific-files", | ||
"name": "Hotkeys for specific files", | ||
"version": "0.0.1", | ||
"description": "Set hotkeys for specific files and open them just with your keyboard.", | ||
"author": "Vinzent", | ||
"authorUrl": "https://github.com/Vinzent03", | ||
"isDesktopOnly": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "my-plugin", | ||
"version": "0.9.7", | ||
"description": "This is a sample plugin for Obsidian (https://obsidian.md)", | ||
"main": "main.js", | ||
"scripts": { | ||
"dev": "rollup --config rollup.config.js -w", | ||
"build": "rollup --config rollup.config.js" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"@rollup/plugin-typescript": "^6.0.0", | ||
"@types/node": "^14.14.2", | ||
"@types/pdfjs-dist": "^2.1.6", | ||
"obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master", | ||
"rollup": "^2.32.1", | ||
"tslib": "^2.0.3", | ||
"typescript": "^4.0.3" | ||
}, | ||
"dependencies": { | ||
"pdfjs-dist": "^2.5.207" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import typescript from '@rollup/plugin-typescript'; | ||
import {nodeResolve} from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
|
||
export default { | ||
input: 'main.ts', | ||
output: { | ||
dir: '.', | ||
sourcemap: 'inline', | ||
format: 'cjs', | ||
exports: 'default' | ||
}, | ||
external: ['obsidian'], | ||
plugins: [ | ||
typescript(), | ||
nodeResolve({browser: true}), | ||
commonjs(), | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"inlineSourceMap": true, | ||
"inlineSources": true, | ||
"module": "ESNext", | ||
"target": "es5", | ||
"allowJs": true, | ||
"noImplicitAny": true, | ||
"moduleResolution": "node", | ||
"importHelpers": true, | ||
"lib": [ | ||
"dom", | ||
"es5", | ||
"scripthost", | ||
"es2015" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts" | ||
] | ||
} |