### Install django-theme-academy Source: https://github.com/caltechads/django-theme-academy/blob/master/doc/source/index.md Install the django-theme-academy package using pip. ```bash pip install django-theme-academy ``` -------------------------------- ### Install Sphinx and RTD Theme Source: https://github.com/caltechads/django-theme-academy/blob/master/doc/requirements.txt Install Sphinx for documentation generation and the Read the Docs theme for a clean presentation. These are essential for building and viewing project documentation. ```shell Sphinx==5.2.3 # https://github.com/sphinx-doc/sphinx sphinx_rtd_theme==1.0.0 ``` -------------------------------- ### Run Demo Service and Initialize Database Source: https://github.com/caltechads/django-theme-academy/blob/master/sandbox/README.md Starts the demo service in detached mode and then executes commands within the running container to initialize the database. Requires the Docker image to be built first. ```bash make dev-detached make exec > ./manage.py migrate ``` -------------------------------- ### Build Docker Image Source: https://github.com/caltechads/django-theme-academy/blob/master/sandbox/README.md Builds the Docker image for the django-theme-academy demo. Ensure Docker is installed and running. ```bash make build ``` -------------------------------- ### Django Wildewidgets View Example Source: https://github.com/caltechads/django-theme-academy/blob/master/README.md A Django view using django-wildewidgets that leverages the academy_theme/base--wildewidgets.html template. It defines a custom MainMenu, BaseBreadcrumbs, and a WildewidgetsView with content and breadcrumbs. ```python from typing import List, Tuple, Type from academy_theme.wildewidgets import AcademyThemeMainMenu from django.templatetags.static import static from wildewidgets import ( BasicMenu, BreadcrumbBlock, CardWidget, MenuMixin, StandardWidgetMixin, WidgetListLayout ) class MainMenu(AcademyThemeMainMenu): brand_image: str = static("myapp/images/logo.png") brand_text: str = "My App" items: List[Tuple[str, str]] = [ ('Home', 'myapp:home'), ] class BaseBreadcrumbs(BreadcrumbBlock): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.add_breadcrumb('Home', reverse('myapp:home')) class WildewidgetsView( MenuMixin, StandardWidgetMixin, TemplateView ): template_name: str = "academy_theme/base--wildewidgets.html" menu_class: Type[BasicMenu] = MainMenu menu_item: str = "Home" def get_content(self) -> WidgetListLayout: layout = WidgetListLayout("Wildewidgets Example") layout.add_widget( CardWidget( card_title='My Card', widget='Here is my card body', ), title='My Card', icon='info-square' ) return layout def get_breadcrumbs(self) -> BreadcrumbBlock: breadcrumbs = BaseBreadcrumbs() breadcrumbs.add_breadcrumb('Wildewidgets') return breadcrumbs ``` -------------------------------- ### Document Ready Execution Source: https://github.com/caltechads/django-theme-academy/blob/master/sandbox/demo/core/templates/core/version_js.html Initializes the version extraction functions once the DOM is fully loaded. ```javascript $(document).ready(function() { get_tabler_version(); get_bootstrap_icons_version(); get_jquery_version(); get_datatables_version(); }); ``` -------------------------------- ### Extending base--wildewidgets.html for Customization Source: https://github.com/caltechads/django-theme-academy/blob/master/README.md Create a custom base--wildewidgets.html that extends the default academy_theme/base--wildewidgets.html to add extra CSS or JavaScript. ```html {% extends 'academy_theme/base--wildewidgets.html' %} {% load static %} {% block extra_css %} {% endblock %} {% block extra_header_js %} {% endblock %} ``` -------------------------------- ### Register Theme in INSTALLED_APPS Source: https://github.com/caltechads/django-theme-academy/blob/master/README.md Add 'academy_theme' to your Django project's INSTALLED_APPS to enable the theme. ```python INSTALLED_APPS = [ ... 'academy_theme', ... ] ``` -------------------------------- ### Load Static and Translation Tags Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Loads necessary template tags for static file handling and internationalization. ```html {% load static i18n %} ``` -------------------------------- ### Conditional Display of Main Menu Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Renders the main menu if the 'menu' variable is present. ```html {# The main menu in the left sidebar #} {% if menu %}{% block main_menu %}{{menu}}{% endblock %}{% endif %} ``` -------------------------------- ### Extending base.html for Customization Source: https://github.com/caltechads/django-theme-academy/blob/master/README.md Create a custom base.html that extends the default academy_theme/base.html to override blocks for title, extra CSS, header JavaScript, navigation menu, and breadcrumbs. ```html {% extends 'academy_theme/base.html' %} {% load static academy_theme i18n %} {% block title %}{% trans 'My App Title' %}{% endblock %} {% block extra_css %} {% endblock %} {% block extra_header_js %} {% endblock %} {% block menu %} {% endblock %} {% block breadcrumbs %} {% endblock %} ``` -------------------------------- ### Add Theme Context Processor Source: https://github.com/caltechads/django-theme-academy/blob/master/README.md Include 'academy_theme.context_processors.theme' in your TEMPLATES settings to process theme-related context. ```python TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'OPTIONS': { ... 'context_processors': [ ... 'academy_theme.context_processors.theme', ... ], }, }, ] ``` -------------------------------- ### Configure Academy Theme Settings Source: https://github.com/caltechads/django-theme-academy/blob/master/README.md Optionally override default theme settings by defining ACADEMY_THEME_SETTINGS in your Django settings. This allows customization of header and footer elements. ```python ACADEMY_THEME_SETTINGS = { # Header 'APPLE_TOUCH_ICON': 'myapp/images/apple-touch-icon.png', 'FAVICON_32': 'myapp/images/favicon-32x32.png', 'FAVICON_16': 'myapp/images/favicon-16x16.png', 'FAVICON': 'myapp/images/favicon.ico', 'SITE_WEBMANIFEST': 'myapp/images/site.webmanifest', 'LOGOUT_TITLE': 'Log out of this site', 'LOGOUT_LINK': '/my/logout/link' # Footer 'ORGANIZATION_LINK': 'https://myorg.com', 'ORGANIZATION_NAME': 'Organization Name', 'ORGANIZATION_ADDRESS': 'Organization Address', 'COPYRIGHT_ORGANIZATION': 'Copyright Organization' 'FOOTER_LINKS': [] } ``` -------------------------------- ### Block for Secondary Menu Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html A placeholder block for rendering a secondary menu, typically used for sub-navigation. ```html {% block secondary_menu %}{{submenu}}{% endblock %} ``` -------------------------------- ### Ribbon Bar Links with Logout Option Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Renders links in the ribbon bar, including a logout link if the user is authenticated. Uses safe filter for LOGOUT_LINK. ```html {% block ribbon_bar_links %} {% if user.is_authenticated %} [{% trans 'Logout' %}]({{ LOGOUT_LINK|safe }} "{{ LOGOUT_TITLE }}". {% endif %} {% endblock %} ``` -------------------------------- ### Block for Displaying Messages Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Iterates through a 'messages' list and displays each message, formatted as an H4 heading. ```html {% block messages %} {% for message in messages %} #### {{ message }} {% endfor %} {% endblock %} ``` -------------------------------- ### Skip to Main Content Link Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Provides a link to skip directly to the main content area, using internationalization for the link text. ```html [{% trans 'Skip to main content' %}](#main-content-anchor) ``` -------------------------------- ### Block for Extra Header JavaScript Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Enables child templates to add JavaScript files to the page header, recommending the use of the 'defer' attribute. ```html {% block extra_header_js %} {# Override this in subtemplates to add additional javascript to the page. Remember to use defer. #} {% for package in extra_header_js %} {% endfor %} {% endblock %} ``` -------------------------------- ### Block for Extra CSS Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Allows child templates to include additional CSS files. It iterates over an 'extra_css' variable if provided. ```html {% block extra_css%} {% for stylesheet in extra_css %} {% endfor %} {% endblock %} ``` -------------------------------- ### Block for Breadcrumbs Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html A placeholder block for rendering breadcrumb navigation in child templates. ```html {% block breadcrumbs %}{% endblock %} ``` -------------------------------- ### Block for Primary Page Content Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html The main content block where child templates insert their specific page content. ```html {% block content %} {# This block is where templates place their primary page content. #} {% endblock %} ``` -------------------------------- ### Block for Page Title Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Defines a block where the page title can be set in child templates. ```html {% block title %}{% endblock %} ``` -------------------------------- ### Block for Extra Footer JavaScript Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Allows child templates to include additional JavaScript files specifically for the footer section. ```html {% block extra_footer_js %} {% for package in extra_footer_js %} {% endfor %} {% endblock %} ``` -------------------------------- ### Extract Bootstrap Icons Version Source: https://github.com/caltechads/django-theme-academy/blob/master/sandbox/demo/core/templates/core/version_js.html Parses the 'href' attribute of a Bootstrap Icons CSS link tag to extract its version number. Assumes the version is part of the path. ```javascript function get_bootstrap_icons_version() { var parts = $("head > link\[href\*='bootstrap-icons'\]").attr('href').split("/"); $("#bootstrap-icons-version .datagrid-content").text(parts[4].split('@')[1]); } ``` -------------------------------- ### Footer Content Block Source: https://github.com/caltechads/django-theme-academy/blob/master/academy_theme/templates/academy_theme/base.html Defines the footer area, including organization name, address, copyright year, and a list of footer links. Uses the 'now' tag for the current year. ```html {% block footer %} [{{ ORGANIZATION_NAME }}]({{ ORGANIZATION_LINK }}) {{ ORGANIZATION_ADDRESS }} © {% now 'Y' %} {{ COPYRIGHT_ORGANIZATION }} {% for link in FOOTER_LINKS %}* [{{ link.1 }}]({{ link.0 }}) {% endfor %} {% endblock %} ``` -------------------------------- ### Extract jQuery Version Source: https://github.com/caltechads/django-theme-academy/blob/master/sandbox/demo/core/templates/core/version_js.html Parses the 'src' attribute of a jQuery script tag to extract its version number. It removes the '.min.js' suffix before displaying. ```javascript function get_jquery_version() { var parts = $("head > script\[src\*='jquery'\]").attr('src').split("/"); $("#jquery-version .datagrid-content").text(parts[3].split('-')[1].replace('.min.js', '')); } ``` -------------------------------- ### Extract Tabler Version Source: https://github.com/caltechads/django-theme-academy/blob/master/sandbox/demo/core/templates/core/version_js.html Parses the 'href' attribute of a Tabler CSS link tag to extract its version number. Assumes the version is part of the path. ```javascript function get_tabler_version() { var parts = $("head > link\[href\*='tabler'\]").attr('href').split("/"); $("#tabler-version .datagrid-content").text(parts[4].split('@')[1]); } ``` -------------------------------- ### Extract DataTables Version Source: https://github.com/caltechads/django-theme-academy/blob/master/sandbox/demo/core/templates/core/version_js.html Parses the 'src' attribute of a DataTables script tag to extract its version number. Assumes the version is directly available in the path segment. ```javascript function get_datatables_version() { var parts = $("head > script\[src\*='datatables'\]").attr('src').split("/"); $("#datatables-version .datagrid-content").text(parts[3]) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.