Ver Fonte

add bookmark-pathname template variable (fix #555)

Gildas há 5 anos atrás
pai
commit
1d8e346da3

+ 2 - 2
extension/core/bg/bookmarks.js

@@ -85,13 +85,13 @@ singlefile.extension.core.bg.bookmarks = (() => {
 			const ignoredBookmark = bookmarkFolders.find(folder => options.ignoredBookmarkFolders.includes(folder));
 			const ignoredBookmark = bookmarkFolders.find(folder => options.ignoredBookmarkFolders.includes(folder));
 			if (!ignoredBookmark) {
 			if (!ignoredBookmark) {
 				if (tabs.length && tabs[0].url == bookmarkInfo.url) {
 				if (tabs.length && tabs[0].url == bookmarkInfo.url) {
-					singlefile.extension.core.bg.business.saveTabs(tabs, { bookmarkId });
+					singlefile.extension.core.bg.business.saveTabs(tabs, { bookmarkId, bookmarkFolders });
 				} else {
 				} else {
 					const tabs = await singlefile.extension.core.bg.tabs.get({});
 					const tabs = await singlefile.extension.core.bg.tabs.get({});
 					if (tabs.length) {
 					if (tabs.length) {
 						const tab = tabs.find(tab => tab.url == bookmarkInfo.url);
 						const tab = tabs.find(tab => tab.url == bookmarkInfo.url);
 						if (tab) {
 						if (tab) {
-							singlefile.extension.core.bg.business.saveTabs([tab], { bookmarkId });
+							singlefile.extension.core.bg.business.saveTabs([tab], { bookmarkId, bookmarkFolders });
 						} else {
 						} else {
 							if (bookmarkInfo.url) {
 							if (bookmarkInfo.url) {
 								if (bookmarkInfo.url == "about:blank") {
 								if (bookmarkInfo.url == "about:blank") {

+ 8 - 1
extension/ui/pages/help.html

@@ -410,7 +410,8 @@
 					<li data-options-label="maxResourceSizeLabel"> <span class="option">Option: maximum size (MB)</span>
 					<li data-options-label="maxResourceSizeLabel"> <span class="option">Option: maximum size (MB)</span>
 						<p>Specify the maximum size of embedded resources in megabytes.</p>
 						<p>Specify the maximum size of embedded resources in megabytes.</p>
 					</li>
 					</li>
-					<li data-options-label="passReferrerOnErrorLabel"> <span class="option">Option: pass \"Referer\" header on
+					<li data-options-label="passReferrerOnErrorLabel"> <span class="option">Option: pass \"Referer\"
+							header on
 							cross-origin errors</span>
 							cross-origin errors</span>
 						<p>Check this option to pass the HTTP header "Referer" with the "origin" policy after an 401,
 						<p>Check this option to pass the HTTP header "Referer" with the "origin" policy after an 401,
 							403, or 404 HTTP error when downloading a cross-origin resource. You should enable this
 							403, or 404 HTTP error when downloading a cross-origin resource. You should enable this
@@ -611,6 +612,12 @@
 						"http://example.com")</li>
 						"http://example.com")</li>
 					<li><code>{url-referrer-flat}</code>: the URI of the page that "linked" to the page with slashed
 					<li><code>{url-referrer-flat}</code>: the URI of the page that "linked" to the page with slashed
 						replaced (e.g. "http_example.com")</li>
 						replaced (e.g. "http_example.com")</li>
+					<li><code>{bookmark-pathname}</code>: the path name of the newly created bookmark with replaced
+						slashes (e.g. "My Bookmarks_Last Month") when the option "Misc &gt; save the page of a
+						newly created bookmark" is enabled</li>
+					<li><code>{bookmark-pathname-flat}</code>: the path name of the newly created bookmark (e.g.
+						"My Bookmarks/Last Month") when the option "Misc &gt; save the page of a
+						newly created bookmark" is enabled</li>
 					<li><code>{tab-id}</code>: the unique identifier of the tab (e.g. "326")</li>
 					<li><code>{tab-id}</code>: the unique identifier of the tab (e.g. "326")</li>
 					<li><code>{tab-index}</code>: the index of the tab in the window (e.g. "1")</li>
 					<li><code>{tab-index}</code>: the index of the tab in the window (e.g. "1")</li>
 					<li><code>{digest-sha-256}</code>: the SHA-256 hash value of the entire page content (e.g.
 					<li><code>{digest-sha-256}</code>: the SHA-256 hash value of the entire page content (e.g.

+ 3 - 0
lib/single-file/single-file-core.js

@@ -1502,6 +1502,9 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				template = await evalTemplateVariable(template, "digest-sha-384", async () => util.digest("SHA-384", content), dontReplaceSlash, options.filenameReplacementCharacter);
 				template = await evalTemplateVariable(template, "digest-sha-384", async () => util.digest("SHA-384", content), dontReplaceSlash, options.filenameReplacementCharacter);
 				template = await evalTemplateVariable(template, "digest-sha-512", async () => util.digest("SHA-512", content), dontReplaceSlash, options.filenameReplacementCharacter);
 				template = await evalTemplateVariable(template, "digest-sha-512", async () => util.digest("SHA-512", content), dontReplaceSlash, options.filenameReplacementCharacter);
 			}
 			}
+			const bookmarkFolder = (options.bookmarkFolders && options.bookmarkFolders.join("/")) || "";
+			template = await evalTemplateVariable(template, "bookmark-pathname", () => bookmarkFolder, dontReplaceSlash === undefined ? true : dontReplaceSlash, options.filenameReplacementCharacter);
+			template = await evalTemplateVariable(template, "bookmark-pathname-flat", () => bookmarkFolder, dontReplaceSlash, options.filenameReplacementCharacter);
 			return template.trim();
 			return template.trim();
 
 
 			function decode(value) {
 			function decode(value) {