Skip to content

Commit

Permalink
deploy: 796db16
Browse files Browse the repository at this point in the history
  • Loading branch information
pcraig3 committed Jun 21, 2023
1 parent be60788 commit ef9cc85
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 7 deletions.
3 changes: 2 additions & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ <h2 class="logo logo--footer"><a href="/">Federal Field Notes</a></h2>
</div>
</footer>


<script src="/js/email.js" defer=""></script>


</body></html>
2 changes: 1 addition & 1 deletion css/style.css

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions js/email.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* Obfuscate emails */

const obfuscateEmail = (node) => {
// Create a new element
const newNode = document.createElement("a");

if (node.dataset.email) {
// Preserve data attributes
newNode.dataset.email = node.dataset.email;
if (node.dataset.text) {
newNode.dataset.text = node.dataset.text;
}

// Get email and text
const email = atob(node.dataset.email);
const text = node.dataset.text || email.split("?")[0];

// Add dummy href and obfuscated email
newNode.setAttribute("href", "#");
// idea comes from https://mauriciorobayo.github.io/react-obfuscate-email/?path=/docs/react-obfuscate-email--mail
newNode.innerHTML = text.replaceAll("@", '<span class="roe"></span>');

newNode.addEventListener("mouseover", unobfuscateEmail, false);
newNode.addEventListener("focus", unobfuscateEmail, false);

node.replaceWith(newNode);
}
};

function unobfuscateEmail(event) {
const node = event.target;
if (node.dataset.email) {
// Get email and text
const email = atob(node.dataset.email);
const text = node.dataset.text || email.split("?")[0];

// Set real mailto attribute and content
node.setAttribute("href", "mailto:".concat(email));
node.innerText = text;
}
}

document.addEventListener("DOMContentLoaded", function () {
// Loop through all elements with "email--swap" classname
var nodes = document.getElementsByClassName("email--swap");
while (nodes.length) {
obfuscateEmail(nodes[0]);
}
});
5 changes: 3 additions & 2 deletions pages/about/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ <h3 id="i-have-a-comment-about-" tabindex="-1"><a class="header-anchor" href="#i
<h3 id="what-are-you-hoping-to-achieve-by-this" tabindex="-1"><a class="header-anchor" href="#what-are-you-hoping-to-achieve-by-this"><span>“What are you hoping to achieve by this?”</span></a></h3>
<p>The goal was always that you would end up on this About page.</p>
<h3 id="i-have-a-great-idea-can-i-contribute-a-post" tabindex="-1"><a class="header-anchor" href="#i-have-a-great-idea-can-i-contribute-a-post"><span>“I have a great idea. Can I contribute a post?”</span></a></h3>
<p>Email me.</p>
<p>Email me: <span class="email--swap" data-email="cGF1bEBwY3JhaWcuY2E=">“paul [a] pcraig [dot] ca”</span></p>
<h3 id="why-a-newsletter" tabindex="-1"><a class="header-anchor" href="#why-a-newsletter"><span>Why a newsletter?</span></a></h3>
<p>It sounds more serious than saying “it’s a blog”.</p>
<h3 id="why-is-it-called-federal-field-notes" tabindex="-1"><a class="header-anchor" href="#why-is-it-called-federal-field-notes"><span>Why is it called “Federal Field Notes”?</span></a></h3>
Expand Down Expand Up @@ -188,6 +188,7 @@ <h2 class="logo logo--footer"><a href="/">Federal Field Notes</a></h2>
</div>
</footer>


<script src="/js/email.js" defer=""></script>


</body></html>
5 changes: 3 additions & 2 deletions pages/contact/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h1 tabindex="-1">Contact</h1>
<p>Hello! I am humbled and delighted by your interest in my writing slash youthful temerity.</p>
<p>Fortunately, I am pretty contactable:</p>
<ul>
<li>email <a href="mailto:paul@pcraig3.ca">paul@pcraig3.ca</a></li>
<li>email <span class="email--swap" data-email="cGF1bEBwY3JhaWcuY2E=">paul [a] pcraig [dot] ca”</span></li>
<li>tweet <a href="https://twitter.com/pcraig3" target="_blank" rel="noopener external">@pcraig3</a></li>
<li>hang around <a href="https://www.google.com/maps/place/Starbucks/@45.4190313,-75.6938579,17z/data=!3m1!5s0x4cce05abd71952f9:0xda669a6c79dbcdbc!4m12!1m6!3m5!1s0x4cce05019604f58f:0x3f2b0767e2ba86b2!2sStarbucks!8m2!3d45.4190683!4d-75.6915809!3m4!1s0x4cce05019604f58f:0x3f2b0767e2ba86b2!8m2!3d45.4190683!4d-75.6915809" target="_blank" rel="nofollow noopener external">the starbucks at Elgin and Lisgar</a> long enough</li>
</ul>
Expand Down Expand Up @@ -169,6 +169,7 @@ <h2 class="logo logo--footer"><a href="/">Federal Field Notes</a></h2>
</div>
</footer>


<script src="/js/email.js" defer=""></script>


</body></html>
2 changes: 1 addition & 1 deletion sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<changefreq>monthly</changefreq>
</url><url>
<loc>https://federal-field-notes.ca/404.html</loc>
<lastmod>2023-02-10T02:43:42.203Z</lastmod>
<lastmod>2023-06-21T21:44:03.542Z</lastmod>
<changefreq>monthly</changefreq>
</url>
</urlset>

0 comments on commit ef9cc85

Please sign in to comment.