commit afc6e0c9374da6b40a53c70cd43df1d7a5bd934b Author: Zakarya Date: Tue May 20 21:27:20 2025 -0700 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..515168b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +db.sqlite3 +__pycache__ +sandbox/__pycache__ diff --git a/DJANGOCMS-LICENSE b/DJANGOCMS-LICENSE new file mode 100644 index 0000000..e56bc21 --- /dev/null +++ b/DJANGOCMS-LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2023, django CMS Association + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..9ef7f21 --- /dev/null +++ b/LICENCE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Colormatic + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..94e313d --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Colormatic Library Sandbox + +This is a development environment for working on templates, views, and models for the Colormatic Library. + +To get started working in this codebase, first ensure that you have Python, Pip, and optionally venv installed. + +Optionally, you can create a virtual environment to install packages locally: + +``` +python -m venv +``` + +Replace `` with whatever you want to call the virtual environment, e.g. "venv". + +Clone this repository: + +``` +git clone https://git.colormatic.org/ColormaticStudios/Colormatic-Library-Sandbox.git +cd Colormatic-Library-Sandbox +``` + +Install the necessary packages: + +``` +python -m pip install -r requirements.in +``` + +Initialize the database with your admin user: + +``` +python -m manage migrate +python -m manage createsuperuser +``` + +Check if everything is configured properly: + +``` +python -m manage cms check +``` + +You should now have a db.sqlite3 ready to go. +Run the project with: + +``` +python -m manage runserver +``` + +Refer to the Django and Django CMS documentation. + +Run `djade ` to format a template. \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..e675a5c --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sandbox.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..86aa9a3 --- /dev/null +++ b/requirements.in @@ -0,0 +1,7 @@ +djangocms-versioning +djangocms-alias +djangocms-frontend>=2.0.0a1 +django-filer +djangocms-text +django-fsm<3 +djade \ No newline at end of file diff --git a/sandbox/__init__.py b/sandbox/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sandbox/asgi.py b/sandbox/asgi.py new file mode 100644 index 0000000..4bc4187 --- /dev/null +++ b/sandbox/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for sandbox project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sandbox.settings') + +application = get_asgi_application() diff --git a/sandbox/settings.py b/sandbox/settings.py new file mode 100644 index 0000000..a0abdb2 --- /dev/null +++ b/sandbox/settings.py @@ -0,0 +1,241 @@ +""" +Django settings for sandbox project. + +Generated by 'djangocms' command using django CMS 5.0.0 and Django 5.2.1. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/topics/settings/ + +For the full list of Django settings and their values, see +https://docs.djangoproject.com/en/5.2/ref/settings/ + +For the list of django CMS settings and their values, see +https://docs.django-cms.org/en/release-5.0.x/reference/configuration.html +""" + +import os +from pathlib import Path + +from django.utils.translation import gettext_lazy as _ + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-l*51_imckgkjri#_$sjsq=mcm0329%)^&nfmq+wj30&e76#prk' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'djangocms_admin_style', + + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django.contrib.sites', + # CMS base apps + 'cms', + 'menus', + + 'djangocms_text', + 'djangocms_link', + 'djangocms_alias', + 'djangocms_versioning', + + 'sekizai', + 'treebeard', + 'parler', + + 'filer', + 'easy_thumbnails', + 'djangocms_frontend', + 'djangocms_frontend.contrib.accordion', + 'djangocms_frontend.contrib.alert', + 'djangocms_frontend.contrib.badge', + 'djangocms_frontend.contrib.card', + 'djangocms_frontend.contrib.carousel', + 'djangocms_frontend.contrib.collapse', + 'djangocms_frontend.contrib.content', + 'djangocms_frontend.contrib.grid', + 'djangocms_frontend.contrib.icon', + 'djangocms_frontend.contrib.image', + 'djangocms_frontend.contrib.jumbotron', + 'djangocms_frontend.contrib.link', + 'djangocms_frontend.contrib.listgroup', + 'djangocms_frontend.contrib.media', + 'djangocms_frontend.contrib.navigation', + 'djangocms_frontend.contrib.tabs', + 'djangocms_frontend.contrib.utilities', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'cms.middleware.user.CurrentUserMiddleware', + 'cms.middleware.page.CurrentPageMiddleware', + 'cms.middleware.toolbar.ToolbarMiddleware', + 'django.middleware.locale.LocaleMiddleware', + 'cms.middleware.language.LanguageCookieMiddleware', +] + +ROOT_URLCONF = 'sandbox.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + os.path.join(BASE_DIR, "sandbox", "templates"), + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.template.context_processors.i18n', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + 'sekizai.context_processors.sekizai', + 'cms.context_processors.cms_settings', + ], + }, + }, +] + +THUMBNAIL_PROCESSORS = ( + 'easy_thumbnails.processors.colorspace', + 'easy_thumbnails.processors.autocrop', + 'filer.thumbnail_processors.scale_and_crop_with_subject_location', + 'easy_thumbnails.processors.filters', +) + +WSGI_APPLICATION = 'sandbox.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.2/topics/i18n/ + +LANGUAGE_CODE = 'en' + +LANGUAGES = [ + ("en", _("English")), + # Add additional languages here +] + +TIME_ZONE = 'UTC' + +USE_I18N = True +USE_L10N = True +USE_THOUSAND_SEPARATOR = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.2/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + +# This is a django CMS 4 template + +CMS_CONFIRM_VERSION4 = True + +# django CMS requires the site framework +# https://docs.django-cms.org/en/release-5.0.x/how_to/multi-site.html + +SITE_ID = 1 + +# A base template is part of this setup +# https://docs.django-cms.org/en/release-5.0.x/reference/configuration.html#cms-templates + +CMS_TEMPLATES = ( + ("base.html", _("Standard")), +) + +# Enable permissions +# https://docs.django-cms.org/en/release-5.0.x/topics/permissions.html + +CMS_PERMISSION = True + +# Allow admin sidebar to open admin URLs + +X_FRAME_OPTIONS = 'SAMEORIGIN' + +# Enable inline editing with djangocms-text +# https://github.com/django-cms/djangocms-text#inline-editing-feature + +TEXT_INLINE_EDITING = True + +# Allow deletion of version objects +# https://djangocms-versioning.readthedocs.io/en/latest/settings.html#DJANGOCMS_VERSIONING_ALLOW_DELETING_VERSIONS + +DJANGOCMS_VERSIONING_ALLOW_DELETING_VERSIONS = True + +# Add project-wide static files directory +# https://docs.djangoproject.com/en/5.2/ref/settings/#staticfiles-dirs + +STATICFILES_DIRS = [ + BASE_DIR / "sandbox" / "static", +] + +INTERNAL_IPS = [ + "127.0.0.1", +] + +# Add project-wide static files directory +# https://docs.djangoproject.com/en/5.2/ref/settings/#media-root + +MEDIA_URL = "media/" +MEDIA_ROOT = str(BASE_DIR.parent / "media") diff --git a/sandbox/static/colormatic_logo.svg b/sandbox/static/colormatic_logo.svg new file mode 100644 index 0000000..f387e58 --- /dev/null +++ b/sandbox/static/colormatic_logo.svg @@ -0,0 +1,211 @@ + + + + diff --git a/sandbox/templates/base.html b/sandbox/templates/base.html new file mode 100644 index 0000000..c79eb42 --- /dev/null +++ b/sandbox/templates/base.html @@ -0,0 +1,81 @@ +{% load cms_tags i18n menu_tags sekizai_tags static %}{% spaceless %} + {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} + + + + + + + {% block meta %} + + + + + {% endblock meta %} + {% block canonical_url %} + + + {% endblock canonical_url %} + {% block fb_meta %}{% endblock %} + {% block title %}{{ request.current_page.get_page_title|striptags }}{% endblock %} + {% block base_css %} + + {% endblock base_css %} +{% endspaceless %}{% render_block 'css' %}{% spaceless %} + {% block page_head %}{% endblock %} + + +{% endspaceless %}{% cms_toolbar %}{% block navbar %} + +{% endblock navbar %} + {% block content %} +
+ {% placeholder "Page Content" %} +
+ {% endblock content %}{% spaceless %} + {% block base_js %} + + {% endblock base_js %} +{% endspaceless %}{% render_block 'js' %}{% spaceless %} + {% block end_js %} + + {% endblock end_js %} + {% block bottom_css %}{% endblock %} + + {% endspaceless %} diff --git a/sandbox/urls.py b/sandbox/urls.py new file mode 100644 index 0000000..c900424 --- /dev/null +++ b/sandbox/urls.py @@ -0,0 +1,34 @@ +""" +URL configuration for sandbox project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.conf import settings +from django.conf.urls.i18n import i18n_patterns +from django.conf.urls.static import static +from django.contrib import admin +from django.urls import include, path +from django.views.i18n import JavaScriptCatalog + +urlpatterns = i18n_patterns( + path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'), + path('admin/', admin.site.urls), + path('filer/', include('filer.urls')), + path('', include('cms.urls')), +) + + +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + diff --git a/sandbox/wsgi.py b/sandbox/wsgi.py new file mode 100644 index 0000000..6c14164 --- /dev/null +++ b/sandbox/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for sandbox project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sandbox.settings') + +application = get_wsgi_application()