django-theme-academy


Namedjango-theme-academy JSON
Version 0.3.10 PyPI version JSON
download
home_pagehttps://github.com/caltechads/django-theme-academy
SummaryA Tabler-based, fixed left sidebar django theme.
upload_time2024-08-21 20:53:04
maintainerNone
docs_urlNone
authorCaltech IMSS ADS
requires_pythonNone
licenseNone
keywords django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-theme-academy

`django-theme-academy` provides the Academy theme for Django websites and applications.  Academy provides the following features:

* Built with Tabler, and Bootstrap 5
* A fixed left sidebar with configurable logo
* Breadcrumbs
* A footer with contact information for your organiization
* Includes [django-wildewidgets](https://github.com/caltechads/django-wildewidgets) support

## Installation

`django-theme-academy` supports Python 3.7+, and Django 3+.

To install from PyPI:

```bash
pip install django-theme-academy
```

### Update settings.py

Register the module in `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    ...
    'academy_theme',
    ...
]
```

Add the custom template context processor:

```python
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'OPTIONS': {
            ...
            'context_processors': [
                ...
                'academy_theme.context_processors.theme',
                ...
            ],
        },
    },
]
```

Optionally configure the theme specific settings.  You don't need to define all of these, but instead
only the ones you wish to override:

```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',

    # Footer
    'ORGANIZATION_LINK': 'https://myorg.com',
    'ORGANIZATION_NAME': 'Organization Name',
    'ORGANIZATION_ADDRESS': 'Organization Address',
    'COPYRIGHT_ORGANIZATION': 'Copyright Organization'
    'FOOTER_LINKS': []
}
```

### Choose a base.hml

`django-theme-academy` ships with two different base templates:

* `academy_theme/base.html`, for regular Django template development
* `academy_theme/base--wildewidgets.html`, for [django-wildewidgets](https://github.com/caltechads/django-wildewidgets) based Django development

#### base.html

To use `academy_theme/base.html`, create your own `base.html` that extends it
and overrides its blocks as needed.  Example:

```html
{% extends 'academy_theme/base.html' %}
{% load static academy_theme i18n %}

{% block title %}{% trans 'My App Title' %}{% endblock %}

{% block extra_css %}
  <link rel="stylesheet" href="{% static 'myapp/css/styles.css' %}">
{% endblock %}

{% block extra_header_js %}
  <script src="{% static 'myapp/js/app.js %}" ></script>
{% endblock %}

{% block menu %}
<nav class="navbar navbar-vertical navbar-expand-lg navbar-dark">
 <div class="container-lg ms-0">
    <a class="navbar-brand" href="#">
        <img src="{% static 'myapp/images/logo.png' %} alt="My App" width="100%">
    </a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContentV_9628" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav me-1">
       <li class="nav-item">
          <a class="nav-link" href="/">Home</a>
        </li>
      </ul>
    </div>
  </div>
</nav>
{% endblock %}

{% block breadcrumbs %}
  <ol class="breadcrumb">
    {% block breadcrumb-items %}
        {% breadcrumb 'Home' 'myapp:home' %}
    {% endblock %}
  </ol>
{% endblock %}
```

#### base-wildewidgets.html

If you don't need to add any Javascript or CSS, this can be used directly in
your ``django-wildewidgets`` based views, like so:

```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
```

If you do need to add Javascript or CSS, create your own `base--wildewidgets.html` that extends the `acadmey_theme`
one and and overrides its blocks as needed.  Example:

```html
{% extends 'academy_theme/base--wildewidgets.html' %}
{% load static %}

{% block extra_css %}
  <link rel="stylesheet" href="{% static 'myapp/css/styles.css' %}">
{% endblock %}

{% block extra_header_js %}
  <script src="{% static 'myapp/js/app.js %}" ></script>
{% endblock %}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/caltechads/django-theme-academy",
    "name": "django-theme-academy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django",
    "author": "Caltech IMSS ADS",
    "author_email": "imss-ads-staff@caltech.edu",
    "download_url": "https://files.pythonhosted.org/packages/77/b3/a6f2c515f69cf5f182f5bea36b6c2a70c6ca520bbfd8a364e8a29a9ddf5b/django-theme-academy-0.3.10.tar.gz",
    "platform": null,
    "description": "# django-theme-academy\n\n`django-theme-academy` provides the Academy theme for Django websites and applications.  Academy provides the following features:\n\n* Built with Tabler, and Bootstrap 5\n* A fixed left sidebar with configurable logo\n* Breadcrumbs\n* A footer with contact information for your organiization\n* Includes [django-wildewidgets](https://github.com/caltechads/django-wildewidgets) support\n\n## Installation\n\n`django-theme-academy` supports Python 3.7+, and Django 3+.\n\nTo install from PyPI:\n\n```bash\npip install django-theme-academy\n```\n\n### Update settings.py\n\nRegister the module in `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n    ...\n    'academy_theme',\n    ...\n]\n```\n\nAdd the custom template context processor:\n\n```python\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'OPTIONS': {\n            ...\n            'context_processors': [\n                ...\n                'academy_theme.context_processors.theme',\n                ...\n            ],\n        },\n    },\n]\n```\n\nOptionally configure the theme specific settings.  You don't need to define all of these, but instead\nonly the ones you wish to override:\n\n```python\nACADEMY_THEME_SETTINGS = {\n    # Header\n    'APPLE_TOUCH_ICON': 'myapp/images/apple-touch-icon.png',\n    'FAVICON_32': 'myapp/images/favicon-32x32.png',\n    'FAVICON_16': 'myapp/images/favicon-16x16.png',\n    'FAVICON': 'myapp/images/favicon.ico',\n    'SITE_WEBMANIFEST': 'myapp/images/site.webmanifest',\n\n    # Footer\n    'ORGANIZATION_LINK': 'https://myorg.com',\n    'ORGANIZATION_NAME': 'Organization Name',\n    'ORGANIZATION_ADDRESS': 'Organization Address',\n    'COPYRIGHT_ORGANIZATION': 'Copyright Organization'\n    'FOOTER_LINKS': []\n}\n```\n\n### Choose a base.hml\n\n`django-theme-academy` ships with two different base templates:\n\n* `academy_theme/base.html`, for regular Django template development\n* `academy_theme/base--wildewidgets.html`, for [django-wildewidgets](https://github.com/caltechads/django-wildewidgets) based Django development\n\n#### base.html\n\nTo use `academy_theme/base.html`, create your own `base.html` that extends it\nand overrides its blocks as needed.  Example:\n\n```html\n{% extends 'academy_theme/base.html' %}\n{% load static academy_theme i18n %}\n\n{% block title %}{% trans 'My App Title' %}{% endblock %}\n\n{% block extra_css %}\n  <link rel=\"stylesheet\" href=\"{% static 'myapp/css/styles.css' %}\">\n{% endblock %}\n\n{% block extra_header_js %}\n  <script src=\"{% static 'myapp/js/app.js %}\" ></script>\n{% endblock %}\n\n{% block menu %}\n<nav class=\"navbar navbar-vertical navbar-expand-lg navbar-dark\">\n <div class=\"container-lg ms-0\">\n    <a class=\"navbar-brand\" href=\"#\">\n        <img src=\"{% static 'myapp/images/logo.png' %} alt=\"My App\" width=\"100%\">\n    </a>\n    <button class=\"navbar-toggler\" type=\"button\" data-bs-toggle=\"collapse\" data-bs-target=\"#navbarSupportedContentV_9628\" aria-controls=\"navbarSupportedContent\" aria-expanded=\"false\" aria-label=\"Toggle navigation\">\n      <span class=\"navbar-toggler-icon\"></span>\n    </button>\n    <div class=\"collapse navbar-collapse\" id=\"navbarSupportedContent\">\n      <ul class=\"navbar-nav me-1\">\n       <li class=\"nav-item\">\n          <a class=\"nav-link\" href=\"/\">Home</a>\n        </li>\n      </ul>\n    </div>\n  </div>\n</nav>\n{% endblock %}\n\n{% block breadcrumbs %}\n  <ol class=\"breadcrumb\">\n    {% block breadcrumb-items %}\n        {% breadcrumb 'Home' 'myapp:home' %}\n    {% endblock %}\n  </ol>\n{% endblock %}\n```\n\n#### base-wildewidgets.html\n\nIf you don't need to add any Javascript or CSS, this can be used directly in\nyour ``django-wildewidgets`` based views, like so:\n\n```python\nfrom typing import List, Tuple, Type\n\nfrom academy_theme.wildewidgets import AcademyThemeMainMenu\nfrom django.templatetags.static import static\nfrom wildewidgets import (\n    BasicMenu,\n    BreadcrumbBlock\n    CardWidget,\n    MenuMixin,\n    StandardWidgetMixin,\n    WidgetListLayout\n)\n\nclass MainMenu(AcademyThemeMainMenu):\n    brand_image: str = static(\"myapp/images/logo.png\")\n    brand_text: str = \"My App\"\n    items: List[Tuple[str, str]] = [\n        ('Home', 'myapp:home'),\n    ]\n\n\nclass BaseBreadcrumbs(BreadcrumbBlock):\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.add_breadcrumb('Home', reverse('myapp:home'))\n\n\nclass WildewidgetsView(\n    MenuMixin,\n    StandardWidgetMixin,\n    TemplateView\n):\n    template_name: str = \"academy_theme/base--wildewidgets.html\"\n    menu_class: Type[BasicMenu] = MainMenu\n    menu_item: str = \"Home\"\n\n    def get_content(self) -> WidgetListLayout:\n        layout = WidgetListLayout(\"Wildewidgets Example\")\n        layout.add_widget(\n            CardWidget(\n                card_title='My Card',\n                widget='Here is my card body',\n            ),\n            title='My Card',\n            icon='info-square'\n        )\n        return layout\n\n    def get_breadcrumbs(self) -> BreadcrumbBlock:\n        breadcrumbs = BaseBreadcrumbs()\n        breadcrumbs.add_breadcrumb('Wildewidgets')\n        return breadcrumbs\n```\n\nIf you do need to add Javascript or CSS, create your own `base--wildewidgets.html` that extends the `acadmey_theme`\none and and overrides its blocks as needed.  Example:\n\n```html\n{% extends 'academy_theme/base--wildewidgets.html' %}\n{% load static %}\n\n{% block extra_css %}\n  <link rel=\"stylesheet\" href=\"{% static 'myapp/css/styles.css' %}\">\n{% endblock %}\n\n{% block extra_header_js %}\n  <script src=\"{% static 'myapp/js/app.js %}\" ></script>\n{% endblock %}\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Tabler-based, fixed left sidebar django theme.",
    "version": "0.3.10",
    "project_urls": {
        "Homepage": "https://github.com/caltechads/django-theme-academy"
    },
    "split_keywords": [
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "60f00344ac8823dd86b09900a940e6a5f6492c98bf8448fd7ffcb0f5c489cfca",
                "md5": "53ef9652798a54d4c97f875309d42345",
                "sha256": "6910a415c5b18c670c63228f00fa62b886045207c8dfab1980c14c16b9cdb4dd"
            },
            "downloads": -1,
            "filename": "django_theme_academy-0.3.10-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "53ef9652798a54d4c97f875309d42345",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 230110,
            "upload_time": "2024-08-21T20:53:02",
            "upload_time_iso_8601": "2024-08-21T20:53:02.972076Z",
            "url": "https://files.pythonhosted.org/packages/60/f0/0344ac8823dd86b09900a940e6a5f6492c98bf8448fd7ffcb0f5c489cfca/django_theme_academy-0.3.10-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "77b3a6f2c515f69cf5f182f5bea36b6c2a70c6ca520bbfd8a364e8a29a9ddf5b",
                "md5": "e20a52bd39beae83ee75d9feff55bac7",
                "sha256": "c2943a55e75a99dc85ea94cd7e8a4b1aca4547bd1e8191478c4138edf094b80d"
            },
            "downloads": -1,
            "filename": "django-theme-academy-0.3.10.tar.gz",
            "has_sig": false,
            "md5_digest": "e20a52bd39beae83ee75d9feff55bac7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 227265,
            "upload_time": "2024-08-21T20:53:04",
            "upload_time_iso_8601": "2024-08-21T20:53:04.875270Z",
            "url": "https://files.pythonhosted.org/packages/77/b3/a6f2c515f69cf5f182f5bea36b6c2a70c6ca520bbfd8a364e8a29a9ddf5b/django-theme-academy-0.3.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-21 20:53:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "caltechads",
    "github_project": "django-theme-academy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "django-theme-academy"
}
        
Elapsed time: 0.49078s