Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release Obsidian plugin

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Build plugin
run: |
npm install
npm run build

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"

gh release create "$tag" \
--title="$tag" \
--draft \
main.js manifest.json styles.css
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) [year] [fullname]
Copyright (c) 2025 Owain Williams

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="assets/UmbracidianLogo.png" alt="Document Type" width="100px"></img>
# Umbracidian - a plugin for Obsidian
<img src="assets/umbPublisher-Logo.png" alt="Document Type" width="100px"></img>
# umbPublisher - an Obsidian plugin.

This plugin allows you to push your [Obsidian](https://obsidian.md/) notes to [Umbraco 15+](https://umbraco.com) as a blog post.
This plugin allows you to push your [Obsidian](https://obsidian.md/) notes to [Umbraco 15+](https://umbraco.com) as a content item.

To see how to use this plugin with Obsidian, check out the [Wiki pages](https://github.com/OwainWilliams/Umbracidian/wiki)
To see how to use this plugin with Obsidian, check out the [Wiki pages](https://github.com/OwainWilliams/umbpublisher/wiki)
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion getLatest.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$Repo = "OwainWilliams/Umbracidian" # Replace with your actual repository name
$Repo = "OwainWilliams/umbpublisher" # Replace with your actual repository name
$ManifestFile = "manifest.json"
$JSFile = "main.js"

Expand Down
6 changes: 3 additions & 3 deletions icons/icons.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { addIcon } from "obsidian";

import umbracoLogo from "./img/umbracidian-logo.svg";
import umbPublisherLogo from "./img/umbpublisher-logo.svg";

export class UmbracidianIcons {
private icons = [{ iconId: "umbracidian-logo", svg: umbracoLogo }];
export class umbpublisherIcons {
private icons = [{ iconId: "umbpublisher-logo", svg: umbPublisherLogo }];

registerIcons = () => {
this.icons.forEach(({ iconId, svg }) => {
Expand Down
File renamed without changes
55 changes: 33 additions & 22 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable @typescript-eslint/no-var-requires */

import { Editor, MarkdownView, Notice, Plugin, requestUrl } from 'obsidian';
import { DEFAULT_SETTINGS, UmbracidianSettings } from "./types/index";
import { DEFAULT_SETTINGS, umbpublisherSettings } from "./types/index";
import { SettingTab } from "./settings";
import { UmbracidianIcons } from "./icons/icons";
import { umbpublisherIcons } from "./icons/icons";
import { GetUmbracoDocType } from "./methods/getUmbracoDocType";
import { CallUmbracoApi } from "./methods/callUmbracoApi";
import { GenerateGuid } from 'methods/generateGuid';
const matter = require("gray-matter");



interface Frontmatter {
Expand All @@ -20,18 +20,18 @@ interface Frontmatter {
content: string;
}

export default class Umbracidian extends Plugin {
settings: UmbracidianSettings;
export default class umbpublisher extends Plugin {
settings: umbpublisherSettings;

private icons = new UmbracidianIcons();
private icons = new umbpublisherIcons();
private bearerToken: null | string = null; // Initialize bearerToken to null

async onload() {
await this.loadSettings();

this.icons.registerIcons();
// This creates an icon in the left ribbon.
this.addRibbonIcon('umbracidian-logo', 'Umbracidian', async (evt: MouseEvent) => {
this.addRibbonIcon('umbpublisher-logo', 'umbpublisher', async (evt: MouseEvent) => {
const view = this.app.workspace.getActiveViewOfType(MarkdownView);
if (!view) {
new Notice('No active Markdown view found.');
Expand All @@ -48,18 +48,24 @@ export default class Umbracidian extends Plugin {
// This adds an editor command that can perform some operation on the current editor instance
this.addCommand({
id: 'push-to-umbraco',
name: 'Push to Umbraco command',
editorCallback: async (editor: Editor) => {
const view = this.app.workspace.getActiveViewOfType(MarkdownView);
if (!view) {
name: 'Push to Umbraco',
editorCheckCallback: (checking: boolean, editor: Editor, view: MarkdownView) =>
{
if(checking) return true;

const value = this.app.workspace.getActiveViewOfType(MarkdownView);

if(!value){
new Notice('No active Markdown view found.');
return;
}
(async () => {
this.bearerToken = await this.getBearerToken();

const umbracoDocType = await GetUmbracoDocType(this.settings.blogDocTypeAlias, this.settings.websiteUrl, this.bearerToken);
await this.createObsidianNode(view, umbracoDocType, this.settings.websiteUrl);
})();
}

});

// This adds a settings tab so the user can configure various aspects of the plugin
Expand Down Expand Up @@ -105,18 +111,16 @@ export default class Umbracidian extends Plugin {
body: body.toString(),
});

// Check if the response contains valid JSON

if (response.json) {
const data = response.json as { access_token: string };
// console.log('Bearer token response:', data);
return data.access_token; // Assuming the token is in the "access_token" field

return data.access_token;
} else {
// console.error('Empty or invalid JSON response:', response);
new Notice('Failed to fetch bearer token.');
return null;
}
} catch (error) {
// console.error('Error fetching bearer token:', error);
new Notice(`Error fetching bearer token: ${error}`);
return null;
}
Expand All @@ -130,24 +134,31 @@ export default class Umbracidian extends Plugin {
return null;
}

const metaMatter = this.app.metadataCache.getFileCache(noteFile)?.frontmatter;
const pageContent = matter(view.getViewData());

const fileCache = this.app.metadataCache.getFileCache(noteFile);
const metaMatter = fileCache?.frontmatter;
const fileContent = await this.app.vault.read(noteFile);

let content = fileContent;
if (fileCache?.frontmatterPosition) {
const { start, end } = fileCache.frontmatterPosition;
const lines = fileContent.split('\n');
content = lines.slice(end.line + 1).join('\n');
}

const frontmatter = {
title: metaMatter?.title || view.file?.basename,
tags: metaMatter?.tags || [],
featured: metaMatter?.featured || false,
status: metaMatter?.published ? "published" : "draft",
excerpt: metaMatter?.excerpt || undefined,
feature_image: metaMatter?.feature_image || undefined,
content: pageContent.content,
content: content,
};
if (!frontmatter) {
new Notice('No frontmatter found.');
return null;
}
else {
// console.log('Meta matter:', frontmatter);
return frontmatter;
}

Expand Down
10 changes: 5 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "umbracidian",
"name": "Umbracidian",
"version": "1.0.0",
"minAppVersion": "1.8.10",
"description": "Push notes to Umbraco CMS as blog posts.",
"id": "umbpublisher",
"name": "umbPublisher",
"version": "1.1.0",
"minAppVersion": "1.9.12",
"description": "Push notes to Umbraco CMS as content.",
"author": "Owain Williams",
"authorUrl": "https://owain.codes",
"fundingUrl": "https://buymeacoffee.com/owaincodes",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "Umbracidian",
"version": "0.1.0",
"description": "Send Blog Posts to Umbraco CMS via Management API",
"name": "umbpublisher",
"version": "1.1.0",
"description": "Send Obsidian Notes to Umbraco CMS via Management API",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [],
"author": "",
"author": "Owain Williams",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.18.126",
Expand All @@ -32,10 +32,10 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/obsidianmd/obsidian-sample-plugin.git"
"url": "git+https://github.com/OwainWilliams/umbPublisher.git"
},
"bugs": {
"url": "https://github.com/obsidianmd/obsidian-sample-plugin/issues"
"url": "https://github.com/OwainWilliams/umbPublisher/issues"
},
"homepage": "https://github.com/obsidianmd/obsidian-sample-plugin#readme"
"homepage": "https://github.com/OwainWilliams/umbPublisher/"
}
Loading