MangAdventure package¶
A simple manga hosting CMS written in Django.
Submodules¶
MangAdventure.cache module¶
MangAdventure.converters module¶
Path converters used in URL patterns.
MangAdventure.fields module¶
Custom database models & model fields.
- class MangAdventure.fields.TwitterField(*args, **kwargs)[source]¶
Bases:
CharField
A
CharField
for Twitter usernames.- default_validators = (<MangAdventure.validators.TwitterNameValidator object>,)¶
- class MangAdventure.fields.DiscordNameField(*args, **kwargs)[source]¶
Bases:
CharField
A
CharField
for Discord usernames.- default_validators = (<MangAdventure.validators.DiscordNameValidator object>,)¶
MangAdventure.filters module¶
A collection of filters used in the admin interface.
- MangAdventure.filters.title_filter(title, klass=<class 'django.contrib.admin.filters.FieldListFilter'>)[source]¶
A
FieldListFilter
with a custom title.
A
title_filter()
for related fields.- Returns:
A class that inherits from
RelatedFieldListFilter
.
MangAdventure.forms module¶
Custom form fields.
MangAdventure.jsonld module¶
Functions used to generate JSON-LD objects.
- MangAdventure.jsonld.schema(at_type, items)[source]¶
Generate an arbitrary JSON-LD object.
The object’s
@context
links to https://schema.org.
- MangAdventure.jsonld.breadcrumbs(items)[source]¶
Generate a BreadcrumbList JSON-LD object.
MangAdventure.middleware module¶
Custom middleware.
- class MangAdventure.middleware.BaseMiddleware(get_response)[source]¶
Bases:
CommonMiddleware
CommonMiddleware
with custom patches.- __call__(request)[source]¶
Patched to allow
blocked user agents
to view/robots.txt
.It also sends a 425 response if the Early-Data header has been set.
- Parameters:
request (
HttpRequest
) – The original request.- Return type:
- Returns:
The response to the request.
MangAdventure.search module¶
Functions used for searching.
- MangAdventure.search.parse(request)[source]¶
Parse a request and return a
namedtuple
of search parameters.- Parameters:
request (
HttpRequest
) – The original request.- Return type:
_SearchParams
- Returns:
The parameters of the request.
- MangAdventure.search.qsfilter(params)[source]¶
Create a queryset filter from the given search parameters.
- Parameters:
params (
_SearchParams
) – Anamedtuple
of parameters.- Return type:
- Returns:
The created queryset filter.
- MangAdventure.search.query(params)[source]¶
Get a queryset of
Series
from the given search parameters.- Parameters:
params (
_SearchParams
) – Anamedtuple
of parameters.- Return type:
- Returns:
A queryset of series matching the given parameters.
- MangAdventure.search.get_response(request)[source]¶
Get a queryset of
Series
from the given request.- Parameters:
request (
HttpRequest
) – The original request.- Return type:
- Returns:
A queryset of series matching the parameters of the request.
MangAdventure.settings module¶
The project’s settings.
- MangAdventure.settings.BASE_DIR¶
Build paths inside the project like this:
BASE_DIR / ...
.
- MangAdventure.settings.ALLOWED_HOSTS¶
A list of host/domain names that this site can serve. See ALLOWED_HOSTS.
- MangAdventure.settings.DEBUG¶
- A boolean that turns debug mode on/off. See DEBUG.SECURITY WARNING: never turn this on in production!
- MangAdventure.settings.SECRET_KEY¶
- A secret key used to provide cryptographic signing. See SECRET_KEY.SECURITY WARNING: this must be kept secret!
- MangAdventure.settings.INSTALLED_APPS¶
A list of strings designating all applications that are enabled in this Django installation. See INSTALLED_APPS.
- MangAdventure.settings.MIDDLEWARE¶
A list of middleware to use. See MIDDLEWARE.
- MangAdventure.settings.ROOT_URLCONF¶
A string representing the full Python import path to the root URLconf. See ROOT_URLCONF.
- MangAdventure.settings.TEMPLATES¶
A list containing the settings for all template engines to be used. See TEMPLATES.
- MangAdventure.settings.WSGI_APPLICATION¶
The full Python path of the WSGI application object that Django’s built-in servers will use. See WSGI_APPLICATION.
- MangAdventure.settings.DEFAULT_AUTO_FIELD¶
Default primary key field type to use.
- MangAdventure.settings.SESSION_ENGINE¶
Controls where session data is stored. See SESSION_ENGINE.
- MangAdventure.settings.EMAIL_SUBJECT_PREFIX¶
Subject prefix for email messages sent to admins/managers. See EMAIL_SUBJECT_PREFIX.
- MangAdventure.settings.IGNORABLE_404_URLS¶
URLs that should be ignored when reporting HTTP 404 errors. See IGNORABLE_404_URLS.
- MangAdventure.settings.STATIC_URL¶
URL that handles the files served from
STATIC_ROOT
. See STATIC_URL.
- MangAdventure.settings.STATIC_ROOT¶
Absolute filesystem path to the directory that will hold static files. See STATIC_ROOT.
- MangAdventure.settings.STATICFILES_FINDERS¶
A list of static file finders to use. See STATICFILES_FINDERS.
- MangAdventure.settings.STATICFILES_DIRS¶
A list of directories containing static files. See STATICFILES_DIRS.
- MangAdventure.settings.MEDIA_URL¶
URL that handles the media served from
MEDIA_ROOT
. See MEDIA_URL.
- MangAdventure.settings.MEDIA_ROOT¶
Absolute filesystem path to the directory that will hold user-uploaded files. See MEDIA_ROOT.
- MangAdventure.settings.USE_I18N¶
Enable Django’s translation system. See USE_I18N.
TODO
This is not enabled yet.
- MangAdventure.settings.LANGUAGE_CODE¶
A string representing the language code for this installation. See LANGUAGE_CODE.
- MangAdventure.settings.LANGUAGE_COOKIE_NAME¶
The name of the cookie to use for the language cookie. See LANGUAGE_COOKIE_NAME.
- MangAdventure.settings.LANGUAGE_COOKIE_HTTPONLY¶
Set the
HttpOnly
flag on the language cookie. See LANGUAGE_COOKIE_HTTPONLY.
- MangAdventure.settings.LANGUAGE_COOKIE_SAMESITE¶
Prevent the language cookie from being sent in cross-site requests. See LANGUAGE_COOKIE_SAMESITE.
- MangAdventure.settings.AUTH_PASSWORD_VALIDATORS¶
A list of validators that are used to check the strength of users’ passwords. See AUTH_PASSWORD_VALIDATORS.
- MangAdventure.settings.AUTHENTICATION_BACKENDS¶
A list of authentication backends to use when authenticating a user. See AUTHENTICATION_BACKENDS.
- MangAdventure.settings.ACCOUNT_ADAPTER¶
The account adapter class to use. See ACCOUNT_ADAPTER.
- MangAdventure.settings.ACCOUNT_USER_DISPLAY¶
A callable that returns the display name of the user. See ACCOUNT_USER_DISPLAY.
- MangAdventure.settings.ACCOUNT_EMAIL_REQUIRED¶
The user is required to hand over an e-mail address when signing up. See ACCOUNT_EMAIL_REQUIRED.
- MangAdventure.settings.ACCOUNT_CHANGE_EMAIL¶
The user cannot have more than one e-mail address. See ACCOUNT_CHANGE_EMAIL.
- MangAdventure.settings.ACCOUNT_AUTHENTICATION_METHOD¶
Use either the username or the email to login. See ACCOUNT_AUTHENTICATION_METHOD.
- MangAdventure.settings.ACCOUNT_EMAIL_VERIFICATION¶
The user is blocked from logging in until the email address is verified. See ACCOUNT_EMAIL_VERIFICATION.
- MangAdventure.settings.ACCOUNT_FORMS¶
Override some of the builtin forms. See ACCOUNT_FORMS.
- MangAdventure.settings.SOCIALACCOUNT_ADAPTER¶
The social account adapter class to use. See SOCIALACCOUNT_ADAPTER.
- MangAdventure.settings.SOCIALACCOUNT_EMAIL_AUTHENTICATION_AUTO_CONNECT¶
Automatically connect social accounts to local ones. See SOCIALACCOUNT_EMAIL_AUTHENTICATION_AUTO_CONNECT.
- MangAdventure.settings.SOCIALACCOUNT_PROVIDERS¶
Social account provider customization. See Google, GitHub, Discord.
- MangAdventure.settings.SESSION_COOKIE_AGE¶
The age of session cookies (1 month). See SESSION_COOKIE_AGE.
- MangAdventure.settings.SESSION_COOKIE_HTTPONLY¶
Set the
HttpOnly
flag on the session cookie. See SESSION_COOKIE_HTTPONLY.
- MangAdventure.settings.SESSION_EXPIRE_AT_BROWSER_CLOSE¶
Don’t expire the session when the user closes their browser. See SESSION_EXPIRE_AT_BROWSER_CLOSE.
- MangAdventure.settings.DEFAULT_FROM_EMAIL¶
The default e-mail address of the site. See DEFAULT_FROM_EMAIL.
- MangAdventure.settings.SILENCED_SYSTEM_CHECKS¶
Silence CSRF & HSTS warnings.
- MangAdventure.settings.DISALLOWED_USER_AGENTS¶
List of User-Agents that are not allowed to visit any page. See DISALLOWED_USER_AGENTS.
- MangAdventure.settings.SESSION_COOKIE_SAMESITE¶
Prevent the session cookie from being sent in cross-site requests. See SESSION_COOKIE_SAMESITE.
- MangAdventure.settings.SECURE_PROXY_SSL_HEADER¶
HTTP header/value combination that signifies a secure request. See SECURE_PROXY_SSL_HEADER.
- MangAdventure.settings.SECURE_SSL_REDIRECT¶
Redirect all non-HTTPS requests to HTTPS. See SECURE_SSL_REDIRECT.
- MangAdventure.settings.SECURE_CONTENT_TYPE_NOSNIFF¶
Set the
X-Content-Type-Options: nosniff
header. See SECURE_CONTENT_TYPE_NOSNIFF.
- MangAdventure.settings.SECURE_REFERRER_POLICY¶
Instructs the browser to send only the origin, not the full URL, and to send no referrer when a protocol downgrade occurs. See SECURE_REFERRER_POLICY.
- MangAdventure.settings.LANGUAGE_COOKIE_SECURE¶
Use a secure cookie for the language cookie. See LANGUAGE_COOKIE_SECURE.
- MangAdventure.settings.SESSION_COOKIE_SECURE¶
Use a secure cookie for the session cookie. See SESSION_COOKIE_SECURE.
- MangAdventure.settings.ACCOUNT_DEFAULT_HTTP_PROTOCOL¶
The default protocol used when generating account URLs. See ACCOUNT_DEFAULT_HTTP_PROTOCOL.
- MangAdventure.settings.REST_FRAMEWORK¶
Configuration for the API.
- MangAdventure.settings.CONFIG¶
Configuration variables defined by the user in the
.env
file.
MangAdventure.sitemaps module¶
Miscellaneous sitemaps.
MangAdventure.storage module¶
Custom storages.
- MangAdventure.storage.SCSS_VARS = '$main-bg: %(MAIN_BG_COLOR)s;\n$alter-bg: %(ALTER_BG_COLOR)s;\n$main-fg: %(MAIN_TEXT_COLOR)s;\n$alter-fg: %(ALTER_TEXT_COLOR)s;\n$shadow-color: %(SHADOW_COLOR)s;\n$font-family: %(FONT_NAME)s;\n'¶
Variables used to generate
static/styles/_variables.scss
.
- class MangAdventure.storage.ProcessedStaticFilesFinder(app_names=None, *args, **kwargs)[source]¶
Bases:
FileSystemFinder
Static files finder that for processed files.
- class MangAdventure.storage.ProcessedStaticFilesStorage(*args, **kwargs)[source]¶
Bases:
StaticFilesStorage
Static files storage class with postprocessing.
- url(name)[source]¶
Return an absolute URL where the file’s contents can be accessed directly by a web browser.
- class MangAdventure.storage.CDNStorage(*args, **kwargs)[source]¶
Bases:
FileSystemStorage
Storage class that may use an image CDN.
The options are statically, weserv & photon.
MangAdventure.urls module¶
The root URLconf.
- MangAdventure.urls.urlpatterns = [<URLPattern '' [name='index']>, <URLResolver <module 'config.urls' from '/home/docs/checkouts/readthedocs.org/user_builds/mangadventure/checkouts/latest/config/urls.py'> (None:None) ''>, <URLPattern 'search/' [name='search']>, <URLResolver <URLPattern list> (admin:admin) 'admin-panel/'>, <URLResolver <module 'reader.urls' from '/home/docs/checkouts/readthedocs.org/user_builds/mangadventure/checkouts/latest/reader/urls.py'> (reader:reader) 'reader/'>, <URLResolver <module 'api.urls' from '/home/docs/checkouts/readthedocs.org/user_builds/mangadventure/checkouts/latest/api/urls.py'> (api:api) 'api/'>, <URLResolver <module 'groups.urls' from '/home/docs/checkouts/readthedocs.org/user_builds/mangadventure/checkouts/latest/groups/urls.py'> (groups:groups) 'groups/'>, <URLResolver <module 'users.urls' from '/home/docs/checkouts/readthedocs.org/user_builds/mangadventure/checkouts/latest/users/urls.py'> (None:None) 'user/'>, <URLPattern 'opensearch.xml' [name='opensearch']>, <URLPattern 'contribute.json' [name='contribute']>, <URLPattern 'manifest.webmanifest' [name='manifest']>, <URLPattern 'robots.txt' [name='robots']>, <URLPattern 'releases.atom' [name='releases.atom']>, <URLPattern 'releases.rss' [name='releases.rss']>, <URLPattern 'library.atom' [name='library.atom']>, <URLPattern 'library.rss' [name='library.rss']>, <URLPattern 'sitemap.xml' [name='sitemap.xml']>]¶
The main URL patterns.
- MangAdventure.urls.handler400 = 'MangAdventure.views.handler400'¶
- MangAdventure.urls.handler403 = 'MangAdventure.views.handler403'¶
- MangAdventure.urls.handler404 = 'MangAdventure.views.handler404'¶
- MangAdventure.urls.handler500 = 'MangAdventure.views.handler500'¶
MangAdventure.utils module¶
Various utility functions.
- class MangAdventure.utils.HttpResponseUnauthorized(content=b'', realm='private', auth_type='Bearer', **kwargs)[source]¶
Bases:
HttpResponse
A response class for HTTP 401.
- Parameters:
content (
bytes
) – The body of the response.realm (
str
) – The realm of the WWW-Authenticate header.auth_type (
str
) – The type of the WWW-Authenticate header.
- MangAdventure.utils.img_tag(obj, alt, height=0, width=0)[source]¶
Create an HTML
<img>
from anImageField
.- Parameters:
obj (
ImageField
) – AnImageField
instance.alt (
str
) – The alternate text of the tag.height (
int
) – The height of the<img>
. Unset if0
.width (
int
) – The width of the<img>
. Unset if0
.
- Return type:
- Returns:
An
<img>
tag with the given image.
MangAdventure.validators module¶
Custom validators.
- class MangAdventure.validators.FileSizeValidator(*args, **kwargs)[source]¶
Bases:
object
Validates that a file’s size is not greater than
max_mb
.- Parameters:
max_mb (
int
) – The maximum size of the file in megabytes.
- message = 'File too large. Maximum file size allowed is %(max)d MBs.'¶
str
– The error message of the validator.
- __call__(file)[source]¶
Call the validator on the given file.
- Parameters:
file (
File
) – The file to be validated.- Raises:
ValidationError – If the file is too large.
- deconstruct()¶
Return a 3-tuple of class import path, positional arguments, and keyword arguments.
- class MangAdventure.validators.DiscordServerValidator(*args, **kwargs)[source]¶
Bases:
RegexValidator
Validates a Discord server URL.
- regex = '^https://discord\\.(gg|me)/[A-Za-z0-9_%-]+$'¶
- message = 'Invalid Discord server URL.'¶
- code = 'invalid_discord_url'¶
- MangAdventure.validators.zipfile_validator(file)[source]¶
Validate a zip file:
It must be a valid
ZipFile
.It must only contain image files.
It cannot contain more than 1 subfolder.
- Parameters:
file (
File
) – The file to be validated.- Raises:
ValidationError – If any of the validations failed.
- class MangAdventure.validators.TwitterNameValidator(*args, **kwargs)[source]¶
Bases:
RegexValidator
Validates a Twitter name.
- regex = '^[A-Za-z0-9_-]{1,15}$'¶
- message = 'Invalid Twitter username.'¶
- code = 'invalid_twitter_name'¶
MangAdventure.views module¶
The main views and error handlers.
- MangAdventure.views.index(request)[source]¶
View that serves the index page which shows the latest releases.
- Parameters:
request (
HttpRequest
) – The original request.- Return type:
- Returns:
A response with the rendered
index.html
template.
- MangAdventure.views.search(request)[source]¶
View that serves a page used for searching for series.
- Parameters:
request (
HttpRequest
) – The original request.- Return type:
- Returns:
A response with the rendered
search.html
template.
- MangAdventure.views.opensearch(request)[source]¶
View that serves the
opensearch.xml
file.- Parameters:
request (
HttpRequest
) – The original request.- Return type:
- Returns:
A response with the rendered
opensearch.xml
template.
- MangAdventure.views.robots(request)[source]¶
View that serves the
robots.txt
file.- Parameters:
request (
HttpRequest
) – The original request.- Return type:
- Returns:
A response with the generated
robots.txt
file.
- MangAdventure.views.contribute(request)[source]¶
View that serves the
contribute.json
file.- Parameters:
request (
HttpRequest
) – The original request.- Return type:
- Returns:
A response with the
contribute.json
file.
- MangAdventure.views.manifest(request)[source]¶
View that serves the
manifest.webmanifest
file.- Parameters:
request (
HttpRequest
) – The original request.- Return type:
- Returns:
A response with the
manifest.webmanifest
file.
- MangAdventure.views.handler400(request, exception=None, template_name='error.html')[source]¶
Handler for 400 responses.
- Parameters:
request (
HttpRequest
) – The original request.exception (
Optional
[Exception
]) – The exception that occurred.template_name (
str
) – The name of the error template.
- Return type:
- Returns:
A
JsonResponse
for API URLs, otherwise a response with the rendered error template.
- MangAdventure.views.handler403(request, exception=None, template_name='error.html')[source]¶
Handler for 403 responses.
- Parameters:
request (
HttpRequest
) – The original request.exception (
Optional
[Exception
]) – The exception that occurred.template_name (
str
) – The name of the error template.
- Return type:
- Returns:
A
JsonResponse
for API URLs, otherwise a response with the rendered error template.
- MangAdventure.views.handler404(request, exception=None, template_name='error.html')[source]¶
Handler for 404 responses.
- Parameters:
request (
HttpRequest
) – The original request.exception (
Optional
[Exception
]) – The exception that occurred.template_name (
str
) – The name of the error template.
- Return type:
- Returns:
A
JsonResponse
for API URLs, otherwise a response with the rendered error template.
- MangAdventure.views.handler500(request, exception=None, template_name='error.html')[source]¶
Handler for 500 responses.
- Parameters:
request (
HttpRequest
) – The original request.exception (
Optional
[Exception
]) – The exception that occurred.template_name (
str
) – The name of the error template.
- Return type:
- Returns:
A
JsonResponse
for API URLs, otherwise a response with the rendered error template.
MangAdventure.widgets module¶
Custom form widgets.
MangAdventure.wsgi module¶
WSGI definitions.
- MangAdventure.wsgi.application = <django.core.handlers.wsgi.WSGIHandler object>¶
Django’s WSGI application instance.