Compare commits
No commits in common. "64d01a9b45cc5861fbb77d6976da559b300e17bc" and "4ab42f95433ad2058140ffd286a9534e9fb21eb7" have entirely different histories.
64d01a9b45
...
4ab42f9543
8 changed files with 53 additions and 140 deletions
21
.idea/inspectionProfiles/Project_Default.xml
generated
21
.idea/inspectionProfiles/Project_Default.xml
generated
|
@ -1,21 +0,0 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="HtmlUnknownTag" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="myValues">
|
||||
<value>
|
||||
<list size="7">
|
||||
<item index="0" class="java.lang.String" itemvalue="nobr" />
|
||||
<item index="1" class="java.lang.String" itemvalue="noembed" />
|
||||
<item index="2" class="java.lang.String" itemvalue="comment" />
|
||||
<item index="3" class="java.lang.String" itemvalue="noscript" />
|
||||
<item index="4" class="java.lang.String" itemvalue="embed" />
|
||||
<item index="5" class="java.lang.String" itemvalue="script" />
|
||||
<item index="6" class="java.lang.String" itemvalue="oom-comments" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myCustomValuesEnabled" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
25
.idea/jsonSchemas.xml
generated
25
.idea/jsonSchemas.xml
generated
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JsonSchemaMappingsProjectConfiguration">
|
||||
<state>
|
||||
<map>
|
||||
<entry key="Azure Static Web Apps configuration file">
|
||||
<value>
|
||||
<SchemaInfo>
|
||||
<option name="name" value="Azure Static Web Apps configuration file" />
|
||||
<option name="relativePathToSchema" value="https://www.schemastore.org/staticwebapp.config.json" />
|
||||
<option name="applicationDefined" value="true" />
|
||||
<option name="patterns">
|
||||
<list>
|
||||
<Item>
|
||||
<option name="path" value="staticwebapp.config.json" />
|
||||
</Item>
|
||||
</list>
|
||||
</option>
|
||||
</SchemaInfo>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</state>
|
||||
</component>
|
||||
</project>
|
1
.idea/mercury.iml
generated
1
.idea/mercury.iml
generated
|
@ -10,6 +10,5 @@
|
|||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="n20171213" level="application" />
|
||||
</component>
|
||||
</module>
|
|
@ -234,9 +234,6 @@ const domain = Astro.url.host
|
|||
|
||||
// Initialize with default config
|
||||
initSearch();
|
||||
|
||||
// Re-initialize when Astro's view transitions occur, this provides fix for SPA navigation
|
||||
document.addEventListener('astro:page-load', initSearch);
|
||||
</script>}
|
||||
|
||||
<style>
|
||||
|
|
|
@ -8,11 +8,7 @@ const ArtalkInstanceDomain = siteConfig.comments.artalk.instanceDomain
|
|||
<div id="comments" data-path={Astro.url.pathname} data-server={ArtalkInstanceDomain}></div>
|
||||
<script>
|
||||
import Artalk from "artalk";
|
||||
|
||||
function initArtalk() {
|
||||
const atkElement = document.querySelector('#comments');
|
||||
|
||||
if (!atkElement) return;
|
||||
Artalk.init({
|
||||
el: '#comments',
|
||||
pageKey: atkElement?.getAttribute('data-path') || window.location.pathname,
|
||||
|
@ -20,14 +16,5 @@ const ArtalkInstanceDomain = siteConfig.comments.artalk.instanceDomain
|
|||
darkMode: "auto",
|
||||
versionCheck: false
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', initArtalk);
|
||||
|
||||
// Re-initialize on view transitions, fix issues with Astro's ClientRouter
|
||||
document.addEventListener('astro:page-load', () => {
|
||||
initArtalk();
|
||||
});
|
||||
</script>
|
||||
</div>
|
|
@ -54,34 +54,25 @@ const { encryptedData, iv } = encrypt(content, password);
|
|||
</style>
|
||||
|
||||
<script>
|
||||
// Define the function that sets up the decryption logic
|
||||
function setupDecryption() {
|
||||
// Client-side decryption logic
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const containers = document.querySelectorAll('.encrypted-content');
|
||||
|
||||
containers.forEach(container => {
|
||||
const encryptedData = container.getAttribute('data-encrypted');
|
||||
const iv = container.getAttribute('data-iv');
|
||||
const passwordInput = container.querySelector<HTMLInputElement>('.decrypt-password');
|
||||
const decryptButton = container.querySelector<HTMLButtonElement>('.decrypt-button');
|
||||
const contentContainer = container.querySelector<HTMLDivElement>('.content-container');
|
||||
const passwordForm = container.querySelector<HTMLDivElement>('.password-form');
|
||||
|
||||
if (!encryptedData || !iv || !passwordInput || !decryptButton || !contentContainer || !passwordForm) {
|
||||
console.error('Missing required elements for decryption');
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip if already initialized to prevent duplicate event listeners
|
||||
if (container.getAttribute("initialized") === 'true') {
|
||||
return;
|
||||
}
|
||||
const passwordInput = container.querySelector('.decrypt-password');
|
||||
const decryptButton = container.querySelector('.decrypt-button');
|
||||
const contentContainer = container.querySelector('.content-container');
|
||||
const passwordForm = container.querySelector('.password-form');
|
||||
|
||||
decryptButton.addEventListener('click', async () => {
|
||||
try {
|
||||
const password = passwordInput.value;
|
||||
if (!password) return;
|
||||
|
||||
contentContainer.innerHTML = await decrypt(encryptedData, iv, password);
|
||||
const content = await decrypt(encryptedData, iv, password);
|
||||
contentContainer.innerHTML = content;
|
||||
contentContainer.classList.remove('hidden');
|
||||
passwordForm.classList.add('hidden');
|
||||
} catch (error) {
|
||||
|
@ -91,18 +82,14 @@ const { encryptedData, iv } = encrypt(content, password);
|
|||
});
|
||||
|
||||
// Allow pressing Enter to decrypt
|
||||
passwordInput.addEventListener('keydown', (e: KeyboardEvent) => {
|
||||
passwordInput.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
decryptButton.click();
|
||||
}
|
||||
});
|
||||
|
||||
// Mark as initialized to prevent duplicate event listeners
|
||||
container.setAttribute("initialized", 'true');
|
||||
});
|
||||
}
|
||||
|
||||
async function decrypt(encryptedData: string, iv: string, password: string): Promise<string> {
|
||||
async function decrypt(encryptedData, iv, password) {
|
||||
// Convert base64 to array buffer
|
||||
const encryptedBytes = Uint8Array.from(atob(encryptedData), c => c.charCodeAt(0));
|
||||
const ivBytes = Uint8Array.from(atob(iv), c => c.charCodeAt(0));
|
||||
|
@ -142,10 +129,5 @@ const { encryptedData, iv } = encrypt(content, password);
|
|||
const decoder = new TextDecoder();
|
||||
return decoder.decode(decryptedBytes);
|
||||
}
|
||||
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', setupDecryption);
|
||||
|
||||
// Re-initialize when Astro's view transitions occur, this provides fix for SPA navigation
|
||||
document.addEventListener('astro:page-load', setupDecryption);
|
||||
});
|
||||
</script>
|
|
@ -9,7 +9,6 @@ export const siteConfig = {
|
|||
email: 'hi@mercury.info',
|
||||
},
|
||||
// features
|
||||
spa: false, // enable single page application mode, this will enable navigation (with fade transitions) without reloading the page, and enable client-side routing
|
||||
noClientJavaScript: false, // disable client-side javascript, this will:
|
||||
// 1. disable most built-in client-side javascript from rendering (protected content component and umami still needs javascript to function, sorry)
|
||||
// 2. the full text search will be redirected to a search engine
|
||||
|
|
|
@ -19,9 +19,6 @@ interface Props {
|
|||
ogImage?: string;
|
||||
}
|
||||
|
||||
import { ClientRouter } from "astro:transitions";
|
||||
const spaEnabled = siteConfig.spa
|
||||
|
||||
const noscript = siteConfig.noClientJavaScript
|
||||
|
||||
const statisticsEnabled = siteConfig.siteAnalytics.enabled
|
||||
|
@ -47,8 +44,6 @@ const { title = pageTitle, author = siteConfig.defaultAuthor.name,description =
|
|||
<meta name="generator" content={Astro.generator} />
|
||||
<Meta title={pageTitle} author={author} description={description} ogImage={ogImage} />
|
||||
<title>{pageTitle}</title>
|
||||
{spaEnabled && <ClientRouter fallback="animate" />}
|
||||
<!--transitional animation is broken in firefox though-->
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue