Merge branch 'main' into production

This commit is contained in:
Mouse Reeve 2021-03-20 20:47:53 -07:00
commit 94d18f6c24
28 changed files with 586 additions and 380 deletions

View file

@ -1,2 +1,2 @@
[run]
omit = */test*,celerywyrm*,bookwyrm/migrations/*
omit = */test*,celerywyrm*,bookwyrm/migrations/*

View file

@ -4,4 +4,4 @@ __pycache__
*.pyd
.git
.github
.pytest*
.pytest*

31
.editorconfig Normal file
View file

@ -0,0 +1,31 @@
# @see https://editorconfig.org/
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 100
# C-style doc comments
block_comment_start = /*
block_comment = *
block_comment_end = */
[{bw-dev,fr-dev,LICENSE}]
max_line_length = off
[*.{csv,json,html,md,po,py,svg,tsv}]
max_line_length = off
[*.{md,markdown}]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
max_line_length = off

View file

@ -1,4 +1,4 @@
name: Lint
name: Lint Python
on: [push, pull_request]

21
.github/workflows/linters-global.yaml vendored Normal file
View file

@ -0,0 +1,21 @@
# @url https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Lint Project
on:
push:
branches: [ main, ci ]
pull_request:
branches: [ main, ci ]
jobs:
linters:
name: linters
runs-on: ubuntu-20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: EditorConfig
uses: greut/eclint-action@v0

View file

@ -23,13 +23,13 @@ include:
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
professional setting
## Our Responsibilities

208
README.md
View file

