Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .copier/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v2024.3
_src_path: gh:westerveltco/django-twc-package
author_email: [email protected]
author_name: Josh Thomas
current_version: 0.1.0
django_versions:
- '3.2'
- '4.2'
- '5.0'
docs_domain: westervelt.dev
github_owner: westerveltco
github_repo: django-simple-nav
module_name: django_simple_nav
package_description: A simple, flexible, and extensible navigation menu for Django.
package_name: django-simple-nav
python_versions:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
test_django_main: true
versioning_scheme: SemVer
10 changes: 6 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{{J,j}ustfile,.{J,j}ustfile,{*.{py,rst,ini,md}}}]
[{,.}{j,J}ustfile]
indent_size = 4

[*.{py,rst,ini,md}]
indent_size = 4
indent_style = space

[*.py]
line_length = 120
multi_line_output = 3

[*.{css,html,js,json,sass,scss,yml,yaml}]
[*.{css,html,js,json,jsx,sass,scss,svelte,ts,tsx,yml,yaml}]
indent_size = 2
indent_style = space

[*.md]
trim_trailing_whitespace = false
Expand Down
Empty file added .env.example
Empty file.
6 changes: 5 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ updates:
interval: weekly
timezone: America/Chicago
labels:
- "dependabot"
- dependabot
groups:
gha:
patterns:
- "*"
27 changes: 10 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ name: release
on:
release:
types: [created]
workflow_dispatch:
inputs:
pypi:
description: "Publish to PyPI"
required: false
default: true
type: boolean

jobs:
check:
Expand All @@ -21,6 +14,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- name: Check most recent test run on `main`
id: latest-test-result
run: |
Expand All @@ -30,16 +24,17 @@ jobs:
--json headBranch,workflowName,conclusion \
--jq '.[] | select(.headBranch=="main" and .conclusion=="success") | .conclusion' \
| head -n 1)" >> $GITHUB_OUTPUT

- name: OK
if: ${{ (contains(steps.latest-test-result.outputs.result, 'success')) }}
run: exit 0

- name: Fail
if: ${{ !contains(steps.latest-test-result.outputs.result, 'success') }}
run: exit 1


pypi:
if: ${{ github.event_name == 'release' || inputs.pypi }}
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
needs: check
environment: release
Expand All @@ -48,21 +43,19 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install hatch

