lib.itmens/boofilsic/settings.py

544 lines
18 KiB
Python
Raw Normal View History

2020-05-01 22:46:15 +08:00
import os
2022-12-09 19:38:11 -05:00
import environ
2023-07-20 21:59:49 -04:00
2023-11-19 10:59:51 -05:00
from boofilsic import __version__
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
try:
with open(os.path.join(BASE_DIR, "build_version")) as f:
NEODB_VERSION = __version__ + "-" + f.read().strip()
except:
2023-12-01 17:29:40 -05:00
NEODB_VERSION = __version__ + "-unknown"
2023-11-19 10:59:51 -05:00
2023-08-24 05:48:14 +00:00
2023-09-25 19:47:46 +00:00
# Parse configuration from:
# - environment variables
# - neodb.env file in project root directory
# - /etc/neodb.env
environ.Env.read_env("/etc/neodb.env")
environ.Env.read_env(os.path.join(BASE_DIR, "neodb.env"))
2023-09-25 19:47:46 +00:00
# ====== List of user configuration variables ======
env = environ.FileAwareEnv(
# WARNING: do not run with debug mode turned on in production
2023-09-25 23:22:34 +00:00
NEODB_DEBUG=(bool, True),
2023-09-25 19:47:46 +00:00
# WARNING: must use your own key and keep it secret
NEODB_SECRET_KEY=(str),
# Site information
NEODB_SITE_NAME=(str),
NEODB_SITE_DOMAIN=(str),
NEODB_SITE_LOGO=(str, "/s/img/logo.svg"),
NEODB_SITE_ICON=(str, "/s/img/logo.svg"),
NEODB_USER_ICON=(str, "/s/img/avatar.svg"),
NEODB_SITE_INTRO=(str, ""),
2023-12-01 18:09:49 -05:00
NEODB_SITE_HEAD=(str, ""),
2023-09-25 19:47:46 +00:00
# Links in site footer
NEODB_SITE_LINKS=(dict, {}),
# Invite only mode
# when True: user will not be able to register unless with invite token
# (generated by `neodb-manage invite --create`)
NEODB_INVITE_ONLY=(bool, False),
# Mastodon/Pleroma instance allowed to login, keep empty to allow any instance to login
NEODB_LOGIN_MASTODON_WHITELIST=(list, []),
# DATABASE
NEODB_DB_URL=(str, "postgres://user:pass@127.0.0.1:5432/neodb"),
# Redis, for cache and job queue
NEODB_REDIS_URL=(str, "redis://127.0.0.1:6379/0"),
# Search backend, in one of these formats:
# typesense://user:insecure@127.0.0.1:8108/catalog
NEODB_SEARCH_URL=(str, ""),
# EMAIL CONFIGURATION, in one of these formats:
# "smtp://<username>:<password>@<host>:<port>"
# "smtp+tls://<username>:<password>@<host>:<port>"
# "smtp+ssl://<username>:<password>@<host>:<port>"
# "anymail://<anymail_backend_name>?<anymail_args>"
NEODB_EMAIL_URL=(str, ""),
# EMAIL FROM
NEODB_EMAIL_FROM=(str, "🧩 NeoDB <no-reply@neodb.social>"),
# ADMIN_USERS
NEODB_ADMIN_USERNAMES=(list, []),
# List of available proxies for proxy downloader, in format of http://server1?url=__URL__,http://s2?url=__URL__,...
NEODB_DOWNLOADER_PROXY_LIST=(list, []),
# Timeout of downloader requests, in seconds
NEODB_DOWNLOADER_REQUEST_TIMEOUT=(int, 90),
# Timeout of downloader cache, in seconds
NEODB_DOWNLOADER_CACHE_TIMEOUT=(int, 300),
# Number of retries of downloader, when site is using RetryDownloader
NEODB_DOWNLOADER_RETRIES=(int, 3),
2023-11-22 20:55:45 -05:00
# Disable cron jobs
NEODB_DISABLE_CRON=(bool, False),
2023-09-25 19:47:46 +00:00
# INTEGRATED TAKAHE CONFIGURATION
TAKAHE_DB_URL=(str, "postgres://takahe:takahepass@127.0.0.1:5432/takahe"),
# Spotify - https://developer.spotify.com/
2023-09-25 23:22:34 +00:00
SPOTIFY_API_KEY=(str, "TESTONLY"),
2023-09-25 19:47:46 +00:00
# The Movie Database (TMDB) - https://developer.themoviedb.org/
2023-09-25 23:22:34 +00:00
TMDB_API_V3_KEY=(str, "TESTONLY"),
2023-09-25 19:47:46 +00:00
# Google Books - https://developers.google.com/books/docs/v1/using - not used at the moment
2023-09-25 23:22:34 +00:00
GOOGLE_API_KEY=(str, "TESTONLY"),
2023-09-25 19:47:46 +00:00
# Discogs - personal access token from https://www.discogs.com/settings/developers
2023-09-25 23:22:34 +00:00
DISCOGS_API_KEY=(str, "TESTONLY"),
2023-09-25 19:47:46 +00:00
# IGDB - https://api-docs.igdb.com/
2023-09-25 23:22:34 +00:00
IGDB_API_CLIENT_ID=(str, "TESTONLY"),
IGDB_API_CLIENT_SECRET=(str, ""),
2023-09-25 19:47:46 +00:00
# Discord webhooks
DISCORD_WEBHOOKS=(dict, {"user-report": None}),
# Slack API token, for sending exceptions to Slack, may deprecate in future
SLACK_API_TOKEN=(str, ""),
# SSL only, better be True for production security
SSL_ONLY=(bool, False),
2023-11-21 00:49:42 -05:00
NEODB_SENTRY_DSN=(str, ""),
2023-11-23 10:11:42 -05:00
NEODB_FANOUT_LIMIT_DAYS=(int, 9),
NEODB_FORCE_CLASSIC_REPOST=(bool, False),
2023-09-25 19:47:46 +00:00
)
2023-08-24 05:48:14 +00:00
2023-09-25 19:47:46 +00:00
# ====== End of user configuration variables ======
2023-08-24 05:48:14 +00:00
2023-09-25 19:47:46 +00:00
SECRET_KEY = env("NEODB_SECRET_KEY")
DEBUG = env("NEODB_DEBUG")
2023-08-24 05:48:14 +00:00
DATABASES = {
2023-09-25 19:47:46 +00:00
"default": env.db_url("NEODB_DB_URL"),
"takahe": env.db_url("TAKAHE_DB_URL"),
2023-08-24 05:48:14 +00:00
}
2023-09-25 19:47:46 +00:00
DATABASES["default"]["OPTIONS"] = {"client_encoding": "UTF8"}
DATABASES["default"]["TEST"] = {"DEPENDENCIES": ["takahe"]}
DATABASES["takahe"]["OPTIONS"] = {"client_encoding": "UTF8"}
DATABASES["takahe"]["TEST"] = {"DEPENDENCIES": []}
REDIS_URL = env("NEODB_REDIS_URL")
2023-09-25 19:47:46 +00:00
CACHES = {"default": env.cache_url("NEODB_REDIS_URL")}
_parsed_redis_url = env.url("NEODB_REDIS_URL")
RQ_QUEUES = {
q: {
"HOST": _parsed_redis_url.hostname,
"PORT": _parsed_redis_url.port,
"DB": _parsed_redis_url.path[1:],
"DEFAULT_TIMEOUT": -1,
}
2023-10-21 05:41:38 +00:00
for q in ["mastodon", "export", "import", "fetch", "crawl", "ap", "cron"]
2023-08-24 05:48:14 +00:00
}
2023-09-25 19:47:46 +00:00
_parsed_search_url = env.url("NEODB_SEARCH_URL")
SEARCH_BACKEND = None
TYPESENSE_CONNECTION = {}
if _parsed_search_url.scheme == "typesense":
SEARCH_BACKEND = "TYPESENSE"
TYPESENSE_CONNECTION = {
"api_key": _parsed_search_url.password,
"nodes": [
{
"host": _parsed_search_url.hostname,
"port": _parsed_search_url.port,
"protocol": "http",
}
],
"connection_timeout_seconds": 2,
}
TYPESENSE_INDEX_NAME = _parsed_search_url.path[1:]
# elif _parsed_search_url.scheme == "meilisearch":
# SEARCH_BACKEND = 'MEILISEARCH'
# MEILISEARCH_SERVER = 'http://127.0.0.1:7700'
# MEILISEARCH_KEY = _parsed_search_url.password
DEFAULT_FROM_EMAIL = env("NEODB_EMAIL_FROM")
_parsed_email_url = env.url("NEODB_EMAIL_URL")
if _parsed_email_url.scheme == "anymail":
# "anymail://<anymail_backend_name>?<anymail_args>"
# see https://anymail.dev/
from urllib import parse
EMAIL_BACKEND = _parsed_email_url.hostname
ANYMAIL = dict(parse.parse_qsl(_parsed_email_url.query))
elif _parsed_email_url.scheme:
_parsed_email_config = env.email("NEODB_EMAIL_URL")
EMAIL_TIMEOUT = 5
vars().update(_parsed_email_config)
SITE_DOMAIN = env("NEODB_SITE_DOMAIN")
2023-08-24 05:48:14 +00:00
SITE_INFO = {
2023-12-01 17:29:40 -05:00
"neodb_version": NEODB_VERSION,
2023-09-25 19:47:46 +00:00
"site_name": env("NEODB_SITE_NAME"),
2023-08-24 05:48:14 +00:00
"site_domain": SITE_DOMAIN,
2023-09-25 19:47:46 +00:00
"site_url": env("NEODB_SITE_URL", default="https://" + SITE_DOMAIN),
"site_logo": env("NEODB_SITE_LOGO"),
"site_icon": env("NEODB_SITE_ICON"),
"user_icon": env("NEODB_USER_ICON"),
"site_intro": env("NEODB_SITE_INTRO"),
2023-12-01 18:09:49 -05:00
"site_head": env("NEODB_SITE_HEAD"),
2023-09-25 19:47:46 +00:00
"site_links": [{"title": k, "url": v} for k, v in env("NEODB_SITE_LINKS").items()],
2023-08-24 05:48:14 +00:00
}
2023-09-25 19:47:46 +00:00
SETUP_ADMIN_USERNAMES = env("NEODB_ADMIN_USERNAMES")
2023-08-24 05:48:14 +00:00
2023-09-25 19:47:46 +00:00
INVITE_ONLY = env("NEODB_INVITE_ONLY")
2023-08-24 05:48:14 +00:00
# By default, NeoDB will relay with relay.neodb.net so that public user ratings/etc can be shared across instances
# If you are running a development server, set this to True to disable this behavior
2023-09-25 19:47:46 +00:00
DISABLE_DEFAULT_RELAY = env("NEODB_DISABLE_DEFAULT_RELAY", default=DEBUG)
2023-09-25 19:47:46 +00:00
MASTODON_ALLOWED_SITES = env("NEODB_LOGIN_MASTODON_WHITELIST")
2023-08-24 05:48:14 +00:00
# Allow user to create account with email (and link to Mastodon account later)
2023-09-25 19:47:46 +00:00
ALLOW_EMAIL_ONLY_ACCOUNT = env.bool(
"NEODB_LOGIN_ENABLE_EMAIL_ONLY",
default=(_parsed_email_url.scheme and len(MASTODON_ALLOWED_SITES) == 0), # type: ignore
)
# Allow user to login via any Mastodon/Pleroma sites
MASTODON_ALLOW_ANY_SITE = len(MASTODON_ALLOWED_SITES) == 0
REDIRECT_URIS = env(
"NEODB_LOGIN_MASTODON_REDIRECT_URI",
default=SITE_INFO["site_url"] + "/account/login/oauth",
)
# for sites migrated from previous version, either wipe mastodon client ids or use:
# REDIRECT_URIS = f'{SITE_INFO["site_url"]}/users/OAuth2_login/'
2023-08-24 05:48:14 +00:00
# Timeout of requests to Mastodon, in seconds
2023-09-25 19:47:46 +00:00
MASTODON_TIMEOUT = env("NEODB_LOGIN_MASTODON_TIMEOUT", default=10) # type: ignore
2023-11-26 17:23:53 -05:00
TAKAHE_REMOTE_TIMEOUT = MASTODON_TIMEOUT
NEODB_USER_AGENT = f"NeoDB/{NEODB_VERSION} (+{SITE_INFO.get('site_url', 'undefined')})"
TAKAHE_USER_AGENT = NEODB_USER_AGENT
2023-08-24 05:48:14 +00:00
2023-09-25 19:47:46 +00:00
# Scope when creating Mastodon apps
# Alternatively, use "read write follow" to avoid re-authorize when migrating to a future version with more features
MASTODON_CLIENT_SCOPE = env(
"NEODB_MASTODON_CLIENT_SCOPE",
default="read:accounts read:follows read:search read:blocks read:mutes write:statuses write:media", # type: ignore
)
2023-08-24 05:48:14 +00:00
# some Mastodon-compatible software like Pixelfed does not support granular scopes
MASTODON_LEGACY_CLIENT_SCOPE = "read write follow"
# Emoji code in mastodon
STAR_SOLID = ":star_solid:"
STAR_HALF = ":star_half:"
STAR_EMPTY = ":star_empty:"
2023-09-25 19:47:46 +00:00
DISCORD_WEBHOOKS = env("DISCORD_WEBHOOKS")
SPOTIFY_CREDENTIAL = env("SPOTIFY_API_KEY")
TMDB_API3_KEY = env("TMDB_API_V3_KEY")
# TMDB_API4_KEY = env('TMDB_API_V4_KEY')
# GOOGLE_API_KEY = env('GOOGLE_API_KEY')
DISCOGS_API_KEY = env("DISCOGS_API_KEY")
2023-09-25 23:22:34 +00:00
IGDB_CLIENT_ID = env("IGDB_API_CLIENT_ID")
IGDB_CLIENT_SECRET = env("IGDB_API_CLIENT_SECRET")
2023-09-25 19:47:46 +00:00
SLACK_TOKEN = env("SLACK_API_TOKEN")
SLACK_CHANNEL = "alert"
DOWNLOADER_PROXY_LIST = env("NEODB_DOWNLOADER_PROXY_LIST")
DOWNLOADER_BACKUP_PROXY = env("NEODB_DOWNLOADER_BACKUP_PROXY", default="") # type: ignore
DOWNLOADER_REQUEST_TIMEOUT = env("NEODB_DOWNLOADER_REQUEST_TIMEOUT")
DOWNLOADER_CACHE_TIMEOUT = env("NEODB_DOWNLOADER_CACHE_TIMEOUT")
DOWNLOADER_RETRIES = env("NEODB_DOWNLOADER_RETRIES")
2023-08-24 05:48:14 +00:00
2023-11-22 20:55:45 -05:00
DISABLE_CRON = env("NEODB_DISABLE_CRON")
2023-11-23 10:11:42 -05:00
FANOUT_LIMIT_DAYS = env("NEODB_FANOUT_LIMIT_DAYS")
FORCE_CLASSIC_REPOST = env("NEODB_FORCE_CLASSIC_REPOST")
2023-08-24 05:48:14 +00:00
# ====== USER CONFIGUTRATION END ======
2023-07-20 21:59:49 -04:00
DATABASE_ROUTERS = ["takahe.db_routes.TakaheRouter"]
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# for legacy deployment:
# DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
2020-05-01 22:46:15 +08:00
2023-01-02 00:03:13 -05:00
ALLOWED_HOSTS = ["*"]
2020-05-01 22:46:15 +08:00
2021-02-25 19:49:50 +01:00
# To allow debug in template context
# https://docs.djangoproject.com/en/3.1/ref/settings/#internal-ips
2023-01-02 00:03:13 -05:00
INTERNAL_IPS = ["127.0.0.1"]
2020-05-01 22:46:15 +08:00
# Application definition
INSTALLED_APPS = [
2023-07-08 17:58:45 -04:00
# "maintenance_mode", # this has to be first if enabled
2023-01-02 00:03:13 -05:00
"django.contrib.admin",
"hijack",
"hijack.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.humanize",
"django.contrib.postgres",
"django_rq",
2023-01-26 17:31:20 -05:00
"django_bleach",
"django_jsonform",
2023-01-10 22:36:13 -05:00
"tz_detect",
"sass_processor",
2023-06-18 23:13:30 -04:00
"auditlog",
2023-01-02 00:03:13 -05:00
"markdownx",
2023-01-11 00:55:56 -05:00
"polymorphic",
"easy_thumbnails",
"user_messages",
"corsheaders",
2023-09-25 19:47:46 +00:00
"anymail",
2023-07-08 17:58:45 -04:00
# "silk",
2023-01-11 00:55:56 -05:00
]
INSTALLED_APPS += [
2023-01-02 00:03:13 -05:00
"management.apps.ManagementConfig",
"mastodon.apps.MastodonConfig",
"common.apps.CommonConfig",
"users.apps.UsersConfig",
"catalog.apps.CatalogConfig",
"journal.apps.JournalConfig",
"social.apps.SocialConfig",
2023-06-21 08:36:30 -04:00
"developer.apps.DeveloperConfig",
2023-07-20 21:59:49 -04:00
"takahe.apps.TakaheConfig",
2023-01-02 00:03:13 -05:00
"legacy.apps.LegacyConfig",
2023-01-11 00:55:56 -05:00
]
2023-06-27 23:11:20 -04:00
INSTALLED_APPS += [ # we may override templates in these 3rd party apps
"oauth2_provider",
]
2020-05-01 22:46:15 +08:00
MIDDLEWARE = [
2023-01-02 00:03:13 -05:00
"django.middleware.security.SecurityMiddleware",
2023-07-08 17:58:45 -04:00
# "silk.middleware.SilkyMiddleware",
2023-01-02 00:03:13 -05:00
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware",
2023-01-02 00:03:13 -05:00
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"oauth2_provider.middleware.OAuth2TokenMiddleware",
2023-01-02 00:03:13 -05:00
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"hijack.middleware.HijackUserMiddleware",
2023-01-10 22:36:13 -05:00
"tz_detect.middleware.TimezoneMiddleware",
2023-06-18 23:13:30 -04:00
"auditlog.middleware.AuditlogMiddleware",
2023-07-08 17:58:45 -04:00
# "maintenance_mode.middleware.MaintenanceModeMiddleware", # this should be last if enabled
2020-05-01 22:46:15 +08:00
]
2023-01-02 00:03:13 -05:00
ROOT_URLCONF = "boofilsic.urls"
2020-05-01 22:46:15 +08:00
TEMPLATES = [
{
2023-01-02 00:03:13 -05:00
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
2023-07-08 17:58:45 -04:00
# "django.template.context_processors.debug",
2023-01-02 00:03:13 -05:00
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
add all NeoDB features to NiceDB (#115) * fix scraping failure with wepb image (merge upstream/fix-webp-scrape) * add filetype to requirements * add proxycrawl.com as fallback for douban scraper * load 3p js/css from cdn * add fix-cover task * fix book/album cover tasks * scrapestack * bandcamp scrape and preview ; manage.py scrape <url> ; make ^C work when DEBUG * use scrapestack when fix cover * add user agent to improve compatibility * search BandCamp for music albums * add missing MovieGenre * fix search 500 when song has no parent album * adjust timeout * individual scrapers * fix tmdb parser * export marks via rq; pref to send public toot; move import to data page * fix spotify import * fix edge cases * export: fix dupe tags * use rq to manage doufen import * add django command to manage rq jobs * fix export edge case * tune rq admin * fix detail page 502 step 1: async pull mastodon follow/block/mute list * fix detail page 502 step 2: calculate relationship by local cached data * manual sync mastodon follow info * domain_blocks parsing fix * marks by who i follows * adjust label * use username in urls * add page to list a user\'s review * review widget on user home page * fix preview 500 * fix typo * minor fix * fix google books parsing * allow mark/review visible to oneself * fix auto sync masto for new user * fix search 500 * add command to restart a sync task * reset visibility * delete user data * fix tag search result pagination * not upgrade to django 4 yet * basic doc * wip: collection * wip * wip * collection use htmx * show in-collection section for entities * fix typo * add su for easier debug * fix some 500s * fix login using alternative domain * hide data from disabled user * add item to list from detail page * my tags * collection: inline comment edit * show number of ratings * fix collection delete * more detail in collection view * use item template in search result * fix 500 * write index to meilisearch * fix search * reindex in batch * fix 500 * show search result from meilisearch * more search commands * index less fields * index new items only * search highlights * fix 500 * auto set search category * classic search if no meili server * fix index stats error * support typesense backend * workaround typesense bug * make external search async * fix 500, typo * fix cover scripts * fix minor issue in douban parser * supports m.douban.com and customized bandcamp domain * move account * reword with gender-friendly and instance-neutral language * Friendica does not have vapid_key in api response * enable anonymous search * tweak book result template * API v0 API v0 * fix meilisearch reindex * fix search by url error * login via twitter.com * login via pixelfed * minor fix * no refresh on inactive users * support refresh access token * get rid of /users/number-id/ * refresh twitter handler automatically * paste image when review * support PixelFed (very long token) * fix django-markdownx version * ignore single quote for meilisearch for now * update logo * show book review/mark from same isbn * show movie review/mark from same imdb * fix login with older mastodon servers * import Goodreads book list and profile * add timestamp to Goodreads import * support new google books api * import goodreads list * minor goodreads fix * click corner action icon to add to wishlist * clean up duplicated code * fix anonymous search * fix 500 * minor fix search 500 * show rating only if votes > 5 * Entity.refresh_rating() * preference to append text when sharing; clean up duplicated code * fix missing data for user tagged view * fix page link for tag view * fix 500 when language field longer than 10 * fix 500 when sharing mark for song * fix error when reimport goodread profile * fix minor typo * fix a rare 500 * error log dump less * fix tags in marks export * fix missing param in pagination * import douban review * clarify text * fix missing sheet in review import * review: show in progress * scrape douban: ignore unknown genre * minor fix * improve review import by guess entity urls * clear guide text for review import * improve review import form text * workaround some 500 * fix mark import error * fix img in review import * load external results earlier * ignore search server errors * simplify user register flow to avoid inconsistent state * Add a learn more link on login page * Update login.html * show mark created timestamp as mark time * no 500 for api error * redirect for expired tokens * ensure preference object created. * mark collections * tag list * fix tag display * fix sorting etc * fix 500 * fix potential export 500; save shared links * fix share to twittwe * fix review url * fix 500 * fix 500 * add timeline, etc * missing status change in timeline * missing id in timeline * timeline view by default * workaround bug in markdownx... * fix typo * option to create new collection when add from detail page * add missing announcement and tags in timeline home * add missing announcement * add missing announcement * opensearch * show fediverse shared link * public review no longer requires login * fix markdownx bug * fix 500 * use cloudflare cdn * validate jquery load and domain input * fix 500 * tips for goodreads import * collaborative collection * show timeline and profile link on nav bar * minor tweak * share collection * fix Goodreads search * show wish mark in timeline * resync failed urls with local proxy * resync failed urls with local proxy: check proxy first * scraper minor fix * resync failed urls * fix fields limit * fix douban parsing error * resync * scraper minor fix * scraper minor fix * scraper minor fix * local proxy * local proxy * sync default config from neodb * configurable site name * fix 500 * fix 500 for anonymous user * add sentry * add git version in log * add git version in log * no longer rely on cdnjs.cloudflare.com * move jq/cash to _common_libs template partial * fix rare js error * fix 500 * avoid double submission error * import tag in lower case * catch some js network errors * catch some js network errors * support more goodread urls * fix unaired tv in tmdb * support more google book urls * fix related series * more goodreads urls * robust googlebooks search * robust search * Update settings.py * Update scraper.py * Update requirements.txt * make nicedb work * doc update * simplify permission check * update doc * update doc for bug report link * skip spotify tracks * fix 500 * improve search api * blind fix import compatibility * show years for movie in timeline * show years for movie in timeline; thinner font * export reviews * revert user home to use jquery https://github.com/fabiospampinato/cash/issues/246 * IGDB * use IGDB for Steam * use TMDB for IMDb * steam: igdb then fallback to steam * keep change history * keep change history: add django settings * Steam: keep localized title/brief while merging IGDB * basic Docker support * rescrape * Create codeql-analysis.yml * Create SECURITY.md * Create pysa.yml Co-authored-by: doubaniux <goodsir@vivaldi.net> Co-authored-by: Your Name <you@example.com> Co-authored-by: Their Name <they@example.com> Co-authored-by: Mt. Front <mfcndw@gmail.com>
2022-11-09 13:56:50 -05:00
# 'django.contrib.messages.context_processors.messages',
"user_messages.context_processors.messages",
2023-01-02 00:03:13 -05:00
"boofilsic.context_processors.site_info",
2020-05-01 22:46:15 +08:00
],
},
},
]
2023-01-02 00:03:13 -05:00
WSGI_APPLICATION = "boofilsic.wsgi.application"
2020-05-01 22:46:15 +08:00
2023-07-20 21:59:49 -04:00
SESSION_COOKIE_NAME = "neodbsid"
2020-05-01 22:46:15 +08:00
AUTHENTICATION_BACKENDS = [
2023-01-02 00:03:13 -05:00
"mastodon.auth.OAuth2Backend",
"oauth2_provider.backends.OAuth2Backend",
2020-05-11 19:16:56 +08:00
]
2020-05-01 22:46:15 +08:00
2023-09-25 19:47:46 +00:00
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {"class": "logging.StreamHandler"},
},
"loggers": {
"": {
"handlers": ["console"],
"level": env("NEODB_LOG_LEVEL", default="DEBUG" if DEBUG else "INFO"), # type: ignore
},
},
}
if SLACK_TOKEN:
2023-11-21 20:57:06 -05:00
INSTALLED_APPS += [
"django_slack",
]
2023-09-25 19:47:46 +00:00
LOGGING["handlers"]["slack"] = {
"level": "ERROR",
"class": "django_slack.log.SlackExceptionHandler",
}
LOGGING["loggers"]["django"] = {"handlers": ["slack"], "level": "ERROR"}
2020-05-01 22:46:15 +08:00
2023-08-11 01:43:19 -04:00
MARKDOWNX_MARKDOWNIFY_FUNCTION = "journal.models.render_md"
2023-01-30 22:11:47 -05:00
2020-05-01 22:46:15 +08:00
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
2023-01-02 00:03:13 -05:00
LANGUAGE_CODE = "zh-hans"
2020-05-01 22:46:15 +08:00
2023-09-25 19:47:46 +00:00
TIME_ZONE = env("NEODB_TIMEZONE", default="Asia/Shanghai") # type: ignore
2020-05-01 22:46:15 +08:00
USE_I18N = True
USE_L10N = True
USE_TZ = True
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
DATA_UPLOAD_MAX_MEMORY_SIZE = 100 * 1024 * 1024
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
SSL_ONLY = env("SSL_ONLY")
SECURE_SSL_REDIRECT = SSL_ONLY
SECURE_HSTS_PRELOAD = SSL_ONLY
SECURE_HSTS_INCLUDE_SUBDOMAINS = SSL_ONLY
SECURE_HSTS_SECONDS = 2592000 if SSL_ONLY else 0
2021-02-25 19:49:50 +01:00
2023-08-14 08:15:55 -04:00
STATIC_URL = "/s/"
2023-09-25 19:47:46 +00:00
STATIC_ROOT = env("NEODB_STATIC_ROOT", default=os.path.join(BASE_DIR, "static/")) # type: ignore
if DEBUG:
# django-sass-processor will generate neodb.css on-the-fly when DEBUG
# NEODB_STATIC_ROOT is readonly in docker mode, so we give it a writable place
SASS_PROCESSOR_ROOT = "/tmp"
2020-05-01 22:46:15 +08:00
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
"sass_processor.finders.CssFinder",
]
2021-02-25 19:49:50 +01:00
2023-01-02 00:03:13 -05:00
AUTH_USER_MODEL = "users.User"
2020-05-01 22:46:15 +08:00
add all NeoDB features to NiceDB (#115) * fix scraping failure with wepb image (merge upstream/fix-webp-scrape) * add filetype to requirements * add proxycrawl.com as fallback for douban scraper * load 3p js/css from cdn * add fix-cover task * fix book/album cover tasks * scrapestack * bandcamp scrape and preview ; manage.py scrape <url> ; make ^C work when DEBUG * use scrapestack when fix cover * add user agent to improve compatibility * search BandCamp for music albums * add missing MovieGenre * fix search 500 when song has no parent album * adjust timeout * individual scrapers * fix tmdb parser * export marks via rq; pref to send public toot; move import to data page * fix spotify import * fix edge cases * export: fix dupe tags * use rq to manage doufen import * add django command to manage rq jobs * fix export edge case * tune rq admin * fix detail page 502 step 1: async pull mastodon follow/block/mute list * fix detail page 502 step 2: calculate relationship by local cached data * manual sync mastodon follow info * domain_blocks parsing fix * marks by who i follows * adjust label * use username in urls * add page to list a user\'s review * review widget on user home page * fix preview 500 * fix typo * minor fix * fix google books parsing * allow mark/review visible to oneself * fix auto sync masto for new user * fix search 500 * add command to restart a sync task * reset visibility * delete user data * fix tag search result pagination * not upgrade to django 4 yet * basic doc * wip: collection * wip * wip * collection use htmx * show in-collection section for entities * fix typo * add su for easier debug * fix some 500s * fix login using alternative domain * hide data from disabled user * add item to list from detail page * my tags * collection: inline comment edit * show number of ratings * fix collection delete * more detail in collection view * use item template in search result * fix 500 * write index to meilisearch * fix search * reindex in batch * fix 500 * show search result from meilisearch * more search commands * index less fields * index new items only * search highlights * fix 500 * auto set search category * classic search if no meili server * fix index stats error * support typesense backend * workaround typesense bug * make external search async * fix 500, typo * fix cover scripts * fix minor issue in douban parser * supports m.douban.com and customized bandcamp domain * move account * reword with gender-friendly and instance-neutral language * Friendica does not have vapid_key in api response * enable anonymous search * tweak book result template * API v0 API v0 * fix meilisearch reindex * fix search by url error * login via twitter.com * login via pixelfed * minor fix * no refresh on inactive users * support refresh access token * get rid of /users/number-id/ * refresh twitter handler automatically * paste image when review * support PixelFed (very long token) * fix django-markdownx version * ignore single quote for meilisearch for now * update logo * show book review/mark from same isbn * show movie review/mark from same imdb * fix login with older mastodon servers * import Goodreads book list and profile * add timestamp to Goodreads import * support new google books api * import goodreads list * minor goodreads fix * click corner action icon to add to wishlist * clean up duplicated code * fix anonymous search * fix 500 * minor fix search 500 * show rating only if votes > 5 * Entity.refresh_rating() * preference to append text when sharing; clean up duplicated code * fix missing data for user tagged view * fix page link for tag view * fix 500 when language field longer than 10 * fix 500 when sharing mark for song * fix error when reimport goodread profile * fix minor typo * fix a rare 500 * error log dump less * fix tags in marks export * fix missing param in pagination * import douban review * clarify text * fix missing sheet in review import * review: show in progress * scrape douban: ignore unknown genre * minor fix * improve review import by guess entity urls * clear guide text for review import * improve review import form text * workaround some 500 * fix mark import error * fix img in review import * load external results earlier * ignore search server errors * simplify user register flow to avoid inconsistent state * Add a learn more link on login page * Update login.html * show mark created timestamp as mark time * no 500 for api error * redirect for expired tokens * ensure preference object created. * mark collections * tag list * fix tag display * fix sorting etc * fix 500 * fix potential export 500; save shared links * fix share to twittwe * fix review url * fix 500 * fix 500 * add timeline, etc * missing status change in timeline * missing id in timeline * timeline view by default * workaround bug in markdownx... * fix typo * option to create new collection when add from detail page * add missing announcement and tags in timeline home * add missing announcement * add missing announcement * opensearch * show fediverse shared link * public review no longer requires login * fix markdownx bug * fix 500 * use cloudflare cdn * validate jquery load and domain input * fix 500 * tips for goodreads import * collaborative collection * show timeline and profile link on nav bar * minor tweak * share collection * fix Goodreads search * show wish mark in timeline * resync failed urls with local proxy * resync failed urls with local proxy: check proxy first * scraper minor fix * resync failed urls * fix fields limit * fix douban parsing error * resync * scraper minor fix * scraper minor fix * scraper minor fix * local proxy * local proxy * sync default config from neodb * configurable site name * fix 500 * fix 500 for anonymous user * add sentry * add git version in log * add git version in log * no longer rely on cdnjs.cloudflare.com * move jq/cash to _common_libs template partial * fix rare js error * fix 500 * avoid double submission error * import tag in lower case * catch some js network errors * catch some js network errors * support more goodread urls * fix unaired tv in tmdb * support more google book urls * fix related series * more goodreads urls * robust googlebooks search * robust search * Update settings.py * Update scraper.py * Update requirements.txt * make nicedb work * doc update * simplify permission check * update doc * update doc for bug report link * skip spotify tracks * fix 500 * improve search api * blind fix import compatibility * show years for movie in timeline * show years for movie in timeline; thinner font * export reviews * revert user home to use jquery https://github.com/fabiospampinato/cash/issues/246 * IGDB * use IGDB for Steam * use TMDB for IMDb * steam: igdb then fallback to steam * keep change history * keep change history: add django settings * Steam: keep localized title/brief while merging IGDB * basic Docker support * rescrape * Create codeql-analysis.yml * Create SECURITY.md * Create pysa.yml Co-authored-by: doubaniux <goodsir@vivaldi.net> Co-authored-by: Your Name <you@example.com> Co-authored-by: Their Name <they@example.com> Co-authored-by: Mt. Front <mfcndw@gmail.com>
2022-11-09 13:56:50 -05:00
SILENCED_SYSTEM_CHECKS = [
2023-01-02 00:03:13 -05:00
"admin.E404", # Required by django-user-messages
2023-07-20 21:59:49 -04:00
"models.W035", # Required by takahe: identical table name in different database
"fields.W344", # Required by takahe: identical table name in different database
add all NeoDB features to NiceDB (#115) * fix scraping failure with wepb image (merge upstream/fix-webp-scrape) * add filetype to requirements * add proxycrawl.com as fallback for douban scraper * load 3p js/css from cdn * add fix-cover task * fix book/album cover tasks * scrapestack * bandcamp scrape and preview ; manage.py scrape <url> ; make ^C work when DEBUG * use scrapestack when fix cover * add user agent to improve compatibility * search BandCamp for music albums * add missing MovieGenre * fix search 500 when song has no parent album * adjust timeout * individual scrapers * fix tmdb parser * export marks via rq; pref to send public toot; move import to data page * fix spotify import * fix edge cases * export: fix dupe tags * use rq to manage doufen import * add django command to manage rq jobs * fix export edge case * tune rq admin * fix detail page 502 step 1: async pull mastodon follow/block/mute list * fix detail page 502 step 2: calculate relationship by local cached data * manual sync mastodon follow info * domain_blocks parsing fix * marks by who i follows * adjust label * use username in urls * add page to list a user\'s review * review widget on user home page * fix preview 500 * fix typo * minor fix * fix google books parsing * allow mark/review visible to oneself * fix auto sync masto for new user * fix search 500 * add command to restart a sync task * reset visibility * delete user data * fix tag search result pagination * not upgrade to django 4 yet * basic doc * wip: collection * wip * wip * collection use htmx * show in-collection section for entities * fix typo * add su for easier debug * fix some 500s * fix login using alternative domain * hide data from disabled user * add item to list from detail page * my tags * collection: inline comment edit * show number of ratings * fix collection delete * more detail in collection view * use item template in search result * fix 500 * write index to meilisearch * fix search * reindex in batch * fix 500 * show search result from meilisearch * more search commands * index less fields * index new items only * search highlights * fix 500 * auto set search category * classic search if no meili server * fix index stats error * support typesense backend * workaround typesense bug * make external search async * fix 500, typo * fix cover scripts * fix minor issue in douban parser * supports m.douban.com and customized bandcamp domain * move account * reword with gender-friendly and instance-neutral language * Friendica does not have vapid_key in api response * enable anonymous search * tweak book result template * API v0 API v0 * fix meilisearch reindex * fix search by url error * login via twitter.com * login via pixelfed * minor fix * no refresh on inactive users * support refresh access token * get rid of /users/number-id/ * refresh twitter handler automatically * paste image when review * support PixelFed (very long token) * fix django-markdownx version * ignore single quote for meilisearch for now * update logo * show book review/mark from same isbn * show movie review/mark from same imdb * fix login with older mastodon servers * import Goodreads book list and profile * add timestamp to Goodreads import * support new google books api * import goodreads list * minor goodreads fix * click corner action icon to add to wishlist * clean up duplicated code * fix anonymous search * fix 500 * minor fix search 500 * show rating only if votes > 5 * Entity.refresh_rating() * preference to append text when sharing; clean up duplicated code * fix missing data for user tagged view * fix page link for tag view * fix 500 when language field longer than 10 * fix 500 when sharing mark for song * fix error when reimport goodread profile * fix minor typo * fix a rare 500 * error log dump less * fix tags in marks export * fix missing param in pagination * import douban review * clarify text * fix missing sheet in review import * review: show in progress * scrape douban: ignore unknown genre * minor fix * improve review import by guess entity urls * clear guide text for review import * improve review import form text * workaround some 500 * fix mark import error * fix img in review import * load external results earlier * ignore search server errors * simplify user register flow to avoid inconsistent state * Add a learn more link on login page * Update login.html * show mark created timestamp as mark time * no 500 for api error * redirect for expired tokens * ensure preference object created. * mark collections * tag list * fix tag display * fix sorting etc * fix 500 * fix potential export 500; save shared links * fix share to twittwe * fix review url * fix 500 * fix 500 * add timeline, etc * missing status change in timeline * missing id in timeline * timeline view by default * workaround bug in markdownx... * fix typo * option to create new collection when add from detail page * add missing announcement and tags in timeline home * add missing announcement * add missing announcement * opensearch * show fediverse shared link * public review no longer requires login * fix markdownx bug * fix 500 * use cloudflare cdn * validate jquery load and domain input * fix 500 * tips for goodreads import * collaborative collection * show timeline and profile link on nav bar * minor tweak * share collection * fix Goodreads search * show wish mark in timeline * resync failed urls with local proxy * resync failed urls with local proxy: check proxy first * scraper minor fix * resync failed urls * fix fields limit * fix douban parsing error * resync * scraper minor fix * scraper minor fix * scraper minor fix * local proxy * local proxy * sync default config from neodb * configurable site name * fix 500 * fix 500 for anonymous user * add sentry * add git version in log * add git version in log * no longer rely on cdnjs.cloudflare.com * move jq/cash to _common_libs template partial * fix rare js error * fix 500 * avoid double submission error * import tag in lower case * catch some js network errors * catch some js network errors * support more goodread urls * fix unaired tv in tmdb * support more google book urls * fix related series * more goodreads urls * robust googlebooks search * robust search * Update settings.py * Update scraper.py * Update requirements.txt * make nicedb work * doc update * simplify permission check * update doc * update doc for bug report link * skip spotify tracks * fix 500 * improve search api * blind fix import compatibility * show years for movie in timeline * show years for movie in timeline; thinner font * export reviews * revert user home to use jquery https://github.com/fabiospampinato/cash/issues/246 * IGDB * use IGDB for Steam * use TMDB for IMDb * steam: igdb then fallback to steam * keep change history * keep change history: add django settings * Steam: keep localized title/brief while merging IGDB * basic Docker support * rescrape * Create codeql-analysis.yml * Create SECURITY.md * Create pysa.yml Co-authored-by: doubaniux <goodsir@vivaldi.net> Co-authored-by: Your Name <you@example.com> Co-authored-by: Their Name <they@example.com> Co-authored-by: Mt. Front <mfcndw@gmail.com>
2022-11-09 13:56:50 -05:00
]
2023-08-14 08:15:55 -04:00
MEDIA_URL = "/m/"
2023-09-25 19:47:46 +00:00
MEDIA_ROOT = env("NEODB_MEDIA_ROOT", default=os.path.join(BASE_DIR, "media")) # type: ignore
TAKAHE_MEDIA_URL = env("TAKAHE_MEDIA_URL", default="/media/") # type: ignore
TAKAHE_MEDIA_ROOT = env("TAKAHE_MEDIA_ROOT", default="media") # type: ignore
2023-08-22 17:13:52 +00:00
STORAGES = { # TODO: support S3
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
},
"takahe": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
"OPTIONS": {
"location": TAKAHE_MEDIA_ROOT,
"base_url": TAKAHE_MEDIA_URL,
},
},
}
2023-08-24 05:48:14 +00:00
2023-08-17 18:54:00 -04:00
CSRF_TRUSTED_ORIGINS = [SITE_INFO["site_url"]]
if DEBUG:
CSRF_TRUSTED_ORIGINS += ["http://127.0.0.1:8000", "http://localhost:8000"]
2021-02-25 19:49:50 +01:00
# Path to save report related images, ends with slash
2023-01-02 00:03:13 -05:00
REPORT_MEDIA_PATH_ROOT = "report/"
MARKDOWNX_MEDIA_PATH = "review/"
BOOK_MEDIA_PATH_ROOT = "book/"
DEFAULT_BOOK_IMAGE = os.path.join(BOOK_MEDIA_PATH_ROOT, "default.svg")
MOVIE_MEDIA_PATH_ROOT = "movie/"
DEFAULT_MOVIE_IMAGE = os.path.join(MOVIE_MEDIA_PATH_ROOT, "default.svg")
SONG_MEDIA_PATH_ROOT = "song/"
DEFAULT_SONG_IMAGE = os.path.join(SONG_MEDIA_PATH_ROOT, "default.svg")
ALBUM_MEDIA_PATH_ROOT = "album/"
DEFAULT_ALBUM_IMAGE = os.path.join(ALBUM_MEDIA_PATH_ROOT, "default.svg")
GAME_MEDIA_PATH_ROOT = "game/"
DEFAULT_GAME_IMAGE = os.path.join(GAME_MEDIA_PATH_ROOT, "default.svg")
COLLECTION_MEDIA_PATH_ROOT = "collection/"
DEFAULT_COLLECTION_IMAGE = os.path.join(COLLECTION_MEDIA_PATH_ROOT, "default.svg")
SYNC_FILE_PATH_ROOT = "sync/"
EXPORT_FILE_PATH_ROOT = "export/"
add all NeoDB features to NiceDB (#115) * fix scraping failure with wepb image (merge upstream/fix-webp-scrape) * add filetype to requirements * add proxycrawl.com as fallback for douban scraper * load 3p js/css from cdn * add fix-cover task * fix book/album cover tasks * scrapestack * bandcamp scrape and preview ; manage.py scrape <url> ; make ^C work when DEBUG * use scrapestack when fix cover * add user agent to improve compatibility * search BandCamp for music albums * add missing MovieGenre * fix search 500 when song has no parent album * adjust timeout * individual scrapers * fix tmdb parser * export marks via rq; pref to send public toot; move import to data page * fix spotify import * fix edge cases * export: fix dupe tags * use rq to manage doufen import * add django command to manage rq jobs * fix export edge case * tune rq admin * fix detail page 502 step 1: async pull mastodon follow/block/mute list * fix detail page 502 step 2: calculate relationship by local cached data * manual sync mastodon follow info * domain_blocks parsing fix * marks by who i follows * adjust label * use username in urls * add page to list a user\'s review * review widget on user home page * fix preview 500 * fix typo * minor fix * fix google books parsing * allow mark/review visible to oneself * fix auto sync masto for new user * fix search 500 * add command to restart a sync task * reset visibility * delete user data * fix tag search result pagination * not upgrade to django 4 yet * basic doc * wip: collection * wip * wip * collection use htmx * show in-collection section for entities * fix typo * add su for easier debug * fix some 500s * fix login using alternative domain * hide data from disabled user * add item to list from detail page * my tags * collection: inline comment edit * show number of ratings * fix collection delete * more detail in collection view * use item template in search result * fix 500 * write index to meilisearch * fix search * reindex in batch * fix 500 * show search result from meilisearch * more search commands * index less fields * index new items only * search highlights * fix 500 * auto set search category * classic search if no meili server * fix index stats error * support typesense backend * workaround typesense bug * make external search async * fix 500, typo * fix cover scripts * fix minor issue in douban parser * supports m.douban.com and customized bandcamp domain * move account * reword with gender-friendly and instance-neutral language * Friendica does not have vapid_key in api response * enable anonymous search * tweak book result template * API v0 API v0 * fix meilisearch reindex * fix search by url error * login via twitter.com * login via pixelfed * minor fix * no refresh on inactive users * support refresh access token * get rid of /users/number-id/ * refresh twitter handler automatically * paste image when review * support PixelFed (very long token) * fix django-markdownx version * ignore single quote for meilisearch for now * update logo * show book review/mark from same isbn * show movie review/mark from same imdb * fix login with older mastodon servers * import Goodreads book list and profile * add timestamp to Goodreads import * support new google books api * import goodreads list * minor goodreads fix * click corner action icon to add to wishlist * clean up duplicated code * fix anonymous search * fix 500 * minor fix search 500 * show rating only if votes > 5 * Entity.refresh_rating() * preference to append text when sharing; clean up duplicated code * fix missing data for user tagged view * fix page link for tag view * fix 500 when language field longer than 10 * fix 500 when sharing mark for song * fix error when reimport goodread profile * fix minor typo * fix a rare 500 * error log dump less * fix tags in marks export * fix missing param in pagination * import douban review * clarify text * fix missing sheet in review import * review: show in progress * scrape douban: ignore unknown genre * minor fix * improve review import by guess entity urls * clear guide text for review import * improve review import form text * workaround some 500 * fix mark import error * fix img in review import * load external results earlier * ignore search server errors * simplify user register flow to avoid inconsistent state * Add a learn more link on login page * Update login.html * show mark created timestamp as mark time * no 500 for api error * redirect for expired tokens * ensure preference object created. * mark collections * tag list * fix tag display * fix sorting etc * fix 500 * fix potential export 500; save shared links * fix share to twittwe * fix review url * fix 500 * fix 500 * add timeline, etc * missing status change in timeline * missing id in timeline * timeline view by default * workaround bug in markdownx... * fix typo * option to create new collection when add from detail page * add missing announcement and tags in timeline home * add missing announcement * add missing announcement * opensearch * show fediverse shared link * public review no longer requires login * fix markdownx bug * fix 500 * use cloudflare cdn * validate jquery load and domain input * fix 500 * tips for goodreads import * collaborative collection * show timeline and profile link on nav bar * minor tweak * share collection * fix Goodreads search * show wish mark in timeline * resync failed urls with local proxy * resync failed urls with local proxy: check proxy first * scraper minor fix * resync failed urls * fix fields limit * fix douban parsing error * resync * scraper minor fix * scraper minor fix * scraper minor fix * local proxy * local proxy * sync default config from neodb * configurable site name * fix 500 * fix 500 for anonymous user * add sentry * add git version in log * add git version in log * no longer rely on cdnjs.cloudflare.com * move jq/cash to _common_libs template partial * fix rare js error * fix 500 * avoid double submission error * import tag in lower case * catch some js network errors * catch some js network errors * support more goodread urls * fix unaired tv in tmdb * support more google book urls * fix related series * more goodreads urls * robust googlebooks search * robust search * Update settings.py * Update scraper.py * Update requirements.txt * make nicedb work * doc update * simplify permission check * update doc * update doc for bug report link * skip spotify tracks * fix 500 * improve search api * blind fix import compatibility * show years for movie in timeline * show years for movie in timeline; thinner font * export reviews * revert user home to use jquery https://github.com/fabiospampinato/cash/issues/246 * IGDB * use IGDB for Steam * use TMDB for IMDb * steam: igdb then fallback to steam * keep change history * keep change history: add django settings * Steam: keep localized title/brief while merging IGDB * basic Docker support * rescrape * Create codeql-analysis.yml * Create SECURITY.md * Create pysa.yml Co-authored-by: doubaniux <goodsir@vivaldi.net> Co-authored-by: Your Name <you@example.com> Co-authored-by: Their Name <they@example.com> Co-authored-by: Mt. Front <mfcndw@gmail.com>
2022-11-09 13:56:50 -05:00
2020-05-01 22:46:15 +08:00
# Default redirect loaction when access login required view
2023-07-05 14:36:50 -04:00
LOGIN_URL = "/account/login"
2020-05-01 22:46:15 +08:00
2023-09-25 19:47:46 +00:00
ADMIN_ENABLED = DEBUG
ADMIN_URL = "neodb-admin"
2020-05-01 22:46:15 +08:00
2023-01-26 17:31:20 -05:00
BLEACH_STRIP_COMMENTS = True
BLEACH_STRIP_TAGS = True
2021-02-25 19:49:50 +01:00
# Thumbnail setting
# It is possible to optimize the image size even more: https://easy-thumbnails.readthedocs.io/en/latest/ref/optimize/
THUMBNAIL_ALIASES = {
2023-01-02 00:03:13 -05:00
"": {
"normal": {
"size": (200, 200),
"crop": "scale",
"autocrop": True,
2021-02-25 19:49:50 +01:00
},
},
}
# THUMBNAIL_PRESERVE_EXTENSIONS = ('svg',)
2023-09-25 19:47:46 +00:00
THUMBNAIL_DEBUG = DEBUG
2020-07-03 15:36:23 +08:00
2023-09-25 19:47:46 +00:00
DJANGO_REDIS_IGNORE_EXCEPTIONS = not DEBUG
add all NeoDB features to NiceDB (#115) * fix scraping failure with wepb image (merge upstream/fix-webp-scrape) * add filetype to requirements * add proxycrawl.com as fallback for douban scraper * load 3p js/css from cdn * add fix-cover task * fix book/album cover tasks * scrapestack * bandcamp scrape and preview ; manage.py scrape <url> ; make ^C work when DEBUG * use scrapestack when fix cover * add user agent to improve compatibility * search BandCamp for music albums * add missing MovieGenre * fix search 500 when song has no parent album * adjust timeout * individual scrapers * fix tmdb parser * export marks via rq; pref to send public toot; move import to data page * fix spotify import * fix edge cases * export: fix dupe tags * use rq to manage doufen import * add django command to manage rq jobs * fix export edge case * tune rq admin * fix detail page 502 step 1: async pull mastodon follow/block/mute list * fix detail page 502 step 2: calculate relationship by local cached data * manual sync mastodon follow info * domain_blocks parsing fix * marks by who i follows * adjust label * use username in urls * add page to list a user\'s review * review widget on user home page * fix preview 500 * fix typo * minor fix * fix google books parsing * allow mark/review visible to oneself * fix auto sync masto for new user * fix search 500 * add command to restart a sync task * reset visibility * delete user data * fix tag search result pagination * not upgrade to django 4 yet * basic doc * wip: collection * wip * wip * collection use htmx * show in-collection section for entities * fix typo * add su for easier debug * fix some 500s * fix login using alternative domain * hide data from disabled user * add item to list from detail page * my tags * collection: inline comment edit * show number of ratings * fix collection delete * more detail in collection view * use item template in search result * fix 500 * write index to meilisearch * fix search * reindex in batch * fix 500 * show search result from meilisearch * more search commands * index less fields * index new items only * search highlights * fix 500 * auto set search category * classic search if no meili server * fix index stats error * support typesense backend * workaround typesense bug * make external search async * fix 500, typo * fix cover scripts * fix minor issue in douban parser * supports m.douban.com and customized bandcamp domain * move account * reword with gender-friendly and instance-neutral language * Friendica does not have vapid_key in api response * enable anonymous search * tweak book result template * API v0 API v0 * fix meilisearch reindex * fix search by url error * login via twitter.com * login via pixelfed * minor fix * no refresh on inactive users * support refresh access token * get rid of /users/number-id/ * refresh twitter handler automatically * paste image when review * support PixelFed (very long token) * fix django-markdownx version * ignore single quote for meilisearch for now * update logo * show book review/mark from same isbn * show movie review/mark from same imdb * fix login with older mastodon servers * import Goodreads book list and profile * add timestamp to Goodreads import * support new google books api * import goodreads list * minor goodreads fix * click corner action icon to add to wishlist * clean up duplicated code * fix anonymous search * fix 500 * minor fix search 500 * show rating only if votes > 5 * Entity.refresh_rating() * preference to append text when sharing; clean up duplicated code * fix missing data for user tagged view * fix page link for tag view * fix 500 when language field longer than 10 * fix 500 when sharing mark for song * fix error when reimport goodread profile * fix minor typo * fix a rare 500 * error log dump less * fix tags in marks export * fix missing param in pagination * import douban review * clarify text * fix missing sheet in review import * review: show in progress * scrape douban: ignore unknown genre * minor fix * improve review import by guess entity urls * clear guide text for review import * improve review import form text * workaround some 500 * fix mark import error * fix img in review import * load external results earlier * ignore search server errors * simplify user register flow to avoid inconsistent state * Add a learn more link on login page * Update login.html * show mark created timestamp as mark time * no 500 for api error * redirect for expired tokens * ensure preference object created. * mark collections * tag list * fix tag display * fix sorting etc * fix 500 * fix potential export 500; save shared links * fix share to twittwe * fix review url * fix 500 * fix 500 * add timeline, etc * missing status change in timeline * missing id in timeline * timeline view by default * workaround bug in markdownx... * fix typo * option to create new collection when add from detail page * add missing announcement and tags in timeline home * add missing announcement * add missing announcement * opensearch * show fediverse shared link * public review no longer requires login * fix markdownx bug * fix 500 * use cloudflare cdn * validate jquery load and domain input * fix 500 * tips for goodreads import * collaborative collection * show timeline and profile link on nav bar * minor tweak * share collection * fix Goodreads search * show wish mark in timeline * resync failed urls with local proxy * resync failed urls with local proxy: check proxy first * scraper minor fix * resync failed urls * fix fields limit * fix douban parsing error * resync * scraper minor fix * scraper minor fix * scraper minor fix * local proxy * local proxy * sync default config from neodb * configurable site name * fix 500 * fix 500 for anonymous user * add sentry * add git version in log * add git version in log * no longer rely on cdnjs.cloudflare.com * move jq/cash to _common_libs template partial * fix rare js error * fix 500 * avoid double submission error * import tag in lower case * catch some js network errors * catch some js network errors * support more goodread urls * fix unaired tv in tmdb * support more google book urls * fix related series * more goodreads urls * robust googlebooks search * robust search * Update settings.py * Update scraper.py * Update requirements.txt * make nicedb work * doc update * simplify permission check * update doc * update doc for bug report link * skip spotify tracks * fix 500 * improve search api * blind fix import compatibility * show years for movie in timeline * show years for movie in timeline; thinner font * export reviews * revert user home to use jquery https://github.com/fabiospampinato/cash/issues/246 * IGDB * use IGDB for Steam * use TMDB for IMDb * steam: igdb then fallback to steam * keep change history * keep change history: add django settings * Steam: keep localized title/brief while merging IGDB * basic Docker support * rescrape * Create codeql-analysis.yml * Create SECURITY.md * Create pysa.yml Co-authored-by: doubaniux <goodsir@vivaldi.net> Co-authored-by: Your Name <you@example.com> Co-authored-by: Their Name <they@example.com> Co-authored-by: Mt. Front <mfcndw@gmail.com>
2022-11-09 13:56:50 -05:00
2023-09-25 19:47:46 +00:00
RQ_SHOW_ADMIN_LINK = DEBUG
add all NeoDB features to NiceDB (#115) * fix scraping failure with wepb image (merge upstream/fix-webp-scrape) * add filetype to requirements * add proxycrawl.com as fallback for douban scraper * load 3p js/css from cdn * add fix-cover task * fix book/album cover tasks * scrapestack * bandcamp scrape and preview ; manage.py scrape <url> ; make ^C work when DEBUG * use scrapestack when fix cover * add user agent to improve compatibility * search BandCamp for music albums * add missing MovieGenre * fix search 500 when song has no parent album * adjust timeout * individual scrapers * fix tmdb parser * export marks via rq; pref to send public toot; move import to data page * fix spotify import * fix edge cases * export: fix dupe tags * use rq to manage doufen import * add django command to manage rq jobs * fix export edge case * tune rq admin * fix detail page 502 step 1: async pull mastodon follow/block/mute list * fix detail page 502 step 2: calculate relationship by local cached data * manual sync mastodon follow info * domain_blocks parsing fix * marks by who i follows * adjust label * use username in urls * add page to list a user\'s review * review widget on user home page * fix preview 500 * fix typo * minor fix * fix google books parsing * allow mark/review visible to oneself * fix auto sync masto for new user * fix search 500 * add command to restart a sync task * reset visibility * delete user data * fix tag search result pagination * not upgrade to django 4 yet * basic doc * wip: collection * wip * wip * collection use htmx * show in-collection section for entities * fix typo * add su for easier debug * fix some 500s * fix login using alternative domain * hide data from disabled user * add item to list from detail page * my tags * collection: inline comment edit * show number of ratings * fix collection delete * more detail in collection view * use item template in search result * fix 500 * write index to meilisearch * fix search * reindex in batch * fix 500 * show search result from meilisearch * more search commands * index less fields * index new items only * search highlights * fix 500 * auto set search category * classic search if no meili server * fix index stats error * support typesense backend * workaround typesense bug * make external search async * fix 500, typo * fix cover scripts * fix minor issue in douban parser * supports m.douban.com and customized bandcamp domain * move account * reword with gender-friendly and instance-neutral language * Friendica does not have vapid_key in api response * enable anonymous search * tweak book result template * API v0 API v0 * fix meilisearch reindex * fix search by url error * login via twitter.com * login via pixelfed * minor fix * no refresh on inactive users * support refresh access token * get rid of /users/number-id/ * refresh twitter handler automatically * paste image when review * support PixelFed (very long token) * fix django-markdownx version * ignore single quote for meilisearch for now * update logo * show book review/mark from same isbn * show movie review/mark from same imdb * fix login with older mastodon servers * import Goodreads book list and profile * add timestamp to Goodreads import * support new google books api * import goodreads list * minor goodreads fix * click corner action icon to add to wishlist * clean up duplicated code * fix anonymous search * fix 500 * minor fix search 500 * show rating only if votes > 5 * Entity.refresh_rating() * preference to append text when sharing; clean up duplicated code * fix missing data for user tagged view * fix page link for tag view * fix 500 when language field longer than 10 * fix 500 when sharing mark for song * fix error when reimport goodread profile * fix minor typo * fix a rare 500 * error log dump less * fix tags in marks export * fix missing param in pagination * import douban review * clarify text * fix missing sheet in review import * review: show in progress * scrape douban: ignore unknown genre * minor fix * improve review import by guess entity urls * clear guide text for review import * improve review import form text * workaround some 500 * fix mark import error * fix img in review import * load external results earlier * ignore search server errors * simplify user register flow to avoid inconsistent state * Add a learn more link on login page * Update login.html * show mark created timestamp as mark time * no 500 for api error * redirect for expired tokens * ensure preference object created. * mark collections * tag list * fix tag display * fix sorting etc * fix 500 * fix potential export 500; save shared links * fix share to twittwe * fix review url * fix 500 * fix 500 * add timeline, etc * missing status change in timeline * missing id in timeline * timeline view by default * workaround bug in markdownx... * fix typo * option to create new collection when add from detail page * add missing announcement and tags in timeline home * add missing announcement * add missing announcement * opensearch * show fediverse shared link * public review no longer requires login * fix markdownx bug * fix 500 * use cloudflare cdn * validate jquery load and domain input * fix 500 * tips for goodreads import * collaborative collection * show timeline and profile link on nav bar * minor tweak * share collection * fix Goodreads search * show wish mark in timeline * resync failed urls with local proxy * resync failed urls with local proxy: check proxy first * scraper minor fix * resync failed urls * fix fields limit * fix douban parsing error * resync * scraper minor fix * scraper minor fix * scraper minor fix * local proxy * local proxy * sync default config from neodb * configurable site name * fix 500 * fix 500 for anonymous user * add sentry * add git version in log * add git version in log * no longer rely on cdnjs.cloudflare.com * move jq/cash to _common_libs template partial * fix rare js error * fix 500 * avoid double submission error * import tag in lower case * catch some js network errors * catch some js network errors * support more goodread urls * fix unaired tv in tmdb * support more google book urls * fix related series * more goodreads urls * robust googlebooks search * robust search * Update settings.py * Update scraper.py * Update requirements.txt * make nicedb work * doc update * simplify permission check * update doc * update doc for bug report link * skip spotify tracks * fix 500 * improve search api * blind fix import compatibility * show years for movie in timeline * show years for movie in timeline; thinner font * export reviews * revert user home to use jquery https://github.com/fabiospampinato/cash/issues/246 * IGDB * use IGDB for Steam * use TMDB for IMDb * steam: igdb then fallback to steam * keep change history * keep change history: add django settings * Steam: keep localized title/brief while merging IGDB * basic Docker support * rescrape * Create codeql-analysis.yml * Create SECURITY.md * Create pysa.yml Co-authored-by: doubaniux <goodsir@vivaldi.net> Co-authored-by: Your Name <you@example.com> Co-authored-by: Their Name <they@example.com> Co-authored-by: Mt. Front <mfcndw@gmail.com>
2022-11-09 13:56:50 -05:00
SEARCH_INDEX_NEW_ONLY = False
2023-09-25 19:47:46 +00:00
DOWNLOADER_SAVEDIR = env("NEODB_DOWNLOADER_SAVE_DIR", default=None) # type: ignore
2023-08-24 05:48:14 +00:00
2023-01-02 00:03:13 -05:00
DISABLE_MODEL_SIGNAL = False # disable index and social feeds during importing/etc
2023-01-11 00:55:56 -05:00
2023-07-08 17:58:45 -04:00
# MAINTENANCE_MODE = False
# MAINTENANCE_MODE_IGNORE_ADMIN_SITE = True
# MAINTENANCE_MODE_IGNORE_SUPERUSER = True
# MAINTENANCE_MODE_IGNORE_ANONYMOUS_USER = True
# MAINTENANCE_MODE_IGNORE_URLS = (r"^/users/connect/", r"^/users/OAuth2_login/")
# SILKY_AUTHENTICATION = True # User must login
# SILKY_AUTHORISATION = True # User must have permissions
# SILKY_PERMISSIONS = lambda user: user.is_superuser
# SILKY_MAX_RESPONSE_BODY_SIZE = 1024 # If response body>1024 bytes, ignore
# SILKY_INTERCEPT_PERCENT = 10
NINJA_PAGINATION_PER_PAGE = 20
2023-06-27 23:11:20 -04:00
OAUTH2_PROVIDER = {
"ACCESS_TOKEN_EXPIRE_SECONDS": 3600 * 24 * 365,
"PKCE_REQUIRED": False,
}
2023-06-21 08:36:30 -04:00
OAUTH2_PROVIDER_APPLICATION_MODEL = "developer.Application"
DEVELOPER_CONSOLE_APPLICATION_CLIENT_ID = "NEODB_DEVELOPER_CONSOLE"
# https://github.com/adamchainz/django-cors-headers#configuration
# CORS_ALLOWED_ORIGINS = []
# CORS_ALLOWED_ORIGIN_REGEXES = []
CORS_ALLOW_ALL_ORIGINS = True
2023-11-22 20:55:45 -05:00
CORS_URLS_REGEX = r"^/(api|nodeinfo)/.*$"
CORS_ALLOW_METHODS = (
"DELETE",
"GET",
"OPTIONS",
# "PATCH",
"POST",
# "PUT",
)
DEACTIVATE_AFTER_UNREACHABLE_DAYS = 120
DEFAULT_RELAY_SERVER = "https://relay.neodb.net/actor"
2023-11-21 00:49:42 -05:00
SENTRY_DSN = env("NEODB_SENTRY_DSN")
if SENTRY_DSN:
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=[DjangoIntegration()],
release=NEODB_VERSION,
traces_sample_rate=1 if DEBUG else 0.01,
)