Ver Fonte

pass title and URL (fix #1827)

Gildas há 2 meses atrás
pai
commit
aa92c16004

+ 2 - 0
src/core/bg/autosave.js

@@ -204,6 +204,8 @@ async function saveContent(message, tab) {
 						await companion.save({
 							filename: pageData.filename,
 							content: pageData.content,
+							title: pageData.title,
+							url: options.url,
 							filenameConflictAction: options.filenameConflictAction
 						});
 					} else if (options.saveToRestFormApi) {

+ 2 - 0
src/core/bg/downloads.js

@@ -221,6 +221,8 @@ async function downloadContent(contents, tab, incognito, message) {
 				await companion.save({
 					filename: message.filename,
 					content: message.content,
+					title: message.title,
+					url: message.originalUrl,
 					filenameConflictAction: message.filenameConflictAction
 				});
 			} else if (message.saveToRestFormApi) {

+ 2 - 1
src/core/common/download.js

@@ -125,7 +125,8 @@ async function downloadPage(pageData, options) {
 		infobarPositionBottom: options.infobarPositionBottom,
 		infobarPositionLeft: options.infobarPositionLeft,
 		infobarPositionRight: options.infobarPositionRight,
-		originalUrl: options.url
+		originalUrl: options.url,
+		title: pageData.title
 	};
 	const pingInterval = setInterval(() => {
 		browser.runtime.sendMessage({ method: "ping" }).then(() => { });

+ 12 - 2
src/ui/bg/ui-editor.js

@@ -332,17 +332,21 @@ addEventListener("message", async event => {
 			if (tabData.options.addProof) {
 				pageData.hash = await singlefile.helper.digest("SHA-256", message.content);
 			}
+			tabData.options.url = message.url;
 			await download.downloadPage(pageData, tabData.options);
 		} else {
 			const pageData = {
 				content: message.content,
 				filename: message.filename || tabData.filename,
-				mimeType: "text/html"
+				mimeType: "text/html",
+				title: message.title,
+				url: message.url
 			};
 			if (tabData.options.addProof) {
 				pageData.hash = await singlefile.helper.digest("SHA-256", message.content);
 			}
 			tabData.options.compressContent = false;
+			tabData.options.url = message.url;
 			await download.downloadPage(pageData, tabData.options);
 		}
 	}
@@ -434,7 +438,13 @@ async function onMessage(message) {
 			tabData = JSON.parse(tabDataContents.join(""));
 			tabData.options = message.options;
 			tabDataContents = [];
-			editorElement.contentWindow.postMessage(JSON.stringify({ method: "init", content: tabData.content, password: tabData.options.password, compressContent: message.compressContent }), "*");
+			editorElement.contentWindow.postMessage(JSON.stringify({ 
+				method: "init", 
+				content: tabData.content, 
+				password: tabData.options.password, 
+				compressContent: message.compressContent,
+				url: tabData.url
+			}), "*");
 			editorElement.contentWindow.focus();
 			setInterval(() => browser.runtime.sendMessage({ method: "ping" }), 15000);
 		}

+ 5 - 1
src/ui/content/content-ui-editor-web.js

@@ -215,7 +215,9 @@ import { downloadPageForeground } from "../../core/common/download.js";
 						window.parent.postMessage(JSON.stringify({
 							method: "setContent",
 							content,
-							filename
+							filename,
+							title: document.title,
+							url: pageUrl
 						}), "*");
 					}
 				}
@@ -295,6 +297,8 @@ import { downloadPageForeground } from "../../core/common/download.js";
 			pageCompressContent = true;
 			const contentDocument = (new DOMParser()).parseFromString(docContent, "text/html");
 			if (detectSavedPage(contentDocument)) {
+				const { saveUrl } = singlefile.helper.extractInfobarData(contentDocument);
+				pageUrl = saveUrl;
 				await singlefile.helper.display(document, docContent, { disableFramePointerEvents: true });
 				singlefile.helper.fixInvalidNesting(document);
 				const infobarElement = document.querySelector(singlefile.helper.INFOBAR_TAGNAME);