Merge branch 'main' into merge-alert-autofix-4-and-main

This commit is contained in:
pacnpal
2025-01-28 22:07:20 -05:00
committed by GitHub
4 changed files with 51 additions and 32 deletions

View File

@@ -14,7 +14,7 @@ RUN apt-get update && \
python3-pip \ python3-pip \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel && python3 -m pip install --no-cache-dir --upgrade "pip>=21.3" setuptools wheel
# Add architecture-specific compiler flags if needed # Add architecture-specific compiler flags if needed
ENV ARCHFLAGS="" ENV ARCHFLAGS=""
@@ -24,7 +24,7 @@ RUN mkdir -p /app/src/simpleguardhome && \
chmod -R 755 /app chmod -R 755 /app
# Copy source code, maintaining directory structure # Copy source code, maintaining directory structure
COPY setup.py requirements.txt /app/ COPY setup.py requirements.txt pyproject.toml /app/
COPY src /app/src/ COPY src /app/src/
# Set PYTHONPATH # Set PYTHONPATH
@@ -37,10 +37,8 @@ RUN pip install --no-cache-dir -r requirements.txt
RUN set -e && \ RUN set -e && \
echo "Installing package..." && \ echo "Installing package..." && \
pip uninstall -y simpleguardhome || true && \ pip uninstall -y simpleguardhome || true && \
# First install dependencies only # Install package in editable mode with compatibility mode enabled
pip install --no-deps -v -e . && \ pip install --use-pep517 -e . --config-settings editable_mode=compat && \
# Then install package with dependencies
pip install -e . && \
echo "Verifying installation..." && \ echo "Verifying installation..." && \
pip show simpleguardhome && \ pip show simpleguardhome && \
# List all package files # List all package files

29
pyproject.toml Normal file
View File

@@ -0,0 +1,29 @@
[build-system]
requires = ["setuptools>=64.0.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "simpleguardhome"
version = "0.1.0"
description = "SimpleGuardHome - A lightweight AdGuardHome UI"
authors = [
{name = "SimpleGuardHome Team"}
]
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.7"
dependencies = [
"fastapi",
"uvicorn",
"python-dotenv",
"httpx",
"pydantic",
"jinja2",
]
[tool.setuptools]
package-dir = {"" = "src"}
packages = {find = {where = ["src"]}}
[tool.setuptools.package-data]
simpleguardhome = ["templates/*", "favicon.ico"]

View File

@@ -1,22 +1,3 @@
from setuptools import setup, find_packages from setuptools import setup
from pathlib import Path
setup( setup()
name="simpleguardhome",
version="0.1.0",
packages=find_packages(where="src"),
package_dir={"": "src"},
include_package_data=True,
package_data={
"simpleguardhome": ["templates/*", "favicon.ico"]
},
python_requires=">=3.7",
install_requires=[
"fastapi",
"uvicorn",
"python-dotenv",
"httpx",
"pydantic",
"jinja2",
],
)

View File

@@ -4,7 +4,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SimpleGuardHome</title> <title>SimpleGuardHome</title>
<script src="https://cdn.tailwindcss.com"></script> <script src="https://unpkg.com/@tailwindcss/browser@4" integrity="sha384-fsXZ0Oru5QjGkveFx8DdmBAyKdwnJ7TnbRzDN5LROCKt8PAN8h7y7oqCwtk9cN68" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.3.4/purify.min.js" integrity="sha384-KGmzmwrs7oAU2sG5qfETslFsscVcCaxQrX2d7PW7I9bTrsuTD/eSMFr9jaMS9i+b" crossorigin="anonymous"></script>
<script> <script>
function escapeHtml(unsafe) { function escapeHtml(unsafe) {
return unsafe return unsafe
@@ -14,10 +15,20 @@
.replace(/"/g, "&quot;") .replace(/"/g, "&quot;")
.replace(/'/g, "&#039;"); .replace(/'/g, "&#039;");
} }
return unsafe.replace(/[&<"']/g, function (m) {
switch (m) {
case '&': return '&amp;';
case '<': return '&lt;';
case '>': return '&gt;';
case '"': return '&quot;';
case "'": return '&#039;';
default: return m;
}
});
}
async function checkDomain(event) { async function checkDomain(event) {
event.preventDefault(); event.preventDefault();
const domain = document.getElementById('domain').value; const domain = DOMPurify.sanitize(document.getElementById('domain').value);
const resultDiv = document.getElementById('result'); const resultDiv = document.getElementById('result');
const unblockDiv = document.getElementById('unblock-action'); const unblockDiv = document.getElementById('unblock-action');
const submitBtn = document.getElementById('submit-btn'); const submitBtn = document.getElementById('submit-btn');
@@ -69,7 +80,7 @@
resultDiv.innerHTML = ` resultDiv.innerHTML = `
<div class="bg-${bgColor}-100 border-l-4 border-${bgColor}-500 text-${bgColor}-700 p-4"> <div class="bg-${bgColor}-100 border-l-4 border-${bgColor}-500 text-${bgColor}-700 p-4">
<p class="font-bold">Error checking domain</p> <p class="font-bold">Error checking domain</p>
<p class="text-sm">${errorMsg}</p> <p class="text-sm">${escapeHtml(errorMsg)}</p>
</div>`; </div>`;
unblockDiv.innerHTML = ''; unblockDiv.innerHTML = '';
} }