Allows to add the page content into the email, server-side #5

Merged
Shikiryu merged 1 commits from feature/extract/1 into master 2020-07-02 16:58:53 +02:00
7 changed files with 120 additions and 70 deletions

View File

@ -23,6 +23,10 @@
"message": "Token:", "message": "Token:",
"description": "Token label" "description": "Token label"
}, },
"optionsExtract": {
"message": "Send page content into the email:",
"description": "Extract label"
},
"URLChanged": { "URLChanged": {
"message": "URL changed!", "message": "URL changed!",
"description": "Message when URL is changed." "description": "Message when URL is changed."
@ -31,6 +35,10 @@
"message": "Token saved!", "message": "Token saved!",
"description": "Message when token is changed." "description": "Message when token is changed."
}, },
"optionSaved": {
"message": "Option saved!",
"description": "Message when option is changed."
},
"cantExtractTitle": { "cantExtractTitle": {
"message": "Sorry, could not extract this page's title and URL", "message": "Sorry, could not extract this page's title and URL",
"description": "Message when we could not extract the page's title and URL" "description": "Message when we could not extract the page's title and URL"
@ -46,5 +54,9 @@
"defaultURL": { "defaultURL": {
"message": "https://app.readlater.shikiryu.com", "message": "https://app.readlater.shikiryu.com",
"description": "Default URL" "description": "Default URL"
},
"excerpt": {
"message": "Add content",
"description": "Option to add the webpage content into the email"
} }
} }

View File

@ -23,14 +23,22 @@
"message": "Jeton :", "message": "Jeton :",
"description": "Token label" "description": "Token label"
}, },
"optionsExtract": {
"message": "Envoyer le contenu de la page dans le mail:",
"description": "Extract label"
},
"URLChanged": { "URLChanged": {
"message": "URL changed!", "message": "URL enregistrée !",
"description": "Message when URL is changed." "description": "Message when URL is changed."
}, },
"tokenSaved": { "tokenSaved": {
"message": "Token saved!", "message": "Jeton enregistré !",

faute

faute
"description": "Message when token is changed." "description": "Message when token is changed."
}, },
"optionSaved": {
"message": "Option enregistrée !",
"description": "Message when option is changed."
},
"cantExtractTitle": { "cantExtractTitle": {
"message": "Sorry, could not extract this page's title and URL", "message": "Sorry, could not extract this page's title and URL",
"description": "Message when we could not extract the page's title and URL" "description": "Message when we could not extract the page's title and URL"
@ -46,5 +54,9 @@
"defaultURL": { "defaultURL": {
"message": "https://app.readlater.shikiryu.com", "message": "https://app.readlater.shikiryu.com",
"description": "Default URL" "description": "Default URL"
},
"excerpt": {
"message": "Ajouter le contenu",
"description": "Option to add the webpage content into the email"
} }
} }

View File

@ -1,12 +1,12 @@
<!doctype html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<link href="styles/options.css" rel="stylesheet"> <link href="styles/options.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1" />
<title data-message="optionsAndSettings"></title> <title data-message="optionsAndSettings"></title>
</head> </head>
<body class="wrap"> <body class="wrap">
<div class="grid"> <div class="grid">
<div class="unit whole center-on-mobiles"> <div class="unit whole center-on-mobiles">
<div class="heading"> <div class="heading">
@ -29,7 +29,11 @@
<div class="unit whole center-on-mobiles"> <div class="unit whole center-on-mobiles">
<div class="option"> <div class="option">
<h5 data-message="optionsURL"></h5> <h5 data-message="optionsURL"></h5>
<input type="text" name="url" value="https://app.readlater.shikiryu.com" /> <input
type="text"
name="url"
value="https://app.readlater.shikiryu.com"
/>
</div> </div>
<div class="option"> <div class="option">
@ -37,11 +41,14 @@
<input type="text" name="token" value="" /> <input type="text" name="token" value="" />
</div> </div>
<div class="option">
<h5 data-message="optionsExtract"></h5>
<input type="checkbox" name="extract" value="1" />
</div>
</div> </div>
</div> </div>
</section> </section>
<footer class="main-footer"> <footer class="main-footer">
<div class="grid"> <div class="grid">
<div class="unit whole center-on-mobiles"> <div class="unit whole center-on-mobiles">
@ -50,8 +57,7 @@
</p> </p>
</div> </div>
</div> </div>
</footer> </footer>
<script src="scripts/options.js"></script> <script src="scripts/options.js"></script>
</body> </body>
</html> </html>

