mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-05 15:27:53 +10:00
Fix: Make CUSTOM_TEMPLATES_DIR configurable again
Resolves issue #1484 where CUSTOM_TEMPLATES_DIR configuration was being ignored. The setting was previously removed from ServerConfig and hardcoded as a constant, preventing users from customizing the templates directory location. Changes: - Added CUSTOM_TEMPLATES_DIR field to StorageConfig in common.py - Updated settings.py to use STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR - Updated paths.py to use configurable value in version output Users can now configure the custom templates directory via: - ArchiveBox.conf: CUSTOM_TEMPLATES_DIR = ./custom_templates - Environment variable: export CUSTOM_TEMPLATES_DIR=/path/to/templates - Defaults to DATA_DIR/user_templates if not configured 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Nick Sweeting <pirate@users.noreply.github.com>
This commit is contained in:
@@ -66,6 +66,10 @@ class StorageConfig(BaseConfigSet):
|
|||||||
# should not be a remote/network/FUSE mount for speed reasons, otherwise extractors will be slow
|
# should not be a remote/network/FUSE mount for speed reasons, otherwise extractors will be slow
|
||||||
LIB_DIR: Path = Field(default=CONSTANTS.DEFAULT_LIB_DIR)
|
LIB_DIR: Path = Field(default=CONSTANTS.DEFAULT_LIB_DIR)
|
||||||
|
|
||||||
|
# CUSTOM_TEMPLATES_DIR allows users to override default templates
|
||||||
|
# defaults to DATA_DIR / 'user_templates' but can be configured
|
||||||
|
CUSTOM_TEMPLATES_DIR: Path = Field(default=CONSTANTS.CUSTOM_TEMPLATES_DIR)
|
||||||
|
|
||||||
OUTPUT_PERMISSIONS: str = Field(default="644")
|
OUTPUT_PERMISSIONS: str = Field(default="644")
|
||||||
RESTRICT_FILE_NAMES: str = Field(default="windows")
|
RESTRICT_FILE_NAMES: str = Field(default="windows")
|
||||||
ENFORCE_ATOMIC_WRITES: bool = Field(default=True)
|
ENFORCE_ATOMIC_WRITES: bool = Field(default=True)
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ def get_data_locations():
|
|||||||
def get_code_locations():
|
def get_code_locations():
|
||||||
from archivebox.config import CONSTANTS
|
from archivebox.config import CONSTANTS
|
||||||
from archivebox.config.common import STORAGE_CONFIG
|
from archivebox.config.common import STORAGE_CONFIG
|
||||||
|
|
||||||
return benedict({
|
return benedict({
|
||||||
'PACKAGE_DIR': {
|
'PACKAGE_DIR': {
|
||||||
'path': (PACKAGE_DIR).resolve(),
|
'path': (PACKAGE_DIR).resolve(),
|
||||||
@@ -274,9 +274,9 @@ def get_code_locations():
|
|||||||
'is_valid': os.access(CONSTANTS.STATIC_DIR, os.R_OK) and os.access(CONSTANTS.STATIC_DIR, os.X_OK), # read + list
|
'is_valid': os.access(CONSTANTS.STATIC_DIR, os.R_OK) and os.access(CONSTANTS.STATIC_DIR, os.X_OK), # read + list
|
||||||
},
|
},
|
||||||
'CUSTOM_TEMPLATES_DIR': {
|
'CUSTOM_TEMPLATES_DIR': {
|
||||||
'path': CONSTANTS.CUSTOM_TEMPLATES_DIR.resolve(),
|
'path': STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR.resolve(),
|
||||||
'enabled': os.path.isdir(CONSTANTS.CUSTOM_TEMPLATES_DIR),
|
'enabled': os.path.isdir(STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR),
|
||||||
'is_valid': os.path.isdir(CONSTANTS.CUSTOM_TEMPLATES_DIR) and os.access(CONSTANTS.CUSTOM_TEMPLATES_DIR, os.R_OK), # read
|
'is_valid': os.path.isdir(STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR) and os.access(STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR, os.R_OK), # read
|
||||||
},
|
},
|
||||||
'USER_PLUGINS_DIR': {
|
'USER_PLUGINS_DIR': {
|
||||||
'path': CONSTANTS.USER_PLUGINS_DIR.resolve(),
|
'path': CONSTANTS.USER_PLUGINS_DIR.resolve(),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from django.utils.crypto import get_random_string
|
|||||||
import archivebox
|
import archivebox
|
||||||
|
|
||||||
from archivebox.config import DATA_DIR, PACKAGE_DIR, ARCHIVE_DIR, CONSTANTS # noqa
|
from archivebox.config import DATA_DIR, PACKAGE_DIR, ARCHIVE_DIR, CONSTANTS # noqa
|
||||||
from archivebox.config.common import SHELL_CONFIG, SERVER_CONFIG # noqa
|
from archivebox.config.common import SHELL_CONFIG, SERVER_CONFIG, STORAGE_CONFIG # noqa
|
||||||
|
|
||||||
|
|
||||||
IS_MIGRATING = "makemigrations" in sys.argv[:3] or "migrate" in sys.argv[:3]
|
IS_MIGRATING = "makemigrations" in sys.argv[:3] or "migrate" in sys.argv[:3]
|
||||||
@@ -116,9 +116,9 @@ AUTHENTICATION_BACKENDS = [
|
|||||||
|
|
||||||
STATIC_URL = "/static/"
|
STATIC_URL = "/static/"
|
||||||
TEMPLATES_DIR_NAME = "templates"
|
TEMPLATES_DIR_NAME = "templates"
|
||||||
CUSTOM_TEMPLATES_ENABLED = os.path.isdir(CONSTANTS.CUSTOM_TEMPLATES_DIR) and os.access(CONSTANTS.CUSTOM_TEMPLATES_DIR, os.R_OK)
|
CUSTOM_TEMPLATES_ENABLED = os.path.isdir(STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR) and os.access(STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR, os.R_OK)
|
||||||
STATICFILES_DIRS = [
|
STATICFILES_DIRS = [
|
||||||
*([str(CONSTANTS.CUSTOM_TEMPLATES_DIR / "static")] if CUSTOM_TEMPLATES_ENABLED else []),
|
*([str(STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR / "static")] if CUSTOM_TEMPLATES_ENABLED else []),
|
||||||
# *[
|
# *[
|
||||||
# str(plugin_dir / 'static')
|
# str(plugin_dir / 'static')
|
||||||
# for plugin_dir in PLUGIN_DIRS.values()
|
# for plugin_dir in PLUGIN_DIRS.values()
|
||||||
@@ -129,7 +129,7 @@ STATICFILES_DIRS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
TEMPLATE_DIRS = [
|
TEMPLATE_DIRS = [
|
||||||
*([str(CONSTANTS.CUSTOM_TEMPLATES_DIR)] if CUSTOM_TEMPLATES_ENABLED else []),
|
*([str(STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR)] if CUSTOM_TEMPLATES_ENABLED else []),
|
||||||
# *[
|
# *[
|
||||||
# str(plugin_dir / 'templates')
|
# str(plugin_dir / 'templates')
|
||||||
# for plugin_dir in PLUGIN_DIRS.values()
|
# for plugin_dir in PLUGIN_DIRS.values()
|
||||||
|
|||||||
Reference in New Issue
Block a user