@ -6,12 +6,12 @@ Social reading and reviewing, decentralized with ActivityPub
- [Joining BookWyrm](#joining-bookwyrm)
- [Contributing](#contributing)
- [About BookWyrm](#about-bookwyrm)
- [What it is and isn't](#what-it-is-and-isnt)
- [The role of federation](#the-role-of-federation)
- [Features](#features)
- [Setting up the developer environment](#setting-up-the-developer-environment)
- [Installing in Production](#installing-in-production)
- [Book data](#book-data)
- [What it is and isn't](#what-it-is-and-isnt)
- [The role of federation](#the-role-of-federation)
- [Features](#features)
- [Setting up the developer environment](#setting-up-the-developer-environment)
- [Installing in Production](#installing-in-production)
- [Book data](#book-data)
## Joining BookWyrm
BookWyrm is still a young piece of software, and isn't at the level of stability and feature-richness that you'd find in a production-ready application. But it does what it says on the box! If you'd like to join an instance, you can check out the [instances](https://github.com/mouse-reeve/bookwyrm/blob/main/instances.md) list.
@ -47,49 +47,49 @@ Federation makes it possible to have small, self-determining communities, in con
### Features
Since the project is still in its early stages, the features are growing every day, and there is plenty of room for suggestions and ideas. Open an [issue](https://github.com/mouse-reeve/bookwyrm/issues) to get the conversation going!
- Posting about books
- Posting about books
- Compose reviews, with or without ratings, which are aggregated in the book page
- Compose other kinds of statuses about books, such as:
- Comments on a book
- Quotes or excerpts
- Comments on a book
- Quotes or excerpts
- Reply to statuses
- View aggregate reviews of a book across connected BookWyrm instances
- Differentiate local and federated reviews and rating in your activity feed
- Track reading activity
- Track reading activity
- Shelve books on default "to-read," "currently reading," and "read" shelves
- Create custom shelves
- Store started reading/finished reading dates, as well as progress updates along the way
- Update followers about reading activity (optionally, and with granular privacy controls)
- Create lists of books which can be open to submissions from anyone, curated, or only edited by the creator
- Federation with ActivityPub
- Federation with ActivityPub
- Broadcast and receive user statuses and activity
- Share book data between instances to create a networked database of metadata
- Identify shared books across instances and aggregate related content
- Follow and interact with users across BookWyrm instances
- Inter-operate with non-BookWyrm ActivityPub services (currently, Mastodon is supported)
- Granular privacy controls
- Granular privacy controls
- Private, followers-only, and public privacy levels for posting, shelves, and lists
- Option for users to manually approve followers
- Allow blocking and flagging for moderation
### The Tech Stack
Web backend
- [Django](https://www.djangoproject.com/) web server
- [PostgreSQL](https://www.postgresql.org/) database
- [ActivityPub](http://activitypub.rocks/) federation
- [Celery](http://celeryproject.org/) task queuing
- [Redis](https://redis.io/) task backend
- [Django](https://www.djangoproject.com/) web server
- [PostgreSQL](https://www.postgresql.org/) database
- [ActivityPub](http://activitypub.rocks/) federation
- [Celery](http://celeryproject.org/) task queuing
- [Redis](https://redis.io/) task backend
Front end
- Django templates
- [Bulma.io](https://bulma.io/) css framework
- Vanilla JavaScript, in moderation
- Django templates
- [Bulma.io](https://bulma.io/) css framework
- Vanilla JavaScript, in moderation
Deployment
- [Docker](https://www.docker.com/) and docker-compose
- [Gunicorn](https://gunicorn.org/) web runner
- [Flower](https://github.com/mher/flower) celery monitoring
- [Nginx](https://nginx.org/en/) HTTP server
- [Docker](https://www.docker.com/) and docker-compose
- [Gunicorn](https://gunicorn.org/) web runner
- [Flower](https://github.com/mher/flower) celery monitoring
- [Nginx](https://nginx.org/en/) HTTP server
## Setting up the developer environment
@ -147,10 +147,10 @@ You can add the `-l <language code>` to only compile one language. When you refr
This project is still young and isn't, at the moment, very stable, so please proceed with caution when running in production.
### Server setup
- Get a domain name and set up DNS for your server
- Set your server up with appropriate firewalls for running a web application (this instruction set is tested against Ubuntu 20.04)
- Set up an email service (such as mailgun) and the appropriate SMTP/DNS settings
- Install Docker and docker-compose
- Get a domain name and set up DNS for your server
- Set your server up with appropriate firewalls for running a web application (this instruction set is tested against Ubuntu 20.04)
- Set up an email service (such as mailgun) and the appropriate SMTP/DNS settings
- Install Docker and docker-compose
### Install and configure BookWyrm
@ -158,37 +158,55 @@ The `production` branch of BookWyrm contains a number of tools not on the `main`
Instructions for running BookWyrm in production:
- Get the application code:
`git clone git@github.com:mouse-reeve/bookwyrm.git`
- Switch to the `production` branch
`git checkout production`
- Create your environment variables file
`cp .env.example .env`
- Add your domain, email address, SMTP credentials
- Set a secure redis password and secret key
- Set a secure database password for postgres
- Update your nginx configuration in `nginx/default.conf`
- Replace `your-domain.com` with your domain name
- If you aren't using the `www` subdomain, remove the www.your-domain.com version of the domain from the `server_name` in the first server block in `nginx/default.conf` and remove the `-d www.${DOMAIN}` flag at the end of the `certbot` command in `docker-compose.yml`.
- If you are running another web-server on your host machine, you will need to follow the [reverse-proxy instructions](#running-bookwyrm-behind-a-reverse-proxy)
- Run the application (this should also set up a Certbot ssl cert for your domain) with
`docker-compose up --build`, and make sure all the images build successfully
- Get the application code:
`git clone git@github.com:mouse-reeve/bookwyrm.git`
- Switch to the `production` branch
`git checkout production`
- Create your environment variables file
`cp .env.example .env`
- Add your domain, email address, SMTP credentials
- Set a secure redis password and secret key
- Set a secure database password for postgres
- Update your nginx configuration in `nginx/default.conf`
- Replace `your-domain.com` with your domain name
- Run the application (this should also set up a Certbot ssl cert for your domain) with
`docker-compose up --build`, and make sure all the images build successfully
- When docker has built successfully, stop the process with `CTRL-C`
- Comment out the `command: certonly...` line in `docker-compose.yml`
- Run docker-compose in the background with: `docker-compose up -d`
- Initialize the database with: `./bw-dev initdb`
- Set up schedule backups with cron that runs that `docker-compose exec db pg_dump -U <databasename>` and saves the backup to a safe location
- Get the application code:
`git clone git@github.com:mouse-reeve/bookwyrm.git`
- Switch to the `production` branch
`git checkout production`
- Create your environment variables file
`cp .env.example .env`
- Add your domain, email address, SMTP credentials
- Set a secure redis password and secret key
- Set a secure database password for postgres
- Update your nginx configuration in `nginx/default.conf`
- Replace `your-domain.com` with your domain name
- If you aren't using the `www` subdomain, remove the www.your-domain.com version of the domain from the `server_name` in the first server block in `nginx/default.conf` and remove the `-d www.${DOMAIN}` flag at the end of the `certbot` command in `docker-compose.yml`.
- If you are running another web-server on your host machine, you will need to follow the [reverse-proxy instructions](#running-bookwyrm-behind-a-reverse-proxy)
- Run the application (this should also set up a Certbot ssl cert for your domain) with
`docker-compose up --build`, and make sure all the images build successfully
- If you are running other services on your host machine, you may run into errors where services fail when attempting to bind to a port.
See the [troubleshooting guide](#port-conflicts) for advice on resolving this.
- When docker has built successfully, stop the process with `CTRL-C`
- Comment out the `command: certonly...` line in `docker-compose.yml`, and uncomment the following line (`command: renew ...`) so that the certificate will be automatically renewed.
- Uncomment the https redirect and `server` block in `nginx/default.conf` (lines 17-48).
- Run docker-compose in the background with: `docker-compose up -d`
- Initialize the database with: `./bw-dev initdb`
- When docker has built successfully, stop the process with `CTRL-C`
- Comment out the `command: certonly...` line in `docker-compose.yml`, and uncomment the following line (`command: renew ...`) so that the certificate will be automatically renewed.
- Uncomment the https redirect and `server` block in `nginx/default.conf` (lines 17-48).
- Run docker-compose in the background with: `docker-compose up -d`
- Initialize the database with: `./bw-dev initdb`
Congrats! You did it, go to your domain and enjoy the fruits of your labors.
### Configure your instance
- Register a user account in the application UI
- Make your account a superuser (warning: do *not* use django's `createsuperuser` command)
- On your server, open the django shell
- Register a user account in the application UI
- Make your account a superuser (warning: do *not* use django's `createsuperuser` command)
- On your server, open the django shell
`./bw-dev shell`
- Load your user and make it a superuser
- Load your user and make it a superuser
```python
from bookwyrm import models
user = models.User.objects.get(id=1)
@ -196,17 +214,17 @@ Congrats! You did it, go to your domain and enjoy the fruits of your labors.
user.is_superuser = True
user.save()
```
- Go to the site settings (`/settings/site-settings` on your domain) and configure your instance name, description, code of conduct, and toggle whether registration is open on your instance
- Go to the site settings (`/settings/site-settings` on your domain) and configure your instance name, description, code of conduct, and toggle whether registration is open on your instance
## Book data
The application is set up to share book and author data between instances, and get book data from arbitrary outside sources. Right now, the only connector is to OpenLibrary, but other connectors could be written.
There are three concepts in the book data model:
- `Book`, an abstract, high-level concept that could mean either a `Work` or an `Edition`. No data is saved as a `Book`, it serves as shared model for `Work` and `Edition`
- `Work`, the theoretical umbrella concept of a book that encompasses every edition of the book, and
- `Edition`, a concrete, actually published version of a book
- `Book`, an abstract, high-level concept that could mean either a `Work` or an `Edition`. No data is saved as a `Book`, it serves as shared model for `Work` and `Edition`
- `Work`, the theoretical umbrella concept of a book that encompasses every edition of the book, and
- `Edition`, a concrete, actually published version of a book
Whenever a user interacts with a book, they are interacting with a specific edition. Every work has a default edition, but the user can select other editions. Reviews aggregated for all editions of a work when you view an edition's page.
### Backups
@ -216,12 +234,12 @@ Backups are named `backup__%Y-%m-%d.sql`.
The db service has an optional script for periodically pruning the backups directory so that all recent daily backups are kept, but for older backups, only weekly or monthly backups are kept.
To enable this script:
- Uncomment the final line in `postgres-docker/cronfile`
- rebuild your instance `docker-compose up --build`
- Uncomment the final line in `postgres-docker/cronfile`
- rebuild your instance `docker-compose up --build`
You can copy backups from the backups volume to your host machine with `docker cp`:
- Run `docker-compose ps` to confirm the db service's full name (it's probably `bookwyrm_db_1`.
- Run `docker cp <container_name>:/backups <host machine path>`
- Run `docker-compose ps` to confirm the db service's full name (it's probably `bookwyrm_db_1`.
- Run `docker cp <container_name>:/backups <host machine path>`
### Port Conflicts
@ -230,15 +248,15 @@ This means that, depending on what else you are running on your host machine, yo
If this occurs, you will need to change your configuration to run services on different ports.
This may require one or more changes the following files:
- `docker-compose.yml`
- `nginx/default.conf`
- `.env` (You create this file yourself during setup)
- `docker-compose.yml`
- `nginx/default.conf`
- `.env` (You create this file yourself during setup)
E.g., If you need Redis to run on a different port:
- In `docker-compose.yml`:
- In `docker-compose.yml`:
- In `services` -> `redis` -> `command`, add `--port YOUR_PORT` to the command
- In `services` -> `redis` -> `ports`, change `6379:6379` to your port
- In `.env`, update `REDIS_PORT`
- In `.env`, update `REDIS_PORT`
If you are already running a web-server on your machine, you will need to set up a reverse-proxy.
@ -250,11 +268,11 @@ The default BookWyrm configuration already has an nginx server that proxies requ
The static files are stored in a Docker volume that several BookWyrm services access, so it is not recommended to remove this server completely.
To run BookWyrm behind a reverse-proxy, make the following changes:
- In `nginx/default.conf`:
- In `nginx/default.conf`:
- Comment out the two default servers
- Uncomment the server labeled Reverse-Proxy server
- Replace `your-domain.com` with your domain name
- In `docker-compose.yml`:
- In `docker-compose.yml`:
- In `services` -> `nginx` -> `ports`, comment out the default ports and add `- 8001:8001`
- In `services` -> `nginx` -> `volumes`, comment out the two volumes that begin `./certbot/`
- In `services`, comment out the `certbot` service
@ -270,35 +288,35 @@ Before you can set up nginx, you will need to locate your nginx configuration di
See [nginx's guide](http://nginx.org/en/docs/beginners_guide.html) for details.
To set up your server:
- In you `nginx.conf` file, ensure that `include servers/*;` isn't commented out.
- In your nginx `servers` directory, create a new file named after your domain containing the following information:
```nginx
server {
server_name your-domain.com www.your-domain.com;
- In you `nginx.conf` file, ensure that `include servers/*;` isn't commented out.
- In your nginx `servers` directory, create a new file named after your domain containing the following information:
```nginx
server {
server_name your-domain.com www.your-domain.com;
location / {
proxy_pass http://localhost:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
location / {
proxy_pass http://localhost:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
location /images/ {
proxy_pass http://localhost:8001;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
location /images/ {
proxy_pass http://localhost:8001;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
location /static/ {
proxy_pass http://localhost:8001;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
location /static/ {
proxy_pass http://localhost:8001;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
listen [::]:80 ssl;
listen 80 ssl;
}
```
- run `sudo certbot run --nginx --email YOUR_EMAIL -d your-domain.com -d www.your-domain.com`
- restart nginx
listen [::]:80 ssl;
listen 80 ssl;
}
```
- run `sudo certbot run --nginx --email YOUR_EMAIL -d your-domain.com -d www.your-domain.com`
- restart nginx
If everything worked correctly, your BookWyrm instance should now be externally accessible.
If everything worked correctly, your BookWyrm instance should now be externally accessible.

View file

@ -76,7 +76,16 @@ class ReviewForm(CustomForm):
class CommentForm(CustomForm):
class Meta:
model = models.Comment
fields = ["user", "book", "content", "content_warning", "sensitive", "privacy"]
fields = [
"user",
"book",
"content",
"content_warning",
"sensitive",
"privacy",
"progress",
"progress_mode",
]
class QuotationForm(CustomForm):

View file

@ -0,0 +1,34 @@
# Generated by Django 3.1.6 on 2021-03-21 01:01
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0054_auto_20210319_1942"),
]
operations = [
migrations.AddField(
model_name="comment",
name="progress",
field=models.IntegerField(
blank=True,
null=True,
validators=[django.core.validators.MinValueValidator(0)],
),
),
migrations.AddField(
model_name="comment",
name="progress_mode",
field=models.CharField(
blank=True,
choices=[("PG", "page"), ("PCT", "percent")],
default="PG",
max_length=3,
null=True,
),
),
]

View file

@ -7,6 +7,8 @@ from .base_model import BookWyrmModel
class ProgressMode(models.TextChoices):
""" types of prgress available """
PAGE = "PG", "page"
PERCENT = "PCT", "percent"
@ -32,10 +34,12 @@ class ReadThrough(BookWyrmModel):
super().save(*args, **kwargs)
def create_update(self):
""" add update to the readthrough """
if self.progress:
return self.progressupdate_set.create(
user=self.user, progress=self.progress, mode=self.progress_mode
)
return None
class ProgressUpdate(BookWyrmModel):

View file

@ -14,6 +14,7 @@ from .activitypub_mixin import ActivitypubMixin, ActivityMixin
from .activitypub_mixin import OrderedCollectionPageMixin
from .base_model import BookWyrmModel
from .fields import image_serializer
from .readthrough import ProgressMode
from . import fields
@ -229,6 +230,19 @@ class Comment(Status):
"Edition", on_delete=models.PROTECT, activitypub_field="inReplyToBook"
)
# this is it's own field instead of a foreign key to the progress update
# so that the update can be deleted without impacting the status
progress = models.IntegerField(
validators=[MinValueValidator(0)], null=True, blank=True
)
progress_mode = models.CharField(
max_length=3,
choices=ProgressMode.choices,
default=ProgressMode.PAGE,
null=True,
blank=True,
)
@property
def pure_content(self):
""" indicate the book in question for mastodon (or w/e) users """

View file

@ -0,0 +1,4 @@
# @see https://editorconfig.org/
[*.svg]
insert_final_newline = unset

View file

@ -14,9 +14,6 @@ html {
.card {
overflow: visible;
}
.card-header-title {
overflow: hidden;
}
/* --- SHELVING --- */
.shelf-option:disabled > *::after {
@ -70,8 +67,8 @@ html {
content: '\e9d9';
}
.form-rate-stars label.icon:hover:before {
content: '\e9d9';
}
content: '\e9d9';
}
.form-rate-stars label.icon:hover ~ label.icon:before{
content: '\e9d7';
}

View file

@ -1,153 +1,153 @@
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?n5x55');
src: url('fonts/icomoon.eot?n5x55#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?n5x55') format('truetype'),
url('fonts/icomoon.woff?n5x55') format('woff'),
url('fonts/icomoon.svg?n5x55#icomoon') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
font-family: 'icomoon';
src: url('fonts/icomoon.eot?n5x55');
src: url('fonts/icomoon.eot?n5x55#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?n5x55') format('truetype'),
url('fonts/icomoon.woff?n5x55') format('woff'),
url('fonts/icomoon.svg?n5x55#icomoon') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
[class^="icon-"], [class*=" icon-"] {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'icomoon' !important;
speak: never;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'icomoon' !important;
speak: never;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-graphic-heart:before {
content: "\e91e";
content: "\e91e";
}
.icon-graphic-paperplane:before {
content: "\e91f";
content: "\e91f";
}
.icon-graphic-banknote:before {
content: "\e920";
content: "\e920";
}
.icon-stars:before {
content: "\e91a";
content: "\e91a";
}
.icon-warning:before {
content: "\e91b";
content: "\e91b";
}
.icon-book:before {
content: "\e900";
content: "\e900";
}
.icon-bookmark:before {
content: "\e91c";
content: "\e91c";
}
.icon-rss:before {
content: "\e91d";
content: "\e91d";
}
.icon-envelope:before {
content: "\e901";
content: "\e901";
}
.icon-arrow-right:before {
content: "\e902";
content: "\e902";
}
.icon-bell:before {
content: "\e903";
content: "\e903";
}
.icon-x:before {
content: "\e904";
content: "\e904";
}
.icon-quote-close:before {
content: "\e905";
content: "\e905";
}
.icon-quote-open:before {
content: "\e906";
content: "\e906";
}
.icon-image:before {
content: "\e907";
content: "\e907";
}
.icon-pencil:before {
content: "\e908";
content: "\e908";
}
.icon-list:before {
content: "\e909";
content: "\e909";
}
.icon-unlock:before {
content: "\e90a";
content: "\e90a";
}
.icon-unlisted:before {
content: "\e90a";
content: "\e90a";
}
.icon-globe:before {
content: "\e90b";
content: "\e90b";
}
.icon-public:before {
content: "\e90b";
content: "\e90b";
}
.icon-lock:before {
content: "\e90c";
content: "\e90c";
}
.icon-followers:before {
content: "\e90c";
content: "\e90c";
}
.icon-chain-broken:before {
content: "\e90d";
content: "\e90d";
}
.icon-chain:before {
content: "\e90e";
content: "\e90e";
}
.icon-comments:before {
content: "\e90f";
content: "\e90f";
}
.icon-comment:before {
content: "\e910";
content: "\e910";
}
.icon-boost:before {
content: "\e911";
content: "\e911";
}
.icon-arrow-left:before {
content: "\e912";
content: "\e912";
}
.icon-arrow-up:before {
content: "\e913";
content: "\e913";
}
.icon-arrow-down:before {
content: "\e914";
content: "\e914";
}
.icon-home:before {
content: "\e915";
content: "\e915";
}
.icon-local:before {
content: "\e916";
content: "\e916";
}
.icon-dots-three:before {
content: "\e917";
content: "\e917";
}
.icon-check:before {
content: "\e918";
content: "\e918";
}
.icon-dots-three-vertical:before {
content: "\e919";
content: "\e919";
}
.icon-search:before {
content: "\e986";
content: "\e986";
}
.icon-star-empty:before {
content: "\e9d7";
content: "\e9d7";
}
.icon-star-half:before {
content: "\e9d8";
content: "\e9d8";
}
.icon-star-full:before {
content: "\e9d9";
content: "\e9d9";
}
.icon-heart:before {
content: "\e9da";
content: "\e9da";
}
.icon-plus:before {
content: "\ea0a";
content: "\ea0a";
}

View file

@ -59,7 +59,9 @@ class TabGroup {
}
initPanels() {
let selectedPanelId = this.tablist.querySelector('[role="tab"][aria-selected="true"]').getAttribute("aria-controls");
let selectedPanelId = this.tablist
.querySelector('[role="tab"][aria-selected="true"]')
.getAttribute("aria-controls");
for(let panel of this.panels) {
if(panel.getAttribute("id") !== selectedPanelId) {
panel.setAttribute("hidden", "");

View file

@ -47,20 +47,18 @@
{% for book in shelf.books %}
<div class="suggested-tabs card" role="tabpanel" id="book-{{ book.id }}"{% if shelf_counter != 1 or not forloop.first %} hidden{% endif %} aria-labelledby="tab-book-{{ book.id }}">
<div class="card-header">
<p class="card-header-title">
<span>{% include 'snippets/book_titleby.html' with book=book %}</span>
</p>
<div class="card-header-title">
<div>
<p class="mb-2">{% include 'snippets/book_titleby.html' with book=book %}</p>
{% include 'snippets/shelve_button/shelve_button.html' with book=book %}
</div>
</div>
<div class="card-header-icon is-hidden-tablet">
{% trans "Close" as button_text %}
{% include 'snippets/toggle/toggle_button.html' with label=button_text controls_text="book" controls_uid=book.id class="delete" nonbutton=True pressed=True %}
</div>
</div>
<div class="card-content">
{% include 'snippets/shelve_button/shelve_button.html' with book=book %}
{% active_shelf book as active_shelf %}
{% if active_shelf.shelf.identifier == 'reading' and book.latest_readthrough %}
{% include 'snippets/progress_update.html' with readthrough=book.latest_readthrough %}
{% endif %}
{% include 'snippets/create_status.html' with book=book %}
</div>
</div>

View file

@ -11,16 +11,16 @@
{% csrf_token %}
<label class="label" for="source">
<p>{% trans "Data source" %}</p>
<p>{% trans "Data source" %}</p>
<div class="select {{ class }}">
<select name="source" id="source">
<option value="GoodReads" {% if current == 'GoodReads' %}selected{% endif %}>
GoodReads
</option>
<option value="LibraryThing" {% if current == 'LibraryThing' %}selected{% endif %}>
LibraryThing
</option>
</select>
<select name="source" id="source">
<option value="GoodReads" {% if current == 'GoodReads' %}selected{% endif %}>
GoodReads
</option>
<option value="LibraryThing" {% if current == 'LibraryThing' %}selected{% endif %}>
LibraryThing
</option>
</select>
</div>
</label>

View file

@ -13,7 +13,15 @@
{% endif %}
<div class="control">
{% if type != 'reply' and type != 'direct' %}
<label class="label" for="id_{% if type == 'quotation' %}quote{% else %}content{% endif %}_{{ book.id }}_{{ type }}">{{ type|title }}:</label>
<label class="label" for="id_{% if type == 'quotation' %}quote{% else %}content{% endif %}_{{ book.id }}_{{ type }}">
{% if type == 'comment' %}
{% trans "Comment:" %}
{% elif type == 'quotation' %}
{% trans "Quote:" %}
{% elif type == 'review' %}
{% trans "Review:" %}
{% endif %}
</label>
{% endif %}
{% if type == 'review' %}
@ -45,6 +53,33 @@
{% include 'snippets/content_warning_field.html' with parent_status=status %}
<textarea name="content" class="textarea is-small" id="id_content_quote-{{ book.id }}"></textarea>
</div>
{% elif type == 'comment' %}
<div class="control">
{% active_shelf book as active_shelf %}
{% if active_shelf.shelf.identifier == 'reading' and book.latest_readthrough %}
{% with readthrough=book.latest_readthrough %}
<div class="field">
<input type="hidden" name="id" value="{{ readthrough.id }}"/>
<label class="label" for="progress-{{ uuid }}">{% trans "Progress:" %}</label>
<div class="field has-addons mb-0">
<div class="control">
<input aria-label="{% if readthrough.progress_mode == 'PG' %}Current page{% else %}Percent read{% endif %}" class="input" type="number" min="0" name="progress" size="3" value="{{ readthrough.progress|default:'' }}" id="progress-{{ uuid }}">
</div>
<div class="control select">
<select name="progress_mode" aria-label="Progress mode">
<option value="PG" {% if readthrough.progress_mode == 'PG' %}selected{% endif %}>{% trans "pages" %}</option>
<option value="PCT" {% if readthrough.progress_mode == 'PCT' %}selected{% endif %}>{% trans "percent" %}</option>
</select>
</div>
</div>
{% if readthrough.progress_mode == 'PG' and book.pages %}
<p class="help">{% blocktrans with pages=book.pages %}of {{ pages }} pages{% endblocktrans %}</p>
{% endif %}
</div>
{% endwith %}
{% endif %}
</div>
{% endif %}
<input type="checkbox" class="hidden" name="sensitive" id="id_show_spoilers-{{ uuid }}" {% if status.content_warning %}checked{% endif %} aria-hidden="true">
{# bottom bar #}

View file

@ -1,28 +0,0 @@
{% load i18n %}
<form class="field is-grouped is-small" action="/edit-readthrough" method="POST">
{% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}"/>
<div class="field">
<label class="label is-align-self-center mb-0 pr-2" for="progress">{% trans "Progress:" %}</label>
<div class="field has-addons mb-0">
<div class="control">
<input
aria-label="{% if readthrough.progress_mode == 'PG' %}Current page{% else %}Percent read{% endif %}"
class="input is-small" type="number" min="0"
name="progress" size="3" value="{{ readthrough.progress|default:'' }}">
</div>
<div class="control select is-small">
<select name="progress_mode" aria-label="Progress mode">
<option value="PG" {% if readthrough.progress_mode == 'PG' %}selected{% endif %}>{% trans "pages" %}</option>
<option value="PCT" {% if readthrough.progress_mode == 'PCT' %}selected{% endif %}>{% trans "percent" %}</option>
</select>
</div>
<div class="control">
<button class="button is-small px-2 is-primary" type="submit">{% trans "Save" %}</button>
</div>
</div>
{% if readthrough.progress_mode == 'PG' and book.pages %}
<p class="help">{% blocktrans with pages=book.pages %}of {{ pages }} pages{% endblocktrans %}</p>
{% endif %}
</div>
</form>

View file

@ -0,0 +1,46 @@
{% extends 'components/modal.html' %}
{% load i18n %}
{% block modal-title %}
{% trans "Update progress" %}
{% endblock %}
{% block modal-form-open %}
<form action="{% url 'edit-readthrough' %}" method="POST">
{% endblock %}
{% block modal-body %}
{% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}"/>
<div class="field">
<label class="label is-align-self-center mb-0 pr-2" for="progress">{% trans "Progress:" %}</label>
<div class="field has-addons mb-0">
<div class="control">
<input
aria-label="{% if readthrough.progress_mode == 'PG' %}Current page{% else %}Percent read{% endif %}"
class="input"
type="number"
min="0"
name="progress"
size="3"
value="{{ readthrough.progress|default:'' }}">
</div>
<div class="control select">
<select name="progress_mode" aria-label="Progress mode">
<option value="PG" {% if readthrough.progress_mode == 'PG' %}selected{% endif %}>{% trans "pages" %}</option>
<option value="PCT" {% if readthrough.progress_mode == 'PCT' %}selected{% endif %}>{% trans "percent" %}</option>
</select>
</div>
</div>
{% if readthrough.progress_mode == 'PG' and book.pages %}
<p class="help">{% blocktrans with pages=book.pages %}of {{ pages }} pages{% endblocktrans %}</p>
{% endif %}
</div>
{% endblock %}
{% block modal-footer %}
<button class="button is-success" type="submit">{% trans "Save" %}</button>
{% trans "Cancel" as button_text %}
{% include 'snippets/toggle/toggle_button.html' with text=button_text %}
{% endblock %}
{% block modal-form-close %}</form>{% endblock %}

View file

@ -3,7 +3,7 @@
{% with book.id|uuid as uuid %}
{% active_shelf book as active_shelf %}
<div class="field has-addons">
<div class="field has-addons mb-0">
{% if switch_mode and active_shelf.book != book %}
<div class="control">
{% include 'snippets/switch_edition_button.html' with edition=book size='is-small' %}
@ -23,5 +23,7 @@
{% latest_read_through book request.user as readthrough %}
{% include 'snippets/shelve_button/finish_reading_modal.html' with book=active_shelf.book controls_text="finish-reading" controls_uid=uuid readthrough=readthrough %}
{% include 'snippets/shelve_button/progress_update_modal.html' with book=shelf_book.book controls_text="progress-update" controls_uid=uuid readthrough=readthrough %}
{% endwith %}
{% endif %}

View file

@ -27,3 +27,11 @@
</div>
{% if dropdown %}</li>{% endif %}
{% endfor %}
{% if dropdown %}
<li role="menuitem">
<div class="dropdown-item pt-0 pb-0">
{% trans "Update progress" as button_text %}
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="progress-update" controls_uid=button_uuid focus="modal-title-progress-update" %}
</div>
</li>
{% endif %}

View file

@ -35,3 +35,9 @@
{% elif status.mention_books %}
<a href="/book/{{ status.mention_books.first.id }}">{{ status.mention_books.first.title }}</a>
{% endif %}
{% if status.progress %}
<p class="help">
({% if status.progress_mode == 'PG' %}page {{ status.progress }}{%else %}{{ status.progress }}%{% endif %})
</p>
{% endif %}

View file

@ -1,45 +1,45 @@
{
"ISBN:9782070427796": {
"url": "https://openlibrary.org/books/OL16262504M/Les_ombres_errantes",
"key": "/books/OL16262504M",
"title": "Les ombres errantes",
"authors": [
{
"url": "https://openlibrary.org/authors/OL269675A/Pascal_Quignard",
"name": "Pascal Quignard"
}
],
"by_statement": "Pascal Quignard.",
"identifiers": {
"goodreads": [
"1835483"
],
"librarything": [
"983474"
],
"isbn_10": [
"207042779X"
],
"openlibrary": [
"OL16262504M"
]
},
"classifications": {
"dewey_decimal_class": [
"848/.91403"
]
},
"publishers": [
{
"name": "Gallimard"
}
],
"publish_places": [
{
"name": "Paris"
}
],
"publish_date": "2002",
"notes": "Hardback published Grasset, 2002."
}
"ISBN:9782070427796": {
"url": "https://openlibrary.org/books/OL16262504M/Les_ombres_errantes",
"key": "/books/OL16262504M",
"title": "Les ombres errantes",
"authors": [
{
"url": "https://openlibrary.org/authors/OL269675A/Pascal_Quignard",
"name": "Pascal Quignard"
}
],
"by_statement": "Pascal Quignard.",
"identifiers": {
"goodreads": [
"1835483"
],
"librarything": [
"983474"
],
"isbn_10": [
"207042779X"
],
"openlibrary": [
"OL16262504M"
]
},
"classifications": {
"dewey_decimal_class": [
"848/.91403"
]
},
"publishers": [
{
"name": "Gallimard"
}
],
"publish_places": [
{
"name": "Paris"
}
],
"publish_date": "2002",
"notes": "Hardback published Grasset, 2002."
}
}

View file

@ -183,7 +183,7 @@ urlpatterns = [
re_path(r"^shelve/?$", views.shelve),
re_path(r"^unshelve/?$", views.unshelve),
# reading progress
re_path(r"^edit-readthrough/?$", views.edit_readthrough),
re_path(r"^edit-readthrough/?$", views.edit_readthrough, name="edit-readthrough"),
re_path(r"^delete-readthrough/?$", views.delete_readthrough),
re_path(r"^create-readthrough/?$", views.create_readthrough),
re_path(r"^delete-progressupdate/?$", views.delete_progressupdate),

View file

@ -13,6 +13,7 @@ from bookwyrm.settings import DOMAIN
from bookwyrm.status import delete_status
from bookwyrm.utils import regex
from .helpers import handle_remote_webfinger
from .reading import edit_readthrough
# pylint: disable= no-self-use
@ -64,6 +65,10 @@ class CreateStatus(View):
status.quote = to_markdown(status.quote)
status.save(created=True)
# update a readthorugh, if needed
edit_readthrough(request)
return redirect(request.headers.get("Referer", "/"))

View file

@ -1,97 +1,97 @@
version: '3'
services:
nginx:
image: nginx:latest
ports:
- 80:80
- 443:443
depends_on:
- web
networks:
- main
volumes:
- ./nginx:/etc/nginx/conf.d
- ./certbot/conf:/etc/nginx/ssl
- ./certbot/data:/var/www/certbot
- static_volume:/app/static
- media_volume:/app/images
certbot:
image: certbot/certbot:latest
command: certonly --webroot --webroot-path=/var/www/certbot --email ${EMAIL} --agree-tos --no-eff-email -d ${DOMAIN} -d www.${DOMAIN}
#command: renew --webroot --webroot-path /var/www/certbot
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/logs:/var/log/letsencrypt
- ./certbot/data:/var/www/certbot
db:
build: postgres-docker
env_file: .env
entrypoint: /bookwyrm-entrypoint.sh
command: cron postgres
volumes:
- pgdata:/var/lib/postgresql/data
- backups:/backups
networks:
- main
web:
build: .
env_file: .env
command: gunicorn bookwyrm.wsgi:application --bind 0.0.0.0:8000
volumes:
- .:/app
- static_volume:/app/static
- media_volume:/app/images
depends_on:
- db
- celery_worker
networks:
- main
ports:
- 8000:8000
redis:
image: redis
command: redis-server --requirepass ${REDIS_PASSWORD}
volumes:
- ./redis.conf:/etc/redis/redis.conf
env_file: .env
ports:
- 6379:6379
networks:
- main
restart: on-failure
celery_worker:
env_file: .env
build: .
networks:
- main
command: celery -A celerywyrm worker -l info
volumes:
- .:/app
- static_volume:/app/static
- media_volume:/app/images
depends_on:
- db
- redis
restart: on-failure
flower:
build: .
command: flower --port=8888 --basic_auth=${FLOWER_USER}:${FLOWER_PASSWORD}
env_file: .env
environment:
- CELERY_BROKER_URL=${CELERY_BROKER}
networks:
- main
depends_on:
- db
- redis
restart: on-failure
ports:
- 8888:8888
nginx:
image: nginx:latest
ports:
- 80:80
- 443:443
depends_on:
- web
networks:
- main
volumes:
- ./nginx:/etc/nginx/conf.d
- ./certbot/conf:/etc/nginx/ssl
- ./certbot/data:/var/www/certbot
- static_volume:/app/static
- media_volume:/app/images
certbot:
image: certbot/certbot:latest
command: certonly --webroot --webroot-path=/var/www/certbot --email ${EMAIL} --agree-tos --no-eff-email -d ${DOMAIN} -d www.${DOMAIN}
#command: renew --webroot --webroot-path /var/www/certbot
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/logs:/var/log/letsencrypt
- ./certbot/data:/var/www/certbot
db:
build: postgres-docker
env_file: .env
entrypoint: /bookwyrm-entrypoint.sh
command: cron postgres
volumes:
- pgdata:/var/lib/postgresql/data
- backups:/backups
networks:
- main
web:
build: .
env_file: .env
command: gunicorn bookwyrm.wsgi:application --bind 0.0.0.0:8000
volumes:
- .:/app
- static_volume:/app/static
- media_volume:/app/images
depends_on:
- db
- celery_worker
networks:
- main
ports:
- 8000:8000
redis:
image: redis
command: redis-server --requirepass ${REDIS_PASSWORD}
volumes:
- ./redis.conf:/etc/redis/redis.conf
env_file: .env
ports:
- 6379:6379
networks:
- main
restart: on-failure
celery_worker:
env_file: .env
build: .
networks:
- main
command: celery -A celerywyrm worker -l info
volumes:
- .:/app
- static_volume:/app/static
- media_volume:/app/images
depends_on:
- db
- redis
restart: on-failure
flower:
build: .
command: flower --port=8888 --basic_auth=${FLOWER_USER}:${FLOWER_PASSWORD}
env_file: .env
environment:
- CELERY_BROKER_URL=${CELERY_BROKER}
networks:
- main
depends_on:
- db
- redis
restart: on-failure
ports:
- 8888:8888
volumes:
pgdata:
backups:
static_volume:
media_volume:
pgdata:
backups:
static_volume:
media_volume:
networks:
main:
main:

View file

@ -73,7 +73,7 @@ msgstr "Deutsch"
#: bookwyrm/settings.py:144
msgid "Spanish"
msgstr ""
msgstr "Spanisch"
#: bookwyrm/settings.py:145
msgid "French"
@ -139,7 +139,7 @@ msgstr "%(pages)s Seiten"
#: bookwyrm/templates/book/book.html:86
#, python-format
msgid "Published %(date)s by %(publisher)s."
msgstr ""
msgstr "Am %(date)s von %(publisher)s veröffentlicht."
#: bookwyrm/templates/book/book.html:88
#, fuzzy, python-format
@ -150,7 +150,7 @@ msgstr "Veröffentlichungsdatum:"
#: bookwyrm/templates/book/book.html:90
#, python-format
msgid "Published by %(publisher)s."
msgstr ""
msgstr "Veröffentlicht von %(publisher)s."
#: bookwyrm/templates/book/book.html:95
msgid "View on OpenLibrary"
@ -283,7 +283,7 @@ msgstr "Cover hinzufügen"
#: bookwyrm/templates/book/cover_modal.html:23
#: bookwyrm/templates/book/edit_book.html:169
msgid "Load cover from url:"
msgstr ""
msgstr "Cover von URL laden:"
#: bookwyrm/templates/book/edit_book.html:5
#: bookwyrm/templates/book/edit_book.html:11
@ -316,12 +316,12 @@ msgstr "Zuletzt bearbeitet von:"
#: bookwyrm/templates/book/edit_book.html:40
msgid "Confirm Book Info"
msgstr ""
msgstr "Buchinfo bestätigen"
#: bookwyrm/templates/book/edit_book.html:47
#, python-format
msgid "Is \"%(name)s\" an existing author?"
msgstr ""
msgstr "Existiert \"%(name)s\" bereits als Autor:in?"
#: bookwyrm/templates/book/edit_book.html:52
#, fuzzy, python-format
@ -331,20 +331,20 @@ msgstr "\"<em>%(book_title)s</em>\" beginnen"
#: bookwyrm/templates/book/edit_book.html:55
msgid "This is a new author"
msgstr ""
msgstr "Neue:r Autor:in"
#: bookwyrm/templates/book/edit_book.html:61
#, python-format
msgid "Creating a new author: %(name)s"
msgstr ""
msgstr "Neu als Autor:in erstellen: %(name)s"
#: bookwyrm/templates/book/edit_book.html:67
msgid "Is this an edition of an existing work?"
msgstr ""
msgstr "Ist das eine Edition eines vorhandenen Werkes?"
#: bookwyrm/templates/book/edit_book.html:71
msgid "This is a new work"
msgstr ""
msgstr "Dies ist ein neues Werk."
#: bookwyrm/templates/book/edit_book.html:77
#: bookwyrm/templates/password_reset.html:30
@ -385,7 +385,7 @@ msgstr "Veröffentlicht"
#: bookwyrm/templates/book/edit_book.html:119
msgid "Separate multiple publishers with commas."
msgstr ""
msgstr "Mehrere Herausgeber:innen durch Kommata trennen"
#: bookwyrm/templates/book/edit_book.html:125
msgid "First published date:"
@ -729,7 +729,7 @@ msgstr "Laden fehlgeschlagen"
#: bookwyrm/templates/import_status.html:44
#, python-format
msgid "Jump to the bottom of the list to select the %(failed_count)s items which failed to import."
msgstr ""
msgstr "Zum Ende der Liste springen, um die %(failed_count)s Einträge, deren Import fehlschlug, auszuwählen."
#: bookwyrm/templates/import_status.html:79
msgid "Select all"
@ -882,7 +882,7 @@ msgstr "Admin kontaktieren"
#: bookwyrm/templates/layout.html:202
#, python-format
msgid "Support %(site_name)s on <a href=\"%(support_link)s\" target=\"_blank\">%(support_title)s</a>"
msgstr ""
msgstr "%(site_name)s auf <a href=\"%(support_link)s\" target=\"_blank\">%(support_title)s</a> unterstützen"
#: bookwyrm/templates/layout.html:206
msgid "BookWyrm is open source software. You can contribute or report issues on <a href=\"https://github.com/mouse-reeve/bookwyrm\">GitHub</a>."
@ -1046,11 +1046,11 @@ msgstr "Mehr über diese Seite"
#: bookwyrm/templates/moderation/report_preview.html:6
#, python-format
msgid "Report #%(report_id)s: %(username)s"
msgstr ""
msgstr "Meldung #%(report_id)s: %(username)s"
#: bookwyrm/templates/moderation/report.html:10
msgid "Back to reports"
msgstr ""
msgstr "Zurück zu den Meldungen"
#: bookwyrm/templates/moderation/report.html:18
#, fuzzy
@ -1072,15 +1072,15 @@ msgstr "Direktnachricht senden"
#: bookwyrm/templates/moderation/report.html:27
msgid "Deactivate user"
msgstr ""
msgstr "Nutzer:in deaktivieren"
#: bookwyrm/templates/moderation/report.html:29
msgid "Reactivate user"
msgstr ""
msgstr "Nutzer:in reaktivieren"
#: bookwyrm/templates/moderation/report.html:36
msgid "Moderator Comments"
msgstr ""
msgstr "Moderator:innenkommentare"
#: bookwyrm/templates/moderation/report.html:54
#: bookwyrm/templates/snippets/create_status.html:12
@ -1096,11 +1096,11 @@ msgstr "Post löschen"
#: bookwyrm/templates/moderation/report.html:61
msgid "No statuses reported"
msgstr ""
msgstr "Keine Beiträge gemeldet"
#: bookwyrm/templates/moderation/report.html:67
msgid "Statuses has been deleted"
msgstr ""
msgstr "Beiträge wurden gelöscht"
#: bookwyrm/templates/moderation/report_modal.html:6
#, fuzzy, python-format
@ -1111,7 +1111,7 @@ msgstr "Listen: %(username)s"
#: bookwyrm/templates/moderation/report_modal.html:21
#, python-format
msgid "This report will be sent to %(site_name)s's moderators for review."
msgstr ""
msgstr "Diese Meldung wird an die Moderator:innen von %(site_name)s weitergeletiet."
#: bookwyrm/templates/moderation/report_modal.html:22
#, fuzzy
@ -1121,11 +1121,11 @@ msgstr "Mehr über diese Seite"
#: bookwyrm/templates/moderation/report_modal.html:31
msgid "Submit"
msgstr ""
msgstr "Absenden"
#: bookwyrm/templates/moderation/report_preview.html:13
msgid "No notes provided"
msgstr ""
msgstr "Keine Notizen angegeben."
#: bookwyrm/templates/moderation/report_preview.html:20
#, fuzzy, python-format
@ -1135,11 +1135,11 @@ msgstr "Direktnachrichten mit <a href=\"%(path)s\">%(username)s</a>"
#: bookwyrm/templates/moderation/report_preview.html:30
msgid "Re-open"
msgstr ""
msgstr "Wiedereröffnen"
#: bookwyrm/templates/moderation/report_preview.html:32
msgid "Resolve"
msgstr ""
msgstr "Lösen"
#: bookwyrm/templates/moderation/reports.html:4
#: bookwyrm/templates/moderation/reports.html:5
@ -1273,7 +1273,7 @@ msgstr "Dein <a href=\"/import/%(related_id)s\">Import</a> ist abgeschlossen."
#: bookwyrm/templates/notifications.html:113
#, python-format
msgid "A new <a href=\"%(path)s\">report</a> needs moderation."
msgstr ""
msgstr "Eine neue <a href=\"%(path)s\">Meldung</a> muss moderiert werden."
#: bookwyrm/templates/notifications.html:139
msgid "You're all caught up!"
@ -1345,7 +1345,7 @@ msgstr "Bio:"
#: bookwyrm/templates/preferences/edit_user.html:46
msgid "Show set reading goal prompt in feed:"
msgstr ""
msgstr "Angegebenes Leseziel im Feed anzeigen."
#: bookwyrm/templates/preferences/edit_user.html:52
msgid "Manually approve followers:"