Skip to content

Commit

Permalink
Merge pull request #31 from chnm/tailwind-setup
Browse files Browse the repository at this point in the history
Project setup for django-tailwind
  • Loading branch information
hepplerj authored May 31, 2024
2 parents c6be3f9 + cec0be9 commit 83a6f74
Show file tree
Hide file tree
Showing 21 changed files with 2,053 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
db.sqlite3
.idea/
lasfera.dbml
data.json

# Django #
*.log
Expand Down
13 changes: 12 additions & 1 deletion config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.staticfiles",
"tailwind",
"theme",
"django_browser_reload",
"import_export",
# "nested_admin",
"django_dbml",
"accounts",
"manuscript",
Expand All @@ -65,6 +67,7 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.middleware.locale.LocaleMiddleware",
"allauth.account.middleware.AccountMiddleware",
"django_browser_reload.middleware.BrowserReloadMiddleware",
]

ROOT_URLCONF = "config.urls"
Expand Down Expand Up @@ -160,8 +163,16 @@

STATIC_ROOT = str(BASE_DIR / "staticfiles")
STATIC_URL = "static/"
MEDIA_ROOT = str(BASE_DIR / "media")
MEDIA_URL = "media/"

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

# Tailwind CSS
TAILWIND_APP_NAME = "theme"
INTERNAL_IPS = [
"127.0.0.1",
]
1 change: 1 addition & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
path("accounts/", include("allauth.urls")),
path("admin/", admin.site.urls),
path("prose/", include("prose.urls")),
path("__reload__/", include("django_browser_reload.urls")),
]
2 changes: 1 addition & 1 deletion make_library_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
}
)

with open("manuscript/fixtures/libraries.json", "w") as f:
with open("manuscript/fixtures/libraries.json", "w", encoding="utf-8") as f:
json.dump(data, f)
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Generated by Django 5.0.2 on 2024-05-30 20:54

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("manuscript", "0071_alter_folio_options_alter_stanza_options"),
]

operations = [
migrations.AlterField(
model_name="detail",
name="distance_lines",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="detail",
name="is_sea_red",
field=models.CharField(
blank=True,
max_length=510,
null=True,
verbose_name="Is the Red Sea colored red?",
),
),
migrations.AlterField(
model_name="detail",
name="laiazzo",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="detail",
name="standard_water",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="detail",
name="stanzas_ed",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="detail",
name="stanzas_separated",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="detail",
name="tabriz",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="editorialstatus",
name="collated",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="folio",
name="folio_includes_map",
field=models.CharField(
blank=True,
choices=[
("yes", "Yes"),
("yes_toponyms", "Yes with toponyms"),
("yes_no_toponyms", "Yes without toponyms"),
("no", "No"),
],
max_length=510,
null=True,
verbose_name="Does the folio include a map?",
),
),
migrations.AlterField(
model_name="folio",
name="folio_number",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="location",
name="line_code",
field=models.CharField(
blank=True, help_text="Citation line code.", max_length=510, null=True
),
),
migrations.AlterField(
model_name="location",
name="placename_id",
field=models.CharField(
blank=True, max_length=510, null=True, verbose_name="Placename ID"
),
),
migrations.AlterField(
model_name="textdecoration",
name="diagrams",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="textdecoration",
name="illumination",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="textdecoration",
name="maps",
field=models.CharField(blank=True, max_length=510, null=True),
),
migrations.AlterField(
model_name="textdecoration",
name="white_vine_work",
field=models.CharField(blank=True, max_length=510, null=True),
),
]
38 changes: 23 additions & 15 deletions manuscript/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class EditorialStatus(models.Model):
)
# siglum = models.CharField(max_length=255, blank=True, null=True, unique=True)
editorial_priority = models.IntegerField(blank=True, null=True)
collated = models.CharField(blank=True, null=True)
collated = models.CharField(blank=True, null=True, max_length=510)
access = models.IntegerField(blank=True, null=True)
spatial_priority = models.CharField(max_length=6, blank=True, null=True)
dataset = models.CharField(max_length=255, blank=True, null=True)
Expand Down Expand Up @@ -127,10 +127,10 @@ class TextDecoration(models.Model):
)
text_script = models.CharField(max_length=255, blank=True, null=True)
label_script = models.CharField(max_length=255, blank=True, null=True)
diagrams = models.CharField(blank=True, null=True)
maps = models.CharField(blank=True, null=True)
illumination = models.CharField(blank=True, null=True)
white_vine_work = models.CharField(blank=True, null=True)
diagrams = models.CharField(blank=True, null=True, max_length=510)
maps = models.CharField(blank=True, null=True, max_length=510)
illumination = models.CharField(blank=True, null=True, max_length=510)
white_vine_work = models.CharField(blank=True, null=True, max_length=510)
other = models.CharField(max_length=255, blank=True, null=True)
relative_quality = models.CharField(max_length=255, blank=True, null=True)

