Compare commits
32 commits
Author | SHA1 | Date | |
---|---|---|---|
Danielle McLean | 880b899e81 | ||
Danielle McLean | 6061d6f600 | ||
Danielle McLean | a680a6501c | ||
Danielle McLean | 625b5d963a | ||
Danielle McLean | 9d11cc7576 | ||
Danielle McLean | c49e17db90 | ||
Danielle McLean | 7696ff45db | ||
Danielle McLean | 731f177d18 | ||
Danielle McLean | 0061111ad8 | ||
Danielle McLean | 6b53c00d7c | ||
Danielle McLean | 1490a95735 | ||
Danielle McLean | c398b0d3f4 | ||
Danielle McLean | 95cca433bc | ||
Danielle McLean | 4f081c8d34 | ||
Danielle McLean | 8386f77d72 | ||
Danielle McLean | 03956637be | ||
Danielle McLean | 60bdaa27a0 | ||
Danielle McLean | a6fa7ebb3a | ||
Danielle McLean | d0bd6c1231 | ||
Danielle McLean | 960e64963f | ||
Danielle McLean | 0b1a548ee4 | ||
Danielle McLean | 04bd6dd35d | ||
Danielle McLean | 2e7d12b3e6 | ||
Danielle McLean | cd990e4e2f | ||
Danielle McLean | fe187da491 | ||
Danielle McLean | 636b470001 | ||
Danielle McLean | e5cf94d488 | ||
Danielle McLean | c5458c2d06 | ||
Danielle McLean | 7af8636687 | ||
Danielle McLean | 5ac46dad63 | ||
Danielle McLean | d4c814c79a | ||
Danielle McLean | db0d6e28a3 |
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Created by https://www.gitignore.io/api/django
|
||||
|
||||
### Django ###
|
||||
|
@ -15,8 +14,10 @@ media
|
|||
# <django-project-name>/staticfiles/
|
||||
|
||||
# End of https://www.gitignore.io/api/django
|
||||
|
||||
/.pdm-python
|
||||
/.env
|
||||
/.mypy_cache
|
||||
/.pytest_cache
|
||||
/static
|
||||
node_modules
|
||||
/node_modules
|
||||
|
|
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -1,3 +1,3 @@
|
|||
[submodule "lemoncurry/static/base16-materialtheme-scheme"]
|
||||
path = lemoncurry/static/base16-materialtheme-scheme
|
||||
url = git://github.com/ntpeters/base16-materialtheme-scheme.git
|
||||
url = https://github.com/ntpeters/base16-materialtheme-scheme
|
||||
|
|
|
@ -1,30 +1,41 @@
|
|||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.1.0
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: check-byte-order-marker
|
||||
- id: check-ast
|
||||
- id: check-builtin-literals
|
||||
- id: check-case-conflict
|
||||
- id: check-docstring-first
|
||||
- id: check-executables-have-shebangs
|
||||
- id: check-json
|
||||
- id: check-merge-conflict
|
||||
- id: check-symlinks
|
||||
- id: check-toml
|
||||
- id: check-vcs-permalinks
|
||||
- id: check-yaml
|
||||
- id: destroyed-symlinks
|
||||
- id: end-of-file-fixer
|
||||
- id: flake8
|
||||
- id: fix-byte-order-marker
|
||||
- id: mixed-line-ending
|
||||
args:
|
||||
- --fix=lf
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 23.7.0
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.11
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: pytest
|
||||
name: Check pytest unit tests pass
|
||||
entry: pipenv run pytest
|
||||
entry: poetry run pytest
|
||||
pass_filenames: false
|
||||
language: system
|
||||
types: [python]
|
||||
- id: mypy
|
||||
name: Check mypy static types match
|
||||
entry: pipenv run mypy . --ignore-missing-imports
|
||||
entry: poetry run mypy . --ignore-missing-imports
|
||||
pass_filenames: false
|
||||
language: system
|
||||
types: [python]
|
||||
|
|
63
Pipfile
63
Pipfile
|
@ -1,63 +0,0 @@
|
|||
[[source]]
|
||||
url = "https://pypi.python.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[requires]
|
||||
python_version = '3.7'
|
||||
|
||||
[packages]
|
||||
django = "*"
|
||||
django-compressor = "*"
|
||||
gunicorn = {extras = ["gevent"]}
|
||||
"psycopg2-binary" = "*"
|
||||
pillow = "*"
|
||||
django-meta = "*"
|
||||
django-activeurl = "*"
|
||||
django-otp = "*"
|
||||
qrcode = "*"
|
||||
django-otp-agents = "*"
|
||||
python-slugify = "*"
|
||||
"mf2py" = "*"
|
||||
markdown = "*"
|
||||
bleach = "*"
|
||||
django-debug-toolbar = "*"
|
||||
xrd = "*"
|
||||
django-push = "*"
|
||||
pyyaml = "*"
|
||||
django-annoying = "*"
|
||||
accept-types = "*"
|
||||
django-analytical = "*"
|
||||
django-model-utils = "*"
|
||||
django-rq = "*"
|
||||
ronkyuu = "*"
|
||||
cachecontrol = "*"
|
||||
hiredis = "*"
|
||||
"mf2util" = "*"
|
||||
django-cors-headers = "*"
|
||||
"argon2-cffi" = "*"
|
||||
python-baseconv = "*"
|
||||
django-computed-property = "*"
|
||||
docutils = "*"
|
||||
django-super-favicon = "*"
|
||||
django-redis = "*"
|
||||
gevent = "*"
|
||||
django-extensions = "*"
|
||||
python-magic = "*"
|
||||
pyup-django = "*"
|
||||
"jinja2" = "*"
|
||||
msgpack = "*"
|
||||
django-randomslugfield = "*"
|
||||
ago = "*"
|
||||
|
||||
[dev-packages]
|
||||
ptpython = "*"
|
||||
pytest-django = "*"
|
||||
werkzeug = "*"
|
||||
watchdog = "*"
|
||||
mypy = "*"
|
||||
types-pyyaml = "*"
|
||||
types-requests = "*"
|
||||
types-python-slugify = "*"
|
||||
types-bleach = "*"
|
||||
types-markdown = "*"
|
1522
Pipfile.lock
generated
1522
Pipfile.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,12 +8,10 @@ class SyndicationInline(admin.TabularInline):
|
|||
|
||||
|
||||
class EntryAdmin(admin.ModelAdmin):
|
||||
date_hierarchy = 'created'
|
||||
list_display = ('title', 'id', 'kind', 'created')
|
||||
list_filter = ('kind',)
|
||||
inlines = (
|
||||
SyndicationInline,
|
||||
)
|
||||
date_hierarchy = "created"
|
||||
list_display = ("title", "id", "kind", "created")
|
||||
list_filter = ("kind",)
|
||||
inlines = (SyndicationInline,)
|
||||
|
||||
|
||||
admin.site.register(Cat)
|
||||
|
|
|
@ -2,4 +2,4 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class EntriesConfig(AppConfig):
|
||||
name = 'entries'
|
||||
name = "entries"
|
||||
|
|
|
@ -11,24 +11,24 @@ from .models import Entry
|
|||
def from_url(url: str) -> Entry:
|
||||
domain = Site.objects.get_current().domain
|
||||
if not url:
|
||||
raise error.bad_req('url parameter required')
|
||||
if '//' not in url:
|
||||
url = '//' + url
|
||||
parts = urlparse(url, scheme='https')
|
||||
if parts.scheme not in ('http', 'https') or parts.netloc != domain:
|
||||
raise error.bad_req('url does not point to this site')
|
||||
raise error.bad_req("url parameter required")
|
||||
if "//" not in url:
|
||||
url = "//" + url
|
||||
parts = urlparse(url, scheme="https")
|
||||
if parts.scheme not in ("http", "https") or parts.netloc != domain:
|
||||
raise error.bad_req("url does not point to this site")
|
||||
|
||||
try:
|
||||
match = resolve(parts.path)
|
||||
except Resolver404:
|
||||
raise error.bad_req('url does not point to a valid page on this site')
|
||||
raise error.bad_req("url does not point to a valid page on this site")
|
||||
|
||||
if match.view_name != 'entries:entry':
|
||||
raise error.bad_req('url does not point to an entry on this site')
|
||||
if match.view_name != "entries:entry":
|
||||
raise error.bad_req("url does not point to an entry on this site")
|
||||
|
||||
try:
|
||||
entry = Entry.objects.get(pk=match.kwargs['id'])
|
||||
entry = Entry.objects.get(pk=match.kwargs["id"])
|
||||
except Entry.DoesNotExist:
|
||||
raise error.bad_req('url does not point to an existing entry')
|
||||
raise error.bad_req("url does not point to an existing entry")
|
||||
|
||||
return entry
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{% extends 'lemoncurry/layout.html' %}
|
||||
{% block head %}
|
||||
<link rel="shortlink" href="{{ entry.short_url }}" />
|
||||
<link rel="alternate" type="application/json+oembed" href="https://wirres.net/oembed/oembed/php?url={{ entry.absolute_url | urlencode }}" />
|
||||
{% endblock %}
|
||||
|
||||
{% block styles %}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<article class="h-entry media">
|
||||
{{i}}<aside class="info">
|
||||
{{i}}<a class="p-author h-card" href="{{ entry.author.url }}">
|
||||
{{i}}<img class="u-photo img-fluid" src="{{ entry.author.avatar.url }}" alt="{{ entry.author.name }}" />
|
||||
{{i}}{% if entry.author.avatar %}<img class="u-photo img-fluid" src="{{ entry.author.avatar.url }}" alt="{{ entry.author.name }}" />{% endif %}
|
||||
{{i}}<span class="p-name sr-only">{{ entry.author.name }}</span>
|
||||
{{i}}</a>
|
||||
{{i}}<a class="u-uid u-url" href="{{ entry.url }}">
|
||||
|
|
|
@ -7,16 +7,19 @@ from ronkyuu import webmention
|
|||
@job
|
||||
def ping_hub(*urls):
|
||||
for url in urls:
|
||||
requests.post(settings.PUSH_HUB, data={
|
||||
'hub.mode': 'publish',
|
||||
'hub.url': url,
|
||||
})
|
||||
requests.post(
|
||||
settings.PUSH_HUB,
|
||||
data={
|
||||
"hub.mode": "publish",
|
||||
"hub.url": url,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@job
|
||||
def send_mentions(source, targets=None):
|
||||
if targets is None:
|
||||
targets = webmention.findMentions(source)['refs']
|
||||
targets = webmention.findMentions(source)["refs"]
|
||||
for target in targets:
|
||||
status, endpoint = webmention.discoverEndpoint(target)
|
||||
if endpoint is not None and status == 200:
|
||||
|
|
|
@ -14,62 +14,62 @@ class Entry:
|
|||
return self.index_page()
|
||||
|
||||
def index_page(self, page=0):
|
||||
kwargs = {'kind': self}
|
||||
kwargs = {"kind": self}
|
||||
if page > 1:
|
||||
kwargs['page'] = page
|
||||
return reverse('entries:index', kwargs=kwargs)
|
||||
kwargs["page"] = page
|
||||
return reverse("entries:index", kwargs=kwargs)
|
||||
|
||||
@property
|
||||
def entry(self):
|
||||
return self.plural + '_entry'
|
||||
return self.plural + "_entry"
|
||||
|
||||
@property
|
||||
def atom(self):
|
||||
return reverse('entries:atom_by_kind', kwargs={'kind': self})
|
||||
return reverse("entries:atom_by_kind", kwargs={"kind": self})
|
||||
|
||||
@property
|
||||
def rss(self):
|
||||
return reverse('entries:rss_by_kind', kwargs={'kind': self})
|
||||
return reverse("entries:rss_by_kind", kwargs={"kind": self})
|
||||
|
||||
|
||||
Note = Entry(
|
||||
id='note',
|
||||
icon='fas fa-paper-plane',
|
||||
plural='notes',
|
||||
id="note",
|
||||
icon="fas fa-paper-plane",
|
||||
plural="notes",
|
||||
)
|
||||
|
||||
|
||||
Article = Entry(
|
||||
id='article',
|
||||
icon='fas fa-file-alt',
|
||||
plural='articles',
|
||||
id="article",
|
||||
icon="fas fa-file-alt",
|
||||
plural="articles",
|
||||
slug=True,
|
||||
)
|
||||
|
||||
Photo = Entry(
|
||||
id='photo',
|
||||
icon='fas fa-camera',
|
||||
plural='photos',
|
||||
id="photo",
|
||||
icon="fas fa-camera",
|
||||
plural="photos",
|
||||
)
|
||||
|
||||
Reply = Entry(
|
||||
id='reply',
|
||||
icon='fas fa-comment',
|
||||
plural='replies',
|
||||
id="reply",
|
||||
icon="fas fa-comment",
|
||||
plural="replies",
|
||||
on_home=False,
|
||||
)
|
||||
|
||||
Like = Entry(
|
||||
id='like',
|
||||
icon='fas fa-heart',
|
||||
plural='likes',
|
||||
id="like",
|
||||
icon="fas fa-heart",
|
||||
plural="likes",
|
||||
on_home=False,
|
||||
)
|
||||
|
||||
Repost = Entry(
|
||||
id='repost',
|
||||
icon='fas fa-retweet',
|
||||
plural='reposts',
|
||||
id="repost",
|
||||
icon="fas fa-retweet",
|
||||
plural="reposts",
|
||||
)
|
||||
|
||||
all = (Note, Article, Photo)
|
||||
|
@ -79,7 +79,7 @@ from_plural = {k.plural: k for k in all}
|
|||
|
||||
|
||||
class EntryKindConverter:
|
||||
regex = '|'.join(k.plural for k in all)
|
||||
regex = "|".join(k.plural for k in all)
|
||||
|
||||
def to_python(self, plural):
|
||||
return from_plural[plural]
|
||||
|
|
|
@ -8,7 +8,6 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
|
@ -17,20 +16,41 @@ class Migration(migrations.Migration):
|
|||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Entry',
|
||||
name="Entry",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('kind', models.CharField(choices=[('note', 'Note'), ('article', 'Article')], default='note', max_length=30)),
|
||||
('name', models.CharField(blank=True, max_length=100)),
|
||||
('summary', models.TextField(blank=True)),
|
||||
('content', models.TextField()),
|
||||
('published', models.DateTimeField()),
|
||||
('updated', models.DateTimeField()),
|
||||
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"kind",
|
||||
models.CharField(
|
||||
choices=[("note", "Note"), ("article", "Article")],
|
||||
default="note",
|
||||
max_length=30,
|
||||
),
|
||||
),
|
||||
("name", models.CharField(blank=True, max_length=100)),
|
||||
("summary", models.TextField(blank=True)),
|
||||
("content", models.TextField()),
|
||||
("published", models.DateTimeField()),
|
||||
("updated", models.DateTimeField()),
|
||||
(
|
||||
"author",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'entries',
|
||||
'ordering': ['-published'],
|
||||
"verbose_name_plural": "entries",
|
||||
"ordering": ["-published"],
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
|
@ -7,23 +7,42 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0005_auto_20171023_0158'),
|
||||
('entries', '0001_initial'),
|
||||
("users", "0005_auto_20171023_0158"),
|
||||
("entries", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Syndication',
|
||||
name="Syndication",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('url', models.CharField(max_length=255)),
|
||||
('entry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='syndications', to='entries.Entry')),
|
||||
('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.Profile')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("url", models.CharField(max_length=255)),
|
||||
(
|
||||
"entry",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="syndications",
|
||||
to="entries.Entry",
|
||||
),
|
||||
),
|
||||
(
|
||||
"profile",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to="users.Profile"
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'ordering': ['profile'],
|
||||
"ordering": ["profile"],
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,14 +6,13 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entries', '0002_syndication'),
|
||||
("entries", "0002_syndication"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='entry',
|
||||
name='summary',
|
||||
model_name="entry",
|
||||
name="summary",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -8,20 +8,28 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entries', '0003_remove_entry_summary'),
|
||||
("entries", "0003_remove_entry_summary"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='entry',
|
||||
name='author',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='entries', to=settings.AUTH_USER_MODEL),
|
||||
model_name="entry",
|
||||
name="author",
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="entries",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='entry',
|
||||
name='kind',
|
||||
field=models.CharField(choices=[('note', 'note'), ('article', 'article')], db_index=True, default='note', max_length=30),
|
||||
model_name="entry",
|
||||
name="kind",
|
||||
field=models.CharField(
|
||||
choices=[("note", "note"), ("article", "article")],
|
||||
db_index=True,
|
||||
default="note",
|
||||
max_length=30,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,20 +6,24 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entries', '0004_auto_20171027_0846'),
|
||||
("entries", "0004_auto_20171027_0846"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='entry',
|
||||
name='photo',
|
||||
field=models.ImageField(blank=True, upload_to=''),
|
||||
model_name="entry",
|
||||
name="photo",
|
||||
field=models.ImageField(blank=True, upload_to=""),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='entry',
|
||||
name='kind',
|
||||
field=models.CharField(choices=[('note', 'note'), ('article', 'article'), ('photo', 'photo')], db_index=True, default='note', max_length=30),
|
||||
model_name="entry",
|
||||
name="kind",
|
||||
field=models.CharField(
|
||||
choices=[("note", "note"), ("article", "article"), ("photo", "photo")],
|
||||
db_index=True,
|
||||
default="note",
|
||||
max_length=30,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -8,34 +8,41 @@ import model_utils.fields
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entries', '0005_auto_20171027_1557'),
|
||||
("entries", "0005_auto_20171027_1557"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='entry',
|
||||
options={'ordering': ['-created'], 'verbose_name_plural': 'entries'},
|
||||
name="entry",
|
||||
options={"ordering": ["-created"], "verbose_name_plural": "entries"},
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='entry',
|
||||
old_name='published',
|
||||
new_name='created',
|
||||
model_name="entry",
|
||||
old_name="published",
|
||||
new_name="created",
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='entry',
|
||||
old_name='updated',
|
||||
new_name='modified',
|
||||
model_name="entry",
|
||||
old_name="updated",
|
||||
new_name="modified",
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='entry',
|
||||
name='created',
|
||||
field=model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created'),
|
||||
model_name="entry",
|
||||
name="created",
|
||||
field=model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='entry',
|
||||
name='modified',
|
||||
field=model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified'),
|
||||
model_name="entry",
|
||||
name="modified",
|
||||
field=model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,20 +6,31 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entries', '0006_auto_20171102_1200'),
|
||||
("entries", "0006_auto_20171102_1200"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='entry',
|
||||
name='cite',
|
||||
model_name="entry",
|
||||
name="cite",
|
||||
field=models.CharField(blank=True, max_length=255),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='entry',
|
||||
name='kind',
|
||||
field=models.CharField(choices=[('note', 'note'), ('article', 'article'), ('photo', 'photo'), ('reply', 'reply'), ('like', 'like'), ('repost', 'repost')], db_index=True, default='note', max_length=30),
|
||||
model_name="entry",
|
||||
name="kind",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("note", "note"),
|
||||
("article", "article"),
|
||||
("photo", "photo"),
|
||||
("reply", "reply"),
|
||||
("like", "like"),
|
||||
("repost", "repost"),
|
||||
],
|
||||
db_index=True,
|
||||
default="note",
|
||||
max_length=30,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,25 +6,24 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entries', '0007_auto_20171113_0841'),
|
||||
("entries", "0007_auto_20171113_0841"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='entry',
|
||||
old_name='cite',
|
||||
new_name='in_reply_to',
|
||||
model_name="entry",
|
||||
old_name="cite",
|
||||
new_name="in_reply_to",
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='entry',
|
||||
name='like_of',
|
||||
model_name="entry",
|
||||
name="like_of",
|
||||
field=models.CharField(blank=True, max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='entry',
|
||||
name='repost_of',
|
||||
model_name="entry",
|
||||
name="repost_of",
|
||||
field=models.CharField(blank=True, max_length=255),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,21 +6,28 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entries', '0008_auto_20171116_2116'),
|
||||
("entries", "0008_auto_20171116_2116"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Tag',
|
||||
name="Tag",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255, unique=True)),
|
||||
('slug', models.CharField(max_length=255, unique=True)),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("name", models.CharField(max_length=255, unique=True)),
|
||||
("slug", models.CharField(max_length=255, unique=True)),
|
||||
],
|
||||
options={
|
||||
'ordering': ('name',),
|
||||
"ordering": ("name",),
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,15 +6,14 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entries', '0009_tag'),
|
||||
("entries", "0009_tag"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='entry',
|
||||
name='tags',
|
||||
field=models.ManyToManyField(related_name='entries', to='entries.Tag'),
|
||||
model_name="entry",
|
||||
name="tags",
|
||||
field=models.ManyToManyField(related_name="entries", to="entries.Tag"),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -9,17 +9,17 @@ class Migration(migrations.Migration):
|
|||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
('entries', '0010_entry_tags'),
|
||||
("entries", "0010_entry_tags"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='Tag',
|
||||
new_name='Cat',
|
||||
old_name="Tag",
|
||||
new_name="Cat",
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='entry',
|
||||
old_name='tags',
|
||||
new_name='cats',
|
||||
model_name="entry",
|
||||
old_name="tags",
|
||||
new_name="cats",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -5,25 +5,25 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entries', '0011_auto_20171120_1108'),
|
||||
("entries", "0011_auto_20171120_1108"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='syndication',
|
||||
options={'ordering': ['domain']},
|
||||
name="syndication",
|
||||
options={"ordering": ["domain"]},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='syndication',
|
||||
name='profile',
|
||||
model_name="syndication",
|
||||
name="profile",
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='syndication',
|
||||
name='domain',
|
||||
model_name="syndication",
|
||||
name="domain",
|
||||
field=computed_property.fields.ComputedCharField(
|
||||
compute_from='calc_domain', default='', editable=False, max_length=255),
|
||||
compute_from="calc_domain", default="", editable=False, max_length=255
|
||||
),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
|
|
22
entries/migrations/0013_alter_entry_kind.py
Normal file
22
entries/migrations/0013_alter_entry_kind.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 3.2.12 on 2022-03-12 04:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("entries", "0012_auto_20180628_2044"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="entry",
|
||||
name="kind",
|
||||
field=models.CharField(
|
||||
choices=[("note", "note"), ("article", "article"), ("photo", "photo")],
|
||||
db_index=True,
|
||||
default="note",
|
||||
max_length=30,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -17,6 +17,7 @@ from users.models import Site
|
|||
|
||||
from . import kinds
|
||||
from lemoncurry import requests, utils
|
||||
|
||||
ENTRY_KINDS = [(k.id, k.id) for k in kinds.all]
|
||||
|
||||
|
||||
|
@ -32,38 +33,33 @@ class Cat(models.Model):
|
|||
slug = models.CharField(max_length=255, unique=True)
|
||||
|
||||
def __str__(self):
|
||||
return '#' + self.name
|
||||
return "#" + self.name
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
return reverse('entries:cat', args=(self.slug,))
|
||||
return reverse("entries:cat", args=(self.slug,))
|
||||
|
||||
class Meta:
|
||||
ordering = ('name',)
|
||||
ordering = ("name",)
|
||||
|
||||
|
||||
class EntryManager(models.Manager):
|
||||
def get_queryset(self):
|
||||
qs = super(EntryManager, self).get_queryset()
|
||||
return (qs
|
||||
.select_related('author')
|
||||
.prefetch_related('cats', 'syndications'))
|
||||
return qs.select_related("author").prefetch_related("cats", "syndications")
|
||||
|
||||
|
||||
class Entry(ModelMeta, TimeStampedModel):
|
||||
objects = EntryManager()
|
||||
kind = models.CharField(
|
||||
max_length=30,
|
||||
choices=ENTRY_KINDS,
|
||||
db_index=True,
|
||||
default=ENTRY_KINDS[0][0]
|
||||
max_length=30, choices=ENTRY_KINDS, db_index=True, default=ENTRY_KINDS[0][0]
|
||||
)
|
||||
|
||||
name = models.CharField(max_length=100, blank=True)
|
||||
photo = models.ImageField(blank=True)
|
||||
content = models.TextField()
|
||||
|
||||
cats = models.ManyToManyField(Cat, related_name='entries')
|
||||
cats = models.ManyToManyField(Cat, related_name="entries")
|
||||
|
||||
in_reply_to = models.CharField(max_length=255, blank=True)
|
||||
like_of = models.CharField(max_length=255, blank=True)
|
||||
|
@ -71,7 +67,7 @@ class Entry(ModelMeta, TimeStampedModel):
|
|||
|
||||
author = models.ForeignKey(
|
||||
get_user_model(),
|
||||
related_name='entries',
|
||||
related_name="entries",
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
|
||||
|
@ -79,10 +75,7 @@ class Entry(ModelMeta, TimeStampedModel):
|
|||
def reply_context(self):
|
||||
if not self.in_reply_to:
|
||||
return None
|
||||
return interpret(
|
||||
requests.mf2(self.in_reply_to).to_dict(),
|
||||
self.in_reply_to
|
||||
)
|
||||
return interpret(requests.mf2(self.in_reply_to).to_dict(), self.in_reply_to)
|
||||
|
||||
@property
|
||||
def published(self):
|
||||
|
@ -93,35 +86,29 @@ class Entry(ModelMeta, TimeStampedModel):
|
|||
return self.modified
|
||||
|
||||
_metadata = {
|
||||
'description': 'excerpt',
|
||||
'image': 'image_url',
|
||||
'twitter_creator': 'twitter_creator',
|
||||
'og_profile_id': 'og_profile_id',
|
||||
"description": "excerpt",
|
||||
"image": "image_url",
|
||||
"twitter_creator": "twitter_creator",
|
||||
"og_profile_id": "og_profile_id",
|
||||
}
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
if self.name:
|
||||
return self.name
|
||||
return shorten(
|
||||
utils.to_plain(self.paragraphs[0]),
|
||||
width=100,
|
||||
placeholder='…'
|
||||
)
|
||||
return shorten(utils.to_plain(self.paragraphs[0]), width=100, placeholder="…")
|
||||
|
||||
@property
|
||||
def excerpt(self):
|
||||
try:
|
||||
return utils.to_plain(self.paragraphs[0 if self.name else 1])
|
||||
except IndexError:
|
||||
return ' '
|
||||
return " "
|
||||
|
||||
@property
|
||||
def paragraphs(self):
|
||||
lines = self.content.splitlines()
|
||||
return [
|
||||
"\n".join(para) for k, para in groupby(lines, key=bool) if k
|
||||
]
|
||||
return ["\n".join(para) for k, para in groupby(lines, key=bool) if k]
|
||||
|
||||
@property
|
||||
def twitter_creator(self):
|
||||
|
@ -136,31 +123,31 @@ class Entry(ModelMeta, TimeStampedModel):
|
|||
return self.photo.url if self.photo else self.author.avatar_url
|
||||
|
||||
def __str__(self):
|
||||
return '{0} {1}: {2}'.format(self.kind, self.id, self.title)
|
||||
return "{0} {1}: {2}".format(self.kind, self.id, self.title)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return self.absolute_url
|
||||
|
||||
@property
|
||||
def absolute_url(self):
|
||||
base = 'https://' + DjangoSite.objects.get_current().domain
|
||||
base = "https://" + DjangoSite.objects.get_current().domain
|
||||
return urljoin(base, self.url)
|
||||
|
||||
@property
|
||||
def affected_urls(self):
|
||||
base = 'https://' + DjangoSite.objects.get_current().domain
|
||||
base = "https://" + DjangoSite.objects.get_current().domain
|
||||
kind = kinds.from_id[self.kind]
|
||||
urls = {
|
||||
self.url,
|
||||
reverse('entries:index', kwargs={'kind': kind}),
|
||||
reverse('entries:atom_by_kind', kwargs={'kind': kind}),
|
||||
reverse('entries:rss_by_kind', kwargs={'kind': kind}),
|
||||
reverse("entries:index", kwargs={"kind": kind}),
|
||||
reverse("entries:atom_by_kind", kwargs={"kind": kind}),
|
||||
reverse("entries:rss_by_kind", kwargs={"kind": kind}),
|
||||
} | {cat.url for cat in self.cats.all()}
|
||||
if kind.on_home:
|
||||
urls |= {
|
||||
reverse('home:index'),
|
||||
reverse('entries:atom'),
|
||||
reverse('entries:rss')
|
||||
reverse("home:index"),
|
||||
reverse("entries:atom"),
|
||||
reverse("entries:rss"),
|
||||
}
|
||||
return {urljoin(base, u) for u in urls}
|
||||
|
||||
|
@ -170,7 +157,7 @@ class Entry(ModelMeta, TimeStampedModel):
|
|||
args = [kind, self.id]
|
||||
if kind.slug:
|
||||
args.append(self.slug)
|
||||
return reverse('entries:entry', args=args)
|
||||
return reverse("entries:entry", args=args)
|
||||
|
||||
@property
|
||||
def short_url(self):
|
||||
|
@ -182,49 +169,48 @@ class Entry(ModelMeta, TimeStampedModel):
|
|||
|
||||
@property
|
||||
def json_ld(self):
|
||||
base = 'https://' + DjangoSite.objects.get_current().domain
|
||||
base = "https://" + DjangoSite.objects.get_current().domain
|
||||
url = urljoin(base, self.url)
|
||||
|
||||
posting = {
|
||||
'@context': 'http://schema.org',
|
||||
'@type': 'BlogPosting',
|
||||
'@id': url,
|
||||
'url': url,
|
||||
'mainEntityOfPage': url,
|
||||
'author': {
|
||||
'@type': 'Person',
|
||||
'url': urljoin(base, self.author.url),
|
||||
'name': self.author.name,
|
||||
"@context": "http://schema.org",
|
||||
"@type": "BlogPosting",
|
||||
"@id": url,
|
||||
"url": url,
|
||||
"mainEntityOfPage": url,
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"url": urljoin(base, self.author.url),
|
||||
"name": self.author.name,
|
||||
},
|
||||
'headline': self.title,
|
||||
'description': self.excerpt,
|
||||
'datePublished': self.created.isoformat(),
|
||||
'dateModified': self.modified.isoformat(),
|
||||
"headline": self.title,
|
||||
"description": self.excerpt,
|
||||
"datePublished": self.created.isoformat(),
|
||||
"dateModified": self.modified.isoformat(),
|
||||
}
|
||||
if self.photo:
|
||||
posting['image'] = (urljoin(base, self.photo.url), )
|
||||
posting["image"] = (urljoin(base, self.photo.url),)
|
||||
return posting
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'entries'
|
||||
ordering = ['-created']
|
||||
verbose_name_plural = "entries"
|
||||
ordering = ["-created"]
|
||||
|
||||
|
||||
class Syndication(models.Model):
|
||||
entry = models.ForeignKey(
|
||||
Entry,
|
||||
related_name='syndications',
|
||||
on_delete=models.CASCADE
|
||||
Entry, related_name="syndications", on_delete=models.CASCADE
|
||||
)
|
||||
url = models.CharField(max_length=255)
|
||||
|
||||
domain = ComputedCharField(
|
||||
compute_from='calc_domain', max_length=255,
|
||||
compute_from="calc_domain",
|
||||
max_length=255,
|
||||
)
|
||||
|
||||
def calc_domain(self):
|
||||
domain = urlparse(self.url).netloc
|
||||
if domain.startswith('www.'):
|
||||
if domain.startswith("www."):
|
||||
domain = domain[4:]
|
||||
return domain
|
||||
|
||||
|
@ -234,7 +220,7 @@ class Syndication(models.Model):
|
|||
try:
|
||||
return Site.objects.get(domain=d)
|
||||
except Site.DoesNotExist:
|
||||
return Site(name=d, domain=d, icon='fas fa-newspaper')
|
||||
return Site(name=d, domain=d, icon="fas fa-newspaper")
|
||||
|
||||
class Meta:
|
||||
ordering = ['domain']
|
||||
ordering = ["domain"]
|
||||
|
|
|
@ -3,27 +3,27 @@ import pytest
|
|||
|
||||
@pytest.mark.django_db
|
||||
def test_atom(client):
|
||||
res = client.get('/atom')
|
||||
res = client.get("/atom")
|
||||
assert res.status_code == 200
|
||||
assert res['Content-Type'] == 'application/atom+xml; charset=utf-8'
|
||||
assert res["Content-Type"] == "application/atom+xml; charset=utf-8"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_rss(client):
|
||||
res = client.get('/rss')
|
||||
res = client.get("/rss")
|
||||
assert res.status_code == 200
|
||||
assert res['Content-Type'] == 'application/rss+xml; charset=utf-8'
|
||||
assert res["Content-Type"] == "application/rss+xml; charset=utf-8"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_atom_by_kind(client):
|
||||
res = client.get('/notes/atom')
|
||||
res = client.get("/notes/atom")
|
||||
assert res.status_code == 200
|
||||
assert res['Content-Type'] == 'application/atom+xml; charset=utf-8'
|
||||
assert res["Content-Type"] == "application/atom+xml; charset=utf-8"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_rss_by_kind(client):
|
||||
res = client.get('/notes/rss')
|
||||
res = client.get("/notes/rss")
|
||||
assert res.status_code == 200
|
||||
assert res['Content-Type'] == 'application/rss+xml; charset=utf-8'
|
||||
assert res["Content-Type"] == "application/rss+xml; charset=utf-8"
|
||||
|
|
|
@ -3,47 +3,46 @@ from . import kinds
|
|||
from .views import feeds, lists, perma
|
||||
from lemoncurry import breadcrumbs as crumbs
|
||||
|
||||
register_converter(kinds.EntryKindConverter, 'kind')
|
||||
register_converter(kinds.EntryKindConverter, "kind")
|
||||
|
||||
|
||||
def to_pat(*args):
|
||||
return '^{0}$'.format(''.join(args))
|
||||
return "^{0}$".format("".join(args))
|
||||
|
||||
|
||||
def prefix(route):
|
||||
return app_name + ':' + route
|
||||
return app_name + ":" + route
|
||||
|
||||
|
||||
id = r'/(?P<id>\d+)'
|
||||
kind = r'(?P<kind>{0})'.format('|'.join(k.plural for k in kinds.all))
|
||||
page = r'(?:/page/(?P<page>\d+))?'
|
||||
slug = r'/(?P<slug>[^/]+)'
|
||||
id = r"/(?P<id>\d+)"
|
||||
kind = r"(?P<kind>{0})".format("|".join(k.plural for k in kinds.all))
|
||||
page = r"(?:/page/(?P<page>\d+))?"
|
||||
slug = r"/(?P<slug>[^/]+)"
|
||||
|
||||
slug_opt = '(?:' + slug + ')?'
|
||||
slug_opt = "(?:" + slug + ")?"
|
||||
|
||||
app_name = 'entries'
|
||||
app_name = "entries"
|
||||
urlpatterns = (
|
||||
path('atom', feeds.AtomHomeEntries(), name='atom'),
|
||||
path('rss', feeds.RssHomeEntries(), name='rss'),
|
||||
path('cats/<slug:slug>', lists.by_cat, name='cat'),
|
||||
path('cats/<slug:slug>/page/<int:page>', lists.by_cat, name='cat'),
|
||||
path('<kind:kind>', lists.by_kind, name='index'),
|
||||
path('<kind:kind>/page/<int:page>', lists.by_kind, name='index'),
|
||||
path('<kind:kind>/atom', feeds.AtomByKind(), name='atom_by_kind'),
|
||||
path('<kind:kind>/rss', feeds.RssByKind(), name='rss_by_kind'),
|
||||
|
||||
path('<kind:kind>/<int:id>', perma.entry, name='entry'),
|
||||
path('<kind:kind>/<int:id>/<slug:slug>', perma.entry, name='entry'),
|
||||
path("atom", feeds.AtomHomeEntries(), name="atom"),
|
||||
path("rss", feeds.RssHomeEntries(), name="rss"),
|
||||
path("cats/<slug:slug>", lists.by_cat, name="cat"),
|
||||
path("cats/<slug:slug>/page/<int:page>", lists.by_cat, name="cat"),
|
||||
path("<kind:kind>", lists.by_kind, name="index"),
|
||||
path("<kind:kind>/page/<int:page>", lists.by_kind, name="index"),
|
||||
path("<kind:kind>/atom", feeds.AtomByKind(), name="atom_by_kind"),
|
||||
path("<kind:kind>/rss", feeds.RssByKind(), name="rss_by_kind"),
|
||||
path("<kind:kind>/<int:id>", perma.entry, name="entry"),
|
||||
path("<kind:kind>/<int:id>/<slug:slug>", perma.entry, name="entry"),
|
||||
)
|
||||
|
||||
|
||||
class IndexCrumb(crumbs.Crumb):
|
||||
def __init__(self):
|
||||
super().__init__(prefix('index'), parent='home:index')
|
||||
super().__init__(prefix("index"), parent="home:index")
|
||||
|
||||
@property
|
||||
def kind(self):
|
||||
return self.match.kwargs['kind']
|
||||
return self.match.kwargs["kind"]
|
||||
|
||||
@property
|
||||
def label(self):
|
||||
|
@ -51,9 +50,9 @@ class IndexCrumb(crumbs.Crumb):
|
|||
|
||||
@property
|
||||
def url(self):
|
||||
return reverse(prefix('index'), kwargs={'kind': self.kind})
|
||||
return reverse(prefix("index"), kwargs={"kind": self.kind})
|
||||
|
||||
|
||||
crumbs.add(prefix('cat'), parent='home:index')
|
||||
crumbs.add(prefix("cat"), parent="home:index")
|
||||
crumbs.add(IndexCrumb())
|
||||
crumbs.add(prefix('entry'), parent=prefix('index'))
|
||||
crumbs.add(prefix("entry"), parent=prefix("index"))
|
||||
|
|
|
@ -11,8 +11,8 @@ from ..models import Entry
|
|||
class Atom1FeedWithHub(Atom1Feed):
|
||||
def add_root_elements(self, handler):
|
||||
super().add_root_elements(handler)
|
||||
handler.startElement('link', {'rel': 'hub', 'href': settings.PUSH_HUB})
|
||||
handler.endElement('link')
|
||||
handler.startElement("link", {"rel": "hub", "href": settings.PUSH_HUB})
|
||||
handler.endElement("link")
|
||||
|
||||
|
||||
class EntriesFeed(Feed):
|
||||
|
@ -79,7 +79,7 @@ class RssHomeEntries(EntriesFeed):
|
|||
return Site.objects.get_current().name
|
||||
|
||||
def link(self):
|
||||
return reverse('home:index')
|
||||
return reverse("home:index")
|
||||
|
||||
def description(self):
|
||||
return "content from {0}".format(
|
||||
|
|
|
@ -5,32 +5,32 @@ from ..models import Entry, Cat
|
|||
from ..pagination import paginate
|
||||
|
||||
|
||||
@render_to('entries/index.html')
|
||||
@render_to("entries/index.html")
|
||||
def by_kind(request, kind, page=None):
|
||||
entries = Entry.objects.filter(kind=kind.id)
|
||||
entries = paginate(queryset=entries, reverse=kind.index_page, page=page)
|
||||
|
||||
return {
|
||||
'entries': entries,
|
||||
'atom': kind.atom,
|
||||
'rss': kind.rss,
|
||||
'title': kind.plural,
|
||||
"entries": entries,
|
||||
"atom": kind.atom,
|
||||
"rss": kind.rss,
|
||||
"title": kind.plural,
|
||||
}
|
||||
|
||||
|
||||
@render_to('entries/index.html')
|
||||
@render_to("entries/index.html")
|
||||
def by_cat(request, slug, page=None):
|
||||
def url(page):
|
||||
kwargs = {'slug': slug}
|
||||
kwargs = {"slug": slug}
|
||||
if page > 1:
|
||||
kwargs['page'] = page
|
||||
return reverse('entries:cat', kwargs=kwargs)
|
||||
kwargs["page"] = page
|
||||
return reverse("entries:cat", kwargs=kwargs)
|
||||
|
||||
cat = get_object_or_404(Cat, slug=slug)
|
||||
entries = cat.entries.all()
|
||||
entries = paginate(queryset=entries, reverse=url, page=page)
|
||||
|
||||
return {
|
||||
'entries': entries,
|
||||
'title': '#' + cat.name,
|
||||
"entries": entries,
|
||||
"title": "#" + cat.name,
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ from django.shortcuts import redirect, get_object_or_404
|
|||
from ..models import Entry
|
||||
|
||||
|
||||
@render_to('entries/entry.html')
|
||||
@render_to("entries/entry.html")
|
||||
def entry(request, kind, id, slug=None):
|
||||
entry = get_object_or_404(Entry, pk=id)
|
||||
if request.path != entry.url:
|
||||
return redirect(entry.url, permanent=True)
|
||||
return {
|
||||
'entry': entry,
|
||||
'title': entry.title,
|
||||
"entry": entry,
|
||||
"title": entry.title,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import multiprocessing
|
||||
|
||||
proc_name = 'lemoncurry'
|
||||
worker_class = 'gevent'
|
||||
proc_name = "lemoncurry"
|
||||
worker_class = "gevent"
|
||||
workers = multiprocessing.cpu_count() * 2 + 1
|
||||
|
|
|
@ -3,10 +3,10 @@ from django.urls import reverse
|
|||
|
||||
|
||||
class HomeSitemap(sitemaps.Sitemap):
|
||||
changefreq = 'daily'
|
||||
changefreq = "daily"
|
||||
|
||||
def items(self):
|
||||
return ('home:index',)
|
||||
return ("home:index",)
|
||||
|
||||
def location(self, item):
|
||||
return reverse(item)
|
||||
|
|
|
@ -2,9 +2,9 @@ from django.urls import path
|
|||
|
||||
from . import views
|
||||
|
||||
app_name = 'home'
|
||||
app_name = "home"
|
||||
urlpatterns = [
|
||||
path('', views.index, name='index'),
|
||||
path('page/<int:page>', views.index, name='index'),
|
||||
path('robots.txt', views.robots, name='robots.txt'),
|
||||
path("", views.index, name="index"),
|
||||
path("page/<int:page>", views.index, name="index"),
|
||||
path("robots.txt", views.robots, name="robots.txt"),
|
||||
]
|
||||
|
|
|
@ -8,34 +8,31 @@ from urllib.parse import urljoin
|
|||
from entries import kinds, pagination
|
||||
from lemoncurry import breadcrumbs, utils
|
||||
|
||||
breadcrumbs.add('home:index', 'home')
|
||||
breadcrumbs.add("home:index", "home")
|
||||
|
||||
|
||||
@render_to('home/index.html')
|
||||
@render_to("home/index.html")
|
||||
def index(request, page=None):
|
||||
def url(page):
|
||||
kwargs = {'page': page} if page != 1 else {}
|
||||
return reverse('home:index', kwargs=kwargs)
|
||||
kwargs = {"page": page} if page != 1 else {}
|
||||
return reverse("home:index", kwargs=kwargs)
|
||||
|
||||
user = request.user
|
||||
if not hasattr(user, 'entries'):
|
||||
if not hasattr(user, "entries"):
|
||||
user = get_object_or_404(User, pk=1)
|
||||
|
||||
entries = user.entries.filter(kind__in=kinds.on_home)
|
||||
entries = pagination.paginate(queryset=entries, reverse=url, page=page)
|
||||
|
||||
return {
|
||||
'user': user,
|
||||
'entries': entries,
|
||||
'atom': reverse('entries:atom'),
|
||||
'rss': reverse('entries:rss'),
|
||||
"user": user,
|
||||
"entries": entries,
|
||||
"atom": reverse("entries:atom"),
|
||||
"rss": reverse("entries:rss"),
|
||||
}
|
||||
|
||||
|
||||
def robots(request):
|
||||
base = utils.origin(request)
|
||||
lines = (
|
||||
'User-agent: *',
|
||||
'Sitemap: {0}'.format(urljoin(base, reverse('sitemap')))
|
||||
)
|
||||
return HttpResponse("\n".join(lines) + "\n", content_type='text/plain')
|
||||
lines = ("User-agent: *", "Sitemap: {0}".format(urljoin(base, reverse("sitemap"))))
|
||||
return HttpResponse("\n".join(lines) + "\n", content_type="text/plain")
|
||||
|
|
|
@ -62,17 +62,19 @@
|
|||
</div>
|
||||
|
||||
<div id="verified-success" hidden>
|
||||
this client has been <strong>verified</strong> using <code>{{ '<link rel="redirect_uri">' | escape }}</code> - they are who they claim to be!
|
||||
this client has been <strong>verified</strong> using <code>{{ '<link rel="redirect_uri">' | escape }}</code> <br/>- they are who they claim to be!
|
||||
</div>
|
||||
<div id="verified-warning" hidden>
|
||||
this client could <strong>not</strong> be verified using <code>{{ '<link rel="redirect_uri">' | escape }}</code> - check the redirect uri carefully yourself!
|
||||
this client could <strong>not</strong> be verified using <code>{{ '<link rel="redirect_uri">' | escape }}</code> <br/>- check the redirect uri carefully yourself!
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block foot %}
|
||||
<script type="text/javascript">
|
||||
tippy('[data-tippy-theme]', {
|
||||
tippy('[data-tippy-html]', {
|
||||
arrow: true,
|
||||
allowHTML: true,
|
||||
maxWidth: 500,
|
||||
content: function(element) {
|
||||
return document.querySelector(element.getAttribute('data-tippy-html')).innerHTML;
|
||||
}
|
||||
|
|
|
@ -7,25 +7,36 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
] # type: List[Tuple[str, str]]
|
||||
dependencies = [] # type: List[Tuple[str, str]]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='IndieAuthCode',
|
||||
name="IndieAuthCode",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True,
|
||||
primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('code', models.CharField(max_length=64, unique=True)),
|
||||
('me', models.CharField(max_length=255)),
|
||||
('client_id', models.CharField(max_length=255)),
|
||||
('redirect_uri', models.CharField(max_length=255)),
|
||||
('response_type', models.CharField(choices=[
|
||||
('id', 'id'), ('code', 'code')], default='id', max_length=4)),
|
||||
('scope', models.CharField(blank=True, max_length=200)),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("code", models.CharField(max_length=64, unique=True)),
|
||||
("me", models.CharField(max_length=255)),
|
||||
("client_id", models.CharField(max_length=255)),
|
||||
("redirect_uri", models.CharField(max_length=255)),
|
||||
(
|
||||
"response_type",
|
||||
models.CharField(
|
||||
choices=[("id", "id"), ("code", "code")],
|
||||
default="id",
|
||||
max_length=4,
|
||||
),
|
||||
),
|
||||
("scope", models.CharField(blank=True, max_length=200)),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,13 +6,12 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('lemonauth', '0001_initial'),
|
||||
("lemonauth", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.DeleteModel(
|
||||
name='IndieAuthCode',
|
||||
name="IndieAuthCode",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -9,43 +9,112 @@ import randomslugfield.fields
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('lemonauth', '0002_delete_indieauthcode'),
|
||||
("lemonauth", "0002_delete_indieauthcode"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='IndieAuthCode',
|
||||
name="IndieAuthCode",
|
||||
fields=[
|
||||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
|
||||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
|
||||
('id', randomslugfield.fields.RandomSlugField(blank=True, editable=False, length=30, max_length=30, primary_key=True, serialize=False, unique=True)),
|
||||
('client_id', models.URLField()),
|
||||
('scope', models.TextField(blank=True)),
|
||||
('redirect_uri', models.URLField()),
|
||||
('response_type', model_utils.fields.StatusField(choices=[('id', 'id'), ('code', 'code')], default='id', max_length=100, no_check_for_status=True)),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
randomslugfield.fields.RandomSlugField(
|
||||
blank=True,
|
||||
editable=False,
|
||||
length=30,
|
||||
max_length=30,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
),
|
||||
),
|
||||
("client_id", models.URLField()),
|
||||
("scope", models.TextField(blank=True)),
|
||||
("redirect_uri", models.URLField()),
|
||||
(
|
||||
"response_type",
|
||||
model_utils.fields.StatusField(
|
||||
choices=[("id", "id"), ("code", "code")],
|
||||
default="id",
|
||||
max_length=100,
|
||||
no_check_for_status=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"user",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
"abstract": False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Token',
|
||||
name="Token",
|
||||
fields=[
|
||||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
|
||||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
|
||||
('id', randomslugfield.fields.RandomSlugField(blank=True, editable=False, length=30, max_length=30, primary_key=True, serialize=False, unique=True)),
|
||||
('client_id', models.URLField()),
|
||||
('scope', models.TextField(blank=True)),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
randomslugfield.fields.RandomSlugField(
|
||||
blank=True,
|
||||
editable=False,
|
||||
length=30,
|
||||
max_length=30,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
),
|
||||
),
|
||||
("client_id", models.URLField()),
|
||||
("scope", models.TextField(blank=True)),
|
||||
(
|
||||
"user",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
"abstract": False,
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
|
@ -17,6 +17,7 @@ class AuthSecret(TimeStampedModel):
|
|||
authorisation codes and tokens in IndieAuth - the two contain many
|
||||
identical fields, but just a few differences.
|
||||
"""
|
||||
|
||||
id = RandomSlugField(primary_key=True, length=30)
|
||||
client_id = models.URLField()
|
||||
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
|
||||
|
@ -27,7 +28,7 @@ class AuthSecret(TimeStampedModel):
|
|||
return self.user.full_url
|
||||
|
||||
def __contains__(self, scope):
|
||||
return scope in self.scope.split(' ')
|
||||
return scope in self.scope.split(" ")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -41,10 +42,11 @@ class IndieAuthCode(AuthSecret):
|
|||
Codes are single-use, and if unused will be expired automatically after
|
||||
thirty seconds.
|
||||
"""
|
||||
|
||||
redirect_uri = models.URLField()
|
||||
|
||||
RESPONSE_TYPE = Choices('id', 'code')
|
||||
response_type = StatusField(choices_name='RESPONSE_TYPE')
|
||||
RESPONSE_TYPE = Choices("id", "code")
|
||||
response_type = StatusField(choices_name="RESPONSE_TYPE")
|
||||
|
||||
@property
|
||||
def expired(self):
|
||||
|
@ -56,4 +58,5 @@ class Token(AuthSecret):
|
|||
A Token grants a client long-term authorisation - it will not expire unless
|
||||
explicitly revoked by the user.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
img
|
||||
height 2em
|
||||
margin-right .5em
|
||||
.tippy-tooltip
|
||||
&.success-theme
|
||||
.tippy-box
|
||||
&[data-theme~='success']
|
||||
color $base0B
|
||||
&.warning-theme
|
||||
&[data-theme~='warning']
|
||||
color $base0A
|
||||
.verified-success
|
||||
color $base0B
|
||||
|
|
|
@ -3,17 +3,17 @@ from .models import IndieAuthCode, Token
|
|||
|
||||
|
||||
def auth(request) -> Token:
|
||||
if 'HTTP_AUTHORIZATION' in request.META:
|
||||
auth = request.META.get('HTTP_AUTHORIZATION').split(' ')
|
||||
if auth[0] != 'Bearer':
|
||||
raise error.bad_req('auth type {0} not supported'.format(auth[0]))
|
||||
if "HTTP_AUTHORIZATION" in request.META:
|
||||
auth = request.META.get("HTTP_AUTHORIZATION").split(" ")
|
||||
if auth[0] != "Bearer":
|
||||
raise error.bad_req("auth type {0} not supported".format(auth[0]))
|
||||
if len(auth) != 2:
|
||||
raise error.bad_req('invalid Bearer auth format, must be Bearer <token>')
|
||||
raise error.bad_req("invalid Bearer auth format, must be Bearer <token>")
|
||||
token = auth[1]
|
||||
elif 'access_token' in request.POST:
|
||||
token = request.POST.get('access_token')
|
||||
elif 'access_token' in request.GET:
|
||||
token = request.GET.get('access_token')
|
||||
elif "access_token" in request.POST:
|
||||
token = request.POST.get("access_token")
|
||||
elif "access_token" in request.GET:
|
||||
token = request.GET.get("access_token")
|
||||
else:
|
||||
raise error.unauthorized()
|
||||
|
||||
|
@ -28,11 +28,11 @@ def auth(request) -> Token:
|
|||
def gen_auth_code(req):
|
||||
code = IndieAuthCode()
|
||||
code.user = req.user
|
||||
code.client_id = req.POST['client_id']
|
||||
code.redirect_uri = req.POST['redirect_uri']
|
||||
code.response_type = req.POST.get('response_type', 'id')
|
||||
if 'scope' in req.POST:
|
||||
code.scope = ' '.join(req.POST.getlist('scope'))
|
||||
code.client_id = req.POST["client_id"]
|
||||
code.redirect_uri = req.POST["redirect_uri"]
|
||||
code.response_type = req.POST.get("response_type", "id")
|
||||
if "scope" in req.POST:
|
||||
code.scope = " ".join(req.POST.getlist("scope"))
|
||||
code.save()
|
||||
return code.id
|
||||
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
app_name = 'lemonauth'
|
||||
app_name = "lemonauth"
|
||||
urlpatterns = [
|
||||
path('login', views.login, name='login'),
|
||||
path('logout', views.logout, name='logout'),
|
||||
path('indie', views.IndieView.as_view(), name='indie'),
|
||||
path('indie/approve', views.indie_approve, name='indie_approve'),
|
||||
path('token', views.TokenView.as_view(), name='token'),
|
||||
path('tokens', views.TokensListView.as_view(), name='tokens'),
|
||||
path('tokens/<path:client_id>', views.TokensRevokeView.as_view(), name='tokens_revoke'),
|
||||
path("login", views.login, name="login"),
|
||||
path("logout", views.logout, name="logout"),
|
||||
path("indie", views.IndieView.as_view(), name="indie"),
|
||||
path("indie/approve", views.indie_approve, name="indie_approve"),
|
||||
path("token", views.TokenView.as_view(), name="token"),
|
||||
path("tokens", views.TokensListView.as_view(), name="tokens"),
|
||||
path(
|
||||
"tokens/<path:client_id>",
|
||||
views.TokensRevokeView.as_view(),
|
||||
name="tokens_revoke",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -12,120 +12,114 @@ from urllib.parse import urlencode, urljoin, urlunparse, urlparse
|
|||
from .. import tokens
|
||||
from ..models import IndieAuthCode
|
||||
|
||||
breadcrumbs.add('lemonauth:indie', parent='home:index')
|
||||
breadcrumbs.add("lemonauth:indie", parent="home:index")
|
||||
|
||||
|
||||
def canonical(url):
|
||||
if '//' not in url:
|
||||
url = '//' + url
|
||||
if "//" not in url:
|
||||
url = "//" + url
|
||||
(scheme, netloc, path, params, query, fragment) = urlparse(url)
|
||||
if not scheme or scheme == 'http':
|
||||
scheme = 'https'
|
||||
if not scheme or scheme == "http":
|
||||
scheme = "https"
|
||||
if not path:
|
||||
path = '/'
|
||||
path = "/"
|
||||
return urlunparse((scheme, netloc, path, params, query, fragment))
|
||||
|
||||
|
||||
@method_decorator(csrf_exempt, name='dispatch')
|
||||
@method_decorator(csrf_exempt, name="dispatch")
|
||||
class IndieView(TemplateView):
|
||||
template_name = 'lemonauth/indie.html'
|
||||
required_params = ('client_id', 'redirect_uri')
|
||||
template_name = "lemonauth/indie.html"
|
||||
required_params = ("client_id", "redirect_uri")
|
||||
|
||||
@method_decorator(login_required)
|
||||
@method_decorator(render_to(template_name))
|
||||
def get(self, request):
|
||||
params = request.GET.dict()
|
||||
params.setdefault('response_type', 'id')
|
||||
params.setdefault("response_type", "id")
|
||||
|
||||
for param in self.required_params:
|
||||
if param not in params:
|
||||
return utils.bad_req(
|
||||
'parameter {0} is required'.format(param)
|
||||
)
|
||||
return utils.bad_req("parameter {0} is required".format(param))
|
||||
|
||||
me = request.user.full_url
|
||||
if 'me' in params:
|
||||
param_me = canonical(params['me'])
|
||||
if "me" in params:
|
||||
param_me = canonical(params["me"])
|
||||
if me != param_me:
|
||||
return utils.forbid(
|
||||
'you are logged in as {}, not as {}'.format(me, param_me)
|
||||
"you are logged in as {}, not as {}".format(me, param_me)
|
||||
)
|
||||
|
||||
redirect_uri = urljoin(params['client_id'], params['redirect_uri'])
|
||||
redirect_uri = urljoin(params["client_id"], params["redirect_uri"])
|
||||
|
||||
type = params['response_type']
|
||||
if type not in ('id', 'code'):
|
||||
return utils.bad_req(
|
||||
'unknown response_type: {0}'.format(type)
|
||||
)
|
||||
type = params["response_type"]
|
||||
if type not in ("id", "code"):
|
||||
return utils.bad_req("unknown response_type: {0}".format(type))
|
||||
|
||||
scopes = ()
|
||||
if type == 'code':
|
||||
if 'scope' not in params:
|
||||
return utils.bad_req(
|
||||
'scopes required for code type'
|
||||
)
|
||||
scopes = params['scope'].split(' ')
|
||||
if type == "code":
|
||||
if "scope" not in params:
|
||||
return utils.bad_req("scopes required for code type")
|
||||
scopes = params["scope"].split(" ")
|
||||
|
||||
client = requests.mf2(params['client_id'])
|
||||
rels = (client.to_dict()['rel-urls']
|
||||
.get(redirect_uri, {})
|
||||
.get('rels', ()))
|
||||
verified = 'redirect_uri' in rels
|
||||
client = requests.mf2(params["client_id"])
|
||||
rels = client.to_dict()["rel-urls"].get(redirect_uri, {}).get("rels", ())
|
||||
verified = "redirect_uri" in rels
|
||||
|
||||
try:
|
||||
app = client.to_dict(filter_by_type='h-x-app')[0]['properties']
|
||||
app = client.to_dict(filter_by_type="h-x-app")[0]["properties"]
|
||||
except IndexError:
|
||||
app = None
|
||||
|
||||
return {
|
||||
'app': app,
|
||||
'me': me,
|
||||
'redirect_uri': redirect_uri,
|
||||
'verified': verified,
|
||||
'params': params,
|
||||
'scopes': scopes,
|
||||
'title': 'indieauth from {client_id}'.format(**params),
|
||||
"app": app,
|
||||
"me": me,
|
||||
"redirect_uri": redirect_uri,
|
||||
"verified": verified,
|
||||
"params": params,
|
||||
"scopes": scopes,
|
||||
"title": "indieauth from {client_id}".format(**params),
|
||||
}
|
||||
|
||||
def post(self, request):
|
||||
post = request.POST.dict()
|
||||
try:
|
||||
code = IndieAuthCode.objects.get(pk=post.get('code'))
|
||||
code = IndieAuthCode.objects.get(pk=post.get("code"))
|
||||
except IndieAuthCode.DoesNotExist:
|
||||
# if anything at all goes wrong when decoding the auth code, bail
|
||||
# out immediately.
|
||||
return utils.forbid('invalid auth code')
|
||||
return utils.forbid("invalid auth code")
|
||||
code.delete()
|
||||
if code.expired:
|
||||
return utils.forbid('invalid auth code')
|
||||
return utils.forbid("invalid auth code")
|
||||
|
||||
if code.response_type != 'id':
|
||||
return utils.bad_req(
|
||||
'this endpoint only supports response_type=id'
|
||||
)
|
||||
if code.client_id != post.get('client_id'):
|
||||
return utils.forbid('client id did not match')
|
||||
if code.redirect_uri != post.get('redirect_uri'):
|
||||
return utils.forbid('redirect uri did not match')
|
||||
if code.response_type != "id":
|
||||
return utils.bad_req("this endpoint only supports response_type=id")
|
||||
if code.client_id != post.get("client_id"):
|
||||
return utils.forbid("client id did not match")
|
||||
if code.redirect_uri != post.get("redirect_uri"):
|
||||
return utils.forbid("redirect uri did not match")
|
||||
|
||||
# If we got here, it's valid! Yay!
|
||||
return utils.choose_type(request, {'me': code.me}, {
|
||||
'application/x-www-form-urlencoded': utils.form_encoded_response,
|
||||
'application/json': JsonResponse,
|
||||
})
|
||||
return utils.choose_type(
|
||||
request,
|
||||
{"me": code.me},
|
||||
{
|
||||
"application/x-www-form-urlencoded": utils.form_encoded_response,
|
||||
"application/json": JsonResponse,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def approve(request):
|
||||
params = {
|
||||
'me': urljoin(utils.origin(request), request.user.url),
|
||||
'code': tokens.gen_auth_code(request),
|
||||
"me": urljoin(utils.origin(request), request.user.url),
|
||||
"code": tokens.gen_auth_code(request),
|
||||
}
|
||||
if 'state' in request.POST:
|
||||
params['state'] = request.POST['state']
|
||||
if "state" in request.POST:
|
||||
params["state"] = request.POST["state"]
|
||||
|
||||
uri = request.POST['redirect_uri']
|
||||
sep = '&' if '?' in uri else '?'
|
||||
uri = request.POST["redirect_uri"]
|
||||
sep = "&" if "?" in uri else "?"
|
||||
return redirect(uri + sep + urlencode(params))
|
||||
|
|
|
@ -2,11 +2,11 @@ import django.contrib.auth.views
|
|||
from otp_agents.forms import OTPAuthenticationForm
|
||||
from lemoncurry import breadcrumbs
|
||||
|
||||
breadcrumbs.add(route='lemonauth:login', label='log in', parent='home:index')
|
||||
breadcrumbs.add(route="lemonauth:login", label="log in", parent="home:index")
|
||||
|
||||
login = django.contrib.auth.views.LoginView.as_view(
|
||||
authentication_form=OTPAuthenticationForm,
|
||||
extra_context={'title': 'log in'},
|
||||
template_name='lemonauth/login.html',
|
||||
extra_context={"title": "log in"},
|
||||
template_name="lemonauth/login.html",
|
||||
redirect_authenticated_user=True,
|
||||
)
|
||||
|
|
|
@ -7,41 +7,42 @@ from ..models import IndieAuthCode
|
|||
from lemoncurry import utils
|
||||
|
||||
|
||||
@method_decorator(csrf_exempt, name='dispatch')
|
||||
@method_decorator(csrf_exempt, name="dispatch")
|
||||
class TokenView(View):
|
||||
def get(self, req):
|
||||
token = tokens.auth(req)
|
||||
res = {
|
||||
'me': token.me,
|
||||
'client_id': token.client_id,
|
||||
'scope': token.scope,
|
||||
"me": token.me,
|
||||
"client_id": token.client_id,
|
||||
"scope": token.scope,
|
||||
}
|
||||
return utils.choose_type(req, res)
|
||||
|
||||
def post(self, req):
|
||||
post = req.POST
|
||||
try:
|
||||
code = IndieAuthCode.objects.get(pk=post.get('code'))
|
||||
code = IndieAuthCode.objects.get(pk=post.get("code"))
|
||||
except IndieAuthCode.DoesNotExist:
|
||||
return utils.forbid('invalid auth code')
|
||||
return utils.forbid("invalid auth code")
|
||||
code.delete()
|
||||
if code.expired:
|
||||
return utils.forbid('invalid auth code')
|
||||
return utils.forbid("invalid auth code")
|
||||
|
||||
if code.response_type != 'code':
|
||||
return utils.bad_req(
|
||||
'this endpoint only supports response_type=code'
|
||||
)
|
||||
if 'client_id' in post and code.client_id != post['client_id']:
|
||||
return utils.forbid('client id did not match')
|
||||
if code.redirect_uri != post.get('redirect_uri'):
|
||||
return utils.forbid('redirect uri did not match')
|
||||
if code.response_type != "code":
|
||||
return utils.bad_req("this endpoint only supports response_type=code")
|
||||
if "client_id" in post and code.client_id != post["client_id"]:
|
||||
return utils.forbid("client id did not match")
|
||||
if code.redirect_uri != post.get("redirect_uri"):
|
||||
return utils.forbid("redirect uri did not match")
|
||||
|
||||
if 'me' in post and code.me != post['me']:
|
||||
return utils.forbid('me did not match')
|
||||
if "me" in post and code.me != post["me"]:
|
||||
return utils.forbid("me did not match")
|
||||
|
||||
return utils.choose_type(req, {
|
||||
'access_token': tokens.gen_token(code),
|
||||
'me': code.me,
|
||||
'scope': code.scope,
|
||||
})
|
||||
return utils.choose_type(
|
||||
req,
|
||||
{
|
||||
"access_token": tokens.gen_token(code),
|
||||
"me": code.me,
|
||||
"scope": code.scope,
|
||||
},
|
||||
)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from requests.exceptions import RequestException
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic import TemplateView
|
||||
from typing import Dict, Optional, Set
|
||||
|
@ -20,15 +21,15 @@ class Client:
|
|||
self.id = client_id
|
||||
self.count = 0
|
||||
self.scopes = set()
|
||||
apps = mf2(self.id).to_dict(filter_by_type='h-x-app')
|
||||
try:
|
||||
self.app = apps[0]['properties']
|
||||
except IndexError:
|
||||
apps = mf2(self.id).to_dict(filter_by_type="h-x-app")
|
||||
self.app = apps[0]["properties"]
|
||||
except (RequestException, IndexError):
|
||||
self.app = None
|
||||
|
||||
|
||||
class TokensListView(LoginRequiredMixin, TemplateView):
|
||||
template_name = 'lemonauth/tokens.html'
|
||||
template_name = "lemonauth/tokens.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
@ -36,6 +37,6 @@ class TokensListView(LoginRequiredMixin, TemplateView):
|
|||
for token in self.request.user.token_set.all():
|
||||
client = clients[token.client_id]
|
||||
client.count += 1
|
||||
client.scopes |= set(token.scope.split(' '))
|
||||
context.update({'clients': clients, 'title': 'tokens'})
|
||||
client.scopes |= set(token.scope.split(" "))
|
||||
context.update({"clients": clients, "title": "tokens"})
|
||||
return context
|
||||
|
|
|
@ -14,7 +14,7 @@ class Crumb:
|
|||
return self._label
|
||||
|
||||
def __eq__(self, other):
|
||||
if hasattr(other, 'route'):
|
||||
if hasattr(other, "route"):
|
||||
return self.route == other.route
|
||||
return self.route == other
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@ from debug_toolbar.middleware import show_toolbar as core_show_toolbar
|
|||
|
||||
|
||||
def show_toolbar(request):
|
||||
if request.path.endswith('/amp'):
|
||||
if request.path.endswith("/amp"):
|
||||
return False
|
||||
return core_show_toolbar(request)
|
||||
|
|
|
@ -22,18 +22,22 @@ def environment(**options):
|
|||
lstrip_blocks=True,
|
||||
**options
|
||||
)
|
||||
env.filters.update({
|
||||
'ago': ago,
|
||||
'friendly_url': friendly_url,
|
||||
'markdown': markdown,
|
||||
})
|
||||
env.globals.update({
|
||||
'entry_kinds': entry_kinds,
|
||||
'favicons': favicons,
|
||||
'package': load_package_json(),
|
||||
'settings': settings,
|
||||
'static': staticfiles_storage.url,
|
||||
'theme_color': theme_color,
|
||||
'url': reverse,
|
||||
})
|
||||
env.filters.update(
|
||||
{
|
||||
"ago": ago,
|
||||
"friendly_url": friendly_url,
|
||||
"markdown": markdown,
|
||||
}
|
||||
)
|
||||
env.globals.update(
|
||||
{
|
||||
"entry_kinds": entry_kinds,
|
||||
"favicons": favicons,
|
||||
"package": load_package_json(),
|
||||
"settings": settings,
|
||||
"static": staticfiles_storage.url,
|
||||
"theme_color": theme_color,
|
||||
"url": reverse,
|
||||
}
|
||||
)
|
||||
return env
|
||||
|
|
|
@ -6,4 +6,4 @@ def ago(dt: datetime) -> str:
|
|||
# We have to convert the datetime we get to local time first, because ago
|
||||
# just strips the timezone from a timezone-aware datetime.
|
||||
dt = dt.astimezone()
|
||||
return human(dt, precision=1, past_tense='{}', abbreviate=True)
|
||||
return human(dt, precision=1, past_tense="{}", abbreviate=True)
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
from bleach.sanitizer import Cleaner, ALLOWED_TAGS
|
||||
from bleach.linkifier import LinkifyFilter
|
||||
from jinja2 import evalcontextfilter, Markup
|
||||
from jinja2 import pass_eval_context
|
||||
from markupsafe import Markup
|
||||
|
||||
TAGS = ['cite', 'code', 'details', 'p', 'pre', 'img', 'span', 'summary']
|
||||
TAGS = ["cite", "code", "details", "p", "pre", "img", "span", "summary"]
|
||||
TAGS.extend(ALLOWED_TAGS)
|
||||
ATTRIBUTES = {
|
||||
'a': ['href', 'title', 'class'],
|
||||
'details': ['open'],
|
||||
'img': ['alt', 'src', 'title'],
|
||||
'span': ['class'],
|
||||
"a": ["href", "title", "class"],
|
||||
"details": ["open"],
|
||||
"img": ["alt", "src", "title"],
|
||||
"span": ["class"],
|
||||
}
|
||||
|
||||
cleaner = Cleaner(tags=TAGS, attributes=ATTRIBUTES, filters=(LinkifyFilter,))
|
||||
|
||||
|
||||
@evalcontextfilter
|
||||
@pass_eval_context
|
||||
def bleach(ctx, html):
|
||||
res = cleaner.clean(html)
|
||||
if ctx.autoescape:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!doctype html>
|
||||
<html{% block html_attr %} dir="ltr" lang="en"{% endblock %}>
|
||||
<html{% block html_attr %} dir="ltr" lang="en" data-bs-theme="dark"{% endblock %}>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
@ -27,10 +27,10 @@
|
|||
<link rel="{{ i.rel }}" type="{{ i.mime }}" sizes="{{ i.sizes }}" href="{{ i.url }}" />
|
||||
{% endfor %}
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/monokai.min.css"
|
||||
integrity="sha384-bHqbpRh/XW+phptvH9nQvMKHwPH1ZbOxpIeAB2D2OIEL4Ni7aZzZgMFpsRra+v1g" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@highlightjs/cdn-assets@11.9.0/styles/monokai.min.css"
|
||||
integrity="sha384-88Jvj9Q2LiBDwL7w3yciRTcH5q2zzvMFYIm4xX9/evqxJsxA33Xk9XYKcvUlPITo" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="https://unpkg.com/openwebicons@1.6.0/css/openwebicons.min.css"
|
||||
integrity="sha384-NkRWM9o4Kfak7GwS+un+sProBBpj02vc/e1EoXvdCUSdRk0muOfkKJ5NtpueAuka" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="https://unpkg.com/tippy.js@3.4.1/dist/tippy.css"
|
||||
|
@ -40,12 +40,11 @@
|
|||
{% block styles %}{% endblock %}
|
||||
{% endcompress %}
|
||||
|
||||
<script type="text/javascript" defer src="https://use.fontawesome.com/releases/v5.8.1/js/all.js"
|
||||
integrity="sha384-g5uSoOSBd7KkhAMlnQILrecXvzst9TdC09/VM+pjDTCM+1il8RHz5fKANTFFb+gQ" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" defer src="https://kit.fontawesome.com/a3aade9b41.js" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body{% block body_attr %}{% endblock %}>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-md navbar-dark">
|
||||
<nav class="navbar navbar-expand-md"><div class="container-fluid">
|
||||
<a class="navbar-brand" rel="home" href="{{ url('home:index') }}">{{ request.site.name }}</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar"
|
||||
aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
|
@ -97,7 +96,7 @@
|
|||
</div>
|
||||
{% endactiveurl %}
|
||||
|
||||
</nav>
|
||||
</div></nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
|
@ -147,14 +146,14 @@
|
|||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"
|
||||
integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" crossorigin="anonymous"
|
||||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" crossorigin="anonymous"
|
||||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js" crossorigin="anonymous"
|
||||
integrity="sha384-BlPof9RtjBqeJFskKv3sK3dh4Wk70iKlpIe92FeVN+6qxaGUOUu+mZNpALZ+K7ya"></script>
|
||||
<script src="https://unpkg.com/tippy.js@3.4.1/dist/tippy.standalone.min.js" crossorigin="anonymous"
|
||||
integrity="sha384-x7dGoSfOWUdyPccAel9dkWte6n8GxDWbByavEixRzW0O9xvPGzg3y0qzZBwGNUw9"></script>
|
||||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.9.0/highlight.min.js" crossorigin="anonymous"
|
||||
integrity="sha384-F/bZzf7p3Joyp5psL90p/p89AZJsndkSoGwRpXcZhleCWhd8SnRuoYo4d0yirjJp"></script>
|
||||
<script src="https://unpkg.com/@popperjs/core@2.11.8/dist/umd/popper.min.js" crossorigin="anonymous"
|
||||
integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" crossorigin="anonymous"
|
||||
integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy"></script>
|
||||
<script src="https://unpkg.com/tippy.js@6.3.7/dist/tippy-bundle.umd.js" crossorigin="anonymous"
|
||||
integrity="sha384-dtMr4wkcxQWUqsJFgElu4AttgIhOsjr2vYIzP2mv0MZbD/uJ6OHxFdbgE3MOKabN"></script>
|
||||
{% compress js %}
|
||||
<script type="text/javascript">
|
||||
hljs.initHighlightingOnLoad();
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
from jinja2 import evalcontextfilter
|
||||
from jinja2 import pass_eval_context
|
||||
from markdown import Markdown
|
||||
|
||||
from .bleach import bleach
|
||||
|
||||
md = Markdown(extensions=(
|
||||
'extra',
|
||||
'sane_lists',
|
||||
'smarty',
|
||||
'toc',
|
||||
))
|
||||
md = Markdown(
|
||||
extensions=(
|
||||
"extra",
|
||||
"sane_lists",
|
||||
"smarty",
|
||||
"toc",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@evalcontextfilter
|
||||
@pass_eval_context
|
||||
def markdown(ctx, source):
|
||||
return bleach(ctx, md.reset().convert(source))
|
||||
|
|
|
@ -8,7 +8,9 @@ class ResponseException(Exception):
|
|||
|
||||
|
||||
class ResponseExceptionMiddleware(MiddlewareMixin):
|
||||
def process_exception(self, request: HttpRequest, exception: Exception) -> HttpResponse:
|
||||
def process_exception(
|
||||
self, request: HttpRequest, exception: Exception
|
||||
) -> HttpResponse:
|
||||
if isinstance(exception, ResponseException):
|
||||
return exception.response
|
||||
raise exception
|
||||
|
|
|
@ -11,7 +11,7 @@ from mf2py import Parser
|
|||
class DjangoCache(BaseCache):
|
||||
@classmethod
|
||||
def key(cls, url):
|
||||
return 'req:' + sha256(url.encode('utf-8')).hexdigest()
|
||||
return "req:" + sha256(url.encode("utf-8")).hexdigest()
|
||||
|
||||
def get(self, url):
|
||||
key = self.key(url)
|
||||
|
@ -45,4 +45,4 @@ def get(url):
|
|||
|
||||
def mf2(url):
|
||||
r = get(url)
|
||||
return Parser(doc=r.text, url=url, html_parser='html5lib')
|
||||
return Parser(doc=r.text, url=url, html_parser="html5lib")
|
||||
|
|
|
@ -16,7 +16,7 @@ from typing import List
|
|||
APPEND_SLASH = False
|
||||
|
||||
ADMINS = [
|
||||
('dani', 'dani@00dani.me'),
|
||||
("dani", "dani@00dani.me"),
|
||||
]
|
||||
|
||||
BASE_DIR = path.dirname(path.dirname(path.dirname(path.abspath(__file__))))
|
||||
|
@ -26,13 +26,13 @@ BASE_DIR = path.dirname(path.dirname(path.dirname(path.abspath(__file__))))
|
|||
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '6riil57g@r^wprf7mdy((+bs&(6l*phcn9&fd$l0@t-kzj+xww'
|
||||
SECRET_KEY = "6riil57g@r^wprf7mdy((+bs&(6l*phcn9&fd$l0@t-kzj+xww"
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = [] # type: List[str]
|
||||
INTERNAL_IPS = ['127.0.0.1', '::1']
|
||||
ALLOWED_HOSTS: List[str] = []
|
||||
INTERNAL_IPS = ["127.0.0.1", "::1"]
|
||||
|
||||
# Settings to tighten up security - these can safely be on in dev mode too,
|
||||
# since I dev using a local HTTPS server.
|
||||
|
@ -50,7 +50,7 @@ CSRF_COOKIE_SECURE = True
|
|||
# Miscellanous headers to protect against attacks.
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
||||
SECURE_BROWSER_XSS_FILTER = True
|
||||
X_FRAME_OPTIONS = 'DENY'
|
||||
X_FRAME_OPTIONS = "DENY"
|
||||
|
||||
# This technically isn't needed, since nginx doesn't let the app be accessed
|
||||
# over insecure HTTP anyway. Just for completeness!
|
||||
|
@ -58,110 +58,104 @@ SECURE_SSL_REDIRECT = True
|
|||
|
||||
# We run behind nginx, so we need nginx to tell us whether we're using HTTPS or
|
||||
# not.
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'lemoncurry',
|
||||
'pyup_django',
|
||||
|
||||
'django.contrib.admin',
|
||||
'django.contrib.admindocs',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.humanize',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.sitemaps',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
'analytical',
|
||||
'annoying',
|
||||
'compressor',
|
||||
'computed_property',
|
||||
'corsheaders',
|
||||
'debug_toolbar',
|
||||
'django_activeurl',
|
||||
'django_agent_trust',
|
||||
'django_extensions',
|
||||
'django_otp',
|
||||
'django_otp.plugins.otp_static',
|
||||
'django_otp.plugins.otp_totp',
|
||||
'django_rq',
|
||||
'favicon',
|
||||
'meta',
|
||||
|
||||
'entries',
|
||||
'home',
|
||||
'lemonauth',
|
||||
'lemonshort',
|
||||
'micropub',
|
||||
'users',
|
||||
'webmention',
|
||||
'wellknowns',
|
||||
"lemoncurry",
|
||||
"pyup_django",
|
||||
"django.contrib.admin",
|
||||
"django.contrib.admindocs",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.humanize",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.sites",
|
||||
"django.contrib.sitemaps",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"annoying",
|
||||
"compressor",
|
||||
"computed_property",
|
||||
"corsheaders",
|
||||
"debug_toolbar",
|
||||
"django_activeurl",
|
||||
"django_agent_trust",
|
||||
"django_extensions",
|
||||
"django_otp",
|
||||
"django_otp.plugins.otp_static",
|
||||
"django_otp.plugins.otp_totp",
|
||||
"django_rq",
|
||||
"meta",
|
||||
"entries",
|
||||
"home",
|
||||
"lemonauth",
|
||||
"lemonshort",
|
||||
"micropub",
|
||||
"users",
|
||||
"webmention",
|
||||
"wellknowns",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||
'django.middleware.http.ConditionalGetMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.admindocs.middleware.XViewMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'corsheaders.middleware.CorsMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django_otp.middleware.OTPMiddleware',
|
||||
'django_agent_trust.middleware.AgentMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'lemoncurry.middleware.ResponseExceptionMiddleware',
|
||||
"debug_toolbar.middleware.DebugToolbarMiddleware",
|
||||
"django.middleware.http.ConditionalGetMiddleware",
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"django.contrib.admindocs.middleware.XViewMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"corsheaders.middleware.CorsMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django_otp.middleware.OTPMiddleware",
|
||||
"django_agent_trust.middleware.AgentMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.contrib.sites.middleware.CurrentSiteMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"lemoncurry.middleware.ResponseExceptionMiddleware",
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'lemoncurry.urls'
|
||||
ROOT_URLCONF = "lemoncurry.urls"
|
||||
|
||||
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
|
||||
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.jinja2.Jinja2',
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'environment': 'lemoncurry.jinja2.environment',
|
||||
"BACKEND": "django.template.backends.jinja2.Jinja2",
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"environment": "lemoncurry.jinja2.environment",
|
||||
},
|
||||
},
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
"django.template.context_processors.debug",
|
||||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'lemoncurry.wsgi.application'
|
||||
WSGI_APPLICATION = "lemoncurry.wsgi.application"
|
||||
|
||||
# Cache
|
||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#std:setting-CACHES
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_redis.cache.RedisCache',
|
||||
'LOCATION': 'redis://127.0.0.1:6380/0',
|
||||
'KEY_PREFIX': 'lemoncurry',
|
||||
'OPTIONS': {
|
||||
'PARSER_CLASS': 'redis.connection.HiredisParser',
|
||||
'SERIALIZER': 'lemoncurry.msgpack.MSGPackModernSerializer',
|
||||
"default": {
|
||||
"BACKEND": "django_redis.cache.RedisCache",
|
||||
"LOCATION": "redis://127.0.0.1:6380/0",
|
||||
"KEY_PREFIX": "lemoncurry",
|
||||
"OPTIONS": {
|
||||
"SERIALIZER": "lemoncurry.msgpack.MSGPackModernSerializer",
|
||||
},
|
||||
'VERSION': 2,
|
||||
"VERSION": 2,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,51 +163,51 @@ CACHES = {
|
|||
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': environ.get('POSTGRES_DB', 'lemoncurry'),
|
||||
'USER': environ.get('POSTGRES_USER'),
|
||||
'PASSWORD': environ.get('POSTGRES_PASSWORD'),
|
||||
'HOST': environ.get('POSTGRES_HOST', 'localhost'),
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": environ.get("POSTGRES_DB", "lemoncurry"),
|
||||
"USER": environ.get("POSTGRES_USER"),
|
||||
"PASSWORD": environ.get("POSTGRES_PASSWORD"),
|
||||
"HOST": environ.get("POSTGRES_HOST", "localhost"),
|
||||
}
|
||||
}
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
||||
|
||||
AUTH_USER_MODEL = 'users.User'
|
||||
AUTH_USER_MODEL = "users.User"
|
||||
|
||||
# Password hashers
|
||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
||||
PASSWORD_HASHERS = [
|
||||
'django.contrib.auth.hashers.Argon2PasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
||||
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
||||
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
||||
"django.contrib.auth.hashers.Argon2PasswordHasher",
|
||||
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
|
||||
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
|
||||
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
|
||||
"django.contrib.auth.hashers.BCryptPasswordHasher",
|
||||
]
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
|
||||
|
||||
PW_VALIDATOR_MODULE = 'django.contrib.auth.password_validation'
|
||||
PW_VALIDATOR_MODULE = "django.contrib.auth.password_validation"
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{'NAME': PW_VALIDATOR_MODULE + '.UserAttributeSimilarityValidator'},
|
||||
{'NAME': PW_VALIDATOR_MODULE + '.MinimumLengthValidator'},
|
||||
{'NAME': PW_VALIDATOR_MODULE + '.CommonPasswordValidator'},
|
||||
{'NAME': PW_VALIDATOR_MODULE + '.NumericPasswordValidator'},
|
||||
{"NAME": PW_VALIDATOR_MODULE + ".UserAttributeSimilarityValidator"},
|
||||
{"NAME": PW_VALIDATOR_MODULE + ".MinimumLengthValidator"},
|
||||
{"NAME": PW_VALIDATOR_MODULE + ".CommonPasswordValidator"},
|
||||
{"NAME": PW_VALIDATOR_MODULE + ".NumericPasswordValidator"},
|
||||
]
|
||||
|
||||
LOGIN_URL = 'lemonauth:login'
|
||||
LOGIN_REDIRECT_URL = 'home:index'
|
||||
LOGIN_URL = "lemonauth:login"
|
||||
LOGIN_REDIRECT_URL = "home:index"
|
||||
LOGOUT_REDIRECT_URL = LOGIN_REDIRECT_URL
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.11/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-au'
|
||||
LANGUAGE_CODE = "en-au"
|
||||
|
||||
TIME_ZONE = 'Australia/Sydney'
|
||||
TIME_ZONE = "Australia/Sydney"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
|
@ -225,21 +219,21 @@ USE_TZ = True
|
|||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.11/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = path.join(BASE_DIR, 'static')
|
||||
STATIC_URL = "/static/"
|
||||
STATIC_ROOT = path.join(BASE_DIR, "static")
|
||||
STATICFILES_FINDERS = (
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
'compressor.finders.CompressorFinder',
|
||||
"django.contrib.staticfiles.finders.FileSystemFinder",
|
||||
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
||||
"compressor.finders.CompressorFinder",
|
||||
)
|
||||
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
|
||||
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
|
||||
|
||||
COMPRESS_PRECOMPILERS = (
|
||||
('text/stylus', 'npx stylus -u ./lemoncurry/static/lemoncurry/css/theme'),
|
||||
("text/stylus", "npx stylus -u ./lemoncurry/static/lemoncurry/css/theme"),
|
||||
)
|
||||
|
||||
MEDIA_URL = STATIC_URL + 'media/'
|
||||
MEDIA_ROOT = path.join(STATIC_ROOT, 'media')
|
||||
MEDIA_URL = STATIC_URL + "media/"
|
||||
MEDIA_ROOT = path.join(STATIC_ROOT, "media")
|
||||
|
||||
# django-contrib-sites
|
||||
# https://docs.djangoproject.com/en/dev/ref/contrib/sites/
|
||||
|
@ -251,28 +245,25 @@ AGENT_COOKIE_SECURE = True
|
|||
|
||||
# django-cors-headers
|
||||
CORS_ORIGIN_ALLOW_ALL = True
|
||||
CORS_URLS_REGEX = r'^/(?!admin|auth/(?:login|logout|indie)).*$'
|
||||
CORS_URLS_REGEX = r"^/(?!admin|auth/(?:login|logout|indie)).*$"
|
||||
|
||||
# lemonshort
|
||||
SHORT_BASE_URL = '/s/'
|
||||
SHORT_BASE_URL = "/s/"
|
||||
SHORTEN_MODELS = {
|
||||
'e': 'entries.entry',
|
||||
"e": "entries.entry",
|
||||
}
|
||||
|
||||
# django-meta
|
||||
# https://django-meta.readthedocs.io/en/latest/settings.html
|
||||
META_SITE_PROTOCOL = 'https'
|
||||
META_SITE_PROTOCOL = "https"
|
||||
META_USE_SITES = True
|
||||
META_USE_OG_PROPERTIES = True
|
||||
META_USE_TWITTER_PROPERTIES = True
|
||||
|
||||
# django-push
|
||||
# https://django-push.readthedocs.io/en/latest/publisher.html
|
||||
PUSH_HUB = 'https://00dani.superfeedr.com/'
|
||||
PUSH_HUB = "https://00dani.superfeedr.com/"
|
||||
|
||||
# django-rq
|
||||
# https://github.com/ui/django-rq
|
||||
RQ_QUEUES = {'default': {'USE_REDIS_CACHE': 'default'}}
|
||||
|
||||
# django-super-favicon
|
||||
FAVICON_STORAGE = 'django.core.files.storage.DefaultStorage'
|
||||
RQ_QUEUES = {"default": {"USE_REDIS_CACHE": "default"}}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from .base import *
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
META_SITE_DOMAIN = '00dani.lo'
|
||||
META_FB_APPID = '142105433189339'
|
||||
STATIC_URL = 'https://static.00dani.lo/'
|
||||
MEDIA_URL = 'https://media.00dani.lo/'
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
META_SITE_DOMAIN = "00dani.lo"
|
||||
META_FB_APPID = "142105433189339"
|
||||
STATIC_URL = "https://static.00dani.lo/"
|
||||
MEDIA_URL = "https://media.00dani.lo/"
|
||||
|
|
|
@ -4,19 +4,19 @@ from os.path import join
|
|||
from .base import *
|
||||
from .base import BASE_DIR, DATABASES
|
||||
|
||||
ALLOWED_HOSTS = ['00dani.me']
|
||||
ALLOWED_HOSTS = ["00dani.me"]
|
||||
DEBUG = False
|
||||
SECRET_KEY = environ['DJANGO_SECRET_KEY']
|
||||
SERVER_EMAIL = 'lemoncurry@00dani.me'
|
||||
SECRET_KEY = environ["DJANGO_SECRET_KEY"]
|
||||
SERVER_EMAIL = "lemoncurry@00dani.me"
|
||||
|
||||
# Authenticate as an app-specific Postgres user in production.
|
||||
DATABASES['default']['USER'] = 'lemoncurry'
|
||||
DATABASES["default"]["USER"] = "lemoncurry"
|
||||
|
||||
SHORT_BASE_URL = 'https://nya.as/'
|
||||
SHORT_BASE_URL = "https://nya.as/"
|
||||
|
||||
STATIC_ROOT = join(BASE_DIR, '..', 'static')
|
||||
MEDIA_ROOT = join(BASE_DIR, '..', 'media')
|
||||
STATIC_URL = 'https://cdn.00dani.me/'
|
||||
MEDIA_URL = STATIC_URL + 'm/'
|
||||
META_SITE_DOMAIN = '00dani.me'
|
||||
META_FB_APPID = '145311792869199'
|
||||
STATIC_ROOT = join(BASE_DIR, "..", "static")
|
||||
MEDIA_ROOT = join(BASE_DIR, "..", "media")
|
||||
STATIC_URL = "https://cdn.00dani.me/"
|
||||
MEDIA_URL = STATIC_URL + "m/"
|
||||
META_SITE_DOMAIN = "00dani.me"
|
||||
META_FB_APPID = "145311792869199"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from .base import *
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
SECURE_SSL_REDIRECT = False
|
||||
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
|
||||
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
STATIC_ROOT = path.join(BASE_DIR, 'media')
|
||||
MEDIA_URL = "/media/"
|
||||
STATIC_ROOT = path.join(BASE_DIR, "media")
|
||||
|
|
|
@ -5,6 +5,7 @@ html
|
|||
|
||||
a
|
||||
color $base0D
|
||||
text-decoration none
|
||||
&:hover
|
||||
color $base0C
|
||||
|
||||
|
@ -31,13 +32,13 @@ code, pre, .code, .pre
|
|||
text-decoration none
|
||||
line-height 1
|
||||
|
||||
for placement in top bottom left right
|
||||
.tippy-popper[x-placement^={placement}] .tippy-tooltip.dark-theme .tippy-arrow
|
||||
border-{placement}-color $base03
|
||||
|
||||
.tippy-tooltip.dark-theme
|
||||
.tippy-box[data-theme~='dark']
|
||||
background-color $base03
|
||||
color $base04
|
||||
text-align center
|
||||
for placement in top bottom left right
|
||||
&[data-placement^={placement}] > .tippy-arrow::before
|
||||
border-{placement}-color $base03
|
||||
|
||||
body
|
||||
display flex
|
||||
|
@ -103,6 +104,12 @@ ul.pagination
|
|||
background-color $base02
|
||||
border 1px solid rgba(0,0,0,.125)
|
||||
|
||||
.media
|
||||
display flex
|
||||
> .media-body
|
||||
flex-grow 1
|
||||
margin-left 3px
|
||||
|
||||
.card
|
||||
background-color $base02
|
||||
|
||||
|
|
|
@ -8,5 +8,5 @@ register = template.Library()
|
|||
@register.simple_tag
|
||||
@register.filter(is_safe=True)
|
||||
def absolute_url(url):
|
||||
base = 'https://' + Site.objects.get_current().domain
|
||||
base = "https://" + Site.objects.get_current().domain
|
||||
return urljoin(base, url)
|
||||
|
|
|
@ -5,13 +5,13 @@ from django.utils.safestring import mark_safe
|
|||
from bleach.sanitizer import Cleaner, ALLOWED_TAGS
|
||||
from bleach.linkifier import LinkifyFilter
|
||||
|
||||
tags = ['cite', 'code', 'details', 'p', 'pre', 'img', 'span', 'summary']
|
||||
tags = ["cite", "code", "details", "p", "pre", "img", "span", "summary"]
|
||||
tags.extend(ALLOWED_TAGS)
|
||||
attributes = {
|
||||
'a': ['href', 'title', 'class'],
|
||||
'details': ['open'],
|
||||
'img': ['alt', 'src', 'title'],
|
||||
'span': ['class'],
|
||||
"a": ["href", "title", "class"],
|
||||
"details": ["open"],
|
||||
"img": ["alt", "src", "title"],
|
||||
"span": ["class"],
|
||||
}
|
||||
|
||||
register = template.Library()
|
||||
|
|
|
@ -11,5 +11,5 @@ register = template.Library()
|
|||
@register.filter
|
||||
def jsonify(value):
|
||||
if isinstance(value, QuerySet):
|
||||
return mark_safe(serialize('json', value))
|
||||
return mark_safe(serialize("json", value))
|
||||
return mark_safe(json.dumps(value, cls=DjangoJSONEncoder))
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from django import template
|
||||
from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
|
@ -40,67 +39,71 @@ def site_name():
|
|||
return Site.objects.get_current().name
|
||||
|
||||
|
||||
@register.inclusion_tag('lemoncurry/tags/nav.html')
|
||||
@register.inclusion_tag("lemoncurry/tags/nav.html")
|
||||
def nav_left(request):
|
||||
items = (MenuItem(
|
||||
label=k.plural,
|
||||
icon=k.icon,
|
||||
url=('entries:index', (k,))
|
||||
) for k in kinds.all)
|
||||
return {'items': items, 'request': request}
|
||||
items = (
|
||||
MenuItem(label=k.plural, icon=k.icon, url=("entries:index", (k,)))
|
||||
for k in kinds.all
|
||||
)
|
||||
return {"items": items, "request": request}
|
||||
|
||||
|
||||
@register.inclusion_tag('lemoncurry/tags/nav.html')
|
||||
@register.inclusion_tag("lemoncurry/tags/nav.html")
|
||||
def nav_right(request):
|
||||
if request.user.is_authenticated:
|
||||
items = (
|
||||
MenuItem(label='admin', icon='fas fa-cog', url='admin:index'),
|
||||
MenuItem(label='log out', icon='fas fa-sign-out-alt',
|
||||
url='lemonauth:logout'),
|
||||
MenuItem(label="admin", icon="fas fa-cog", url="admin:index"),
|
||||
MenuItem(
|
||||
label="log out", icon="fas fa-sign-out-alt", url="lemonauth:logout"
|
||||
),
|
||||
)
|
||||
else:
|
||||
items = (
|
||||
MenuItem(label='log in', icon='fas fa-sign-in-alt',
|
||||
url='lemonauth:login'),
|
||||
MenuItem(label="log in", icon="fas fa-sign-in-alt", url="lemonauth:login"),
|
||||
)
|
||||
return {'items': items, 'request': request}
|
||||
return {"items": items, "request": request}
|
||||
|
||||
|
||||
@register.inclusion_tag('lemoncurry/tags/breadcrumbs.html', takes_context=True)
|
||||
@register.inclusion_tag("lemoncurry/tags/breadcrumbs.html", takes_context=True)
|
||||
def nav_crumbs(context, route):
|
||||
crumbs = breadcrumbs.find(route)
|
||||
current = crumbs.pop()
|
||||
|
||||
item_list_element = [{
|
||||
'@type': 'ListItem',
|
||||
'position': i + 1,
|
||||
'item': {
|
||||
'@id': context['origin'] + crumb.url,
|
||||
'@type': 'WebPage',
|
||||
'name': crumb.label
|
||||
item_list_element = [
|
||||
{
|
||||
"@type": "ListItem",
|
||||
"position": i + 1,
|
||||
"item": {
|
||||
"@id": context["origin"] + crumb.url,
|
||||
"@type": "WebPage",
|
||||
"name": crumb.label,
|
||||
},
|
||||
}
|
||||
} for i, crumb in enumerate(crumbs)]
|
||||
item_list_element.append({
|
||||
'@type': 'ListItem',
|
||||
'position': len(item_list_element) + 1,
|
||||
'item': {
|
||||
'id': context['uri'],
|
||||
'@type': 'WebPage',
|
||||
'name': current.label or context.get('title'),
|
||||
for i, crumb in enumerate(crumbs)
|
||||
]
|
||||
item_list_element.append(
|
||||
{
|
||||
"@type": "ListItem",
|
||||
"position": len(item_list_element) + 1,
|
||||
"item": {
|
||||
"id": context["uri"],
|
||||
"@type": "WebPage",
|
||||
"name": current.label or context.get("title"),
|
||||
},
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
breadcrumb_list = {
|
||||
'@context': 'http://schema.org',
|
||||
'@type': 'BreadcrumbList',
|
||||
'itemListElement': item_list_element
|
||||
"@context": "http://schema.org",
|
||||
"@type": "BreadcrumbList",
|
||||
"itemListElement": item_list_element,
|
||||
}
|
||||
|
||||
return {
|
||||
'breadcrumb_list': breadcrumb_list,
|
||||
'crumbs': crumbs,
|
||||
'current': current,
|
||||
'title': context.get('title'),
|
||||
"breadcrumb_list": breadcrumb_list,
|
||||
"crumbs": crumbs,
|
||||
"current": current,
|
||||
"title": context.get("title"),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,12 +3,14 @@ from django import template
|
|||
from markdown import Markdown
|
||||
from .bleach import bleach
|
||||
|
||||
md = Markdown(extensions=(
|
||||
'extra',
|
||||
'sane_lists',
|
||||
'smarty',
|
||||
'toc',
|
||||
))
|
||||
md = Markdown(
|
||||
extensions=(
|
||||
"extra",
|
||||
"sane_lists",
|
||||
"smarty",
|
||||
"toc",
|
||||
)
|
||||
)
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
|
|
@ -6,43 +6,43 @@ from .. import breadcrumbs as b
|
|||
|
||||
@pytest.fixture
|
||||
def nested_crumbs():
|
||||
x = b.Crumb('nc.x', label='x')
|
||||
y = b.Crumb('nc.y', label='y', parent='nc.x')
|
||||
z = b.Crumb('nc.z', label='z', parent='nc.y')
|
||||
x = b.Crumb("nc.x", label="x")
|
||||
y = b.Crumb("nc.y", label="y", parent="nc.x")
|
||||
z = b.Crumb("nc.z", label="z", parent="nc.y")
|
||||
crumbs = (x, y, z)
|
||||
|
||||
for crumb in crumbs:
|
||||
b.breadcrumbs[crumb.route] = crumb
|
||||
yield namedtuple('NestedCrumbs', 'x y z')(*crumbs)
|
||||
yield namedtuple("NestedCrumbs", "x y z")(*crumbs)
|
||||
for crumb in crumbs:
|
||||
del b.breadcrumbs[crumb.route]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def crumb_match(nested_crumbs):
|
||||
return namedtuple('Match', 'view_name')(nested_crumbs.z.route)
|
||||
return namedtuple("Match", "view_name")(nested_crumbs.z.route)
|
||||
|
||||
|
||||
class TestAdd:
|
||||
def test_inserts_a_breadcrumb_without_parent(self):
|
||||
route = 'tests.add.insert'
|
||||
route = "tests.add.insert"
|
||||
assert route not in b.breadcrumbs
|
||||
b.add(route, 'some label')
|
||||
b.add(route, "some label")
|
||||
assert route in b.breadcrumbs
|
||||
assert b.breadcrumbs[route] == route
|
||||
route = b.breadcrumbs[route]
|
||||
assert route.label == 'some label'
|
||||
assert route.label == "some label"
|
||||
assert route.parent is None
|
||||
|
||||
def test_inserts_a_breadcrumb_with_parent(self):
|
||||
route = 'tests.add.with_parent'
|
||||
parent = 'tests.add.insert'
|
||||
route = "tests.add.with_parent"
|
||||
parent = "tests.add.insert"
|
||||
assert route not in b.breadcrumbs
|
||||
b.add(route, 'child label', parent)
|
||||
b.add(route, "child label", parent)
|
||||
assert route in b.breadcrumbs
|
||||
assert b.breadcrumbs[route] == route
|
||||
route = b.breadcrumbs[route]
|
||||
assert route.label == 'child label'
|
||||
assert route.label == "child label"
|
||||
assert route.parent == parent
|
||||
|
||||
|
||||
|
|
|
@ -5,22 +5,22 @@ from .. import utils
|
|||
class TestOrigin:
|
||||
def test_simple_http(self):
|
||||
"""should return the correct origin for a vanilla HTTP site"""
|
||||
req = Mock(scheme='http', site=Mock(domain='lemoncurry.test'))
|
||||
assert utils.origin(req) == 'http://lemoncurry.test'
|
||||
req = Mock(scheme="http", site=Mock(domain="lemoncurry.test"))
|
||||
assert utils.origin(req) == "http://lemoncurry.test"
|
||||
|
||||
def test_simple_https(self):
|
||||
"""should return the correct origin for a vanilla HTTPS site"""
|
||||
req = Mock(scheme='https', site=Mock(domain='secure.lemoncurry.test'))
|
||||
assert utils.origin(req) == 'https://secure.lemoncurry.test'
|
||||
req = Mock(scheme="https", site=Mock(domain="secure.lemoncurry.test"))
|
||||
assert utils.origin(req) == "https://secure.lemoncurry.test"
|
||||
|
||||
|
||||
class TestUri:
|
||||
def test_siteroot(self):
|
||||
"""should return correct full URI for requests to the site root"""
|
||||
req = Mock(scheme='https', path='/', site=Mock(domain='l.test'))
|
||||
assert utils.uri(req) == 'https://l.test/'
|
||||
req = Mock(scheme="https", path="/", site=Mock(domain="l.test"))
|
||||
assert utils.uri(req) == "https://l.test/"
|
||||
|
||||
def test_path(self):
|
||||
"""should return correct full URI for requests with a path"""
|
||||
req = Mock(scheme='https', path='/notes/23', site=Mock(domain='l.tst'))
|
||||
assert utils.uri(req) == 'https://l.tst/notes/23'
|
||||
req = Mock(scheme="https", path="/notes/23", site=Mock(domain="l.tst"))
|
||||
assert utils.uri(req) == "https://l.tst/notes/23"
|
||||
|
|
|
@ -4,12 +4,14 @@ from yaml import safe_load
|
|||
|
||||
path = join(
|
||||
settings.BASE_DIR,
|
||||
'lemoncurry', 'static',
|
||||
'base16-materialtheme-scheme', 'material-darker.yaml',
|
||||
"lemoncurry",
|
||||
"static",
|
||||
"base16-materialtheme-scheme",
|
||||
"material-darker.yaml",
|
||||
)
|
||||
with open(path, 'r') as f:
|
||||
with open(path, "r") as f:
|
||||
theme = safe_load(f)
|
||||
|
||||
|
||||
def color(i):
|
||||
return '#' + theme['base0' + format(i, '1X')]
|
||||
return "#" + theme["base0" + format(i, "1X")]
|
||||
|
|
|
@ -27,33 +27,37 @@ from entries.sitemaps import EntriesSitemap
|
|||
from home.sitemaps import HomeSitemap
|
||||
|
||||
sections = {
|
||||
'entries': EntriesSitemap,
|
||||
'home': HomeSitemap,
|
||||
"entries": EntriesSitemap,
|
||||
"home": HomeSitemap,
|
||||
}
|
||||
maps = {'sitemaps': sections}
|
||||
maps = {"sitemaps": sections}
|
||||
|
||||
urlpatterns = (
|
||||
path('', include('home.urls')),
|
||||
path('', include('entries.urls')),
|
||||
path('', include('users.urls')),
|
||||
path('.well-known/', include('wellknowns.urls')),
|
||||
path('admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
path('auth/', include('lemonauth.urls')),
|
||||
path('favicon.ico', RedirectView.as_view(
|
||||
url=settings.MEDIA_URL + 'favicon/favicon.ico')),
|
||||
path('micropub', include('micropub.urls')),
|
||||
path('s/', include('lemonshort.urls')),
|
||||
path('webmention', include('webmention.urls')),
|
||||
|
||||
path('django-rq/', include('django_rq.urls')),
|
||||
path('sitemap.xml', sitemap.index, maps, name='sitemap'),
|
||||
path('sitemaps/<section>.xml', sitemap.sitemap, maps,
|
||||
name='django.contrib.sitemaps.views.sitemap'),
|
||||
path("", include("home.urls")),
|
||||
path("", include("entries.urls")),
|
||||
path("", include("users.urls")),
|
||||
path(".well-known/", include("wellknowns.urls")),
|
||||
path("admin/doc/", include("django.contrib.admindocs.urls")),
|
||||
path("admin/", admin.site.urls),
|
||||
path("auth/", include("lemonauth.urls")),
|
||||
path(
|
||||
"favicon.ico",
|
||||
RedirectView.as_view(url=settings.MEDIA_URL + "favicon/favicon.ico"),
|
||||
),
|
||||
path("micropub", include("micropub.urls")),
|
||||
path("s/", include("lemonshort.urls")),
|
||||
path("webmention", include("webmention.urls")),
|
||||
path("django-rq/", include("django_rq.urls")),
|
||||
path("sitemap.xml", sitemap.index, maps, name="sitemap"),
|
||||
path(
|
||||
"sitemaps/<section>.xml",
|
||||
sitemap.sitemap,
|
||||
maps,
|
||||
name="django.contrib.sitemaps.views.sitemap",
|
||||
),
|
||||
) # type: Tuple[URLPattern, ...]
|
||||
|
||||
if settings.DEBUG:
|
||||
import debug_toolbar
|
||||
urlpatterns += (
|
||||
path('__debug__/', include(debug_toolbar.urls)),
|
||||
)
|
||||
|
||||
urlpatterns += (path("__debug__/", include(debug_toolbar.urls)),)
|
||||
|
|
|
@ -20,7 +20,7 @@ class PackageJson:
|
|||
|
||||
def load(self) -> Dict[str, Any]:
|
||||
if self.data is None:
|
||||
with open(join(settings.BASE_DIR, 'package.json')) as f:
|
||||
with open(join(settings.BASE_DIR, "package.json")) as f:
|
||||
self.data = json.load(f)
|
||||
assert self.data is not None
|
||||
return self.data
|
||||
|
@ -30,10 +30,10 @@ PACKAGE = PackageJson()
|
|||
|
||||
|
||||
def friendly_url(url):
|
||||
if '//' not in url:
|
||||
url = '//' + url
|
||||
if "//" not in url:
|
||||
url = "//" + url
|
||||
(scheme, netloc, path, params, q, fragment) = urlparse(url)
|
||||
if path == '/':
|
||||
if path == "/":
|
||||
return netloc
|
||||
return "{}\u200B{}".format(netloc, path)
|
||||
|
||||
|
@ -43,7 +43,7 @@ def load_package_json() -> Dict[str, Any]:
|
|||
|
||||
|
||||
def origin(request):
|
||||
return '{0}://{1}'.format(request.scheme, request.site.domain)
|
||||
return "{0}://{1}".format(request.scheme, request.site.domain)
|
||||
|
||||
|
||||
def absolute_url(request, url):
|
||||
|
@ -56,19 +56,18 @@ def uri(request):
|
|||
|
||||
def form_encoded_response(content):
|
||||
return HttpResponse(
|
||||
urlencode(content),
|
||||
content_type='application/x-www-form-urlencoded'
|
||||
urlencode(content), content_type="application/x-www-form-urlencoded"
|
||||
)
|
||||
|
||||
|
||||
REPS = {
|
||||
'application/x-www-form-urlencoded': form_encoded_response,
|
||||
'application/json': JsonResponse,
|
||||
"application/x-www-form-urlencoded": form_encoded_response,
|
||||
"application/json": JsonResponse,
|
||||
}
|
||||
|
||||
|
||||
def choose_type(request, content, reps=REPS):
|
||||
accept = request.META.get('HTTP_ACCEPT', '*/*')
|
||||
accept = request.META.get("HTTP_ACCEPT", "*/*")
|
||||
type = get_best_match(accept, reps.keys())
|
||||
if type:
|
||||
return reps[type](content)
|
||||
|
@ -76,11 +75,11 @@ def choose_type(request, content, reps=REPS):
|
|||
|
||||
|
||||
def bad_req(message):
|
||||
return HttpResponseBadRequest(message, content_type='text/plain')
|
||||
return HttpResponseBadRequest(message, content_type="text/plain")
|
||||
|
||||
|
||||
def forbid(message):
|
||||
return HttpResponseForbidden(message, content_type='text/plain')
|
||||
return HttpResponseForbidden(message, content_type="text/plain")
|
||||
|
||||
|
||||
def to_plain(md):
|
||||
|
|
|
@ -2,4 +2,4 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class LemonshortConfig(AppConfig):
|
||||
name = 'lemonshort'
|
||||
name = "lemonshort"
|
||||
|
|
|
@ -6,8 +6,9 @@ from string import ascii_lowercase, ascii_uppercase
|
|||
chars = ascii_uppercase + ascii_lowercase
|
||||
conv = BaseConverter(chars)
|
||||
|
||||
|
||||
class AbcIdConverter:
|
||||
regex = '[a-zA-Z]+'
|
||||
regex = "[a-zA-Z]+"
|
||||
|
||||
def to_python(self, value: str) -> int:
|
||||
return int(conv.decode(value))
|
||||
|
|
|
@ -11,7 +11,7 @@ def short_url(entity):
|
|||
if not prefixes:
|
||||
for k, m in settings.SHORTEN_MODELS.items():
|
||||
prefixes[apps.get_model(m)] = k
|
||||
base = '/'
|
||||
if hasattr(settings, 'SHORT_BASE_URL'):
|
||||
base = "/"
|
||||
if hasattr(settings, "SHORT_BASE_URL"):
|
||||
base = settings.SHORT_BASE_URL
|
||||
return base + prefixes[type(entity)] + AbcIdConverter().to_url(entity.id)
|
||||
|
|
|
@ -3,14 +3,14 @@ from .. import convert
|
|||
|
||||
def test_to_python():
|
||||
samples = {
|
||||
'A': 0,
|
||||
'B': 1,
|
||||
'Y': 24,
|
||||
'a': 26,
|
||||
'b': 27,
|
||||
'y': 50,
|
||||
'BA': 52,
|
||||
'BAB': 2705,
|
||||
"A": 0,
|
||||
"B": 1,
|
||||
"Y": 24,
|
||||
"a": 26,
|
||||
"b": 27,
|
||||
"y": 50,
|
||||
"BA": 52,
|
||||
"BAB": 2705,
|
||||
}
|
||||
converter = convert.AbcIdConverter()
|
||||
for abc, id in samples.items():
|
||||
|
@ -19,13 +19,13 @@ def test_to_python():
|
|||
|
||||
def test_id_to_abc():
|
||||
samples = {
|
||||
1: 'B',
|
||||
24: 'Y',
|
||||
26: 'a',
|
||||
52: 'BA',
|
||||
78: 'Ba',
|
||||
104: 'CA',
|
||||
130: 'Ca',
|
||||
1: "B",
|
||||
24: "Y",
|
||||
26: "a",
|
||||
52: "BA",
|
||||
78: "Ba",
|
||||
104: "CA",
|
||||
130: "Ca",
|
||||
}
|
||||
converter = convert.AbcIdConverter()
|
||||
for id, abc in samples.items():
|
||||
|
|
|
@ -4,10 +4,10 @@ from django.urls import path, register_converter
|
|||
from .convert import AbcIdConverter
|
||||
from .views import unshort
|
||||
|
||||
register_converter(AbcIdConverter, 'abc_id')
|
||||
register_converter(AbcIdConverter, "abc_id")
|
||||
|
||||
app_name = 'lemonshort'
|
||||
app_name = "lemonshort"
|
||||
urlpatterns = tuple(
|
||||
path('{0!s}<abc_id:tiny>'.format(k), unshort, name=m, kwargs={'model': m})
|
||||
path("{0!s}<abc_id:tiny>".format(k), unshort, name=m, kwargs={"model": m})
|
||||
for k, m in settings.SHORTEN_MODELS.items()
|
||||
)
|
||||
|
|
|
@ -2,4 +2,4 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class MicropubConfig(AppConfig):
|
||||
name = 'micropub'
|
||||
name = "micropub"
|
||||
|
|
|
@ -4,33 +4,35 @@ from typing import Optional
|
|||
|
||||
|
||||
def forbidden() -> ResponseException:
|
||||
return res('forbidden', 403)
|
||||
return res("forbidden", 403)
|
||||
|
||||
|
||||
def unauthorized() -> ResponseException:
|
||||
return res('unauthorized', 401)
|
||||
return res("unauthorized", 401)
|
||||
|
||||
|
||||
def bad_req(msg: str) -> ResponseException:
|
||||
return res('invalid_request', msg=msg)
|
||||
return res("invalid_request", msg=msg)
|
||||
|
||||
|
||||
def bad_type(type: str) -> ResponseException:
|
||||
msg = 'unsupported request type {0}'.format(type)
|
||||
return res('invalid_request', 415, msg)
|
||||
msg = "unsupported request type {0}".format(type)
|
||||
return res("invalid_request", 415, msg)
|
||||
|
||||
|
||||
def bad_scope(scope: str) -> ResponseException:
|
||||
return res('insufficient_scope', 401, scope=scope)
|
||||
return res("insufficient_scope", 401, scope=scope)
|
||||
|
||||
|
||||
def res(error: str,
|
||||
status: Optional[int]=400,
|
||||
msg: Optional[str]=None,
|
||||
scope: Optional[str]=None):
|
||||
content = {'error': error}
|
||||
def res(
|
||||
error: str,
|
||||
status: Optional[int] = 400,
|
||||
msg: Optional[str] = None,
|
||||
scope: Optional[str] = None,
|
||||
):
|
||||
content = {"error": error}
|
||||
if msg is not None:
|
||||
content['error_description'] = msg
|
||||
content["error_description"] = msg
|
||||
if scope:
|
||||
content['scope'] = scope
|
||||
content["scope"] = scope
|
||||
return ResponseException(JsonResponse(content, status=status))
|
||||
|
|
|
@ -2,8 +2,8 @@ from django.urls import path
|
|||
from .views import micropub
|
||||
from .views.media import media
|
||||
|
||||
app_name = 'micropub'
|
||||
app_name = "micropub"
|
||||
urlpatterns = (
|
||||
path('', micropub, name='micropub'),
|
||||
path('/media', media, name='media'),
|
||||
path("", micropub, name="micropub"),
|
||||
path("/media", media, name="media"),
|
||||
)
|
||||
|
|
|
@ -10,22 +10,22 @@ from .delete import delete
|
|||
from .query import query
|
||||
|
||||
actions = {
|
||||
'create': create,
|
||||
'delete': delete,
|
||||
"create": create,
|
||||
"delete": delete,
|
||||
}
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
@require_http_methods(['GET', 'HEAD', 'POST'])
|
||||
@require_http_methods(["GET", "HEAD", "POST"])
|
||||
def micropub(request):
|
||||
request.token = tokens.auth(request)
|
||||
if request.method in ('GET', 'HEAD'):
|
||||
if request.method in ("GET", "HEAD"):
|
||||
return query(request)
|
||||
|
||||
action = request.POST.get('action', 'create')
|
||||
if request.content_type == 'application/json':
|
||||
action = request.POST.get("action", "create")
|
||||
if request.content_type == "application/json":
|
||||
request.json = json.load(request)
|
||||
action = request.json.get('action', 'create')
|
||||
action = request.json.get("action", "create")
|
||||
if action not in actions:
|
||||
raise error.bad_req('unknown action: {}'.format(action))
|
||||
raise error.bad_req("unknown action: {}".format(action))
|
||||
return actions[action](request)
|
||||
|
|
|
@ -14,63 +14,62 @@ def form_to_mf2(request):
|
|||
properties = {}
|
||||
post = request.POST
|
||||
for key in post.keys():
|
||||
if key.endswith('[]'):
|
||||
if key.endswith("[]"):
|
||||
key = key[:-2]
|
||||
if key == 'access_token':
|
||||
if key == "access_token":
|
||||
continue
|
||||
properties[key] = post.getlist(key) + post.getlist(key + '[]')
|
||||
properties[key] = post.getlist(key) + post.getlist(key + "[]")
|
||||
|
||||
type = []
|
||||
if 'h' in properties:
|
||||
type = ['h-' + p for p in properties['h']]
|
||||
del properties['h']
|
||||
return {'type': type, 'properties': properties}
|
||||
if "h" in properties:
|
||||
type = ["h-" + p for p in properties["h"]]
|
||||
del properties["h"]
|
||||
return {"type": type, "properties": properties}
|
||||
|
||||
|
||||
def create(request):
|
||||
normalise = {
|
||||
'application/json': lambda r: r.json,
|
||||
'application/x-www-form-urlencoded': form_to_mf2,
|
||||
"application/json": lambda r: r.json,
|
||||
"application/x-www-form-urlencoded": form_to_mf2,
|
||||
}
|
||||
if 'create' not in request.token:
|
||||
raise error.bad_scope('create')
|
||||
if "create" not in request.token:
|
||||
raise error.bad_scope("create")
|
||||
if request.content_type not in normalise:
|
||||
raise error.unsupported_type(request.content_type)
|
||||
body = normalise[request.content_type](request)
|
||||
if 'type' not in body:
|
||||
raise error.bad_req('mf2 object type required')
|
||||
if body['type'] != ['h-entry']:
|
||||
raise error.bad_req('only h-entry supported')
|
||||
if "type" not in body:
|
||||
raise error.bad_req("mf2 object type required")
|
||||
if body["type"] != ["h-entry"]:
|
||||
raise error.bad_req("only h-entry supported")
|
||||
|
||||
entry = Entry(author=request.token.user)
|
||||
props = body.get('properties', {})
|
||||
props = body.get("properties", {})
|
||||
kind = Note
|
||||
if 'name' in props:
|
||||
entry.name = '\n'.join(props['name'])
|
||||
if "name" in props:
|
||||
entry.name = "\n".join(props["name"])
|
||||
kind = Article
|
||||
if 'content' in props:
|
||||
entry.content = '\n'.join(
|
||||
c if isinstance(c, str) else c['html']
|
||||
for c in props['content']
|
||||
if "content" in props:
|
||||
entry.content = "\n".join(
|
||||
c if isinstance(c, str) else c["html"] for c in props["content"]
|
||||
)
|
||||
if 'in-reply-to' in props:
|
||||
entry.in_reply_to = props['in-reply-to']
|
||||
if "in-reply-to" in props:
|
||||
entry.in_reply_to = props["in-reply-to"]
|
||||
kind = Reply
|
||||
if 'like-of' in props:
|
||||
entry.like_of = props['like-of']
|
||||
if "like-of" in props:
|
||||
entry.like_of = props["like-of"]
|
||||
kind = Like
|
||||
if 'repost-of' in props:
|
||||
entry.repost_of = props['repost-of']
|
||||
if "repost-of" in props:
|
||||
entry.repost_of = props["repost-of"]
|
||||
kind = Repost
|
||||
|
||||
cats = [Cat.objects.from_name(c) for c in props.get('category', [])]
|
||||
cats = [Cat.objects.from_name(c) for c in props.get("category", [])]
|
||||
|
||||
entry.kind = kind.id
|
||||
entry.save()
|
||||
entry.cats.set(cats)
|
||||
entry.save()
|
||||
|
||||
for url in props.get('syndication', []):
|
||||
for url in props.get("syndication", []):
|
||||
entry.syndications.create(url=url)
|
||||
|
||||
base = utils.origin(request)
|
||||
|
@ -80,6 +79,6 @@ def create(request):
|
|||
send_mentions.delay(perma)
|
||||
|
||||
res = HttpResponse(status=201)
|
||||
res['Location'] = perma
|
||||
res['Link'] = '<{}>; rel="shortlink"'.format(short)
|
||||
res["Location"] = perma
|
||||
res["Link"] = '<{}>; rel="shortlink"'.format(short)
|
||||
return res
|
||||
|
|
|
@ -6,24 +6,25 @@ from entries.jobs import ping_hub, send_mentions
|
|||
|
||||
from .. import error
|
||||
|
||||
|
||||
def delete(request):
|
||||
normalise = {
|
||||
'application/json': lambda r: r.json.get('url'),
|
||||
'application/x-www-form-urlencoded': lambda r: r.POST.get('url'),
|
||||
"application/json": lambda r: r.json.get("url"),
|
||||
"application/x-www-form-urlencoded": lambda r: r.POST.get("url"),
|
||||
}
|
||||
if 'delete' not in request.token:
|
||||
raise error.bad_scope('delete')
|
||||
if "delete" not in request.token:
|
||||
raise error.bad_scope("delete")
|
||||
if request.content_type not in normalise:
|
||||
raise error.unsupported_type(request.content_type)
|
||||
url = normalise[request.content_type](request)
|
||||
entry = from_url(url)
|
||||
|
||||
if entry.author != request.token.user:
|
||||
raise error.forbid('entry belongs to another user')
|
||||
raise error.forbid("entry belongs to another user")
|
||||
|
||||
perma = entry.absolute_url
|
||||
pings = entry.affected_urls
|
||||
mentions = webmention.findMentions(perma)['refs']
|
||||
mentions = webmention.findMentions(perma)["refs"]
|
||||
|
||||
entry.delete()
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ from lemoncurry.utils import absolute_url
|
|||
from .. import error
|
||||
|
||||
ACCEPTED_MEDIA_TYPES = (
|
||||
'image/gif',
|
||||
'image/jpeg',
|
||||
'image/png',
|
||||
"image/gif",
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
)
|
||||
|
||||
|
||||
|
@ -21,15 +21,13 @@ ACCEPTED_MEDIA_TYPES = (
|
|||
@require_POST
|
||||
def media(request):
|
||||
token = tokens.auth(request)
|
||||
if 'file' not in request.FILES:
|
||||
if "file" not in request.FILES:
|
||||
raise error.bad_req(
|
||||
"a file named 'file' must be provided to the media endpoint"
|
||||
)
|
||||
file = request.FILES['file']
|
||||
file = request.FILES["file"]
|
||||
if file.content_type not in ACCEPTED_MEDIA_TYPES:
|
||||
raise error.bad_req(
|
||||
'unacceptable file type {0}'.format(file.content_type)
|
||||
)
|
||||
raise error.bad_req("unacceptable file type {0}".format(file.content_type))
|
||||
|
||||
mime = None
|
||||
sha = hashlib.sha256()
|
||||
|
@ -40,14 +38,15 @@ def media(request):
|
|||
|
||||
if mime != file.content_type:
|
||||
raise error.bad_req(
|
||||
'detected file type {0} did not match specified file type {1}'
|
||||
.format(mime, file.content_type)
|
||||
"detected file type {0} did not match specified file type {1}".format(
|
||||
mime, file.content_type
|
||||
)
|
||||
)
|
||||
|
||||
path = 'mp/{0[0]}/{2}.{1}'.format(*mime.split('/'), sha.hexdigest())
|
||||
path = "mp/{0[0]}/{2}.{1}".format(*mime.split("/"), sha.hexdigest())
|
||||
path = store.save(path, file)
|
||||
url = absolute_url(request, store.url(path))
|
||||
|
||||
res = HttpResponse(status=201)
|
||||
res['Location'] = url
|
||||
res["Location"] = url
|
||||
return res
|
||||
|
|
|
@ -7,48 +7,47 @@ from lemoncurry.utils import absolute_url
|
|||
from .. import error
|
||||
|
||||
|
||||
|
||||
def config(request):
|
||||
config = syndicate_to(request)
|
||||
config['media-endpoint'] = absolute_url(request, reverse('micropub:media'))
|
||||
config["media-endpoint"] = absolute_url(request, reverse("micropub:media"))
|
||||
return config
|
||||
|
||||
|
||||
def source(request):
|
||||
if 'url' not in request.GET:
|
||||
raise error.bad_req('must specify url parameter for source query')
|
||||
entry = from_url(request.GET['url'])
|
||||
if "url" not in request.GET:
|
||||
raise error.bad_req("must specify url parameter for source query")
|
||||
entry = from_url(request.GET["url"])
|
||||
props = {}
|
||||
|
||||
keys = set(request.GET.getlist('properties') + request.GET.getlist('properties[]'))
|
||||
if not keys or 'content' in keys:
|
||||
props['content'] = [entry.content]
|
||||
if (not keys or 'category' in keys) and entry.cats.exists():
|
||||
props['category'] = [cat.name for cat in entry.cats.all()]
|
||||
if (not keys or 'name' in keys) and entry.name:
|
||||
props['name'] = [entry.name]
|
||||
if (not keys or 'syndication' in keys) and entry.syndications.exists():
|
||||
props['syndication'] = [synd.url for synd in entry.syndications.all()]
|
||||
keys = set(request.GET.getlist("properties") + request.GET.getlist("properties[]"))
|
||||
if not keys or "content" in keys:
|
||||
props["content"] = [entry.content]
|
||||
if (not keys or "category" in keys) and entry.cats.exists():
|
||||
props["category"] = [cat.name for cat in entry.cats.all()]
|
||||
if (not keys or "name" in keys) and entry.name:
|
||||
props["name"] = [entry.name]
|
||||
if (not keys or "syndication" in keys) and entry.syndications.exists():
|
||||
props["syndication"] = [synd.url for synd in entry.syndications.all()]
|
||||
|
||||
return {'type': ['h-entry'], 'properties': props}
|
||||
return {"type": ["h-entry"], "properties": props}
|
||||
|
||||
|
||||
def syndicate_to(request):
|
||||
return {'syndicate-to': []}
|
||||
return {"syndicate-to": []}
|
||||
|
||||
|
||||
queries = {
|
||||
'config': config,
|
||||
'source': source,
|
||||
'syndicate-to': syndicate_to,
|
||||
"config": config,
|
||||
"source": source,
|
||||
"syndicate-to": syndicate_to,
|
||||
}
|
||||
|
||||
|
||||
def query(request):
|
||||
if 'q' not in request.GET:
|
||||
raise error.bad_req('must specify q parameter')
|
||||
q = request.GET['q']
|
||||
if "q" not in request.GET:
|
||||
raise error.bad_req("must specify q parameter")
|
||||
q = request.GET["q"]
|
||||
if q not in queries:
|
||||
raise error.bad_req('unsupported query {0}'.format(q))
|
||||
raise error.bad_req("unsupported query {0}".format(q))
|
||||
res = queries[q](request)
|
||||
return JsonResponse(res)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "lemoncurry",
|
||||
"version": "1.11.0",
|
||||
"version": "1.12.4",
|
||||
"repository": "https://git.00dani.me/00dani/lemoncurry",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
|
|
76
pyproject.toml
Normal file
76
pyproject.toml
Normal file
|
@ -0,0 +1,76 @@
|
|||
[project]
|
||||
name = "lemoncurry"
|
||||
version = "1.12.4"
|
||||
description = "Indieweb-compatible personal website"
|
||||
|
||||
authors = [
|
||||
{name = "Danielle McLean", email = "dani@00dani.me"},
|
||||
]
|
||||
license = {text = "MIT"}
|
||||
requires-python = "<4.0,>=3.12"
|
||||
|
||||
dependencies = [
|
||||
"accept-types",
|
||||
"ago",
|
||||
"argon2-cffi",
|
||||
"bleach",
|
||||
"cachecontrol",
|
||||
"django<4,>=3",
|
||||
"django-activeurl",
|
||||
"django-annoying",
|
||||
"django-compressor",
|
||||
"django-computed-property",
|
||||
"django-cors-headers",
|
||||
"django-debug-toolbar",
|
||||
"django-extensions",
|
||||
"django-meta",
|
||||
"django-model-utils",
|
||||
"django-otp",
|
||||
"django-otp-agents",
|
||||
"django-push",
|
||||
"django-randomslugfield",
|
||||
"django-redis",
|
||||
"django-rq",
|
||||
"docutils",
|
||||
"gevent",
|
||||
"gunicorn[gevent]",
|
||||
"hiredis",
|
||||
"jinja2",
|
||||
"markdown",
|
||||
"mf2py",
|
||||
"mf2util",
|
||||
"msgpack",
|
||||
"pillow",
|
||||
"psycopg2-binary",
|
||||
"python-baseconv",
|
||||
"python-magic",
|
||||
"python-slugify",
|
||||
"pyup-django",
|
||||
"pyyaml",
|
||||
"qrcode",
|
||||
"ronkyuu",
|
||||
"xrd",
|
||||
"greenlet",
|
||||
]
|
||||
|
||||
[tool.pdm]
|
||||
[tool.pdm.dev-dependencies]
|
||||
dev = [
|
||||
"mypy",
|
||||
"ptpython",
|
||||
"pytest-django",
|
||||
"types-bleach",
|
||||
"types-markdown",
|
||||
"types-python-slugify",
|
||||
"types-pyyaml",
|
||||
"types-requests",
|
||||
"watchdog",
|
||||
"werkzeug",
|
||||
]
|
||||
|
||||
[tool.pdm.build]
|
||||
includes = []
|
||||
|
||||
[build-system]
|
||||
requires = ["pdm-backend"]
|
||||
build-backend = "pdm.backend"
|
|
@ -1,14 +1,14 @@
|
|||
from django.contrib import admin
|
||||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||
from .models import Key, Profile, Site, User
|
||||
from .models import PgpKey, Profile, Site, User
|
||||
|
||||
|
||||
class SiteAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'icon', 'domain', 'url_template')
|
||||
list_display = ("name", "icon", "domain", "url_template")
|
||||
|
||||
|
||||
class KeyInline(admin.TabularInline):
|
||||
model = Key
|
||||
class PgpKeyInline(admin.TabularInline):
|
||||
model = PgpKey
|
||||
extra = 1
|
||||
|
||||
|
||||
|
@ -19,10 +19,11 @@ class ProfileInline(admin.TabularInline):
|
|||
|
||||
class UserAdmin(BaseUserAdmin):
|
||||
fieldsets = BaseUserAdmin.fieldsets + (
|
||||
('Profile', {'fields': ('avatar', 'xmpp', 'note')}),
|
||||
("Profile", {"fields": ("avatar", "xmpp", "note")}),
|
||||
("Nostr", {"fields": ("nostr_key", "nostr_relays")}),
|
||||
)
|
||||
inlines = (
|
||||
KeyInline,
|
||||
PgpKeyInline,
|
||||
ProfileInline,
|
||||
)
|
||||
|
||||
|
|
|
@ -2,5 +2,5 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class UsersConfig(AppConfig):
|
||||
name = 'users'
|
||||
verbose_name = 'Users and Profiles'
|
||||
name = "users"
|
||||
verbose_name = "Users and Profiles"
|
||||
|
|
|
@ -9,40 +9,127 @@ import django.utils.timezone
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('auth', '0008_alter_user_username_max_length'),
|
||||
("auth", "0008_alter_user_username_max_length"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='User',
|
||||
name="User",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('password', models.CharField(max_length=128, verbose_name='password')),
|
||||
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
|
||||
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
||||
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
|
||||
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
|
||||
('last_name', models.CharField(blank=True, max_length=30, verbose_name='last name')),
|
||||
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
|
||||
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
|
||||
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
|
||||
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
|
||||
('avatar', models.ImageField(upload_to='')),
|
||||
('note', models.TextField(blank=True)),
|
||||
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
|
||||
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("password", models.CharField(max_length=128, verbose_name="password")),
|
||||
(
|
||||
"last_login",
|
||||
models.DateTimeField(
|
||||
blank=True, null=True, verbose_name="last login"
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_superuser",
|
||||
models.BooleanField(
|
||||
default=False,
|
||||
help_text="Designates that this user has all permissions without explicitly assigning them.",
|
||||
verbose_name="superuser status",
|
||||
),
|
||||
),
|
||||
(
|
||||
"username",
|
||||
models.CharField(
|
||||
error_messages={
|
||||
"unique": "A user with that username already exists."
|
||||
},
|
||||
help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
|
||||
max_length=150,
|
||||
unique=True,
|
||||
validators=[
|
||||
django.contrib.auth.validators.UnicodeUsernameValidator()
|
||||
],
|
||||
verbose_name="username",
|
||||
),
|
||||
),
|
||||
(
|
||||
"first_name",
|
||||
models.CharField(
|
||||
blank=True, max_length=30, verbose_name="first name"
|
||||
),
|
||||
),
|
||||
(
|
||||
"last_name",
|
||||
models.CharField(
|
||||
blank=True, max_length=30, verbose_name="last name"
|
||||
),
|
||||
),
|
||||
(
|
||||
"email",
|
||||
models.EmailField(
|
||||
blank=True, max_length=254, verbose_name="email address"
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_staff",
|
||||
models.BooleanField(
|
||||
default=False,
|
||||
help_text="Designates whether the user can log into this admin site.",
|
||||
verbose_name="staff status",
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_active",
|
||||
models.BooleanField(
|
||||
default=True,
|
||||
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
|
||||
verbose_name="active",
|
||||
),
|
||||
),
|
||||
(
|
||||
"date_joined",
|
||||
models.DateTimeField(
|
||||
default=django.utils.timezone.now, verbose_name="date joined"
|
||||
),
|
||||
),
|
||||
("avatar", models.ImageField(upload_to="")),
|
||||
("note", models.TextField(blank=True)),
|
||||
(
|
||||
"groups",
|
||||
models.ManyToManyField(
|
||||
blank=True,
|
||||
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
|
||||
related_name="user_set",
|
||||
related_query_name="user",
|
||||
to="auth.Group",
|
||||
verbose_name="groups",
|
||||
),
|
||||
),
|
||||
(
|
||||
"user_permissions",
|
||||
models.ManyToManyField(
|
||||
blank=True,
|
||||
help_text="Specific permissions for this user.",
|
||||
related_name="user_set",
|
||||
related_query_name="user",
|
||||
to="auth.Permission",
|
||||
verbose_name="user permissions",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'user',
|
||||
'verbose_name_plural': 'users',
|
||||
'abstract': False,
|
||||
"verbose_name": "user",
|
||||
"verbose_name_plural": "users",
|
||||
"abstract": False,
|
||||
},
|
||||
managers=[
|
||||
('objects', django.contrib.auth.models.UserManager()),
|
||||
("objects", django.contrib.auth.models.UserManager()),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
|
@ -7,15 +7,14 @@ import users.models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0001_initial'),
|
||||
("users", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='avatar',
|
||||
model_name="user",
|
||||
name="avatar",
|
||||
field=models.ImageField(upload_to=users.models.avatar_path),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -8,19 +8,33 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0002_auto_20171023_0109'),
|
||||
("users", "0002_auto_20171023_0109"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Key',
|
||||
name="Key",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('fingerprint', models.CharField(max_length=40)),
|
||||
('file', models.FileField(upload_to='keys')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='keys', to=settings.AUTH_USER_MODEL)),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("fingerprint", models.CharField(max_length=40)),
|
||||
("file", models.FileField(upload_to="keys")),
|
||||
(
|
||||
"user",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="keys",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
|
@ -8,48 +8,67 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0003_key'),
|
||||
("users", "0003_key"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Profile',
|
||||
name="Profile",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('username', models.CharField(max_length=100)),
|
||||
('display_name', models.CharField(blank=True, max_length=100)),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("username", models.CharField(max_length=100)),
|
||||
("display_name", models.CharField(blank=True, max_length=100)),
|
||||
],
|
||||
options={
|
||||
'ordering': ('site', 'username'),
|
||||
"ordering": ("site", "username"),
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Site',
|
||||
name="Site",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=100, unique=True)),
|
||||
('icon', models.CharField(max_length=100)),
|
||||
('url', models.CharField(max_length=100)),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("name", models.CharField(max_length=100, unique=True)),
|
||||
("icon", models.CharField(max_length=100)),
|
||||
("url", models.CharField(max_length=100)),
|
||||
],
|
||||
options={
|
||||
'ordering': ('name',),
|
||||
"ordering": ("name",),
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='profile',
|
||||
name='site',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.Site'),
|
||||
model_name="profile",
|
||||
name="site",
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to="users.Site"
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='profile',
|
||||
name='user',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
model_name="profile",
|
||||
name="user",
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='profiles',
|
||||
field=models.ManyToManyField(through='users.Profile', to='users.Site'),
|
||||
model_name="user",
|
||||
name="profiles",
|
||||
field=models.ManyToManyField(through="users.Profile", to="users.Site"),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -8,19 +8,22 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0004_auto_20171023_0143'),
|
||||
("users", "0004_auto_20171023_0143"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='user',
|
||||
name='profiles',
|
||||
model_name="user",
|
||||
name="profiles",
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='user',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='profiles', to=settings.AUTH_USER_MODEL),
|
||||
model_name="profile",
|
||||
name="user",
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="profiles",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,21 +6,20 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0005_auto_20171023_0158'),
|
||||
("users", "0005_auto_20171023_0158"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='site',
|
||||
old_name='url',
|
||||
new_name='url_template',
|
||||
model_name="site",
|
||||
old_name="url",
|
||||
new_name="url_template",
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='site',
|
||||
name='domain',
|
||||
field=models.CharField(default='', max_length=100),
|
||||
model_name="site",
|
||||
name="domain",
|
||||
field=models.CharField(default="", max_length=100),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,15 +6,14 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0006_auto_20171031_1336'),
|
||||
("users", "0006_auto_20171031_1336"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='site',
|
||||
name='domain',
|
||||
model_name="site",
|
||||
name="domain",
|
||||
field=models.CharField(blank=True, max_length=100),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,14 +6,13 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0007_auto_20171031_1347'),
|
||||
("users", "0007_auto_20171031_1347"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='site',
|
||||
options={'ordering': ('domain',)},
|
||||
name="site",
|
||||
options={"ordering": ("domain",)},
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,15 +6,14 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0008_auto_20171031_1357'),
|
||||
("users", "0008_auto_20171031_1357"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='xmpp',
|
||||
model_name="user",
|
||||
name="xmpp",
|
||||
field=models.EmailField(blank=True, max_length=254),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,14 +6,13 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0009_user_xmpp'),
|
||||
("users", "0009_user_xmpp"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='site',
|
||||
options={'ordering': ('name',)},
|
||||
name="site",
|
||||
options={"ordering": ("name",)},
|
||||
),
|
||||
]
|
||||
|
|
|
@ -6,15 +6,13 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0010_auto_20171206_2211'),
|
||||
("users", "0010_auto_20171206_2211"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelManagers(
|
||||
name='user',
|
||||
managers=[
|
||||
],
|
||||
name="user",
|
||||
managers=[],
|
||||
),
|
||||
]
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue