Skip to content

Commit

Permalink
Merge pull request #29 from jparkerweb/develop
Browse files Browse the repository at this point in the history
v1.8.0
  • Loading branch information
jparkerweb authored Nov 30, 2024
2 parents debe2ac + fcca20a commit 3b6e4df
Show file tree
Hide file tree
Showing 15 changed files with 187 additions and 64 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to Rich Foot will be documented in this file.

## [1.8.0] - 2024-11-29
### ✨ Added
- Support for `Page Preview` core plugin for `Outlinks` & `Backlinks`

## [1.7.2] - 2024-11-29
### ✨ Added
- `Date Display Format` option to allow users to specify their own date format
Expand Down
23 changes: 4 additions & 19 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
## 📆 Dates Your Way
## 🫣 Page Preview Support

### v1.7.2
### [1.8.0] - 2024-11-29
#### ✨ Added
- `Date Display Format` option to allow users to specify their own date format
- Support for `Page Preview` core plugin for `Outlinks` & `Backlinks`

#### 🐛 Fixed
- Date not formatted correctly if timestamp was included in the Custom Created/Modified Date Property

### v1.7.1
#### 🐛 Fixed
- Note embeds in canvas now have the correct height
- Duplicate "show dates" option in settings

#### ✨ Added
- If using custom created/modified date properties, the date now displays in the format of "Month Day, Year" if in proper date format, otherwise it displays the raw frontmatter filed string value.

### v1.7.0
#### ✨ Added
- `Custom Created/Modified Date Property` fields to allow users to specify their own frontmatter properties for dates, useful when file system dates are affected by sync processes and you track them separately.

