Skip to content

Commit

Permalink
fix release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
jparkerweb committed Nov 1, 2024
1 parent df9957e commit 12163fd
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 85 deletions.
66 changes: 0 additions & 66 deletions SOW.md

This file was deleted.

Binary file modified example-vault.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
"borderRadius": 15,
"datesOpacity": 1,
"linksOpacity": 1,
"showReleaseNotes": true,
"excludedFolders": [
"exclude"
],
"showBacklinks": true,
"showOutlinks": true,
"showDates": true
"showDates": true,
"lastVersion": "1.4.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ var import_obsidian2 = require("obsidian");
// src/modals.js
var import_obsidian = require("obsidian");
var ReleaseNotesModal = class extends import_obsidian.Modal {
constructor(app, version, releaseNotes2) {
constructor(app, plugin, version, releaseNotes2) {
super(app);
this.plugin = plugin;
this.version = version;
this.releaseNotes = releaseNotes2;
}
onOpen() {
async onOpen() {
const { contentEl } = this;
contentEl.empty();
contentEl.createEl("h2", { text: `Welcome to \u{1F9B6} Rich Foot v${this.version}` });
contentEl.createEl("p", {
text: "After each update you'll be prompted with the release notes. You can disable this in the plugin settings General tab."
text: "After each update you'll be prompted with the release notes. You can disable this in the plugin settings."
});
const kofiContainer = contentEl.createEl("div");
kofiContainer.style.textAlign = "right";
Expand All @@ -60,7 +61,13 @@ var ReleaseNotesModal = class extends import_obsidian.Modal {
}
});
const notesContainer = contentEl.createDiv("release-notes-container");
notesContainer.innerHTML = this.releaseNotes;
await import_obsidian.MarkdownRenderer.renderMarkdown(
this.releaseNotes,
notesContainer,
"",
this.plugin,
this
);
contentEl.createEl("div", { cls: "release-notes-spacer" }).style.height = "20px";
new import_obsidian.Setting(contentEl).addButton((btn) => btn.setButtonText("Close").onClick(() => this.close()));
}
Expand All @@ -80,7 +87,8 @@ var DEFAULT_SETTINGS = {
borderOpacity: 1,
borderRadius: 15,
datesOpacity: 1,
linksOpacity: 1
linksOpacity: 1,
showReleaseNotes: true
};
var RichFootPlugin = class extends import_obsidian2.Plugin {
async onload() {
Expand Down Expand Up @@ -120,9 +128,10 @@ var RichFootPlugin = class extends import_obsidian2.Plugin {
async checkVersion() {
const currentVersion = this.manifest.version;
const lastVersion = this.settings.lastVersion;
if (this.settings.showReleaseNotes && (!lastVersion || lastVersion !== currentVersion)) {
const shouldShow = this.settings.showReleaseNotes && (!lastVersion || lastVersion !== currentVersion);
if (shouldShow) {
const releaseNotes2 = await this.getReleaseNotes(currentVersion);
new ReleaseNotesModal(this.app, currentVersion, releaseNotes2).open();
new ReleaseNotesModal(this.app, this, currentVersion, releaseNotes2).open();
this.settings.lastVersion = currentVersion;
await this.saveSettings();
}
Expand Down Expand Up @@ -449,6 +458,14 @@ var RichFootSettingTab = class extends import_obsidian2.PluginSettingTab {
alt: "Rich Foot Example"
}
});
new import_obsidian2.Setting(containerEl).setName("Show Release Notes").setDesc("Show release notes after plugin updates").addToggle((toggle) => toggle.setValue(this.plugin.settings.showReleaseNotes).onChange(async (value) => {
this.plugin.settings.showReleaseNotes = value;
await this.plugin.saveSettings();
}));
new import_obsidian2.Setting(containerEl).setName("Show Release Notes").setDesc("View release notes for the current version").addButton((button) => button.setButtonText("Show Release Notes").onClick(async () => {
const notes = await this.plugin.getReleaseNotes(this.plugin.manifest.version);
new ReleaseNotesModal(this.app, this.plugin, this.plugin.manifest.version, notes).open();
}));
}
async browseForFolder() {
const folders = this.app.vault.getAllLoadedFiles().filter((file) => file.children).map((folder) => folder.path);
Expand Down
33 changes: 27 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const DEFAULT_SETTINGS = {
borderOpacity: 1,
borderRadius: 15,
datesOpacity: 1,
linksOpacity: 1
linksOpacity: 1,
showReleaseNotes: true
};

class RichFootSettings {
Expand Down Expand Up @@ -83,15 +84,14 @@ class RichFootPlugin extends Plugin {
async checkVersion() {
const currentVersion = this.manifest.version;
const lastVersion = this.settings.lastVersion;
const shouldShow = this.settings.showReleaseNotes &&
(!lastVersion || lastVersion !== currentVersion);

if (this.settings.showReleaseNotes &&
(!lastVersion || lastVersion !== currentVersion)) {

// Get release notes for current version
if (shouldShow) {
const releaseNotes = await this.getReleaseNotes(currentVersion);

// Show the modal
new ReleaseNotesModal(this.app, currentVersion, releaseNotes).open();
new ReleaseNotesModal(this.app, this, currentVersion, releaseNotes).open();

// Update the last shown version
this.settings.lastVersion = currentVersion;
Expand All @@ -100,6 +100,7 @@ class RichFootPlugin extends Plugin {
}

async getReleaseNotes(version) {
// Simply return the bundled release notes
return releaseNotes;
}

Expand Down Expand Up @@ -588,6 +589,26 @@ class RichFootSettingTab extends PluginSettingTab {
alt: 'Rich Foot Example'
}
});

new Setting(containerEl)
.setName('Show Release Notes')
.setDesc('Show release notes after plugin updates')
.addToggle(toggle => toggle
.setValue(this.plugin.settings.showReleaseNotes)
.onChange(async (value) => {
this.plugin.settings.showReleaseNotes = value;
await this.plugin.saveSettings();
}));

new Setting(containerEl)
.setName('Show Release Notes')
.setDesc('View release notes for the current version')
.addButton(button => button
.setButtonText('Show Release Notes')
.onClick(async () => {
const notes = await this.plugin.getReleaseNotes(this.plugin.manifest.version);
new ReleaseNotesModal(this.app, this.plugin, this.plugin.manifest.version, notes).open();
}));
}

async browseForFolder() {
Expand Down
18 changes: 13 additions & 5 deletions src/modals.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Modal, Setting } from 'obsidian';
import { Modal, Setting, MarkdownRenderer } from 'obsidian';

export class ReleaseNotesModal extends Modal {
constructor(app, version, releaseNotes) {
constructor(app, plugin, version, releaseNotes) {
super(app);
this.plugin = plugin;
this.version = version;
this.releaseNotes = releaseNotes;
}

onOpen() {
async onOpen() {
const { contentEl } = this;
contentEl.empty();

Expand All @@ -16,9 +17,10 @@ export class ReleaseNotesModal extends Modal {

// Message
contentEl.createEl('p', {
text: 'After each update you\'ll be prompted with the release notes. You can disable this in the plugin settings General tab.'
text: 'After each update you\'ll be prompted with the release notes. You can disable this in the plugin settings.'
});

// Ko-fi container
const kofiContainer = contentEl.createEl('div');
kofiContainer.style.textAlign = 'right';

Expand All @@ -38,7 +40,13 @@ export class ReleaseNotesModal extends Modal {

// Release notes content
const notesContainer = contentEl.createDiv('release-notes-container');
notesContainer.innerHTML = this.releaseNotes;
await MarkdownRenderer.renderMarkdown(
this.releaseNotes,
notesContainer,
'',
this.plugin,
this
);

// Add some spacing
contentEl.createEl('div', { cls: 'release-notes-spacer' }).style.height = '20px';
Expand Down

0 comments on commit 12163fd

Please sign in to comment.