View File

@ -1,8 +1,8 @@
<!doctype html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<link href="styles/popup.css" rel="stylesheet"> <link href="styles/popup.css" rel="stylesheet" />
</head> </head>
<body> <body>
<div id="app" class="popup-content"> <div id="app" class="popup-content">
@ -20,6 +20,8 @@
<a href="" target="_blank" class="url" data-template="url"></a> <a href="" target="_blank" class="url" data-template="url"></a>
</div> </div>
<div class="action-container"> <div class="action-container">
<label for="save-content" data-message="excerpt"></label>
<input type="checkbox" id="save-content" name="save-content" />
<button id="save-btn" class="btn btn-primary">Save</button> <button id="save-btn" class="btn btn-primary">Save</button>
</div> </div>
</div> </div>

View File

@ -18,6 +18,9 @@ ext.runtime.onMessage.addListener(function(request, sender, sendResponse) {
i: encodeURIComponent(data.image), i: encodeURIComponent(data.image),
c: encodeURIComponent(data.comment) c: encodeURIComponent(data.comment)
}; };
if (data.extract) {
params["e"] = true;
}
var queryString = Object.keys(params) var queryString = Object.keys(params)
.map(key => { .map(key => {
return key + "=" + params[key]; return key + "=" + params[key];

View File

@ -3,6 +3,7 @@ import storage from "./utils/storage";
var urlInput = document.querySelector("[name=url]"); var urlInput = document.querySelector("[name=url]");
var tokenInput = document.querySelector("[name=token]"); var tokenInput = document.querySelector("[name=token]");
var extractInput = document.querySelector("[name=extract]");
var message = document.getElementById("msg"); var message = document.getElementById("msg");
storage.get("url", function(resp) { storage.get("url", function(resp) {
@ -13,6 +14,10 @@ storage.get("token", function(resp) {
tokenInput.value = resp.token; tokenInput.value = resp.token;
}); });
storage.get("extract", function(resp) {
extractInput.value = resp.extract;
});
urlInput.addEventListener("blur", function(e) { urlInput.addEventListener("blur", function(e) {
var value = this.value; var value = this.value;
storage.set({ url: value }, function() { storage.set({ url: value }, function() {
@ -27,6 +32,13 @@ tokenInput.addEventListener("blur", function(e) {
}); });
}); });
extractInput.addEventListener("change", function(e) {
var value = this.value;
storage.set({ extract: value }, function() {
message.textContent = ext.i18n.getMessage("optionSaved");
});
});
document.querySelectorAll("[data-message]").forEach(function(elt) { document.querySelectorAll("[data-message]").forEach(function(elt) {
elt.textContent = ext.i18n.getMessage(elt.dataset.message); elt.textContent = ext.i18n.getMessage(elt.dataset.message);
}); });

View File

@ -10,10 +10,12 @@ var page_data = {
}; };
var popup = document.getElementById("app"); var popup = document.getElementById("app");
storage.get("color", function(resp) { storage.get("extract", function(resp) {
var color = resp.color; var extract = resp.extract;
if (color) { if (extract) {
popup.style.backgroundColor = color; document.getElementById("save-content").checked = extract
? "checked"
: false;
} }
}); });
@ -45,7 +47,7 @@ var renderBookmark = data => {
ext.tabs.query({ active: true, currentWindow: true }, function(tabs) { ext.tabs.query({ active: true, currentWindow: true }, function(tabs) {
var activeTab = tabs[0]; var activeTab = tabs[0];
chrome.tabs.sendMessage( ext.tabs.sendMessage(
activeTab.id, activeTab.id,
{ action: "process-page" }, { action: "process-page" },
renderBookmark renderBookmark
@ -56,6 +58,7 @@ popup.addEventListener("click", function(e) {
if (e.target && e.target.matches("#save-btn")) { if (e.target && e.target.matches("#save-btn")) {
e.preventDefault(); e.preventDefault();
page_data.comment = document.getElementById("comment").value; page_data.comment = document.getElementById("comment").value;
page_data.extract = document.getElementById("save-content").checked;
ext.runtime.sendMessage( ext.runtime.sendMessage(
{ action: "perform-save", data: page_data }, { action: "perform-save", data: page_data },
function(response) { function(response) {