[![screenshot](https://raw.githubusercontent.com/jparkerweb/rich-foot/refs/heads/develop/img/releases/rich-foot-v1.7.0.jpg)](https://raw.githubusercontent.com/jparkerweb/rich-foot/refs/heads/develop/img/releases/rich-foot-v1.7.0.jpg)
[![screenshot]()]()
Binary file modified example-vault.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"showPinIcon": true,
"pinnedImageFolder": "pixel-banner-images",
"showReleaseNotes": true,
"lastVersion": "2.10.1",
"lastVersion": "2.10.2",
"showRefreshIcon": true,
"hidePixelBannerFields": true,
"hidePropertiesSectionIfOnlyBanner": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var DEFAULT_SETTINGS = {
numberOfImages: 10,
defaultKeywords: "nature, abstract, landscape, technology, art, cityscape, wildlife, ocean, mountains, forest, space, architecture, food, travel, science, music, sports, fashion, business, education, health, culture, history, weather, transportation, industry, people, animals, plants, patterns",
yPosition: 50,
// Update these fields to be arrays
customBannerField: ["banner"],
customYPositionField: ["banner-y"],
customContentStartField: ["content-start"],
Expand Down Expand Up @@ -275,21 +274,16 @@ var FolderImageSetting = class extends import_obsidian.Setting {
const colorContainer = containerEl.createDiv("color-settings-container");
new import_obsidian.Setting(colorContainer).setName("inline title color").addColorPicker((color) => color.setValue((() => {
const currentColor = this.folderImage.titleColor || this.plugin.settings.titleColor;
console.log("Current color:", currentColor);
if (currentColor.startsWith("var(--")) {
console.log("Processing CSS variable");
const temp = document.createElement("div");
temp.style.color = currentColor;
document.body.appendChild(temp);
const computedColor = getComputedStyle(temp).color;
console.log("Computed color:", computedColor);
document.body.removeChild(temp);
const rgbMatch = computedColor.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
console.log("RGB match:", rgbMatch);
if (rgbMatch) {
const [_, r, g, b] = rgbMatch;
const hexColor = "#" + parseInt(r).toString(16).padStart(2, "0") + parseInt(g).toString(16).padStart(2, "0") + parseInt(b).toString(16).padStart(2, "0");
console.log("Final hex color:", hexColor);
return hexColor;
}
return "#000000";
Expand Down Expand Up @@ -745,21 +739,16 @@ var PixelBannerSettingTab = class extends import_obsidian.PluginSettingTab {
}));
new import_obsidian.Setting(containerEl).setName("Inline Title Color").setDesc("Set the default inline title color for all banners").addColorPicker((color) => color.setValue((() => {
const currentColor = this.plugin.settings.titleColor;
console.log("General tab - Current color:", currentColor);
if (currentColor.startsWith("var(--")) {
console.log("General tab - Processing CSS variable");
const temp = document.createElement("div");
temp.style.color = currentColor;
document.body.appendChild(temp);
const computedColor = getComputedStyle(temp).color;
console.log("General tab - Computed color:", computedColor);
document.body.removeChild(temp);
const rgbMatch = computedColor.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
console.log("General tab - RGB match:", rgbMatch);
if (rgbMatch) {
const [_, r, g, b] = rgbMatch;
const hexColor = "#" + parseInt(r).toString(16).padStart(2, "0") + parseInt(g).toString(16).padStart(2, "0") + parseInt(b).toString(16).padStart(2, "0");
console.log("General tab - Final hex color:", hexColor);
return hexColor;
}
return "#000000";
Expand Down Expand Up @@ -1070,9 +1059,17 @@ function debounce(func, wait) {
timeout = setTimeout(later, wait);
};
}
function random20characters() {
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let result = "";
for (let i = 0; i < 20; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}
async function testPexelsApi(apiKey) {
try {
const response = await fetch("https://api.pexels.com/v1/search?query=dog&per_page=3", {
const response = await fetch(`https://api.pexels.com/v1/search?query=${random20characters()}&per_page=3`, {
headers: {
"Authorization": apiKey
}
Expand All @@ -1081,7 +1078,9 @@ async function testPexelsApi(apiKey) {
throw new Error("\u274C Invalid Pexels API key");
}
const data = await response.json();
return data.photos && data.photos.length > 0;
console.log(`random20characters: ${random20characters()}`);
console.log(`Pexels API response:`, data);
return data.photos;
} catch (error) {
return false;
}
Expand Down Expand Up @@ -1136,17 +1135,45 @@ var ReleaseNotesModal = class extends import_obsidian2.Modal {
text: "After each update you'll be prompted with the release notes. You can disable this in the plugin settings General tab.",
cls: "release-notes-instructions"
});
const kofiContainer = contentEl.createEl("div");
kofiContainer.style.textAlign = "right";
const kofiLink = kofiContainer.createEl("a", {
const promotionalLinks = contentEl.createEl("div");
promotionalLinks.style.display = "flex";
promotionalLinks.style.flexDirection = "row";
promotionalLinks.style.justifyContent = "space-around";
const equilllabsLink = promotionalLinks.createEl("a", {
href: "https://www.equilllabs.com",
target: "equilllabs"
});
equilllabsLink.createEl("img", {
attr: {
height: "36",
style: "border:0px;height:36px;",
src: "https://raw.githubusercontent.com/jparkerweb/pixel-banner/refs/heads/main/img/equilllabs.png?raw=true",
border: "0",
alt: "eQuill Labs"
}
});
const discordLink = promotionalLinks.createEl("a", {
href: "https://discord.gg/sp8AQQhMJ7",
target: "discord"
});
discordLink.createEl("img", {
attr: {
height: "36",
style: "border:0px;height:36px;",
src: "https://raw.githubusercontent.com/jparkerweb/pixel-banner/refs/heads/main/img/discord.png?raw=true",
border: "0",
alt: "Discord"
}
});
const kofiLink = promotionalLinks.createEl("a", {
href: "https://ko-fi.com/Z8Z212UMBI",
target: "_blank"
target: "kofi"
});
kofiLink.createEl("img", {
attr: {
height: "36",
style: "border:0px;height:36px;",
src: "https://raw.githubusercontent.com/jparkerweb/pixel-banner/refs/heads/main/img/support.png",
src: "https://raw.githubusercontent.com/jparkerweb/pixel-banner/refs/heads/main/img/support.png?raw=true",
border: "0",
alt: "Buy Me a Coffee at ko-fi.com"
}
Expand All @@ -1163,7 +1190,7 @@ var ReleaseNotesModal = class extends import_obsidian2.Modal {
};

// virtual-module:virtual:release-notes
var releaseNotes = "<h2>\u{1F389} What&#39;s New</h2>\n<h3>v2.10.1</h3>\n<h4>Added</h4>\n<ul>\n<li>Color Picker Reset button for Folder Images tab (only applies if Inline Titles are enabled in Obsidian Settings)</li>\n</ul>\n<h4>Fixed</h4>\n<ul>\n<li>Display the correct color in the Color Picker for Inline Titles when the control is reset</li>\n</ul>\n<h3>v2.10.0</h3>\n<h4>Added</h4>\n<ul>\n<li>Color Picker for Inline Titles<ul>\n<li>Only applied if Inline Titles are enabled in Obsidian Settings:<ul>\n<li><code>Appearance</code> &gt; <code>Show inline title</code></li>\n</ul>\n</li>\n<li>Can be defined on the General, Custom Field Names, and Folder Images tabs</li>\n</ul>\n</li>\n</ul>\n";
var releaseNotes = "<h2>\u{1F389} What&#39;s New</h2>\n<h3>v2.10.2</h3>\n<h4>\u{1F41B} Fixed</h4>\n<ul>\n<li>Banners were being applied to the background of embedded media (images, videos, etc.)</li>\n</ul>\n<h4>\u{1F4E6} Updated</h4>\n<ul>\n<li>Improved Pexels API key validation</li>\n</ul>\n<h3>v2.10.1</h3>\n<h4>\u2728 Added</h4>\n<ul>\n<li>Color Picker Reset button for Folder Images tab (only applies if Inline Titles are enabled in Obsidian Settings)</li>\n</ul>\n<h4>\u{1F41B} Fixed</h4>\n<ul>\n<li>Display the correct color in the Color Picker for Inline Titles when the control is reset</li>\n</ul>\n<h3>v2.10.0</h3>\n<h4>\u2728 Added</h4>\n<ul>\n<li>Color Picker for Inline Titles<ul>\n<li>Only applied if Inline Titles are enabled in Obsidian Settings:<ul>\n<li><code>Appearance</code> &gt; <code>Show inline title</code></li>\n</ul>\n</li>\n<li>Can be defined on the General, Custom Field Names, and Folder Images tabs</li>\n</ul>\n</li>\n</ul>\n";

// src/main.js
module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
Expand Down Expand Up @@ -1408,7 +1435,7 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
}
const frontmatter = (_a = this.app.metadataCache.getFileCache(view.file)) == null ? void 0 : _a.frontmatter;
const contentEl = view.contentEl;
const isEmbedded = contentEl.classList.contains("internal-embed");
const isEmbedded = contentEl.classList.contains("internal-embed") && contentEl.classList.contains("markdown-embed");
const existingBanner = contentEl.querySelector(".pixel-banner-image");
const folderSpecific = this.getFolderSpecificImage(view.file.path);
let bannerImage = getFrontmatterValue(frontmatter, this.settings.customBannerField) || (folderSpecific == null ? void 0 : folderSpecific.image);
Expand Down Expand Up @@ -1472,7 +1499,7 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
existingBanner.style.display = "none";
}
if (!isEmbedded) {
const embeddedNotes = contentEl.querySelectorAll(".internal-embed");
const embeddedNotes = contentEl.querySelectorAll(".internal-embed.markdown-embed");
for (const embed of embeddedNotes) {
const embedFile = this.app.metadataCache.getFirstLinkpathDest(embed.getAttribute("src"), "");
if (embedFile) {
Expand Down Expand Up @@ -1595,6 +1622,10 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
if (keywords.length > 0) {
const selectedKeyword = keywords[Math.floor(Math.random() * keywords.length)];
const provider = this.getActiveApiProvider();
const apiKey = provider === "pexels" ? this.settings.pexelsApiKey : provider === "pixabay" ? this.settings.pixabayApiKey : provider === "flickr" ? this.settings.flickrApiKey : provider === "unsplash" ? this.settings.unsplashApiKey : null;
if (!apiKey) {
return null;
}
if (provider === "pexels") {
return this.fetchPexelsImage(selectedKeyword);
} else if (provider === "pixabay") {
Expand All @@ -1612,7 +1643,6 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
async fetchPexelsImage(keyword) {
const apiKey = this.settings.pexelsApiKey;
if (!apiKey) {
new import_obsidian3.Notice("Pexels API key is not set. Please set it in the plugin settings.");
return null;
}
const now = Date.now();
Expand Down Expand Up @@ -1663,7 +1693,6 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
async fetchPixabayImage(keyword) {
const apiKey = this.settings.pixabayApiKey;
if (!apiKey) {
new import_obsidian3.Notice("Pixabay API key is not set. Please set it in the plugin settings.");
return null;
}
const defaultKeywords = this.settings.defaultKeywords.split(",").map((k) => k.trim());
Expand Down Expand Up @@ -1718,7 +1747,6 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
async fetchFlickrImage(keyword) {
const apiKey = this.settings.flickrApiKey;
if (!apiKey) {
new import_obsidian3.Notice("Flickr API key is not set. Please set it in the plugin settings.");
return null;
}
const defaultKeywords = this.settings.defaultKeywords.split(",").map((k) => k.trim());
Expand Down Expand Up @@ -1771,7 +1799,6 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
async fetchUnsplashImage(keyword) {
const apiKey = this.settings.unsplashApiKey;
if (!apiKey) {
new import_obsidian3.Notice("Unsplash API key is not set. Please set it in the plugin settings.");
return null;
}
const defaultKeywords = this.settings.defaultKeywords.split(",").map((k) => k.trim());
Expand Down Expand Up @@ -2027,7 +2054,7 @@ module.exports = class PixelBannerPlugin extends import_obsidian3.Plugin {
var _a, _b;
const { frontmatter, file, isContentChange, yPosition, contentStartPosition, bannerImage, isReadingView } = ctx;
const viewContent = el;
const isEmbedded = viewContent.classList.contains("internal-embed");
const isEmbedded = viewContent.classList.contains("internal-embed") && viewContent.classList.contains("markdown-embed");
if (!isEmbedded) {
viewContent.classList.add("pixel-banner");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id": "pexels-banner",
"name": "Pixel Banner",
"version": "2.10.1",
"version": "2.10.2",
"minAppVersion": "1.6.0",
"description": "Apply an image from various sources as a banner to your notes.",
"author": "Justin Parker",
"authorUrl": "https://www.jparkerweb.com",
"author": "Justin Parker (eQui\\\\ Labs)",
"authorUrl": "https://www.equilllabs.com",
"fundingUrl": "https://ko-fi.com/jparkerweb",
"isDesktopOnly": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"showBacklinks": true,
"showOutlinks": true,
"showDates": true,
"lastVersion": "1.7.1"
"lastVersion": "1.7.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var ReleaseNotesModal = class extends import_obsidian.Modal {
};

// virtual-module:virtual:release-notes
var releaseNotes = '<h2>\u{1F4C6} Dates Your Way</h2>\n<h3>v1.7.2</h3>\n<h4>\u2728 Added</h4>\n<ul>\n<li><code>Date Display Format</code> option to allow users to specify their own date format</li>\n</ul>\n<h4>\u{1F41B} Fixed</h4>\n<ul>\n<li>Date not formatted correctly if timestamp was included in the Custom Created/Modified Date Property</li>\n</ul>\n<h3>v1.7.1</h3>\n<h4>\u{1F41B} Fixed</h4>\n<ul>\n<li>Note embeds in canvas now have the correct height</li>\n<li>Duplicate &quot;show dates&quot; option in settings</li>\n</ul>\n<h4>\u2728 Added</h4>\n<ul>\n<li>If using custom created/modified date properties, the date now displays in the format of &quot;Month Day, Year&quot; if in proper date format, otherwise it displays the raw frontmatter filed string value.</li>\n</ul>\n<h3>v1.7.0</h3>\n<h4>\u2728 Added</h4>\n<ul>\n<li><code>Custom Created/Modified Date Property</code> fields to allow users to specify their own frontmatter properties for dates, useful when file system dates are affected by sync processes and you track them separately.</li>\n</ul>\n<p><a href="https://raw.githubusercontent.com/jparkerweb/rich-foot/refs/heads/develop/img/releases/rich-foot-v1.7.0.jpg"><img src="https://raw.githubusercontent.com/jparkerweb/rich-foot/refs/heads/develop/img/releases/rich-foot-v1.7.0.jpg" alt="screenshot"></a></p>\n';
var releaseNotes = '<h2>\u{1FAE3} Page Preview Support</h2>\n<h3>[1.8.0] - 2024-11-29</h3>\n<h4>\u2728 Added</h4>\n<ul>\n<li>Support for <code>Page Preview</code> core plugin for <code>Outlinks</code> &amp; <code>Backlinks</code></li>\n</ul>\n<p><a href=""><img src="" alt="screenshot"></a></p>\n';

// src/main.js
var DEFAULT_SETTINGS = {
Expand Down Expand Up @@ -352,8 +352,10 @@ var RichFootPlugin = class extends import_obsidian2.Plugin {
const li = backlinksUl.createEl("li");
const link = li.createEl("a", {
href: linkPath,
text: linkPath.split("/").pop().slice(0, -3)
text: linkPath.split("/").pop().slice(0, -3),
cls: this.isEditMode() ? "cm-hmd-internal-link" : "internal-link"
});
link.dataset.href = linkPath;
link.addEventListener("click", (event) => {
event.preventDefault();
this.app.workspace.openLinkText(linkPath, file.path);
Expand All @@ -375,8 +377,10 @@ var RichFootPlugin = class extends import_obsidian2.Plugin {
const li = outlinksUl.createEl("li");
const link = li.createEl("a", {
href: linkPath,
text: displayName
text: displayName,
cls: this.isEditMode() ? "cm-hmd-internal-link" : "internal-link"
});
link.dataset.href = linkPath;
link.addEventListener("click", (event) => {
event.preventDefault();
this.app.workspace.openLinkText(linkPath, file.path);
Expand Down Expand Up @@ -552,6 +556,12 @@ var RichFootPlugin = class extends import_obsidian2.Plugin {
}
return this.settings.excludedFolders.some((folder) => filePath.startsWith(folder));
}
isEditMode() {
var _a, _b;
const activeView = this.app.workspace.getActiveViewOfType(import_obsidian2.MarkdownView);
if (!activeView) return false;
return ((_b = (_a = activeView.getMode) == null ? void 0 : _a.call(activeView)) != null ? _b : activeView.mode) === "source";
}
};
var RichFootSettingTab = class extends import_obsidian2.PluginSettingTab {
constructor(app, plugin) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "rich-foot",
"name": "Rich Foot",
"version": "1.7.2",
"version": "1.8.0",
"minAppVersion": "1.5.0",
"description": "Adds backlink tags and created/modified dates to the footer of your notes.",
"author": "Justin Parker (eQui\\\\ Labs)",
Expand Down
Loading

0 comments on commit 3b6e4df

Please sign in to comment.