Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change package name to "tetra" #55

Merged
merged 45 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e42e904
change package name to "tetra"
nerdoc Mar 31, 2024
360d3e6
add mkdocs config + missing files
nerdoc Mar 31, 2024
b59d09f
pyproject.toml transition
nerdoc Mar 31, 2024
016fe90
use tetra-framework organisation for gh issue tpl
nerdoc Mar 31, 2024
59c8a48
use django-environ for demo site
nerdoc Mar 31, 2024
a5e7b4b
update dependencies for demo site
nerdoc Mar 31, 2024
61d6409
use STATIC_ROOT from env
nerdoc Mar 31, 2024
070b85c
correctly find component origin
nerdoc Mar 31, 2024
dbfb525
update esbuild
nerdoc Apr 1, 2024
e037cd2
fix trailing comma
nerdoc Apr 1, 2024
2b87dbe
make environ settings more robust
nerdoc Apr 1, 2024
9a73cbf
use whitenoise in demo project for easier static files serving
nerdoc Apr 1, 2024
8b6d433
give users a hint when no components are found
nerdoc Apr 3, 2024
f04c6dd
add missing django-environ dependency
nerdoc Apr 3, 2024
74a7cc6
include [demo] packages in [dev]
nerdoc Apr 3, 2024
f9e69ba
add hint to logging output if imported component module can't be impo…
nerdoc Apr 3, 2024
ad46986
sourcetypes is also a demo dependency!
nerdoc Apr 3, 2024
088acf8
add some comments
nerdoc Apr 3, 2024
eae9bf6
+comment
nerdoc Apr 3, 2024
5a70a55
update generated demo js files
nerdoc Apr 3, 2024
c316f26
update generated demo js files (again)
nerdoc Apr 3, 2024
2d11418
update Alpinejs to v3.13.8
nerdoc Apr 4, 2024
70b0251
Merge branch 'main' into tetra-package
nerdoc Apr 4, 2024
b05d62a
improve demo: don't create empty TODOs
nerdoc Apr 4, 2024
a07a170
Changelog++
nerdoc Apr 5, 2024
d33298f
syntax++, PEP 8: E713
nerdoc Apr 5, 2024
08c4bbc
allow django templates from files
nerdoc Apr 5, 2024
8337f31
let `template` and `template_name` coexist, preferring `template`
nerdoc Apr 7, 2024
8250877
update github URL
nerdoc Apr 4, 2024
b085cfc
improve demo: don't create empty TODOs
nerdoc Apr 4, 2024
51199bd
Changelog++
nerdoc Apr 5, 2024
86b617b
syntax++, PEP 8: E713
nerdoc Apr 5, 2024
95e3134
Merge pull request #56 from tetra-framework/files-as-templates
nerdoc Apr 7, 2024
e2d92fe
docs: fix throttle h3
nerdoc Oct 26, 2022
ee7f361
better error message
nerdoc Apr 7, 2024
b12653f
make storage settings Django 5.1 ready
nerdoc Apr 7, 2024
d7dff91
remove double "the"
nerdoc Apr 7, 2024
0d2ae3e
add basic testing framework: pytest
nerdoc Apr 7, 2024
03b3376
pytest CI workflow
nerdoc Apr 7, 2024
180e4b2
fix docs @public watch attr: old_value
nerdoc Apr 7, 2024
8e6d939
improve docs understandability a bit: load, update, update_data methods
nerdoc Apr 8, 2024
acd2617
bump version to 0.1.0 - first pkg named "tetra"
nerdoc Apr 9, 2024
a7d91c9
use MANIFEST.in again for excluding some unneeded files from the sdist
nerdoc Apr 10, 2024
f03360d
bump version number to 0.1.1 + add docstring
nerdoc Apr 10, 2024
6fbc766
correct Sam's email address
nerdoc Apr 14, 2024
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
34 changes: 34 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: pytest-django CI

on:
push:
# TODO: change that to "main" when merging
branches: [ "tetra-package" ]
pull_request:
branches: [ "tetra-package" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.11, 3.12]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[dev]
cd tests
npm install
- name: Run Tests
run: |
cd tests
pytest
16 changes: 16 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Read the Docs configuration file for MkDocs projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

mkdocs:
configuration: mkdocs.yml

python:
install:
- requirements: docs/requirements.txt
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
recursive-include tetra/static *
recursive-include tetra/js *
recursive-include tetra/templates *
prune demosites
prune demosite
prune .github
exclude mkdocs.yml
exclude .readthedocs.yaml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Tetra is a new full stack component framework for Django, bridging the gap betwe

