Skip to content

Commit

Permalink
move footer quote into iframe...
Browse files Browse the repository at this point in the history
and block the iframe urls to avoid being indexed in search engines on pages randomly
  • Loading branch information
janoside committed Jul 18, 2021
1 parent e7d83bf commit 83ae26f
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 8 deletions.
10 changes: 9 additions & 1 deletion public/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ function copyTextToClipboard(text) {
navigator.clipboard.writeText(text).then(() => {}, (err) => {
console.error('Error copying text: ', err);
});
}
}

function iframeLoaded(iframeId) {
var iframeElement = document.getElementById(iframeId);

if (iframeElement) {
iframeElement.height = iframeElement.contentWindow.document.body.scrollHeight + "px";
}
}
3 changes: 2 additions & 1 deletion public/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Disallow: /rpc*
Disallow: /tx-stats
Disallow: /peers
Disallow: /mempool-transactions
Disallow: /block-analysis/
Disallow: /block-analysis/
Disallow: /snippet/
9 changes: 9 additions & 0 deletions routes/snippetRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const coins = require("./../app/coins.js");
const config = require("./../app/config.js");
const coreApi = require("./../app/api/coreApi.js");
const addressApi = require("./../app/api/addressApi.js");
const btcQuotes = require("./../app/coins/btcQuotes.js");

const forceCsrf = csurf({ ignoreMethods: [] });

Expand All @@ -34,5 +35,13 @@ router.get("/formatCurrencyAmount/:amt", function(req, res, next) {
next();
});

router.get("/quote/random", function(req, res, next) {
res.locals.quote = btcQuotes.items[utils.randomInt(0, btcQuotes.items.length)];

res.render("snippets/quote");

next();
});


module.exports = router;
112 changes: 112 additions & 0 deletions views/layout-minimal.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
doctype html
html(lang="en")
head
meta(charset="utf-8")
base(href=config.baseUrl)
meta(name="csrf-token", content=csrfToken)
meta(name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, shrink-to-fit=no")

meta(name="description" content="Open-source, easy-to-use, educational Bitcoin explorer whose only dependency is your Bitcoin Core node.")

if (!homepage)
link(rel="stylesheet", href="./style/highlight.min.css", integrity="sha384-s4RLYRjGGbVqKOyMGGwfxUTMOO6D7r2eom7hWZQ6BjK2Df4ZyfzLXEkonSm0KLIQ")


if (userSettings.uiTheme == "light")
link(rel="stylesheet", href="./style/light.css", integrity="")

else
link(rel="stylesheet", href="./style/dark.css", integrity="")


link(id="canonical" rel="canonical" href="https://bitcoinexplorer.org")

meta(property="og:title" content=(metaTitle != undefined ? metaTitle : "BitcoinExplorer.org - Open-Source Bitcoin Explorer"))
meta(property="og:description" content=(metaDesc != undefined ? metaDesc : "Open-source, easy-to-use, educational Bitcoin explorer whose only dependency is your Bitcoin Core node."))
meta(property="og:image" content="https://bitcoinexplorer.org/img/preview.png")

meta(property="twitter:card" content="summary_large_image")
meta(property="twitter:site" content="@BitcoinExplorer")
meta(property="twitter:creator" content="@BitcoinExplorer")
meta(property="twitter:title" content=(metaTitle != undefined ? metaTitle : "BitcoinExplorer.org"))
meta(property="twitter:description" content=(metaDesc != undefined ? metaDesc : "Open-source, easy-to-use, educational Bitcoin explorer whose only dependency is your Bitcoin Core node."))
meta(property="twitter:image:src" content=(metaImgUrl != undefined ? metaImgUrl : "https://bitcoinexplorer.org/img/preview.png"))
meta(property="twitter:domain" content="bitcoinexplorer.org")

link(rel="apple-touch-icon", sizes="180x180", href="./img/logo/apple-touch-icon.png")
link(rel="icon", type="image/png", sizes="32x32", href="./img/logo/favicon-32x32.png")
link(rel="icon", type="image/png", sizes="16x16", href="./img/logo/favicon-16x16.png")
link(rel="manifest", href="./img/logo/site.webmanifest")
link(rel="mask-icon", href="./img/logo/safari-pinned-tab.svg", color="#f7931a")
link(rel="shortcut icon", href="./img/logo/favicon.ico")
meta(name="apple-mobile-web-app-title", content="BTC Explorer")
meta(name="application-name", content="BTC Explorer")
meta(name="msapplication-TileColor", content="#022e70")
meta(name="msapplication-config", content="./img/logo/browserconfig.xml")
meta(name="theme-color" content="#022e70")

include includes/debug-overrides.pug

block headContent
title Explorer

include ./includes/shared-mixins.pug

body(style="background-color: transparent;")
div
div.px-2.px-sm-3
block content





script(src="./js/jquery.min.js", integrity="sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK")
script(src="./js/bootstrap.bundle.min.js", integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf")
script(defer, src="./js/fontawesome.min.js", integrity="sha384-haqrlim99xjfMxRP6EWtafs0sB1WKcMdynwZleuUSwJR0mDeRYbhtY+KPMr+JL6f")

script(src="./js/site.js", integrity="sha384-TXXIdJrESOEzST0SpP/wCosO/fLqaSAHzYEI1E8FmWaAinjJavL/3YuAvoC8+pCa")

script.
document.addEventListener("DOMContentLoaded", function(event) {
// enable tooltips everywhere
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});

// enable popovers everywhere
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl);
});
});

