Compare commits

..

No commits in common. "master" and "v0.0.2" have entirely different histories.

5 changed files with 113 additions and 86 deletions

21
LICENSE
View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2023 Erica Xu
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.

View file

@ -1,45 +1,96 @@
# Gemmy - Obsidian Unhelper
# Obsidian Sample Plugin
<img src="https://user-images.githubusercontent.com/1171143/229297707-5efa8761-ef55-4d01-a105-88a347bc6cf0.png" width="300">
This is a sample plugin for Obsidian (https://obsidian.md).
Not sure if an AI assistant is going to be helpful in your workflow?
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.
Don't worry, we've eliminated the guesswork for you because Gemmy is 100% going to be unhelpful.
**Note:** The Obsidian API is still in early alpha and is subject to change at any time!
Introducing Obsidian's first assistant — Gemmy, the Obsidian Unhelper. It has two major features:
This sample plugin demonstrates some of the basic functionality the plugin API can do.
- Changes the default font color to red using `styles.css`.
- Adds a ribbon icon, which shows a Notice when clicked.
- Adds a command "Open Sample Modal" which opens a Modal.
- Adds a plugin setting tab to the settings page.
- Registers a global click event and output 'click' to the console.
- Registers a global interval which logs 'setInterval' to the console.
## Randomly saying things
## First time developing plugins?
Gemmy seeks validation by randomly saying things every now and then.
Quick starting guide for new plugin devs:
You can customize how often this happens. Or just don't summon Gemmy.
- Check if [someone already developed a plugin for what you want](https://obsidian.md/plugins)! There might be an existing plugin similar enough that you can partner up with.
- Make a copy of this repo as a template with the "Use this template" button (login to GitHub if you don't see it).
- Clone your repo to a local development folder. For convenience, you can place this folder in your `.obsidian/plugins/your-plugin-name` folder.
- Install NodeJS, then run `npm i` in the command line under your repo folder.
- Run `npm run dev` to compile your plugin from `main.ts` to `main.js`.
- Make changes to `main.ts` (or create new `.ts` files). Those changes should be automatically compiled into `main.js`.
- Reload Obsidian to load the new version of your plugin.
- Enable plugin in settings window.
- For updates to the Obsidian API run `npm update` in the command line under your repo folder.
## Writing mode
## Releasing new releases
Gemmy pops out to [motivate you](https://user-images.githubusercontent.com/1171143/229297494-8a0cae3f-4c8e-47a9-801b-dd1c52dfc917.png) when you have stopped typing for long enough. Again, you can customize how long that should be.
- Update your `manifest.json` with your new version number, such as `1.0.1`, and the minimum Obsidian version required for your latest release.
- Update your `versions.json` file with `"new-plugin-version": "minimum-obsidian-version"` so older versions of Obsidian can download an older version of your plugin that's compatible.
- 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. Note: The manifest.json file must be in two places, first the root path of your repository and also in the release.
- Publish the release.
Risk: Gemmy might actually be helpful with writing if you use this mode. We're not responsible for any extra productivity Gemmy might bring.
> You can simplify the version bump process by running `npm version patch`, `npm version minor` or `npm version major` after updating `minAppVersion` manually in `manifest.json`.
> The command will bump version in `manifest.json` and `package.json`, and add the entry for the new version to `versions.json`
## Adding your plugin to the community plugin list
- Check https://github.com/obsidianmd/obsidian-releases/blob/master/plugin-review.md
- 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
Install Gemmy. There are four commands in the command palette when you type "Gemmy". You can figure out the rest on your own.
- Clone this repo.
- `npm i` or `yarn` to install dependencies
- `npm run dev` to start compilation in watch mode.
---
## Manually installing the plugin
Special thanks: [Rigmarole](https://rigmarolestudio.com/) for creating and animating Gemmy
- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/your-plugin-id/`.
Credit: the talented Obsidian mods team, including argentum, CawlinTeffid, cotmax, Eleanor Konik, koala, Leah, rigmarole, ryanjamurphy & WhiteNoise
## Improve code quality with eslint (optional)
- [ESLint](https://eslint.org/) is a tool that analyzes your code to quickly find problems. You can run ESLint against your plugin to find common bugs and ways to improve your code.
- To use eslint with this project, make sure to install eslint from terminal:
- `npm install -g eslint`
- To use eslint to analyze this project use this command:
- `eslint main.ts`
- eslint will then create a report with suggestions for code improvement by file and line number.
- If your source code is in a folder, such as `src`, you can use eslint with this command to analyze all files in that folder:
- `eslint .\src\`
The code is under MIT license, whereas the Gemmy character is under CC BY 3.0 license.
## Funding URL
Obsidian logo is adapted from:
You can include funding URLs where people who use your plugin can financially support it.
[Crystal shard icon](https://icon-icons.com/icon/Crystal-Shard/88819)
By [Chanut is Industries](https://icon-icons.com/users/W52nHhY3W1VlvwyJTwS4d/icon-sets/)
License: Attribution 3.0 Unported (CC BY 3.0)
The simple way is to set the `fundingUrl` field to your link in your `manifest.json` file:
---
```json
{
"fundingUrl": "https://buymeacoffee.com"
}
```
## Happy April Fools'
If you have multiple URLs, you can also do:
Gemmy was proudly released on April 1, 2023.
```json
{
"fundingUrl": {
"Buy Me a Coffee": "https://buymeacoffee.com",
"GitHub Sponsor": "https://github.com/sponsors",
"Patreon": "https://www.patreon.com/"
}
}
```
## API Documentation
See https://github.com/obsidianmd/obsidian-api

68
main.ts
View file

@ -7,16 +7,18 @@ import LOOK_MOTION from './animations/gemmy_lookAround.gif'
import IDLE_MOTION from './animations/gemmy_idle.gif'
import DISAPPOINT_IMG from './animations/gemmy_disappoint.gif'
// Remember to rename these classes and interfaces!
interface GemmySettings {
// how often does Gemmy talk in idle mode, in minutes
idleTalkFrequency: number;
// the number of minutes you must write before Gemmy appears to mock you
writingModeGracePeriod: number;
writingModeDeadline: number;
}
const DEFAULT_SETTINGS: GemmySettings = {
idleTalkFrequency: 5,
writingModeGracePeriod: 5
writingModeDeadline: 5
};
@ -26,29 +28,27 @@ const GEMMY_IDLE_QUOTES = [
"You have plugins that you can update!",
"Hi I'm Gemmy! Like Clippy but shinier!",
"Everything is connected. Everything.",
"Cant decide which note to work on? Try the Random Note core plugin!",
"Are you sure you dont want to upload all your notes just so we can chat?",
"How tall would all your notes be if you stacked them up?",
"Wanna teach me to say things? Find me on GitHub and open a pull request!",
"Have you considered using Comic Sans?",
"A blank page is just a masterpiece in waiting"
`It looks like youre writing a note.,
Would you like help?
- Get help with writing the note
- Just type the note without help
- [ ] Dont show me this tip again`,
'Cant decide which note to work on? Try the Random Note core plugin!',
'Are you sure you dont want to upload all your notes just so we can chat?',
'How tall would all your notes be if you stacked them up?',
'Wanna teach me to say things? Find me on GitHub and open a pull request!',
'Have you considered using Comic Sans?'
];
const WRITING_MODE_QUOTES = [
"Is that the best you can do? Keep writing!",
"Write first, edit later.",
"I love hearing your keyboard. Don't stop.",
"How about we review some old notes today?",
"Stuck? Try journaling what happened today and see if that gives you inspiration.",
"Maybe it's time to go get some water or coffee.",
"Anything is better than a blank page, even me. Write something!",
"Oh, taking a break? Dont let the ideas get cold!",
"Whats this? Writers block already?",
"Youve got this! Every keystroke is a step closer to brilliance.",
"Youre doing amazing! Keep the momentum going.",
"Bold choice to open Obsidian and then do absolutely nothing.",
"Is this a journal or a staring contest with the cursor?",
"Hmm, I didnt realize staring at the screen was a new note-taking strategy."
`Is that the best you can do? Keep writing!`,
`Write first, editor later.`,
`I love hearing your keyboard. Don't stop.`,
`How about we review some old notes today?`,
`Stuck? Try journaling what happened today and see if that gives you inspiration.`,
`Maybe it's time to go get some water or coffee.`,
`Anything is better than a blank page, even me. Write something!`
];
const BUBBLE_DURATION = 5000;
@ -70,7 +70,7 @@ export default class Gemmy extends Plugin {
gemmyEl.setAttribute('aria-label-delay', '0');
gemmyEl.setAttribute('aria-label-classes', 'gemmy-tooltip');
this.imageEl = gemmyEl.createEl('img', {});
let gemmyImageEl = this.imageEl = gemmyEl.createEl('img', {});
this.addCommand({
id: 'show',
@ -136,8 +136,6 @@ export default class Gemmy extends Plugin {
this.disappear();
this.setWritingModeTimeout();
}, 500)));
app.workspace.onLayoutReady(this.appear.bind(this));
}
appear() {
@ -145,14 +143,18 @@ export default class Gemmy extends Plugin {
imageEl.setAttribute('src', EMERGE_MOTION);
// Quicker if we're in writing mode
// Quick if we're in writing mode
if (this.inWritingMode) {
imageEl.setAttribute('src', POP_MOTION);
setTimeout(() => {
// imageEl.setAttribute('src', DISAPPOINT_IMG);
// setTimeout(() => {
// imageEl.setAttribute('src', DISAPPOINT_IMG);
this.appeared = true;
this.saySomething(WRITING_MODE_QUOTES, true);
// }, 1000);
}, 1800);
}
else {
@ -183,6 +185,7 @@ export default class Gemmy extends Plugin {
}
enterWritingMode() {
let { gemmyEl } = this;
this.inWritingMode = true;
this.disappear();
@ -208,7 +211,7 @@ export default class Gemmy extends Plugin {
}
this.appear();
}, this.settings.writingModeGracePeriod * 1000);
}, this.settings.writingModeDeadline * 60000);
}
startNextIdleTimeout() {
@ -261,7 +264,7 @@ export default class Gemmy extends Plugin {
}
onunload() {
this.disappear();
}
async loadSettings() {
@ -273,6 +276,7 @@ export default class Gemmy extends Plugin {
}
}
// TODO: proper setting tab
class GemmySettingTab extends PluginSettingTab {
plugin: Gemmy;
@ -300,13 +304,13 @@ class GemmySettingTab extends PluginSettingTab {
new Setting(containerEl)
.setName('Writing mode grace period')
.setDesc('How soon Gemmy starts to get disappointed after you stop tying in writing mode, in seconds.')
.setDesc('How soon Gemmy starts to get disappointed after you stop tying in writing mode, in minutes.')
.addSlider(slider => slider
.setLimits(5, 180, 5)
.setLimits(5, 60, 5)
.setDynamicTooltip()
.setValue(this.plugin.settings.writingModeGracePeriod)
.setValue(this.plugin.settings.writingModeDeadline)
.onChange(async (value) => {
this.plugin.settings.writingModeGracePeriod = value;
this.plugin.settings.writingModeDeadline = value;
await this.plugin.saveSettings();
}));
}

View file

@ -1,7 +1,7 @@
{
"id": "gemmy",
"name": "Gemmy",
"version": "1.0.1",
"version": "0.0.2",
"minAppVersion": "0.15.0",
"description": "2023 April Fool's plugin brought to you by Obsidian",
"author": "Obsidian",

View file

@ -15,9 +15,6 @@ If your plugin does not need CSS, delete this file.
position: fixed;
bottom: 30px;
right: 30px;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.gemmy-container img {
@ -26,14 +23,10 @@ If your plugin does not need CSS, delete this file.
border-radius: var(--gemmy-size);
}
.gemmy-container[aria-label]::before {
.gemmy-tooltip {
--background-modifier-message: #FFFFCB;
content: attr(aria-label);
color: #202020;
font-size: var(--font-ui-medium);
border-radius: 20px;
padding: var(--size-4-3) var(--size-4-6);
width: 150px;
background: var(--background-modifier-message);
}
}