Skip to content

Commit

Permalink
address comments from Obsidian review
Browse files Browse the repository at this point in the history
  • Loading branch information
encima committed Jul 20, 2023
1 parent 299334f commit a0c6141
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@

An Obsidian plugin to publish posts to https://write.as.

## Disclosure

1. This plugin publishes content using the Internet
2. This plugin requires an account with https://write.as

## How?

1. Set your username and password in the plugin settings
2. Add `writeas_collection` into your frontmatter, set it to a collection/blog
that you own
that you own (this **must** be set)
3. Run `Publish/update to writeas` (or use alt+shift+p)
4. The plugin will add the ID and the post URL to your frontmatter. Subsequent publish commands will then update the same post.

## API Documentation

See https://developers.write.as/docs/api/#retrieve-a-post
See https://developers.write.as/docs
20 changes: 3 additions & 17 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class WriteasPlugin extends Plugin {

async handleFile(file: TFile) {
let c = new WriteasClient(this.settings.writeasUser, this.settings.writeasPassword);
this.app.vault.read(file).then(async lines => {
this.app.vault.cachedRead(file).then(async lines => {
var content = this.app.metadataCache.getFileCache(file);
if (content?.frontmatter && content.frontmatter[COLL_KEY]) {
let coll = content.frontmatter[COLL_KEY]
Expand All @@ -71,12 +71,14 @@ export default class WriteasPlugin extends Plugin {
res = await c.updatePost(post_body, id)
if (res === undefined) {
new Notice("Failed to update post. Does it exist?")
return;
}
c.getPost(id);
} else {
res = await c.publishPost(post_body, content.frontmatter[COLL_KEY])
if (res === undefined) {
new Notice("Failed to publish, does the collection exist?")
return;
}
const keys: Record<string, string> = { 'writeas_url': res['url'].replace('http', 'https'), '_writeas_id': res['id'] }
this.updateFrontmatter(file, keys)
Expand All @@ -101,22 +103,6 @@ export default class WriteasPlugin extends Plugin {
}
}

class SampleModal extends Modal {
constructor(app: App) {
super(app);
}

onOpen() {
const { contentEl } = this;
contentEl.setText('Woah!');
}

onClose() {
const { contentEl } = this;
contentEl.empty();
}
}

class SettingTab extends PluginSettingTab {
plugin: WriteasPlugin;

Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "writeas-publisher",
"version": "1.0.1",
"name": "Writeas Blog Publisher",
"version": "1.0.0",
"minAppVersion": "0.15.0",
"description": "This is a plugin for Obsidian to publish a note to a collection on write.as. Set your username and password in settings. Set `writeas_collection` as your alias in your frontmatter and publish!",
"author": "encima",
"authorUrl": "https://github.com/encima/obsidian-writeas-plugin",
"isDesktopOnly": false
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "writeas-publisher",
"version": "1.0.0",
"version": "1.0.1",
"description": "This is a plugin for Obsidian to publish to a collection on write.as. Set your username and password in settings. Set `writeas_collection` as your alias in your frontmatter and publish!",
"main": "main.js",
"scripts": {
Expand All @@ -22,4 +22,4 @@
"typescript": "4.7.4"
},
"dependencies": {}
}
}
4 changes: 3 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"1.0.0": "0.15.0"
"1.0.0": "0.15.0",
"1.0.1": "0.15.0",
"undefined": "0.15.0"
}

0 comments on commit a0c6141

Please sign in to comment.