diff --git a/bookwyrm/activitypub/note.py b/bookwyrm/activitypub/note.py index d61471fe0..eb18b8b8a 100644 --- a/bookwyrm/activitypub/note.py +++ b/bookwyrm/activitypub/note.py @@ -35,6 +35,7 @@ class Note(ActivityObject): tag: List[Link] = field(default_factory=lambda: []) attachment: List[Document] = field(default_factory=lambda: []) sensitive: bool = False + updated: str = None type: str = "Note" diff --git a/bookwyrm/activitypub/verbs.py b/bookwyrm/activitypub/verbs.py index 50a479b71..b32b04133 100644 --- a/bookwyrm/activitypub/verbs.py +++ b/bookwyrm/activitypub/verbs.py @@ -69,8 +69,9 @@ class Update(Verb): def action(self): """update a model instance from the dataclass""" - if self.object: - self.object.to_model(allow_create=False) + if not self.object: + return + self.object.to_model(allow_create=False) @dataclass(init=False) diff --git a/bookwyrm/importers/goodreads_import.py b/bookwyrm/importers/goodreads_import.py index 7b577ea85..c62e65827 100644 --- a/bookwyrm/importers/goodreads_import.py +++ b/bookwyrm/importers/goodreads_import.py @@ -3,10 +3,10 @@ from . import Importer class GoodreadsImporter(Importer): - """GoodReads is the default importer, thus Importer follows its structure. + """Goodreads is the default importer, thus Importer follows its structure. For a more complete example of overriding see librarything_import.py""" - service = "GoodReads" + service = "Goodreads" def parse_fields(self, entry): """handle the specific fields in goodreads csvs""" diff --git a/bookwyrm/importers/importer.py b/bookwyrm/importers/importer.py index a10b4060c..6d898a2a3 100644 --- a/bookwyrm/importers/importer.py +++ b/bookwyrm/importers/importer.py @@ -1,4 +1,4 @@ -""" handle reading a csv from an external service, defaults are from GoodReads """ +""" handle reading a csv from an external service, defaults are from Goodreads """ import csv import logging diff --git a/bookwyrm/migrations/0107_alter_user_preferred_language.py b/bookwyrm/migrations/0107_alter_user_preferred_language.py new file mode 100644 index 000000000..be0fc5ea3 --- /dev/null +++ b/bookwyrm/migrations/0107_alter_user_preferred_language.py @@ -0,0 +1,31 @@ +# Generated by Django 3.2.5 on 2021-10-11 16:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0106_user_preferred_language"), + ] + + operations = [ + migrations.AlterField( + model_name="user", + name="preferred_language", + field=models.CharField( + blank=True, + choices=[ + ("en-us", "English"), + ("de-de", "Deutsch (German)"), + ("es", "Español (Spanish)"), + ("fr-fr", "Français (French)"), + ("pt-br", "Português - Brasil (Brazilian Portugues)"), + ("zh-hans", "简体中文 (Simplified Chinese)"), + ("zh-hant", "繁體中文 (Traditional Chinese)"), + ], + max_length=255, + null=True, + ), + ), + ] diff --git a/bookwyrm/migrations/0108_alter_user_preferred_language.py b/bookwyrm/migrations/0108_alter_user_preferred_language.py new file mode 100644 index 000000000..3614ae1c1 --- /dev/null +++ b/bookwyrm/migrations/0108_alter_user_preferred_language.py @@ -0,0 +1,31 @@ +# Generated by Django 3.2.5 on 2021-10-11 17:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0107_alter_user_preferred_language"), + ] + + operations = [ + migrations.AlterField( + model_name="user", + name="preferred_language", + field=models.CharField( + blank=True, + choices=[ + ("en-us", "English"), + ("de-de", "Deutsch (German)"), + ("es-es", "Español (Spanish)"), + ("fr-fr", "Français (French)"), + ("pt-br", "Português - Brasil (Brazilian Portuguese)"), + ("zh-hans", "简体中文 (Simplified Chinese)"), + ("zh-hant", "繁體中文 (Traditional Chinese)"), + ], + max_length=255, + null=True, + ), + ), + ] diff --git a/bookwyrm/migrations/0109_status_edited_date.py b/bookwyrm/migrations/0109_status_edited_date.py new file mode 100644 index 000000000..3d4d733b6 --- /dev/null +++ b/bookwyrm/migrations/0109_status_edited_date.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.5 on 2021-10-15 15:54 + +import bookwyrm.models.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0108_alter_user_preferred_language"), + ] + + operations = [ + migrations.AddField( + model_name="status", + name="edited_date", + field=bookwyrm.models.fields.DateTimeField(blank=True, null=True), + ), + ] diff --git a/bookwyrm/migrations/0110_auto_20211015_1734.py b/bookwyrm/migrations/0110_auto_20211015_1734.py new file mode 100644 index 000000000..ed7dd43c0 --- /dev/null +++ b/bookwyrm/migrations/0110_auto_20211015_1734.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.5 on 2021-10-15 17:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0109_status_edited_date"), + ] + + operations = [ + migrations.AddField( + model_name="quotation", + name="raw_quote", + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name="status", + name="raw_content", + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/bookwyrm/models/base_model.py b/bookwyrm/models/base_model.py index ec6ffd405..f62678f7e 100644 --- a/bookwyrm/models/base_model.py +++ b/bookwyrm/models/base_model.py @@ -67,16 +67,15 @@ class BookWyrmModel(models.Model): return # you can see the followers only posts of people you follow - if ( - self.privacy == "followers" - and self.user.followers.filter(id=viewer.id).first() + if self.privacy == "followers" and ( + self.user.followers.filter(id=viewer.id).first() ): return # you can see dms you are tagged in if hasattr(self, "mention_users"): if ( - self.privacy == "direct" + self.privacy in ["direct", "followers"] and self.mention_users.filter(id=viewer.id).first() ): diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 1325aa884..2b395ec8b 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -31,6 +31,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): "User", on_delete=models.PROTECT, activitypub_field="attributedTo" ) content = fields.HtmlField(blank=True, null=True) + raw_content = models.TextField(blank=True, null=True) mention_users = fields.TagField("User", related_name="mention_user") mention_books = fields.TagField("Edition", related_name="mention_book") local = models.BooleanField(default=True) @@ -43,6 +44,9 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): published_date = fields.DateTimeField( default=timezone.now, activitypub_field="published" ) + edited_date = fields.DateTimeField( + blank=True, null=True, activitypub_field="updated" + ) deleted = models.BooleanField(default=False) deleted_date = models.DateTimeField(blank=True, null=True) favorites = models.ManyToManyField( @@ -220,6 +224,16 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): ~Q(Q(user=viewer) | Q(mention_users=viewer)), privacy="direct" ) + @classmethod + def followers_filter(cls, queryset, viewer): + """Override-able filter for "followers" privacy level""" + return queryset.exclude( + ~Q( # not yourself, a follower, or someone who is tagged + Q(user__followers=viewer) | Q(user=viewer) | Q(mention_users=viewer) + ), + privacy="followers", # and the status is followers only + ) + class GeneratedNote(Status): """these are app-generated messages about user activity""" @@ -292,6 +306,7 @@ class Quotation(BookStatus): """like a review but without a rating and transient""" quote = fields.HtmlField() + raw_quote = models.TextField(blank=True, null=True) position = models.IntegerField( validators=[MinValueValidator(0)], null=True, blank=True ) diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 55b4c4454..44d65cca0 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -7,13 +7,14 @@ from django.utils.translation import gettext_lazy as _ env = Env() +env.read_env() DOMAIN = env("DOMAIN") -VERSION = "0.0.1" +VERSION = "0.1.0" PAGE_LENGTH = env("PAGE_LENGTH", 15) DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English") -JS_CACHE = "c02929b1" +JS_CACHE = "3eb4edb1" # email EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend") @@ -162,11 +163,12 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = "en-us" LANGUAGES = [ ("en-us", _("English")), - ("de-de", _("Deutsch (German)")), # German - ("es", _("Español (Spanish)")), # Spanish - ("fr-fr", _("Français (French)")), # French - ("zh-hans", _("简体中文 (Simplified Chinese)")), # Simplified Chinese - ("zh-hant", _("繁體中文 (Traditional Chinese)")), # Traditional Chinese + ("de-de", _("Deutsch (German)")), + ("es-es", _("Español (Spanish)")), + ("fr-fr", _("Français (French)")), + ("pt-br", _("Português - Brasil (Brazilian Portuguese)")), + ("zh-hans", _("简体中文 (Simplified Chinese)")), + ("zh-hant", _("繁體中文 (Traditional Chinese)")), ] diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index eca7914a4..0d280fd53 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -509,6 +509,20 @@ ol.ordered-list li::before { border-left: 2px solid #e0e0e0; } +/* Breadcrumbs + ******************************************************************************/ + +.breadcrumb li:first-child * { + padding-left: 0; +} + +.breadcrumb li > * { + align-items: center; + display: flex; + justify-content: center; + padding: 0 0.75em; +} + /* Dimensions * @todo These could be in rem. ******************************************************************************/ diff --git a/bookwyrm/templates/author/edit_author.html b/bookwyrm/templates/author/edit_author.html index 103341bfd..54d7f4f1c 100644 --- a/bookwyrm/templates/author/edit_author.html +++ b/bookwyrm/templates/author/edit_author.html @@ -12,7 +12,9 @@

{% trans "Added:" %} {{ author.created_date | naturaltime }}

{% trans "Updated:" %} {{ author.updated_date | naturaltime }}

+ {% if author.last_edited_by %}

{% trans "Last edited by:" %} {{ author.last_edited_by.display_name }}

+ {% endif %}
diff --git a/bookwyrm/templates/book/book_identifiers.html b/bookwyrm/templates/book/book_identifiers.html index 8c8313f38..19ab619da 100644 --- a/bookwyrm/templates/book/book_identifiers.html +++ b/bookwyrm/templates/book/book_identifiers.html @@ -1,7 +1,7 @@ {% spaceless %} {% load i18n %} -{% if book.isbn13 or book.oclc_number or book.asin %} +{% if book.isbn_13 or book.oclc_number or book.asin %}
{% if book.isbn_13 %}
diff --git a/bookwyrm/templates/book/edit/edit_book.html b/bookwyrm/templates/book/edit/edit_book.html index ec7b08586..fc11208fd 100644 --- a/bookwyrm/templates/book/edit/edit_book.html +++ b/bookwyrm/templates/book/edit/edit_book.html @@ -108,7 +108,13 @@ {% if not confirm_mode %}
+ {% if book %} {% trans "Cancel" %} + {% else %} + + {% trans "Cancel" %} + + {% endif %}
{% endif %} diff --git a/bookwyrm/templates/book/publisher_info.html b/bookwyrm/templates/book/publisher_info.html index e0711fa82..b39bcf5ce 100644 --- a/bookwyrm/templates/book/publisher_info.html +++ b/bookwyrm/templates/book/publisher_info.html @@ -3,7 +3,7 @@ {% load i18n %} {% load humanize %} -{% firstof book.physical_format_detail book.physical_format as format %} +{% firstof book.physical_format_detail book.get_physical_format_display as format %} {% firstof book.physical_format book.physical_format_detail as format_property %} {% with pages=book.pages %} {% if format or pages %} @@ -18,7 +18,7 @@

{% if format and not pages %} - {% blocktrans %}{{ format }}{% endblocktrans %} + {{ format }} {% elif format and pages %} {% blocktrans %}{{ format }}, {{ pages }} pages{% endblocktrans %} {% elif pages %} diff --git a/bookwyrm/templates/compose.html b/bookwyrm/templates/compose.html index 3a222cf6a..ca0d8296a 100644 --- a/bookwyrm/templates/compose.html +++ b/bookwyrm/templates/compose.html @@ -2,10 +2,10 @@ {% load i18n %} {% load utilities %} -{% block title %}{% trans "Compose status" %}{% endblock %} +{% block title %}{% trans "Edit status" %}{% endblock %} {% block content %}

-

{% trans "Compose status" %}

+

{% trans "Edit status" %}

{% with 0|uuid as uuid %} @@ -22,6 +22,10 @@
{% if draft.reply_parent %} {% include 'snippets/status/status.html' with status=draft.reply_parent no_interact=True %} + {% else %} +
+ {% include "snippets/status/header.html" with status=draft %} +
{% endif %} {% if not draft %} diff --git a/bookwyrm/templates/discover/card-header.html b/bookwyrm/templates/discover/card-header.html new file mode 100644 index 000000000..0eb9a678c --- /dev/null +++ b/bookwyrm/templates/discover/card-header.html @@ -0,0 +1,26 @@ +{% load i18n %} +{% load utilities %} + +{% with user_path=status.user.local_path username=status.user.display_name book_path=status.book.local_poth book_title=book|book_title %} + +{% if status.status_type == 'GeneratedNote' %} + {{ status.content|safe }} +{% elif status.status_type == 'Rating' %} + {% blocktrans trimmed %} + {{ username }} rated {{ book_title }} + {% endblocktrans %} +{% elif status.status_type == 'Review' %} + {% blocktrans trimmed %} + {{ username }} reviewed {{ book_title }} + {% endblocktrans %} +{% elif status.status_type == 'Comment' %} + {% blocktrans trimmed %} + {{ username }} commented on {{ book_title }} + {% endblocktrans %} +{% elif status.status_type == 'Quotation' %} + {% blocktrans trimmed %} + {{ username }} quoted {{ book_title }} + {% endblocktrans %} +{% endif %} + +{% endwith %} diff --git a/bookwyrm/templates/discover/large-book.html b/bookwyrm/templates/discover/large-book.html index 6d80c3daf..1fa0afb92 100644 --- a/bookwyrm/templates/discover/large-book.html +++ b/bookwyrm/templates/discover/large-book.html @@ -36,23 +36,7 @@

- - {{ status.user.display_name }} - - - {% if status.status_type == 'GeneratedNote' %} - {{ status.content|safe }} - {% elif status.status_type == 'Rating' %} - {% trans "rated" %} - {% elif status.status_type == 'Review' %} - {% trans "reviewed" %} - {% elif status.status_type == 'Comment' %} - {% trans "commented on" %} - {% elif status.status_type == 'Quotation' %} - {% trans "quoted" %} - {% endif %} - - {{ book.title }} + {% include "discover/card-header.html" %}

diff --git a/bookwyrm/templates/discover/small-book.html b/bookwyrm/templates/discover/small-book.html index 5b2070188..76732ca14 100644 --- a/bookwyrm/templates/discover/small-book.html +++ b/bookwyrm/templates/discover/small-book.html @@ -22,23 +22,7 @@

- - {{ status.user.display_name }} - - - {% if status.status_type == 'GeneratedNote' %} - {{ status.content|safe }} - {% elif status.status_type == 'Rating' %} - {% trans "rated" %} - {% elif status.status_type == 'Review' %} - {% trans "reviewed" %} - {% elif status.status_type == 'Comment' %} - {% trans "commented on" %} - {% elif status.status_type == 'Quotation' %} - {% trans "quoted" %} - {% endif %} - - {{ book.title }} + {% include "discover/card-header.html" %}

{% if status.rating %}

diff --git a/bookwyrm/templates/email/invite/html_content.html b/bookwyrm/templates/email/invite/html_content.html index 358e23dc1..adc993b7b 100644 --- a/bookwyrm/templates/email/invite/html_content.html +++ b/bookwyrm/templates/email/invite/html_content.html @@ -12,6 +12,6 @@

{% url 'code-of-conduct' as coc_path %} {% url 'about' as about_path %} - {% blocktrans %}Learn more about this instance.{% endblocktrans %} + {% blocktrans %}Learn more about {{ site_name }}.{% endblocktrans %}

{% endblock %} diff --git a/bookwyrm/templates/email/invite/text_content.html b/bookwyrm/templates/email/invite/text_content.html index c3fcdc04e..26dcd1720 100644 --- a/bookwyrm/templates/email/invite/text_content.html +++ b/bookwyrm/templates/email/invite/text_content.html @@ -5,6 +5,6 @@ {{ invite_link }} -{% trans "Learn more about this instance:" %} https://{{ domain }}{% url 'about' %} +{% blocktrans %}Learn more about {{ site_name }}:{% endblocktrans %} https://{{ domain }}{% url 'about' %} {% endblock %} diff --git a/bookwyrm/templates/import/import.html b/bookwyrm/templates/import/import.html index cc296b75b..81f0daa54 100644 --- a/bookwyrm/templates/import/import.html +++ b/bookwyrm/templates/import/import.html @@ -22,8 +22,8 @@
diff --git a/bookwyrm/templates/snippets/create_status/content_warning_toggle.html b/bookwyrm/templates/snippets/create_status/content_warning_toggle.html index f29d47c45..a5c41cbcb 100644 --- a/bookwyrm/templates/snippets/create_status/content_warning_toggle.html +++ b/bookwyrm/templates/snippets/create_status/content_warning_toggle.html @@ -8,7 +8,7 @@ id="id_show_spoilers_{{ uuid }}{{ local_uuid }}" {% if draft.content_warning or status.content_warning %}checked{% endif %} aria-hidden="true" - data-cache-draft="id_sensitive_{{ book.id }}_{{ type }}{{ reply_parent.id }}" + {% if not draft %}data-cache-draft="id_sensitive_{{ book.id }}_{{ type }}{{ reply_parent.id }}"{% endif %} > {% trans "Include spoiler alert" as button_text %} {% firstof draft.content_warning status.content_warning as pressed %} diff --git a/bookwyrm/templates/snippets/create_status/layout.html b/bookwyrm/templates/snippets/create_status/layout.html index 4dded2005..8d24fa021 100644 --- a/bookwyrm/templates/snippets/create_status/layout.html +++ b/bookwyrm/templates/snippets/create_status/layout.html @@ -17,7 +17,11 @@ reply_parent: the Status object this post will be in reply to, if applicable
@@ -29,6 +33,9 @@ reply_parent: the Status object this post will be in reply to, if applicable + {% if draft %} + + {% endif %} {% endblock %} {% include "snippets/create_status/content_warning_field.html" %} diff --git a/bookwyrm/templates/snippets/create_status/quotation.html b/bookwyrm/templates/snippets/create_status/quotation.html index 25f3199bf..cf472c113 100644 --- a/bookwyrm/templates/snippets/create_status/quotation.html +++ b/bookwyrm/templates/snippets/create_status/quotation.html @@ -24,8 +24,8 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j id="id_quote_{{ book.id }}_{{ type }}" placeholder="{% blocktrans with book_title=book.title %}An excerpt from '{{ book_title }}'{% endblocktrans %}" required - data-cache-draft="id_quote_{{ book.id }}_{{ type }}" - >{{ draft.quote|default:'' }} + {% if not draft %}data-cache-draft="id_quote_{{ book.id }}_{{ type }}"{% endif %} + >{% firstof draft.raw_quote draft.quote '' %}
@@ -36,7 +36,7 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j diff --git a/bookwyrm/templates/snippets/status/header.html b/bookwyrm/templates/snippets/status/header.html index 62eae5481..ae25932f2 100644 --- a/bookwyrm/templates/snippets/status/header.html +++ b/bookwyrm/templates/snippets/status/header.html @@ -31,18 +31,38 @@ {% include "snippets/status/header_content.html" %} -

- {{ status.published_date|published_date }} - {% if status.progress %} - - {% if status.progress_mode == 'PG' %} - ({% include 'snippets/page_text.html' with page=status.progress total_pages=status.book.pages %}) - {% else %} - ({{ status.progress }}%) - {% endif %} - - {% endif %} - {% include 'snippets/privacy-icons.html' with item=status %} -

+
diff --git a/bookwyrm/templates/snippets/status/layout.html b/bookwyrm/templates/snippets/status/layout.html index 9d1863ee5..93620a083 100644 --- a/bookwyrm/templates/snippets/status/layout.html +++ b/bookwyrm/templates/snippets/status/layout.html @@ -67,7 +67,7 @@ {% endblock %} {% block card-bonus %} -{% if request.user.is_authenticated and not moderation_mode %} +{% if request.user.is_authenticated and not moderation_mode and not no_interact %} {% with status.id|uuid as uuid %}