First of all, thank you all for support and answering questions on this forum. Ghost community is awesome!
I want to completely remove portal.js, since I don’t have paid members and don’t need them to login. The content is free and and public so there is no need to sign in to view it. However, I do need the email subscription form on the homepage (and I already have it) to collect email so I could send newsletters.
I need only this:
- User lands on the homepage and enters his email into the subscription form.
- Email confirmation request is sent to the user.
- User confirms an email. Email is written to the database of email subscribers. No cookies, or files like “OPTIONS tiers?key=…”, “OPTIONS newsletters?key=…”, “newsletters?key=…”, “tiers?key=…”, “settings?key=…” need to be loaded. I want to get rid of all that to improve performance and privacy.
- User is redirected to the homepage after he confirms an email. There is a toast notification to inform about the successful subscription.
- I’m able to send email newsletters to the subscribers. But I don’t need them to login or store their sessions. Loaded resources has to be reduced as much as possible to improve performance.
I inspected portal.min.js and found code that seems to be relevant to the form:
function vu(e) {
var n = e.siteUrl,
t = e.site,
r = e.member;
n && (n = n.replace(/\/$/, ""), Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"), (function(e) {
var t = e.querySelector("[data-members-error]");
e.addEventListener("submit", (function r(i) {
!function(e) {
var n,
t = e.event,
r = e.form,
i = e.errorEl,
o = e.siteUrl,
a = e.submitHandler;
r.removeEventListener("submit", a),
t.preventDefault(),
i && (i.innerText = ""),
r.classList.remove("success", "invalid", "error");
for (var l = t.target.querySelector("input[data-members-email]"), s = t.target.querySelector("input[data-members-name]"), c = (null === r || void 0 === r || null === (n = r.dataset) || void 0 === n ? void 0 : n.membersAutoredirect) || "true", u = null === l || void 0 === l ? void 0 : l.value, p = s && s.value || void 0, d = void 0, f = [], h = t.target.querySelectorAll("input[data-members-label]") || [], m = 0; m < h.length; ++m)
f.push(h[m].value);
r.dataset.membersForm && (d = r.dataset.membersForm),
r.classList.add("loading");
var g = po(),
v = {
email: u,
emailType: d,
labels: f,
name: p,
autoRedirect: "true" === c
};
g && (v.urlHistory = g),
fetch("".concat(o, "/members/api/send-magic-link/"), {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(v)
}).then((function(e) {
if (r.addEventListener("submit", a), r.classList.remove("loading"), !e.ok)
return ss.fromApiResponse(e).then((function(e) {
throw e
}));
r.classList.add("success")
})).catch((function(e) {
i && (i.innerText = ss.getMessageFromError(e, "There was an error sending the email, please try again")),
r.classList.add("error")
}))
}({
event: I,
errorEl: t,
form: e,
siteUrl: n,
submitHandler: r
})
}))
I want to store it locally. I understand that this bit is a part of a larger function with paid members, Stripe, etc.
Is this the only piece of code I need to make “data-members-form” working?
Removing portal.min.js will not affect /ghost/#/signin page, right?
How can I achieve described above goals?