vault backup: 2026-03-02 09:41:52

This commit is contained in:
2026-03-02 09:41:52 -05:00
parent 944192ae4c
commit 0b1e03a803
23 changed files with 1651 additions and 16178 deletions
+622 -45
View File
@@ -10732,6 +10732,48 @@ var import_obsidian2 = require("obsidian");
// src/repositoryConnection/RepositoryConnection.ts
var import_js_logger = __toESM(require_logger());
// src/forestry/LimitReachedError.ts
var LimitReachedError = class extends Error {
constructor(errorType, responseData) {
var _a2;
const message = (_a2 = responseData.message) != null ? _a2 : "Usage limit reached";
super(message);
this.name = "LimitReachedError";
this.errorType = errorType;
this.buildsUsed = responseData.builds_used;
this.monthlyLimit = responseData.monthly_limit;
this.starterCreditsRemaining = responseData.starter_credits_remaining;
}
};
function throwIfLimitError(error) {
if (error && typeof error === "object" && "status" in error && error.status === 403) {
const responseData = extractResponseData(error);
if (!responseData) return;
const errorType = responseData.error;
if (errorType === "build_limit_reached" || errorType === "storage_limit_exceeded") {
throw new LimitReachedError(errorType, responseData);
}
}
}
function extractResponseData(error) {
const err = error;
if (err.response && typeof err.response === "object") {
const response = err.response;
if (response.data && typeof response.data === "object") {
return response.data;
}
}
if (err.response && typeof err.response === "object") {
const resp = err.response;
if (resp.data && typeof resp.data === "object") {
return resp.data;
}
}
return null;
}
// src/repositoryConnection/RepositoryConnection.ts
var logger = import_js_logger.default.get("repository-connection");
var IMAGE_PATH_BASE = "src/site/";
var NOTE_PATH_BASE = "src/site/notes/";
@@ -10823,6 +10865,7 @@ var RepositoryConnection = class {
);
return result;
} catch (error) {
throwIfLimitError(error);
logger.error(error);
return false;
}
@@ -10875,6 +10918,7 @@ var RepositoryConnection = class {
payload
);
} catch (error) {
throwIfLimitError(error);
logger.error(error);
}
});
@@ -10973,6 +11017,7 @@ var RepositoryConnection = class {
sha: blob.data.sha
};
} catch (error) {
throwIfLimitError(error);
logger.error(error);
}
}));
@@ -11002,6 +11047,7 @@ var RepositoryConnection = class {
sha: blob.data.sha
};
} catch (error) {
throwIfLimitError(error);
logger.error(error);
}
}));
@@ -12902,7 +12948,8 @@ var CanvasCompiler = class {
node,
baseStyle,
colorClass,
file
file,
assets
);
case "file":
return yield this.buildFileNode(
@@ -12927,7 +12974,7 @@ var CanvasCompiler = class {
}
});
}
buildTextNode(node, baseStyle, colorClass, file) {
buildTextNode(node, baseStyle, colorClass, file, assets) {
return __async(this, null, function* () {
var _a2;
let processedText = node.text;
@@ -12935,7 +12982,8 @@ var CanvasCompiler = class {
try {
processedText = yield this.textNodeProcessor.processTextNodeContent(
file,
node.text
node.text,
assets
);
} catch (e) {
console.error("Error processing canvas text node:", e);
@@ -12955,6 +13003,45 @@ var CanvasCompiler = class {
}
buildFileNode(node, baseStyle, colorClass, file, assets) {
return __async(this, null, function* () {
const isPdf = /\.pdf$/i.test(node.file);
if (isPdf) {
const linkedFile = this.metadataCache.getFirstLinkpathDest(
(0, import_obsidian4.getLinkpath)(node.file),
file.getPath()
);
if (linkedFile) {
try {
const pdfData = yield this.vault.readBinary(linkedFile);
const pdfBase64 = arrayBufferToBase64(pdfData);
const pdfPath2 = `/img/user/${linkedFile.path}`;
assets.push({
path: pdfPath2,
content: pdfBase64,
localHash: generateBlobHashFromBase64(pdfBase64)
});
return `<div class="canvas-node canvas-node-file canvas-node-pdf ${colorClass}" data-node-id="${node.id}" style="${baseStyle}">
<div class="canvas-node-container">
<div class="canvas-node-content">
<iframe src="${encodeURI(
pdfPath2
)}" class="canvas-pdf-iframe" loading="lazy" style="width:100%;height:100%;border:none;"></iframe>
</div>
</div>
</div>`;
} catch (e) {
console.error("Error reading canvas PDF:", e);
}
}
const resolvedPath = (linkedFile == null ? void 0 : linkedFile.path) || node.file;
const pdfPath = encodeURI(`/img/user/${resolvedPath}`);
return `<div class="canvas-node canvas-node-file canvas-node-pdf ${colorClass}" data-node-id="${node.id}" style="${baseStyle}">
<div class="canvas-node-container">
<div class="canvas-node-content">
<iframe src="${pdfPath}" class="canvas-pdf-iframe" loading="lazy" style="width:100%;height:100%;border:none;"></iframe>
</div>
</div>
</div>`;
}
const isImage = /\.(png|jpg|jpeg|gif|webp|svg)$/i.test(node.file);
if (isImage) {
const linkedFile = this.metadataCache.getFirstLinkpathDest(
@@ -19415,6 +19502,18 @@ var GardenPageCompiler = class {
linkedFileName = headerSplit[0];
headerPath = headerSplit.length > 1 ? `#${headerSplit[1]}` : "";
}
if (linkedFileName === "" && headerPath !== "") {
const currentFilePath = file.getPath();
const currentExtensionlessPath = currentFilePath.substring(
0,
currentFilePath.lastIndexOf(".")
);
convertedText = convertedText.replace(
linkMatch,
`[[${currentExtensionlessPath}${headerPath}\\|${linkDisplayName}]]`
);
continue;
}
const fullLinkedFilePath = (0, import_obsidian5.getLinkpath)(linkedFileName);
if (fullLinkedFilePath === "") {
continue;
@@ -20122,7 +20221,7 @@ ${headerSection}
* Process text content from canvas text nodes through the same pipeline as notes.
* This enables wiki-links, transclusions, dataview, etc. in canvas text nodes.
*/
processTextNodeContent(file, text2) {
processTextNodeContent(file, text2, assets) {
return __async(this, null, function* () {
const CANVAS_TEXT_COMPILE_STEPS = [
this.convertCustomFilters,
@@ -20130,12 +20229,18 @@ ${headerSection}
this.createTranscludedText(0),
this.convertDataViews,
this.convertLinksToFullPath,
this.removeObsidianComments
this.removeObsidianComments,
this.createSvgEmbeds
];
return yield this.runCompilerSteps(
const compiledText = yield this.runCompilerSteps(
file,
CANVAS_TEXT_COMPILE_STEPS
)(text2);
const [processedText, collectedAssets] = yield this.convertEmbeddedAssets(file)(compiledText);
if (assets) {
assets.push(...collectedAssets);
}
return processedText;
});
}
generateMarkdown(file) {
@@ -20371,6 +20476,9 @@ var Publisher = class {
yield this.uploadAssets(assets, remoteImageHashes);
return true;
} catch (error) {
if (error instanceof LimitReachedError) {
throw error;
}
console.error(error);
return false;
}
@@ -20416,6 +20524,9 @@ var Publisher = class {
);
return true;
} catch (error) {
if (error instanceof LimitReachedError) {
throw error;
}
console.error(error);
return false;
}
@@ -30017,6 +30128,22 @@ var ForestryApi = class {
}
});
}
getUserLimits() {
return __async(this, null, function* () {
try {
const response = yield this.client.get(
"user/limits"
);
if (response.status !== 200) {
return null;
}
return response.data;
} catch (e) {
import_js_logger8.default.error(e);
return null;
}
});
}
};
// src/views/SettingsView/ForestrySettings.svelte
@@ -30033,11 +30160,11 @@ function create_else_block5(ctx) {
pending: create_pending_block,
then: create_then_block,
catch: create_catch_block,
value: 9,
value: 12,
blocks: [, , ,]
};
handle_promise(promise = /*getPageInfo*/
ctx[5](), info);
ctx[7](), info);
return {
c() {
await_block_anchor = empty();
@@ -30125,13 +30252,13 @@ function create_if_block6(ctx) {
input,
"input",
/*input_input_handler*/
ctx[8]
ctx[10]
),
listen(
button,
"click",
/*connect*/
ctx[3]
ctx[5]
)
];
mounted = true;
@@ -30191,7 +30318,7 @@ function create_catch_block(ctx) {
button,
"click",
/*disconnect*/
ctx[4]
ctx[6]
);
mounted = true;
}
@@ -30218,7 +30345,7 @@ function create_then_block(ctx) {
function select_block_type_1(ctx2, dirty) {
if (
/*pageInfo*/
ctx2[9]
ctx2[12]
) return 0;
return 1;
}
@@ -30287,7 +30414,7 @@ function create_else_block_12(ctx) {
button,
"click",
/*disconnect*/
ctx[4]
ctx[6]
);
mounted = true;
}
@@ -30313,7 +30440,7 @@ function create_if_block_15(ctx) {
let t0;
let t1_value = (
/*pageInfo*/
((_a2 = ctx[9].value.pageName) != null ? _a2 : "Unknown") + ""
((_a2 = ctx[12].value.pageName) != null ? _a2 : "Unknown") + ""
);
let t1;
let t2;
@@ -30326,11 +30453,25 @@ function create_if_block_15(ctx) {
let a;
let icon1;
let t7;
let t8;
let if_block_anchor;
let current;
let mounted;
let dispose;
icon0 = new Icon_default({ props: { name: "check-circle" } });
icon1 = new Icon_default({ props: { name: "external-link" } });
function select_block_type_2(ctx2, dirty) {
if (
/*limitsLoading*/
ctx2[4]
) return create_if_block_25;
if (
/*limits*/
ctx2[3]
) return create_if_block_33;
}
let current_block_type = select_block_type_2(ctx, -1);
let if_block = current_block_type && current_block_type(ctx);
return {
c() {
div4 = element("div");
@@ -30351,6 +30492,9 @@ function create_if_block_15(ctx) {
a = element("a");
create_component(icon1.$$.fragment);
t7 = text(" Open Forestry.md Dashboard");
t8 = space();
if (if_block) if_block.c();
if_block_anchor = empty();
attr(div0, "class", "setting-item-name");
set_style(div0, "display", "flex");
set_style(div0, "align-items", "center");
@@ -30384,18 +30528,32 @@ function create_if_block_15(ctx) {
append(div5, a);
mount_component(icon1, a, null);
append(a, t7);
insert(target, t8, anchor);
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
if (!mounted) {
dispose = listen(
button,
"click",
/*disconnect*/
ctx[4]
ctx[6]
);
mounted = true;
}
},
p: noop,
p(ctx2, dirty) {
if (current_block_type === (current_block_type = select_block_type_2(ctx2, dirty)) && if_block) {
if_block.p(ctx2, dirty);
} else {
if (if_block) if_block.d(1);
if_block = current_block_type && current_block_type(ctx2);
if (if_block) {
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
}
},
i(local) {
if (current) return;
transition_in(icon0.$$.fragment, local);
@@ -30412,14 +30570,362 @@ function create_if_block_15(ctx) {
detach(div4);
detach(t6);
detach(div5);
detach(t8);
detach(if_block_anchor);
}
destroy_component(icon0);
destroy_component(icon1);
if (if_block) {
if_block.d(detaching);
}
mounted = false;
dispose();
}
};
}
function create_if_block_33(ctx) {
let div5;
let div0;
let t0;
let t1_value = (
/*limits*/
ctx[3].plan + ""
);
let t1;
let t2;
let t3;
let div4;
let div1;
let span0;
let t5;
let span1;
let t6_value = (
/*limits*/
ctx[3].builds.monthlyLimit - /*limits*/
ctx[3].builds.monthlyRemaining + ""
);
let t6;
let t7;
let t8_value = (
/*limits*/
ctx[3].builds.monthlyLimit + ""
);
let t8;
let t9;
let t10;
let div2;
let span2;
let t12;
let span3;
let t13_value = (
/*limits*/
ctx[3].storage.usedFormatted + ""
);
let t13;
let t14;
let t15_value = (
/*limits*/
ctx[3].storage.limitFormatted + ""
);
let t15;
let t16;
let div3;
let span4;
let t18;
let span5;
let t19_value = (
/*limits*/
ctx[3].sites.current + ""
);
let t19;
let t20;
let t21_value = (
/*limits*/
ctx[3].sites.limit + ""
);
let t21;
let t22;
let if_block0 = (
/*limits*/
ctx[3].builds.starterCreditsRemaining > 0 && create_if_block_53(ctx)
);
let if_block1 = (
/*limits*/
(ctx[3].builds.monthlyRemaining === 0 || /*limits*/
ctx[3].storage.usedBytes >= /*limits*/
ctx[3].storage.limitBytes) && create_if_block_43(ctx)
);
return {
c() {
div5 = element("div");
div0 = element("div");
t0 = text("Usage \u2014 ");
t1 = text(t1_value);
t2 = text(" plan");
t3 = space();
div4 = element("div");
div1 = element("div");
span0 = element("span");
span0.textContent = "Builds this month";
t5 = space();
span1 = element("span");
t6 = text(t6_value);
t7 = text(" / ");
t8 = text(t8_value);
t9 = space();
if (if_block0) if_block0.c();
t10 = space();
div2 = element("div");
span2 = element("span");
span2.textContent = "Storage";
t12 = space();
span3 = element("span");
t13 = text(t13_value);
t14 = text(" / ");
t15 = text(t15_value);
t16 = space();
div3 = element("div");
span4 = element("span");
span4.textContent = "Sites";
t18 = space();
span5 = element("span");
t19 = text(t19_value);
t20 = text(" / ");
t21 = text(t21_value);
t22 = space();
if (if_block1) if_block1.c();
set_style(div0, "font-weight", "600");
set_style(div0, "margin-bottom", "8px");
set_style(
span1,
"color",
/*limits*/
ctx[3].builds.monthlyRemaining === 0 ? "var(--text-error)" : "var(--text-normal)"
);
set_style(div1, "display", "flex");
set_style(div1, "justify-content", "space-between");
set_style(
span3,
"color",
/*limits*/
ctx[3].storage.usedBytes >= /*limits*/
ctx[3].storage.limitBytes ? "var(--text-error)" : "var(--text-normal)"
);
set_style(div2, "display", "flex");
set_style(div2, "justify-content", "space-between");
set_style(div3, "display", "flex");
set_style(div3, "justify-content", "space-between");
set_style(div4, "display", "flex");
set_style(div4, "flex-direction", "column");
set_style(div4, "gap", "6px");
set_style(div4, "font-size", "0.9em");
set_style(div4, "color", "var(--text-muted)");
set_style(div5, "margin-top", "16px");
set_style(div5, "padding", "12px");
set_style(div5, "background", "var(--background-secondary)");
set_style(div5, "border-radius", "8px");
},
m(target, anchor) {
insert(target, div5, anchor);
append(div5, div0);
append(div0, t0);
append(div0, t1);
append(div0, t2);
append(div5, t3);
append(div5, div4);
append(div4, div1);
append(div1, span0);
append(div1, t5);
append(div1, span1);
append(span1, t6);
append(span1, t7);
append(span1, t8);
append(div4, t9);
if (if_block0) if_block0.m(div4, null);
append(div4, t10);
append(div4, div2);
append(div2, span2);
append(div2, t12);
append(div2, span3);
append(span3, t13);
append(span3, t14);
append(span3, t15);
append(div4, t16);
append(div4, div3);
append(div3, span4);
append(div3, t18);
append(div3, span5);
append(span5, t19);
append(span5, t20);
append(span5, t21);
append(div5, t22);
if (if_block1) if_block1.m(div5, null);
},
p(ctx2, dirty) {
if (dirty & /*limits*/
8 && t1_value !== (t1_value = /*limits*/
ctx2[3].plan + "")) set_data(t1, t1_value);
if (dirty & /*limits*/
8 && t6_value !== (t6_value = /*limits*/
ctx2[3].builds.monthlyLimit - /*limits*/
ctx2[3].builds.monthlyRemaining + "")) set_data(t6, t6_value);
if (dirty & /*limits*/
8 && t8_value !== (t8_value = /*limits*/
ctx2[3].builds.monthlyLimit + "")) set_data(t8, t8_value);
if (dirty & /*limits*/
8) {
set_style(
span1,
"color",
/*limits*/
ctx2[3].builds.monthlyRemaining === 0 ? "var(--text-error)" : "var(--text-normal)"
);
}
if (
/*limits*/
ctx2[3].builds.starterCreditsRemaining > 0
) {
if (if_block0) {
if_block0.p(ctx2, dirty);
} else {
if_block0 = create_if_block_53(ctx2);
if_block0.c();
if_block0.m(div4, t10);
}
} else if (if_block0) {
if_block0.d(1);
if_block0 = null;
}
if (dirty & /*limits*/
8 && t13_value !== (t13_value = /*limits*/
ctx2[3].storage.usedFormatted + "")) set_data(t13, t13_value);
if (dirty & /*limits*/
8 && t15_value !== (t15_value = /*limits*/
ctx2[3].storage.limitFormatted + "")) set_data(t15, t15_value);
if (dirty & /*limits*/
8) {
set_style(
span3,
"color",
/*limits*/
ctx2[3].storage.usedBytes >= /*limits*/
ctx2[3].storage.limitBytes ? "var(--text-error)" : "var(--text-normal)"
);
}
if (dirty & /*limits*/
8 && t19_value !== (t19_value = /*limits*/
ctx2[3].sites.current + "")) set_data(t19, t19_value);
if (dirty & /*limits*/
8 && t21_value !== (t21_value = /*limits*/
ctx2[3].sites.limit + "")) set_data(t21, t21_value);
if (
/*limits*/
ctx2[3].builds.monthlyRemaining === 0 || /*limits*/
ctx2[3].storage.usedBytes >= /*limits*/
ctx2[3].storage.limitBytes
) {
if (if_block1) {
} else {
if_block1 = create_if_block_43(ctx2);
if_block1.c();
if_block1.m(div5, null);
}
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
}
},
d(detaching) {
if (detaching) {
detach(div5);
}
if (if_block0) if_block0.d();
if (if_block1) if_block1.d();
}
};
}
function create_if_block_25(ctx) {
let div2;
return {
c() {
div2 = element("div");
div2.innerHTML = `<div class="setting-item-info"><div class="setting-item-name">Loading usage info...</div></div>`;
attr(div2, "class", "setting-item");
set_style(div2, "margin-top", "12px");
},
m(target, anchor) {
insert(target, div2, anchor);
},
p: noop,
d(detaching) {
if (detaching) {
detach(div2);
}
}
};
}
function create_if_block_53(ctx) {
let div;
let span0;
let t1;
let span1;
let t2_value = (
/*limits*/
ctx[3].builds.starterCreditsRemaining + ""
);
let t2;
return {
c() {
div = element("div");
span0 = element("span");
span0.textContent = "Starter credits remaining";
t1 = space();
span1 = element("span");
t2 = text(t2_value);
set_style(div, "display", "flex");
set_style(div, "justify-content", "space-between");
},
m(target, anchor) {
insert(target, div, anchor);
append(div, span0);
append(div, t1);
append(div, span1);
append(span1, t2);
},
p(ctx2, dirty) {
if (dirty & /*limits*/
8 && t2_value !== (t2_value = /*limits*/
ctx2[3].builds.starterCreditsRemaining + "")) set_data(t2, t2_value);
},
d(detaching) {
if (detaching) {
detach(div);
}
}
};
}
function create_if_block_43(ctx) {
let div;
return {
c() {
div = element("div");
div.innerHTML = `You&#39;ve reached your usage limit. <a href="https://dashboard.forestry.md/settings" target="_blank">Upgrade your plan</a> to continue publishing.`;
set_style(div, "margin-top", "8px");
set_style(div, "padding", "8px");
set_style(div, "background", "var(--background-modifier-error)");
set_style(div, "border-radius", "4px");
set_style(div, "font-size", "0.85em");
},
m(target, anchor) {
insert(target, div, anchor);
},
d(detaching) {
if (detaching) {
detach(div);
}
}
};
}
function create_pending_block(ctx) {
let div2;
return {
@@ -30576,6 +31082,8 @@ function instance8($$self, $$props, $$invalidate) {
let { saveSettings } = $$props;
let { onConnect } = $$props;
let apiKey = settings.forestrySettings.apiKey;
let limits = null;
let limitsLoading = false;
const connect = () => __awaiter(void 0, void 0, void 0, function* () {
let pageInfo = yield getPageInfo();
if (!pageInfo) {
@@ -30594,24 +31102,45 @@ function instance8($$self, $$props, $$invalidate) {
$$invalidate(0, settings.forestrySettings.forestryPageName = "", settings);
yield saveSettings();
$$invalidate(2, apiKey = "");
$$invalidate(3, limits = null);
});
const getPageInfo = () => __awaiter(void 0, void 0, void 0, function* () {
let pageInfo = yield new ForestryApi(apiKey).getPageInfo();
return pageInfo;
});
const fetchLimits = () => __awaiter(void 0, void 0, void 0, function* () {
if (!settings.forestrySettings.apiKey) return;
$$invalidate(4, limitsLoading = true);
try {
$$invalidate(3, limits = yield new ForestryApi(settings.forestrySettings.apiKey).getUserLimits());
} catch (_a2) {
$$invalidate(3, limits = null);
}
$$invalidate(4, limitsLoading = false);
});
function input_input_handler() {
apiKey = this.value;
$$invalidate(2, apiKey);
}
$$self.$$set = ($$props2) => {
if ("settings" in $$props2) $$invalidate(0, settings = $$props2.settings);
if ("saveSettings" in $$props2) $$invalidate(6, saveSettings = $$props2.saveSettings);
if ("onConnect" in $$props2) $$invalidate(7, onConnect = $$props2.onConnect);
if ("saveSettings" in $$props2) $$invalidate(8, saveSettings = $$props2.saveSettings);
if ("onConnect" in $$props2) $$invalidate(9, onConnect = $$props2.onConnect);
};
$$self.$$.update = () => {
if ($$self.$$.dirty & /*settings*/
1) {
$: if (settings.forestrySettings.apiKey) {
fetchLimits();
}
}
};
return [
settings,
unique,
apiKey,
limits,
limitsLoading,
connect,
disconnect,
getPageInfo,
@@ -30625,8 +31154,8 @@ var ForestrySettings = class extends SvelteComponent {
super();
init(this, options, instance8, create_fragment8, safe_not_equal, {
settings: 0,
saveSettings: 6,
onConnect: 7
saveSettings: 8,
onConnect: 9
});
}
};
@@ -30699,7 +31228,7 @@ var SettingView = class {
const publishPlatformSettings = this.settingsRootElement.createEl(
"div",
{
cls: "connection-status"
cls: "publish-platform-settings"
}
);
this.initializePublishPlatformSettings(publishPlatformSettings);
@@ -31313,13 +31842,31 @@ var SettingView = class {
cb.setButtonText("Apply settings to site");
cb.setCta();
cb.onClick((_ev) => __async(this, null, function* () {
const octokit = new Octokit({
auth: this.settings.githubToken
});
new import_obsidian15.Notice("Applying settings to site...");
yield this.saveSettingsAndUpdateEnv();
yield this.addFavicon(octokit);
yield this.addLogo(octokit);
const connection = yield PublishPlatformConnectionFactory.createPublishPlatformConnection(
this.settings
);
const octokit = connection.octoKit;
const owner = connection.userName;
const repo = connection.pageName;
try {
yield this.addFavicon(octokit, owner, repo);
} catch (error) {
import_js_logger9.default.error("Failed to update favicon", error);
new import_obsidian15.Notice(
"Failed to update favicon. Check the developer console for details."
);
}
try {
yield this.addLogo(octokit, owner, repo);
} catch (error) {
import_js_logger9.default.error("Failed to update logo", error);
new import_obsidian15.Notice(
"Failed to update logo. Check the developer console for details."
);
}
new import_obsidian15.Notice("Settings applied to site!");
}));
};
new import_obsidian15.Setting(this.settingsRootElement).setName("Appearance").setDesc("Manage themes, sitename and styling on your site").addButton((cb) => {
@@ -31724,7 +32271,7 @@ var SettingView = class {
}
return settings;
}
addFavicon(octokit) {
addFavicon(octokit, owner, repo) {
return __async(this, null, function* () {
let base64SettingsFaviconContent = "";
if (this.settings.faviconPath) {
@@ -31738,11 +32285,12 @@ var SettingView = class {
const faviconContent = yield this.app.vault.readBinary(faviconFile);
base64SettingsFaviconContent = arrayBufferToBase64(faviconContent);
} else {
const defaultFavicon = yield octokit.request(
const baseConnection = PublishPlatformConnectionFactory.createBaseGardenConnection();
const defaultFavicon = yield baseConnection.octoKit.request(
"GET /repos/{owner}/{repo}/contents/{path}",
{
owner: "oleeskild",
repo: "digitalgarden",
owner: baseConnection.userName,
repo: baseConnection.pageName,
path: "src/site/favicon.svg"
}
);
@@ -31755,13 +32303,13 @@ var SettingView = class {
currentFaviconOnSite = yield octokit.request(
"GET /repos/{owner}/{repo}/contents/{path}",
{
owner: this.settings.githubUserName,
repo: this.settings.githubRepo,
owner,
repo,
path: "src/site/favicon.svg"
}
);
faviconsAreIdentical = // @ts-expect-error TODO: abstract octokit response
currentFaviconOnSite.data.content === base64SettingsFaviconContent;
currentFaviconOnSite.data.content.replace(/\n/g, "") === base64SettingsFaviconContent;
if (faviconsAreIdentical) {
import_js_logger9.default.info("Favicons are identical, skipping update");
return;
@@ -31771,8 +32319,8 @@ var SettingView = class {
}
if (!faviconExists || !faviconsAreIdentical) {
yield octokit.request("PUT /repos/{owner}/{repo}/contents/{path}", {
owner: this.settings.githubUserName,
repo: this.settings.githubRepo,
owner,
repo,
path: "src/site/favicon.svg",
message: `Update favicon.svg`,
content: base64SettingsFaviconContent,
@@ -31782,9 +32330,12 @@ var SettingView = class {
}
});
}
addLogo(octokit) {
addLogo(octokit, owner, repo) {
return __async(this, null, function* () {
var _a2;
import_js_logger9.default.info(
`addLogo called, logoPath setting: "${this.settings.logoPath}", owner: "${owner}", repo: "${repo}"`
);
const logoBasePath = "src/site/logo";
const logoExtensions = ["png", "jpg", "jpeg", "gif", "svg", "webp"];
for (const ext of logoExtensions) {
@@ -31792,8 +32343,8 @@ var SettingView = class {
const existingLogo = yield octokit.request(
"GET /repos/{owner}/{repo}/contents/{path}",
{
owner: this.settings.githubUserName,
repo: this.settings.githubRepo,
owner,
repo,
path: `${logoBasePath}.${ext}`
}
);
@@ -31804,8 +32355,8 @@ var SettingView = class {
yield octokit.request(
"DELETE /repos/{owner}/{repo}/contents/{path}",
{
owner: this.settings.githubUserName,
repo: this.settings.githubRepo,
owner,
repo,
path: `${logoBasePath}.${ext}`,
message: `Remove logo.${ext}`,
// @ts-expect-error TODO: abstract octokit response
@@ -31841,13 +32392,13 @@ var SettingView = class {
currentLogoOnSite = yield octokit.request(
"GET /repos/{owner}/{repo}/contents/{path}",
{
owner: this.settings.githubUserName,
repo: this.settings.githubRepo,
owner,
repo,
path: logoPath
}
);
logosAreIdentical = // @ts-expect-error TODO: abstract octokit response
currentLogoOnSite.data.content === base64LogoContent;
currentLogoOnSite.data.content.replace(/\n/g, "") === base64LogoContent;
if (logosAreIdentical) {
import_js_logger9.default.info("Logos are identical, skipping update");
return;
@@ -31858,8 +32409,8 @@ var SettingView = class {
if (!logoExists || !logosAreIdentical) {
try {
const requestPayload = __spreadValues({
owner: this.settings.githubUserName,
repo: this.settings.githubRepo,
owner,
repo,
path: logoPath,
message: `Update logo.${logoExtension}`,
content: base64LogoContent
@@ -32550,6 +33101,10 @@ var DigitalGarden = class extends import_obsidian19.Plugin {
} catch (e) {
statusBarItem.remove();
this.isPublishing = false;
if (e instanceof LimitReachedError) {
this.showLimitNotice(e);
return;
}
console.error(e);
new import_obsidian19.Notice(
"Unable to publish multiple notes, something went wrong."
@@ -32666,9 +33221,15 @@ var DigitalGarden = class extends import_obsidian19.Plugin {
const publishSuccessful = yield publisher.publish(publishFile);
if (publishSuccessful) {
new import_obsidian19.Notice(`Successfully published note to your garden.`);
} else {
new import_obsidian19.Notice("Unable to publish note, something went wrong.");
}
return publishSuccessful;
} catch (e) {
if (e instanceof LimitReachedError) {
this.showLimitNotice(e);
return false;
}
console.error(e);
new import_obsidian19.Notice("Unable to publish note, something went wrong.");
return false;
@@ -32762,6 +33323,22 @@ var DigitalGarden = class extends import_obsidian19.Plugin {
}
});
}
showLimitNotice(error) {
var _a2, _b;
if (error.errorType === "build_limit_reached") {
const used = (_a2 = error.buildsUsed) != null ? _a2 : 0;
const limit = (_b = error.monthlyLimit) != null ? _b : 0;
new import_obsidian19.Notice(
`Publishing blocked: You've used all ${used}/${limit} builds this month. Upgrade to Pro for 1000 builds/month at dashboard.forestry.md/settings`,
1e4
);
} else {
new import_obsidian19.Notice(
`Publishing blocked: Storage limit exceeded. Free up space or upgrade at dashboard.forestry.md/settings`,
1e4
);
}
}
openPublishModal() {
const siteManager = new DigitalGardenSiteManager(
this.app.metadataCache,
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "digitalgarden",
"name": "Digital Garden",
"version": "2.69.0",
"version": "2.72.0",
"minAppVersion": "1.10.0",
"description": "Publish your notes to the web for others to enjoy. For free.",
"author": "Ole Eskild Steensen",