See examples at [tetraframework.com](https://www.tetraframework.com)

Read the [Documentation](https://www.tetraframework.com/docs)
Read the [Documentation](https://tetra.readthedocs.org)

```
pip install tetraframework
pip install tetra
```

## What does Tetra do?
Expand Down
5 changes: 5 additions & 0 deletions demosite/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DEBUG=True
SECRET_KEY=
# ALLOWED_HOSTS="www.tetraframework.com,tetraframework.com"
# CSRF_TRUSTED_ORIGINS="https://www.tetraframework.com,https://tetraframework.com"
# STATIC_ROOT="..."
19 changes: 11 additions & 8 deletions demosite/demo/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ def load(self):
self.todos = ToDo.objects.filter(session_key=self.request.session.session_key)

@public
def add_todo(self, title):
todo = ToDo(
title=title,
session_key=self.request.session.session_key,
)
todo.save()
self.title = ""
def add_todo(self, title: str):
if self.title:
todo = ToDo(
title=title,
session_key=self.request.session.session_key,
)
todo.save()
self.title = ""

template: django_html = """
<div>
<div class="input-group mb-2">
<input type="text" x-model="title" class="form-control"
placeholder="New task..." @keyup.enter="add_todo(title)">
<button class="btn btn-primary" @click="add_todo(title)">Add</button>
<button class="btn btn-primary" :class="{'disabled': title == ''}"
@click="add_todo(
title)">Add</button>
</div>
<div class="list-group">
{% for todo in todos %}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
demo_default-GUWUK47B.js
demo_default-JLCHQSL2.js
2 changes: 1 addition & 1 deletion demosite/demo/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h4 class="display-7">Full stack reactive component framework for <a href="http:
<i class="fa-solid fa-arrow-right"></i>
Get Started
</a>
<a href="https://github.com/samwillis/tetra" class="btn btn-light btn-lg px-4">
<a href="https://github.com/tetra-framework/tetra" class="btn btn-light btn-lg px-4">
<i class="fa-brands fa-github"></i>
GitHub
</a>
Expand Down
36 changes: 25 additions & 11 deletions demosite/demosite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,31 @@

import os
from pathlib import Path
import environ

env = environ.Env(
# set casting, default value
DEBUG=(bool, False)
)

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# Take environment variables from .env file
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get("SECRET_KEY", "insecure!")
# Raises Django's ImproperlyConfigured exception if SECRET_KEY not in os.environ
SECRET_KEY = env("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv("DEBUG", False) == "True"
DEBUG = env("DEBUG")
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["127.0.0.1", "localhost"])

ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
"www.tetraframework.com",
"tetraframework.com",
]
CSRF_TRUSTED_ORIGINS = ["https://www.tetraframework.com", "https://tetraframework.com"]
CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS", default=[])


# Application definition
Expand All @@ -50,6 +55,7 @@

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
Expand Down Expand Up @@ -126,8 +132,16 @@
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / "static"
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
STATIC_ROOT = env("STATIC_ROOT", default=BASE_DIR / "static")

# STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
STORAGES = (
{
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
},
},
)

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
Expand Down
2 changes: 1 addition & 1 deletion demosite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
},
"directories": {
"doc": "docs"
},
}
}
11 changes: 0 additions & 11 deletions dev-requirements.txt

This file was deleted.

13 changes: 8 additions & 5 deletions docs/attribute-tag.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Title: Attribute Tag
---
title: "The `...` Attribute"
---

# `...` Attribute Tag

Expand All @@ -12,7 +14,7 @@ The attributes tag is automaticity available in your component templates. In oth
checked=a_boolian_varible %}>
```

All Tetra components have a `attrs` context available, which is a `dict` of attributes that have been passed to the component when it is included in a template with the [`@` tag](component-tag). It can be unpacked as HTML attributes on your root node:
All Tetra components have an `attrs` context available, which is a `dict` of attributes that have been passed to the component when it is included in a template with the [`@` tag](component-tag.md). It can be unpacked as HTML attributes on your root node:

``` django
<div {% ... attrs %}>
Expand Down Expand Up @@ -68,14 +70,15 @@ Would result in:
<div style="font-size:2em; color:blue;">
```

> **Note:** Tetra currently does not understand that a style property can be applied in multiple ways. Therefore, if you pass both `margin-top: 1em` and `margin: 2em 0 0 0`, both will appear in the final HTML style tag, with the final property taking precedence in the browser.
!!! note
Tetra currently does not understand that a style property can be applied in multiple ways. Therefore, if you pass both `margin-top: 1em` and `margin: 2em 0 0 0`, both will appear in the final HTML style tag, with the final property taking precedence in the browser.

## Conditional values

The [`if` and `else` template filters](if-else-filters) are provided to enable conditional attribute values:
The [`if` and `else` template filters](if-else-filters.md) are provided to enable conditional attribute values:

``` html
<div {% ... class="class1"|if:variable_name|else:"class2" %}>
```

See the documentation for the [`if` and `else` template filters](if-else-filters).
See the documentation for the [`if` and `else` template filters](if-else-filters.md).
4 changes: 3 additions & 1 deletion docs/basic-components.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Title: Basic Components
---
title: Basic Components
---

# Basic Components

Expand Down
Loading