Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/cloudflare/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Error - Blocked from HathiTrust</title>
<style>
@font-face {
font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
font-family: 'Mulish';
font-style: normal;
font-weight: 400;
src: url('/common/firebird/dist/fonts/mulish-v12-cyrillic_cyrillic-ext_latin_latin-ext_vietnamese-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
body {
height: 100vh;
width: 100vw;
padding-inline-start:1rem;
font-family: 'Mulish', sans-serif;
}
h1 {
font-size: 2rem;
line-height: 1.19
}
h2 {
font-size: 1.75rem;
line-height: 1.21
}
h3 {
font-size: 1.125rem;
line-height: 1.31
}
img {
height: 4.5rem;
width: auto;
padding-block-start: 1em;
}
.col {
max-width: 600px;
margin-inline-end: 2rem;
margin-top: 1.5rem;
/* padding:.5rem 1rem 1rem 1rem;
border: 1px solid #e4e4e4;
border-radius: .5rem;
background: #f8f8f8; */
}
p {
text-wrap: balance;
}
</style>
</head>
<body>
<img src="https://babel.hathitrust.org/common/firebird/dist/hathitrust-logo-horizontal-orange-gray.svg" />
<h1>Sorry, you have been blocked</h1>
<h2>You are unable to access hathitrust.org</h2>
<div class="col">
<h3>Why have I been blocked?</h3>
<p>This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.</p>
</div>
<div class="col">
<h3>What can I do to resolve this?</h3>
<p>You can e-mail HathiTrust Support at <a href="mailto:support@hathitrust.org">support@hathitrust.org</a>. Please include what you were doing when this page came up and provide these details:<p>
<ul>
<li>IP address: ::CLIENT_IP::</li>
<li>Cloudflare Ray ID: ::RAY_ID::</li>
</ul>
</div>
</body>
</html>
22 changes: 19 additions & 3 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import fs from 'fs';

// Find all HTML files and build an object of names and paths to work from
const files = glob
.sync(path.resolve(__dirname, 'src') + '/**/*.html')
.sync(path.resolve(__dirname, 'src') + '/**/*.html', { ignore: [(path.resolve(__dirname, 'src') + '/coverage')] })
.reduce((acc, cur) => {
// we want to keep the path
let name = cur
Expand All @@ -18,7 +18,7 @@ const files = glob
.replace('/', '-');

// let name = path.basename(cur, '.html');
console.log(name, '->', cur);
// console.log(name, '->', cur);

acc[name] = cur;
return acc;
Expand All @@ -31,6 +31,17 @@ const scssOptions = {
// scssOptions.additionalData = `$firebird-font-path: "//localhost:5173"; $fa-font-path: "//localhost:5173/fonts";`;
// }

const removeStylesheet = () => {
return {
name: 'remove-stylesheet',
enforce: 'post',
apply: 'build',
transformIndexHtml(html) {
return html.replaceAll(/<link\s+rel="stylesheet"(\s.*\s)href="(.*)\.css">/gi, "");
},
}
}

export default defineConfig({
plugins: [
svelte({
Expand All @@ -42,7 +53,7 @@ export default defineConfig({
{
name: 'postbuild-commands',
closeBundle: () => {
const path = './dist/manifest.json';
const path = 'dist/manifest.json';
const manifest = JSON.parse(fs.readFileSync(path).toString());
if (manifest['style.css']) {
const newKey = 'index.css';
Expand All @@ -53,6 +64,7 @@ export default defineConfig({
}
}
},
removeStylesheet()
],
root: path.resolve(__dirname, 'src'),
publicDir: 'public',
Expand All @@ -64,6 +76,10 @@ export default defineConfig({
//renames the style asset file to index
//hopefully temporary workaround until we can upgrade to svelte 5/vite 6
rollupOptions: {
input: {
index: path.resolve(__dirname, 'src/index.html'),
cloudflare: path.resolve(__dirname, 'src/cloudflare/index.html'),
},
output: {
assetFileNames: (assetInfo) => {
if (assetInfo.name == 'style.css') {
Expand Down
Loading