Expand Down Expand Up @@ -166,28 +166,31 @@ class Detail(models.Model):
max_length=510, blank=True, null=True
)
stanza_initials = RichTextField(max_length=510, blank=True, null=True)
stanzas_separated = models.CharField(blank=True, null=True)
stanzas_ed = models.CharField(blank=True, null=True)
stanzas_separated = models.CharField(blank=True, null=True, max_length=510)
stanzas_ed = models.CharField(blank=True, null=True, max_length=510)
filigree = models.CharField(
max_length=510,
blank=True,
null=True,
verbose_name="Flourished/Filigree Initials",
)
standard_water = models.CharField(blank=True, null=True)
standard_water = models.CharField(blank=True, null=True, max_length=510)
abbreviations = RichTextField(max_length=510, blank=True, null=True)
catchwords = RichTextField(max_length=510, blank=True, null=True)
mabel_label = models.CharField(max_length=510, blank=True, null=True)
map_labels = RichTextField(max_length=510, blank=True, null=True)
distance_lines = models.CharField(blank=True, null=True)
distance_lines = models.CharField(blank=True, null=True, max_length=510)
distance_numbers = models.CharField(max_length=510, blank=True, null=True)
coat_of_arms = models.CharField(max_length=510, blank=True, null=True)

is_sea_red = models.CharField(
blank=True, null=True, verbose_name="Is the Red Sea colored red?"
blank=True,
null=True,
verbose_name="Is the Red Sea colored red?",
max_length=510,
)
laiazzo = models.CharField(blank=True, null=True)
tabriz = models.CharField(blank=True, null=True)
laiazzo = models.CharField(blank=True, null=True, max_length=510)
tabriz = models.CharField(blank=True, null=True, max_length=510)
rhodes_status = models.CharField(max_length=510, blank=True, null=True)

def __str__(self) -> str:
Expand Down Expand Up @@ -364,7 +367,7 @@ class Folio(models.Model):
)

id = models.AutoField(primary_key=True)
folio_number = models.CharField(blank=True, null=True)
folio_number = models.CharField(blank=True, null=True, max_length=510)
folio_notes = RichTextField(blank=True, null=True)
manuscript = models.ForeignKey(
"SingleManuscript", on_delete=models.CASCADE, blank=True, null=True
Expand All @@ -385,6 +388,7 @@ class Folio(models.Model):
null=True,
choices=FOLIO_MAP_CHOICES,
verbose_name="Does the folio include a map?",
max_length=510,
)
locations_mentioned = models.ManyToManyField(
"Location",
Expand Down Expand Up @@ -492,9 +496,13 @@ class Location(models.Model):
"""Handle the location information and toponyms within a manuscript"""

id = models.AutoField(primary_key=True)
placename_id = models.CharField(blank=True, null=True, verbose_name="Placename ID")
placename_id = models.CharField(
blank=True, null=True, verbose_name="Placename ID", max_length=510
)
# TODO: this could be more than one... eg this toponym shows up at 2.3.4 and 1.4.7
line_code = models.CharField(blank=True, null=True, help_text="Citation line code.")
line_code = models.CharField(
blank=True, null=True, help_text="Citation line code.", max_length=510
)
related_folio = models.ForeignKey(
Folio, on_delete=models.CASCADE, blank=True, null=True
)
Expand Down
7 changes: 5 additions & 2 deletions manuscript/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
from django.urls import reverse
from django.views import generic

from manuscript.models import Stanza
from manuscript.models import SingleManuscript, Stanza


def index(request: HttpRequest):
stanzas = Stanza.objects.all().order_by("stanza_line_code_starts")
return render(request, "index.html", {"stanzas": stanzas})
manuscripts = SingleManuscript.objects.all()
return render(
request, "index.html", {"stanzas": stanzas, "manuscripts": manuscripts}
)
35 changes: 34 additions & 1 deletion poetry.lock

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

4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ beautifulsoup4 = "^4.12.3"
django-prose-editor = "^0.3.4"
django-tinymce = "^4.0.0"
django-import-export = "^4.0.3"
django-tailwind = "^3.8.0"


[tool.poetry.group.development.dependencies]
django-tailwind = {extras = ["reload"], version = "^3.8.0"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
28 changes: 28 additions & 0 deletions staticfiles/django-browser-reload/reload-listener.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use strict";

{
const dataset = document.currentScript.dataset;
const workerScriptPath = dataset.workerScriptPath;
const eventsPath = dataset.eventsPath;

if (!window.SharedWorker) {
console.debug("😭 django-browser-reload cannot work in this browser.");
} else {
const worker = new SharedWorker(workerScriptPath, {
name: "django-browser-reload",
});

worker.port.addEventListener("message", (event) => {
if (event.data === "Reload") {
location.reload();
}
});

worker.port.postMessage({
type: "initialize",
eventsPath,
});

worker.port.start();
}
}
Loading

0 comments on commit 83a6f74

Please sign in to comment.