Skip to content

Commit

Permalink
v0.1.0: first version
Browse files Browse the repository at this point in the history
  • Loading branch information
Floran Hachez committed Nov 7, 2020
1 parent da3acc4 commit 59fc39b
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 515 deletions.
34 changes: 9 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
## Obsidian Sample Plugin
# Obsidian Plugin: Convert an url (ex, youtube) into an iframe (preview)
**Transform an youtube url into a youtube preview.**

This is a sample plugin for Obsidian (https://obsidian.md).
Transform a selected url to an embed view if the website allows it. It offers the possibilitiy to resize the preview.

This project uses Typescript to provide type checking and documentation.
The repo depends on the latest plugin API (obsidian.d.ts) in Typescript Definition format, which contains TSDoc comments describing what it does.

**Note:** The Obsidian API is still in early alpha and is subject to change at any time!

### Releasing new releases

- Update your `manifest.json` with your new version number, such as `1.0.1`.
- Create new GitHub release using your new version number as the "Tag version". Use the exact version number, don't include a prefix `v`. See here for an example: https://github.com/obsidianmd/obsidian-sample-plugin/releases
- Upload the files `manifest.json`, `main.js`, `styles.css` as binary attachments.
- Publish the release.

### Adding your plugin to the community plugin list

- Publish an initial version.
- Make sure you have a `README.md` file in the root of your repo.
- Make a pull request at https://github.com/obsidianmd/obsidian-releases to add your plugin.

### How to use

- Clone this repo.
- `npm i` or `yarn` to install dependencies
- `npm run dev` to start compilation in watch mode.
The default hotkey is `cmd + shift + i`.

### Manually installing the plugin

- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/your-plugin-id/`.

# Installation
Support for 3rd party plugins is enabled in settings (Obsidian > Settings > Third Party plugin > Safe mode - OFF)
To install this plugin, download zip archive from GitHub releases page. Extract the archive into <vault>/.obsidian/plugins.


### API Documentation

See https://github.com/obsidianmd/obsidian-api
17 changes: 15 additions & 2 deletions __tests__/iframe_converter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import { testSameOrigin, updateUrlIfYoutube } from '../iframe_converter';
import { isUrl, updateUrlIfYoutube } from '../iframe_converter';

describe('updateUrlIfYoutube', () => {
const inputToExpectedOutput = [
["https://github.com/", "https://github.com/"],
["https://www.youtube.com/watch?v=FY7DtKMBxBw", "https://www.youtube.com/embed/FY7DtKMBxBw"],
["https://www.youtube.com/watch?v=FY7D_KM-xBw", "https://www.youtube.com/embed/FY7D_KM-xBw"],
["https://www.youtube.com/embed/FY7DtKMBxBw", "https://www.youtube.com/embed/FY7DtKMBxBw"],
]
it.each(inputToExpectedOutput)('should correctly parse "%s"', (input: string, expected) => {

const output = updateUrlIfYoutube(input);

expect(output).toStrictEqual(expected)
})
})

describe('isUrl', () => {
const inputToExpectedOutput = [
["Quotes at vault/test.md", false],
["https://github.com/", true],
["https://www.youtube.com/watch?v=FY7DtKMBxBw", true],
]
it.each(inputToExpectedOutput)('should correctly parse "%s"', (input: string, expected) => {
const output = isUrl(input);

expect(output).toStrictEqual(expected)
})
})
219 changes: 0 additions & 219 deletions __tests__/regex.spec.ts

This file was deleted.

Loading

0 comments on commit 59fc39b

Please sign in to comment.