if (!homepage)
script(src="./js/highlight.pack.js", integrity="sha384-OGoFdvlhYqw3L+BFpHxdz5136RO9tUlt7OZ2qQZ0N6Z9Qqx0rCQBsg9ko7X4vC64")
script.
document.addEventListener("DOMContentLoaded", function(event) {
hljs.highlightAll();
});

if (process.env.BTCEXP_PLAUSIBLE_ANALYTICS_DOMAIN && process.env.BTCEXP_PLAUSIBLE_ANALYTICS_SCRIPT_URL)
script(async defer data-domain=process.env.BTCEXP_PLAUSIBLE_ANALYTICS_DOMAIN src=process.env.BTCEXP_PLAUSIBLE_ANALYTICS_SCRIPT_URL)



if (config.credentials.sentryUrl && config.credentials.sentryUrl.length > 0)
script(src="./js/sentry.min.js", integrity="sha384-da/Bo2Ah6Uw3mlhl6VINMblg2SyGbSnULKrukse3P5D9PTJi4np9HoKvR19D7zOL", crossorigin="anonymous")
script.
Sentry.init({ dsn: '#{config.credentials.sentryUrl}' });

if (config.credentials.googleAnalyticsTrackingId && config.credentials.googleAnalyticsTrackingId.trim().length > 0)
script(async, src=("https://www.googletagmanager.com/gtag/js?id=" + config.credentials.googleAnalyticsTrackingId))
script.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '#{config.credentials.googleAnalyticsTrackingId}');


block endOfBody
11 changes: 5 additions & 6 deletions views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ html(lang="en")

footer.footer.border-top.border-primary.bg-header-footer.pt-3.pb-1.px-3.text-white(style="border-width: 5px !important;")
.container
.row.mb-7
.row.mb-5
.col-7
.text-start
- var darkTheme = (userSettings.uiTheme == "dark");
Expand Down Expand Up @@ -258,10 +258,9 @@ html(lang="en")



if (footerQuote && !crawlerBot)
.text-center.mt-3.mb-4
+quote(footerQuote)

if (!crawlerBot)
.mb-4
iframe(id="quoteIframe", src="./snippet/quote/random", onload="iframeLoaded('quoteIframe');", scrolling="no", height="0", style="width: 100%;")

hr

Expand Down Expand Up @@ -332,7 +331,7 @@ html(lang="en")
script(src="./js/bootstrap.bundle.min.js", integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf")
script(defer, src="./js/fontawesome.min.js", integrity="sha384-haqrlim99xjfMxRP6EWtafs0sB1WKcMdynwZleuUSwJR0mDeRYbhtY+KPMr+JL6f")

script(src="./js/site.js", integrity="sha384-TXXIdJrESOEzST0SpP/wCosO/fLqaSAHzYEI1E8FmWaAinjJavL/3YuAvoC8+pCa")
script(src="./js/site.js", integrity="sha384-vm5VVZ5fSWCFr7otUJ12yWkTUm/K5stVNlqyPnievY00QK3UB72Dl19nS1oyKGeU")

script.
document.addEventListener("DOMContentLoaded", function(event) {
Expand Down
5 changes: 5 additions & 0 deletions views/snippets/quote.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends ../layout-minimal

block content
.text-center
+quote(quote)

0 comments on commit 83ae26f

Please sign in to comment.