- name: Build package
run: |
hatch build
- if: ${{ github.event_name == 'workflow_dispatch' }}
name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- if: ${{ github.event_name != 'workflow_dispatch' }}
name: Publish to PyPI

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,35 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/*.example
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

staticfiles/
mediafiles/

# pyright config for nvim-lspconfig
pyrightconfig.json
30 changes: 21 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: check-yaml

- repo: https://github.com/adamchainz/django-upgrade
rev: "1.15.0"
rev: 1.15.0
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
Expand All @@ -20,7 +20,7 @@ repos:
rev: v0.1.3
hooks:
- id: ruff
args: [ --fix ]
args: [--fix]
- id: ruff-format

- repo: https://github.com/adamchainz/blacken-docs
Expand All @@ -31,18 +31,30 @@ repos:
additional_dependencies:
- black==22.12.0

- repo: https://github.com/rtts/djhtml
rev: "3.0.6"
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: djhtml
entry: djhtml --tabwidth 2
alias: autoformat
- id: prettier
# lint the following with prettier:
# - javascript
# - typescript
# - JSX/TSX
# - CSS
# - yaml
# ignore any minified code
files: '^(?!.*\.min\..*)(?P<name>[\w-]+(\.[\w-]+)*\.(js|jsx|ts|tsx|yml|yaml|css))$'

- repo: https://github.com/djlint/djLint
rev: v1.34.1
hooks:
- id: djlint-reformat-django
- id: djlint-django

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.11.0
hooks:
- id: pretty-format-toml
args: [--autofix]
- id: pretty-format-toml
args: [--autofix]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"

sphinx:
configuration: docs/conf.py
Expand Down
14 changes: 14 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"recommendations": [
"charliermarsh.ruff",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"monosans.djlint",
"ms-python.black-formatter",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"skellock.just",
"tamasfe.even-better-toml"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"editor.formatOnSave": true,
"files.associations": {
"Justfile": "just"
},
"ruff.organizeImports": true,
"[django-html][handlebars][hbs][mustache][jinja][jinja-html][nj][njk][nunjucks][twig]": {
"editor.defaultFormatter": "monosans.djlint"
}
}
2 changes: 1 addition & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Authors

- Josh Thomas <[email protected]>
- Jeff Triplett <@jefftriplett>
- Jeff Triplett [@jefftriplett](https://github.com/jefftriplett)
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/

## [Unreleased]

### Changed

- Now using [`django-twc-package`](https://github.com/westerveltco/django-twc-package) template for repository and package structure.

## [0.1.0]

Initial release! 🎉

### Added

- A group of navigation classes -- `Nav`, `NavGroup`, and `NavItem` -- that can be used together to build a simple navigation structure.
- `Nav` is the main container for a navigation structure.
- `NavGroup` is a container for a group of `NavItem` objects.
- `NavItem` is a single navigation item.
- `Nav` is the main container for a navigation structure.
- `NavGroup` is a container for a group of `NavItem` objects.
- `NavItem` is a single navigation item.
- A `django_simple_nav` template tag that renders a `Nav` object to a template. The template tag takes a string represented the dotted path to a `Nav` object and renders it to the template.
- Navigation item urls can be either a URL string (e.g. `https://example.com/about/` or `/about/`) or a Django URL name (e.g. `about-view`). When rendering out to the template, the template tag will resolve the URL name to the actual URL.
- Navigation items also can take a list of permissions to control the visibility of the item. The permissions can be user attributes (e.g. `is_staff`, `is_superuser`, etc.) or a specific permission (e.g. `auth.add_user`).
Expand All @@ -37,7 +41,7 @@ Initial release! 🎉
- Initial tests.
- Initial CI/CD (GitHub Actions).

### New Contributors!
### New Contributors

- Josh Thomas <[email protected]> (maintainer)
- Jeff Triplett [@jefftriplett](https://github.com/jefftriplett)
Expand Down
16 changes: 11 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ We adhere to Django's Code of Conduct in all interactions and expect all contrib

## Setup

The following setup steps assume you are using a Unix-like operating system, such as Linux or macOS, and that you have a [supported](#requirements) version of Python installed. If you are using Windows, you will need to adjust the commands accordingly. If you do not have Python installed, you can visit [python.org](https://www.python.org/) for instructions on how to install it for your operating system.
The following setup steps assume you are using a Unix-like operating system, such as Linux or macOS, and that you have a [supported](README.md#requirements) version of Python installed. If you are using Windows, you will need to adjust the commands accordingly. If you do not have Python installed, you can visit [python.org](https://www.python.org/) for instructions on how to install it for your operating system.

1. Fork the repository and clone it locally.
2. Create a virtual environment and activate it. You can use whatever tool you prefer for this. Below is an example using the Python standard library's `venv` module:
Expand All @@ -23,23 +23,29 @@ source venv/bin/activate
3. Install `django-simple-nav` and the `dev` dependencies in editable mode:

```shell
python -m pip install -e '.[dev]'
python -m pip install --editable '.[dev]'
# or using [just](#just)
just bootstrap
```

## Testing

We use [`pytest`](https://docs.pytest.org/) for testing and [`nox`](https://nox.thea.codes/) to run the tests in multiple environments.

To run the test suite against the current environment, run:
To run the test suite against the default versions of Python (lower bound of supported versions) and Django (lower bound of LTS versions), run:

```shell
python -m pytest
python -m nox --session "test"
# or using [just](#just)
just test
```

To run the test suite against all supported versions of Python and Django, run:

```shell
python -m nox
python -m nox --session "tests"
# or using [just](#just)
just testall
```

## `just`
Expand Down
Loading