forked from mirrors/bookwyrm
Merge branch 'main' into collection-item-refacotr
This commit is contained in:
commit
675b34f5ad
49 changed files with 1059 additions and 668 deletions
|
@ -36,3 +36,4 @@ EMAIL_PORT=587
|
|||
EMAIL_HOST_USER=mail@your.domain.here
|
||||
EMAIL_HOST_PASSWORD=emailpassword123
|
||||
EMAIL_USE_TLS=true
|
||||
EMAIL_USE_SSL=false
|
||||
|
|
1
.eslintignore
Normal file
1
.eslintignore
Normal file
|
@ -0,0 +1 @@
|
|||
**/vendor/**
|
82
.eslintrc.js
82
.eslintrc.js
|
@ -6,5 +6,85 @@ module.exports = {
|
|||
"es6": true
|
||||
},
|
||||
|
||||
"extends": "eslint:recommended"
|
||||
"extends": "eslint:recommended",
|
||||
|
||||
"rules": {
|
||||
// Possible Errors
|
||||
"no-async-promise-executor": "error",
|
||||
"no-await-in-loop": "error",
|
||||
"no-class-assign": "error",
|
||||
"no-confusing-arrow": "error",
|
||||
"no-const-assign": "error",
|
||||
"no-dupe-class-members": "error",
|
||||
"no-duplicate-imports": "error",
|
||||
"no-template-curly-in-string": "error",
|
||||
"no-useless-computed-key": "error",
|
||||
"no-useless-constructor": "error",
|
||||
"no-useless-rename": "error",
|
||||
"require-atomic-updates": "error",
|
||||
|
||||
// Best practices
|
||||
"strict": "error",
|
||||
"no-var": "error",
|
||||
|
||||
// Stylistic Issues
|
||||
"arrow-spacing": "error",
|
||||
"capitalized-comments": [
|
||||
"warn",
|
||||
"always",
|
||||
{
|
||||
"ignoreConsecutiveComments": true
|
||||
},
|
||||
],
|
||||
"keyword-spacing": "error",
|
||||
"lines-around-comment": [
|
||||
"error",
|
||||
{
|
||||
"beforeBlockComment": true,
|
||||
"beforeLineComment": true,
|
||||
"allowBlockStart": true,
|
||||
"allowClassStart": true,
|
||||
"allowObjectStart": true,
|
||||
"allowArrayStart": true,
|
||||
},
|
||||
],
|
||||
"no-multiple-empty-lines": [
|
||||
"error",
|
||||
{
|
||||
"max": 1,
|
||||
},
|
||||
],
|
||||
"padded-blocks": [
|
||||
"error",
|
||||
"never",
|
||||
],
|
||||
"padding-line-between-statements": [
|
||||
"error",
|
||||
{
|
||||
// always before return
|
||||
"blankLine": "always",
|
||||
"prev": "*",
|
||||
"next": "return",
|
||||
},
|
||||
{
|
||||
// always before block-like expressions
|
||||
"blankLine": "always",
|
||||
"prev": "*",
|
||||
"next": "block-like",
|
||||
},
|
||||
{
|
||||
// always after variable declaration
|
||||
"blankLine": "always",
|
||||
"prev": [ "const", "let", "var" ],
|
||||
"next": "*",
|
||||
},
|
||||
{
|
||||
// not necessary between variable declaration
|
||||
"blankLine": "any",
|
||||
"prev": [ "const", "let", "var" ],
|
||||
"next": [ "const", "let", "var" ],
|
||||
},
|
||||
],
|
||||
"space-before-blocks": "error",
|
||||
}
|
||||
};
|
||||
|
|
12
.github/workflows/lint-frontend.yaml
vendored
12
.github/workflows/lint-frontend.yaml
vendored
|
@ -3,12 +3,14 @@ name: Lint Frontend
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, ci ]
|
||||
branches: [ main, ci, frontend ]
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- 'static/**'
|
||||
- '.eslintrc'
|
||||
- '.stylelintrc'
|
||||
pull_request:
|
||||
branches: [ main, ci ]
|
||||
branches: [ main, ci, frontend ]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
|
@ -22,8 +24,10 @@ jobs:
|
|||
- name: Install modules
|
||||
run: yarn
|
||||
|
||||
# See .stylelintignore for files that are not linted.
|
||||
- name: Run stylelint
|
||||
run: yarn stylelint **/static/**/*.css --report-needless-disables --report-invalid-scope-disables
|
||||
run: yarn stylelint bookwyrm/static/**/*.css --report-needless-disables --report-invalid-scope-disables
|
||||
|
||||
# See .eslintignore for files that are not linted.
|
||||
- name: Run ESLint
|
||||
run: yarn eslint . --ext .js,.jsx,.ts,.tsx
|
||||
run: yarn eslint bookwyrm/static --ext .js,.jsx,.ts,.tsx
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
bookwyrm/static/css/bulma.*.css*
|
||||
bookwyrm/static/css/icons.css
|
||||
**/vendor/**
|
||||
|
|
20
README.md
20
README.md
|
@ -116,6 +116,8 @@ If you edit the CSS or JavaScript, you will need to run Django's `collectstatic`
|
|||
./bw-dev collectstatic
|
||||
```
|
||||
|
||||
If you have [installed yarn](https://yarnpkg.com/getting-started/install), you can run `yarn watch:static` to automatically run the previous script every time a change occurs in _bookwyrm/static_ directory.
|
||||
|
||||
### Working with translations and locale files
|
||||
Text in the html files are wrapped in translation tags (`{% trans %}` and `{% blocktrans %}`), and Django generates locale files for all the strings in which you can add translations for the text. You can find existing translations in the `locale/` directory.
|
||||
|
||||
|
@ -156,24 +158,6 @@ 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
|
||||
- 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
|
||||
|
|
|
@ -24,7 +24,8 @@ EMAIL_HOST = env("EMAIL_HOST")
|
|||
EMAIL_PORT = env("EMAIL_PORT", 587)
|
||||
EMAIL_HOST_USER = env("EMAIL_HOST_USER")
|
||||
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD")
|
||||
EMAIL_USE_TLS = env("EMAIL_USE_TLS", True)
|
||||
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", True)
|
||||
EMAIL_USE_SSL = env.bool("EMAIL_USE_SSL", False)
|
||||
DEFAULT_FROM_EMAIL = "admin@{:s}".format(env("DOMAIN"))
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
|
|
|
@ -3,7 +3,6 @@ html {
|
|||
scroll-padding-top: 20%;
|
||||
}
|
||||
|
||||
/* --- --- */
|
||||
.image {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
@ -25,17 +24,8 @@ html {
|
|||
min-width: 75% !important;
|
||||
}
|
||||
|
||||
/* --- "disabled" for non-buttons --- */
|
||||
.is-disabled {
|
||||
background-color: #dbdbdb;
|
||||
border-color: #dbdbdb;
|
||||
box-shadow: none;
|
||||
color: #7a7a7a;
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* --- SHELVING --- */
|
||||
/** Shelving
|
||||
******************************************************************************/
|
||||
|
||||
/** @todo Replace icons with SVG symbols.
|
||||
@see https://www.youtube.com/watch?v=9xXBYcWgCHA */
|
||||
|
@ -45,7 +35,9 @@ html {
|
|||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
/* --- TOGGLES --- */
|
||||
/** Toggles
|
||||
******************************************************************************/
|
||||
|
||||
.toggle-button[aria-pressed=true],
|
||||
.toggle-button[aria-pressed=true]:hover {
|
||||
background-color: hsl(171, 100%, 41%);
|
||||
|
@ -57,12 +49,8 @@ html {
|
|||
display: none;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.hidden.transition-y,
|
||||
.hidden.transition-x {
|
||||
.transition-x.is-hidden,
|
||||
.transition-y.is-hidden {
|
||||
display: block !important;
|
||||
visibility: hidden !important;
|
||||
height: 0;
|
||||
|
@ -71,16 +59,18 @@ html {
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
.transition-x,
|
||||
.transition-y {
|
||||
transition-property: height, margin-top, margin-bottom, padding-top, padding-bottom;
|
||||
transition-duration: 0.5s;
|
||||
transition-timing-function: ease;
|
||||
}
|
||||
|
||||
.transition-x {
|
||||
transition-property: width, margin-left, margin-right, padding-left, padding-right;
|
||||
transition-duration: 0.5s;
|
||||
transition-timing-function: ease;
|
||||
}
|
||||
|
||||
.transition-y {
|
||||
transition-property: height, margin-top, margin-bottom, padding-top, padding-bottom;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
@ -121,7 +111,9 @@ html {
|
|||
content: '\e9d7';
|
||||
}
|
||||
|
||||
/* --- BOOK COVERS --- */
|
||||
/** Book covers
|
||||
******************************************************************************/
|
||||
|
||||
.cover-container {
|
||||
height: 250px;
|
||||
width: max-content;
|
||||
|
@ -186,7 +178,9 @@ html {
|
|||
padding: 0.1em;
|
||||
}
|
||||
|
||||
/* --- AVATAR --- */
|
||||
/** Avatars
|
||||
******************************************************************************/
|
||||
|
||||
.avatar {
|
||||
vertical-align: middle;
|
||||
display: inline;
|
||||
|
@ -202,25 +196,57 @@ html {
|
|||
min-height: 96px;
|
||||
}
|
||||
|
||||
/* --- QUOTES --- */
|
||||
.quote blockquote {
|
||||
/** Statuses: Quotes
|
||||
*
|
||||
* \e906: icon-quote-open
|
||||
* \e905: icon-quote-close
|
||||
*
|
||||
* The `content` class on the blockquote allows to apply styles to markdown
|
||||
* generated HTML in the quote: https://bulma.io/documentation/elements/content/
|
||||
*
|
||||
* ```html
|
||||
* <div class="quote block">
|
||||
* <blockquote dir="auto" class="content mb-2">
|
||||
* User generated quote in markdown…
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> — <a…>Book Title</a> by <a…class="author">Author</a></p>
|
||||
* </div>
|
||||
* ```
|
||||
******************************************************************************/
|
||||
|
||||
.quote > blockquote {
|
||||
position: relative;
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
.quote blockquote::before,
|
||||
.quote blockquote::after {
|
||||
.quote > blockquote::before,
|
||||
.quote > blockquote::after {
|
||||
font-family: 'icomoon';
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.quote blockquote::before {
|
||||
.quote > blockquote::before {
|
||||
content: "\e906";
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.quote blockquote::after {
|
||||
.quote > blockquote::after {
|
||||
content: "\e905";
|
||||
right: 0;
|
||||
}
|
||||
|
||||
/* States
|
||||
******************************************************************************/
|
||||
|
||||
/* "disabled" for non-buttons */
|
||||
|
||||
.is-disabled {
|
||||
background-color: #dbdbdb;
|
||||
border-color: #dbdbdb;
|
||||
box-shadow: none;
|
||||
color: #7a7a7a;
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
|
||||
/** @todo Replace icons with SVG symbols.
|
||||
@see https://www.youtube.com/watch?v=9xXBYcWgCHA */
|
||||
@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');
|
||||
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;
|
285
bookwyrm/static/js/bookwyrm.js
Normal file
285
bookwyrm/static/js/bookwyrm.js
Normal file
|
@ -0,0 +1,285 @@
|
|||
/* exported BookWyrm */
|
||||
/* globals TabGroup */
|
||||
|
||||
let BookWyrm = new class {
|
||||
constructor() {
|
||||
this.initOnDOMLoaded();
|
||||
this.initReccuringTasks();
|
||||
this.initEventListeners();
|
||||
}
|
||||
|
||||
initEventListeners() {
|
||||
document.querySelectorAll('[data-controls]')
|
||||
.forEach(button => button.addEventListener(
|
||||
'click',
|
||||
this.toggleAction.bind(this))
|
||||
);
|
||||
|
||||
document.querySelectorAll('.interaction')
|
||||
.forEach(button => button.addEventListener(
|
||||
'submit',
|
||||
this.interact.bind(this))
|
||||
);
|
||||
|
||||
document.querySelectorAll('.hidden-form input')
|
||||
.forEach(button => button.addEventListener(
|
||||
'change',
|
||||
this.revealForm.bind(this))
|
||||
);
|
||||
|
||||
document.querySelectorAll('[data-back]')
|
||||
.forEach(button => button.addEventListener(
|
||||
'click',
|
||||
this.back)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute code once the DOM is loaded.
|
||||
*/
|
||||
initOnDOMLoaded() {
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.tab-group')
|
||||
.forEach(tabs => new TabGroup(tabs));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute recurring tasks.
|
||||
*/
|
||||
initReccuringTasks() {
|
||||
// Polling
|
||||
document.querySelectorAll('[data-poll]')
|
||||
.forEach(liveArea => this.polling(liveArea));
|
||||
}
|
||||
|
||||
/**
|
||||
* Go back in browser history.
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
back(event) {
|
||||
event.preventDefault();
|
||||
history.back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a counter with recurring requests to the API
|
||||
* The delay is slightly randomized and increased on each cycle.
|
||||
*
|
||||
* @param {Object} counter - DOM node
|
||||
* @param {int} delay - frequency for polling in ms
|
||||
* @return {undefined}
|
||||
*/
|
||||
polling(counter, delay) {
|
||||
const bookwyrm = this;
|
||||
|
||||
delay = delay || 10000;
|
||||
delay += (Math.random() * 1000);
|
||||
|
||||
setTimeout(function() {
|
||||
fetch('/api/updates/' + counter.dataset.poll)
|
||||
.then(response => response.json())
|
||||
.then(data => bookwyrm.updateCountElement(counter, data));
|
||||
|
||||
bookwyrm.polling(counter, delay * 1.25);
|
||||
}, delay, counter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a counter.
|
||||
*
|
||||
* @param {object} counter - DOM node
|
||||
* @param {object} data - json formatted response from a fetch
|
||||
* @return {undefined}
|
||||
*/
|
||||
updateCountElement(counter, data) {
|
||||
const currentCount = counter.innerText;
|
||||
const count = data.count;
|
||||
|
||||
if (count != currentCount) {
|
||||
this.addRemoveClass(counter.closest('[data-poll-wrapper]'), 'is-hidden', count < 1);
|
||||
counter.innerText = count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle form.
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
revealForm(event) {
|
||||
let trigger = event.currentTarget;
|
||||
let hidden = trigger.closest('.hidden-form').querySelectorAll('.is-hidden')[0];
|
||||
|
||||
this.addRemoveClass(hidden, 'is-hidden', !hidden);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute actions on targets based on triggers.
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
toggleAction(event) {
|
||||
let trigger = event.currentTarget;
|
||||
let pressed = trigger.getAttribute('aria-pressed') === 'false';
|
||||
let targetId = trigger.dataset.controls;
|
||||
|
||||
// Toggle pressed status on all triggers controlling the same target.
|
||||
document.querySelectorAll('[data-controls="' + targetId + '"]')
|
||||
.forEach(otherTrigger => otherTrigger.setAttribute(
|
||||
'aria-pressed',
|
||||
otherTrigger.getAttribute('aria-pressed') === 'false'
|
||||
));
|
||||
|
||||
// @todo Find a better way to handle the exception.
|
||||
if (targetId && ! trigger.classList.contains('pulldown-menu')) {
|
||||
let target = document.getElementById(targetId);
|
||||
|
||||
this.addRemoveClass(target, 'is-hidden', !pressed);
|
||||
this.addRemoveClass(target, 'is-active', pressed);
|
||||
}
|
||||
|
||||
// Show/hide pulldown-menus.
|
||||
if (trigger.classList.contains('pulldown-menu')) {
|
||||
this.toggleMenu(trigger, targetId);
|
||||
}
|
||||
|
||||
// Show/hide container.
|
||||
let container = document.getElementById('hide-' + targetId);
|
||||
|
||||
if (container) {
|
||||
this.toggleContainer(container, pressed);
|
||||
}
|
||||
|
||||
// Check checkbox, if appropriate.
|
||||
let checkbox = trigger.dataset.controlsCheckbox;
|
||||
|
||||
if (checkbox) {
|
||||
this.toggleCheckbox(checkbox, pressed);
|
||||
}
|
||||
|
||||
// Set focus, if appropriate.
|
||||
let focus = trigger.dataset.focusTarget;
|
||||
|
||||
if (focus) {
|
||||
this.toggleFocus(focus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide menus.
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
toggleMenu(trigger, targetId) {
|
||||
let expanded = trigger.getAttribute('aria-expanded') == 'false';
|
||||
|
||||
trigger.setAttribute('aria-expanded', expanded);
|
||||
|
||||
if (targetId) {
|
||||
let target = document.getElementById(targetId);
|
||||
|
||||
this.addRemoveClass(target, 'is-active', expanded);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide generic containers.
|
||||
*
|
||||
* @param {object} container - DOM node
|
||||
* @param {boolean} pressed - Is the trigger pressed?
|
||||
* @return {undefined}
|
||||
*/
|
||||
toggleContainer(container, pressed) {
|
||||
this.addRemoveClass(container, 'is-hidden', pressed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check or uncheck a checbox.
|
||||
*
|
||||
* @param {object} checkbox - DOM node
|
||||
* @param {boolean} pressed - Is the trigger pressed?
|
||||
* @return {undefined}
|
||||
*/
|
||||
toggleCheckbox(checkbox, pressed) {
|
||||
document.getElementById(checkbox).checked = !!pressed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the focus to an element.
|
||||
* Only move the focus based on user interactions.
|
||||
*
|
||||
* @param {string} nodeId - ID of the DOM node to focus (button, link…)
|
||||
* @return {undefined}
|
||||
*/
|
||||
toggleFocus(nodeId) {
|
||||
let node = document.getElementById(nodeId);
|
||||
|
||||
node.focus();
|
||||
|
||||
setTimeout(function() {
|
||||
node.selectionStart = node.selectionEnd = 10000;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a request and update the UI accordingly.
|
||||
* This function is used for boosts, favourites, follows and unfollows.
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
interact(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const bookwyrm = this;
|
||||
const form = event.currentTarget;
|
||||
const relatedforms = document.querySelectorAll(`.${form.dataset.id}`);
|
||||
|
||||
// Toggle class on all related forms.
|
||||
relatedforms.forEach(relatedForm => bookwyrm.addRemoveClass(
|
||||
relatedForm,
|
||||
'is-hidden',
|
||||
relatedForm.className.indexOf('is-hidden') == -1
|
||||
));
|
||||
|
||||
this.ajaxPost(form).catch(error => {
|
||||
// @todo Display a notification in the UI instead.
|
||||
console.warn('Request failed:', error);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a form using POST.
|
||||
*
|
||||
* @param {object} form - Form to be submitted
|
||||
* @return {Promise}
|
||||
*/
|
||||
ajaxPost(form) {
|
||||
return fetch(form.action, {
|
||||
method : "POST",
|
||||
body: new FormData(form)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or remove a class based on a boolean condition.
|
||||
*
|
||||
* @param {object} node - DOM node to change class on
|
||||
* @param {string} classname - Name of the class
|
||||
* @param {boolean} add - Add?
|
||||
* @return {undefined}
|
||||
*/
|
||||
addRemoveClass(node, classname, add) {
|
||||
if (add) {
|
||||
node.classList.add(classname);
|
||||
} else {
|
||||
node.classList.remove(classname);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,34 @@
|
|||
/* exported toggleAllCheckboxes */
|
||||
|
||||
/**
|
||||
* Toggle all descendant checkboxes of a target.
|
||||
*
|
||||
* Use `data-target="ID_OF_TARGET"` on the node being listened to.
|
||||
*
|
||||
* @param {Event} event - change Event
|
||||
* @return {undefined}
|
||||
*/
|
||||
function toggleAllCheckboxes(event) {
|
||||
const mainCheckbox = event.target;
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Toggle all descendant checkboxes of a target.
|
||||
*
|
||||
* Use `data-target="ID_OF_TARGET"` on the node on which the event is listened
|
||||
* to (checkbox, button, link…), where_ID_OF_TARGET_ should be the ID of an
|
||||
* ancestor for the checkboxes.
|
||||
*
|
||||
* @example
|
||||
* <input
|
||||
* type="checkbox"
|
||||
* data-action="toggle-all"
|
||||
* data-target="failed-imports"
|
||||
* >
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
function toggleAllCheckboxes(event) {
|
||||
const mainCheckbox = event.target;
|
||||
|
||||
document
|
||||
.querySelectorAll(`#${mainCheckbox.dataset.target} [type="checkbox"]`)
|
||||
.forEach(checkbox => checkbox.checked = mainCheckbox.checked);
|
||||
}
|
||||
|
||||
document
|
||||
.querySelectorAll(`#${mainCheckbox.dataset.target} [type="checkbox"]`)
|
||||
.forEach(checkbox => {checkbox.checked = mainCheckbox.checked;});
|
||||
}
|
||||
.querySelectorAll('[data-action="toggle-all"]')
|
||||
.forEach(input => {
|
||||
input.addEventListener('change', toggleAllCheckboxes);
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -1,20 +1,43 @@
|
|||
/* exported updateDisplay */
|
||||
/* globals addRemoveClass */
|
||||
/* exported LocalStorageTools */
|
||||
/* globals BookWyrm */
|
||||
|
||||
// set javascript listeners
|
||||
function updateDisplay(e) {
|
||||
// used in set reading goal
|
||||
var key = e.target.getAttribute('data-id');
|
||||
var value = e.target.getAttribute('data-value');
|
||||
window.localStorage.setItem(key, value);
|
||||
let LocalStorageTools = new class {
|
||||
constructor() {
|
||||
document.querySelectorAll('[data-hide]')
|
||||
.forEach(t => this.setDisplay(t));
|
||||
|
||||
document.querySelectorAll('[data-hide="' + key + '"]')
|
||||
.forEach(t => setDisplay(t));
|
||||
}
|
||||
|
||||
function setDisplay(el) {
|
||||
// used in set reading goal
|
||||
var key = el.getAttribute('data-hide');
|
||||
var value = window.localStorage.getItem(key);
|
||||
addRemoveClass(el, 'hidden', value);
|
||||
document.querySelectorAll('.set-display')
|
||||
.forEach(t => t.addEventListener('click', this.updateDisplay.bind(this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update localStorage, then display content based on keys in localStorage.
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
updateDisplay(event) {
|
||||
// used in set reading goal
|
||||
let key = event.target.dataset.id;
|
||||
let value = event.target.dataset.value;
|
||||
|
||||
window.localStorage.setItem(key, value);
|
||||
|
||||
document.querySelectorAll('[data-hide="' + key + '"]')
|
||||
.forEach(node => this.setDisplay(node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle display of a DOM node based on its value in the localStorage.
|
||||
*
|
||||
* @param {object} node - DOM node to toggle.
|
||||
* @return {undefined}
|
||||
*/
|
||||
setDisplay(node) {
|
||||
// used in set reading goal
|
||||
let key = node.dataset.hide;
|
||||
let value = window.localStorage.getItem(key);
|
||||
|
||||
BookWyrm.addRemoveClass(node, 'is-hidden', value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,169 +0,0 @@
|
|||
/* globals setDisplay TabGroup toggleAllCheckboxes updateDisplay */
|
||||
|
||||
// set up javascript listeners
|
||||
window.onload = function() {
|
||||
// buttons that display or hide content
|
||||
document.querySelectorAll('[data-controls]')
|
||||
.forEach(t => t.onclick = toggleAction);
|
||||
|
||||
// javascript interactions (boost/fav)
|
||||
Array.from(document.getElementsByClassName('interaction'))
|
||||
.forEach(t => t.onsubmit = interact);
|
||||
|
||||
// handle aria settings on menus
|
||||
Array.from(document.getElementsByClassName('pulldown-menu'))
|
||||
.forEach(t => t.onclick = toggleMenu);
|
||||
|
||||
// hidden submit button in a form
|
||||
document.querySelectorAll('.hidden-form input')
|
||||
.forEach(t => t.onchange = revealForm);
|
||||
|
||||
// polling
|
||||
document.querySelectorAll('[data-poll]')
|
||||
.forEach(el => polling(el));
|
||||
|
||||
// browser back behavior
|
||||
document.querySelectorAll('[data-back]')
|
||||
.forEach(t => t.onclick = back);
|
||||
|
||||
Array.from(document.getElementsByClassName('tab-group'))
|
||||
.forEach(t => new TabGroup(t));
|
||||
|
||||
// display based on localstorage vars
|
||||
document.querySelectorAll('[data-hide]')
|
||||
.forEach(t => setDisplay(t));
|
||||
|
||||
// update localstorage
|
||||
Array.from(document.getElementsByClassName('set-display'))
|
||||
.forEach(t => t.onclick = updateDisplay);
|
||||
|
||||
// Toggle all checkboxes.
|
||||
document
|
||||
.querySelectorAll('[data-action="toggle-all"]')
|
||||
.forEach(input => {
|
||||
input.addEventListener('change', toggleAllCheckboxes);
|
||||
});
|
||||
};
|
||||
|
||||
function back(e) {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
}
|
||||
|
||||
function polling(el, delay) {
|
||||
delay = delay || 10000;
|
||||
delay += (Math.random() * 1000);
|
||||
setTimeout(function() {
|
||||
fetch('/api/updates/' + el.getAttribute('data-poll'))
|
||||
.then(response => response.json())
|
||||
.then(data => updateCountElement(el, data));
|
||||
polling(el, delay * 1.25);
|
||||
}, delay, el);
|
||||
}
|
||||
|
||||
function updateCountElement(el, data) {
|
||||
const currentCount = el.innerText;
|
||||
const count = data.count;
|
||||
if (count != currentCount) {
|
||||
addRemoveClass(el.closest('[data-poll-wrapper]'), 'hidden', count < 1);
|
||||
el.innerText = count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function revealForm(e) {
|
||||
var hidden = e.currentTarget.closest('.hidden-form').getElementsByClassName('hidden')[0];
|
||||
if (hidden) {
|
||||
removeClass(hidden, 'hidden');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function toggleAction(e) {
|
||||
var el = e.currentTarget;
|
||||
var pressed = el.getAttribute('aria-pressed') == 'false';
|
||||
|
||||
var targetId = el.getAttribute('data-controls');
|
||||
document.querySelectorAll('[data-controls="' + targetId + '"]')
|
||||
.forEach(t => t.setAttribute('aria-pressed', (t.getAttribute('aria-pressed') == 'false')));
|
||||
|
||||
if (targetId) {
|
||||
var target = document.getElementById(targetId);
|
||||
addRemoveClass(target, 'hidden', !pressed);
|
||||
addRemoveClass(target, 'is-active', pressed);
|
||||
}
|
||||
|
||||
// show/hide container
|
||||
var container = document.getElementById('hide-' + targetId);
|
||||
if (container) {
|
||||
addRemoveClass(container, 'hidden', pressed);
|
||||
}
|
||||
|
||||
// set checkbox, if appropriate
|
||||
var checkbox = el.getAttribute('data-controls-checkbox');
|
||||
if (checkbox) {
|
||||
document.getElementById(checkbox).checked = !!pressed;
|
||||
}
|
||||
|
||||
// set focus, if appropriate
|
||||
var focus = el.getAttribute('data-focus-target');
|
||||
if (focus) {
|
||||
var focusEl = document.getElementById(focus);
|
||||
focusEl.focus();
|
||||
setTimeout(function(){ focusEl.selectionStart = focusEl.selectionEnd = 10000; }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function interact(e) {
|
||||
e.preventDefault();
|
||||
ajaxPost(e.target);
|
||||
var identifier = e.target.getAttribute('data-id');
|
||||
Array.from(document.getElementsByClassName(identifier))
|
||||
.forEach(t => addRemoveClass(t, 'hidden', t.className.indexOf('hidden') == -1));
|
||||
}
|
||||
|
||||
function toggleMenu(e) {
|
||||
var el = e.currentTarget;
|
||||
var expanded = el.getAttribute('aria-expanded') == 'false';
|
||||
el.setAttribute('aria-expanded', expanded);
|
||||
var targetId = el.getAttribute('data-controls');
|
||||
if (targetId) {
|
||||
var target = document.getElementById(targetId);
|
||||
addRemoveClass(target, 'is-active', expanded);
|
||||
}
|
||||
}
|
||||
|
||||
function ajaxPost(form) {
|
||||
fetch(form.action, {
|
||||
method : "POST",
|
||||
body: new FormData(form)
|
||||
});
|
||||
}
|
||||
|
||||
function addRemoveClass(el, classname, bool) {
|
||||
if (bool) {
|
||||
addClass(el, classname);
|
||||
} else {
|
||||
removeClass(el, classname);
|
||||
}
|
||||
}
|
||||
|
||||
function addClass(el, classname) {
|
||||
var classes = el.className.split(' ');
|
||||
if (classes.indexOf(classname) > -1) {
|
||||
return;
|
||||
}
|
||||
el.className = classes.concat(classname).join(' ');
|
||||
}
|
||||
|
||||
function removeClass(el, className) {
|
||||
var classes = [];
|
||||
if (el.className) {
|
||||
classes = el.className.split(' ');
|
||||
}
|
||||
const idx = classes.indexOf(className);
|
||||
if (idx > -1) {
|
||||
classes.splice(idx, 1);
|
||||
}
|
||||
el.className = classes.join(' ');
|
||||
}
|
|
@ -6,24 +6,36 @@
|
|||
{% block title %}{{ book.title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="block">
|
||||
{% with user_authenticated=request.user.is_authenticated can_edit_book=perms.bookwyrm.edit_book %}
|
||||
<div class="block" itemscope itemtype="https://schema.org/Book">
|
||||
<div class="columns is-mobile">
|
||||
<div class="column">
|
||||
<h1 class="title">
|
||||
{{ book.title }}{% if book.subtitle %}:
|
||||
<small>{{ book.subtitle }}</small>{% endif %}
|
||||
<span itemprop="name">
|
||||
{{ book.title }}{% if book.subtitle %}:
|
||||
<small>{{ book.subtitle }}</small>
|
||||
{% endif %}
|
||||
</span>
|
||||
|
||||
{% if book.series %}
|
||||
<small class="has-text-grey-dark">({{ book.series }}{% if book.series_number %} #{{ book.series_number }}{% endif %})</small><br>
|
||||
<meta itemprop="isPartOf" content="{{ book.series }}">
|
||||
<meta itemprop="volumeNumber" content="{{ book.series_number }}">
|
||||
|
||||
<small class="has-text-grey-dark">
|
||||
({{ book.series }}
|
||||
{% if book.series_number %} #{{ book.series_number }}{% endif %})
|
||||
</small>
|
||||
<br>
|
||||
{% endif %}
|
||||
</h1>
|
||||
{% if book.authors %}
|
||||
<h2 class="subtitle">
|
||||
{% trans "by" %} {% include 'snippets/authors.html' with book=book %}
|
||||
{% trans "by" %} {% include 'snippets/authors.html' with book=book %}
|
||||
</h2>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if request.user.is_authenticated and perms.bookwyrm.edit_book %}
|
||||
{% if user_authenticated and can_edit_book %}
|
||||
<div class="column is-narrow">
|
||||
<a href="{{ book.id }}/edit">
|
||||
<span class="icon icon-pencil" title="{% trans "Edit Book" %}">
|
||||
|
@ -44,7 +56,7 @@
|
|||
{% include 'snippets/shelve_button/shelve_button.html' %}
|
||||
</div>
|
||||
|
||||
{% if request.user.is_authenticated and not book.cover %}
|
||||
{% if user_authenticated and not book.cover %}
|
||||
<div class="block">
|
||||
{% trans "Add cover" as button_text %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with text=button_text controls_text="add-cover" controls_uid=book.id focus="modal-title-add-cover" class="is-small" %}
|
||||
|
@ -60,7 +72,7 @@
|
|||
{% if book.isbn_13 %}
|
||||
<div class="is-flex is-justify-content-space-between is-align-items-center">
|
||||
<dt>{% trans "ISBN:" %}</dt>
|
||||
<dd>{{ book.isbn_13 }}</dd>
|
||||
<dd itemprop="isbn">{{ book.isbn_13 }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@ -89,18 +101,35 @@
|
|||
|
||||
<div class="column is-three-fifths">
|
||||
<div class="block">
|
||||
<h3 class="field is-grouped">
|
||||
<h3
|
||||
class="field is-grouped"
|
||||
itemprop="aggregateRating"
|
||||
itemscope
|
||||
itemtype="https://schema.org/AggregateRating"
|
||||
>
|
||||
<meta itemprop="ratingValue" content="{{ rating|floatformat }}">
|
||||
{# @todo Is it possible to not hard-code the value? #}
|
||||
<meta itemprop="bestRating" content="5">
|
||||
<meta itemprop="reviewCount" content="{{ review_count }}">
|
||||
|
||||
{% include 'snippets/stars.html' with rating=rating %}
|
||||
{% blocktrans count counter=review_count %}({{ review_count }} review){% plural %}({{ review_count }} reviews){% endblocktrans %}
|
||||
|
||||
{% blocktrans count counter=review_count trimmed %}
|
||||
({{ review_count }} review)
|
||||
{% plural %}
|
||||
({{ review_count }} reviews)
|
||||
{% endblocktrans %}
|
||||
</h3>
|
||||
|
||||
{% include 'snippets/trimmed_text.html' with full=book|book_description %}
|
||||
{% with full=book|book_description itemprop='abstract' %}
|
||||
{% include 'snippets/trimmed_text.html' %}
|
||||
{% endwith %}
|
||||
|
||||
{% if request.user.is_authenticated and perms.bookwyrm.edit_book and not book|book_description %}
|
||||
{% if user_authenticated and can_edit_book and not book|book_description %}
|
||||
{% trans 'Add Description' as button_text %}
|
||||
{% include 'snippets/toggle/open_button.html' with text=button_text controls_text="add-description" controls_uid=book.id focus="id_description" hide_active=True id="hide-description" %}
|
||||
|
||||
<div class="box hidden" id="add-description-{{ book.id }}">
|
||||
<div class="box is-hidden" id="add-description-{{ book.id }}">
|
||||
<form name="add-description" method="POST" action="/add-description/{{ book.id }}">
|
||||
{% csrf_token %}
|
||||
<p class="fields is-grouped">
|
||||
|
@ -138,7 +167,7 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if request.user.is_authenticated %}
|
||||
{% if user_authenticated %}
|
||||
<section class="block">
|
||||
<header class="columns">
|
||||
<h2 class="column title is-5 mb-1">{% trans "Your reading activity" %}</h2>
|
||||
|
@ -150,7 +179,7 @@
|
|||
{% if not readthroughs.exists %}
|
||||
<p>{% trans "You don't have any reading activity for this book." %}</p>
|
||||
{% endif %}
|
||||
<section class="hidden box" id="add-readthrough">
|
||||
<section class="is-hidden box" id="add-readthrough">
|
||||
<form name="add-readthrough" action="/create-readthrough" method="post">
|
||||
{% include 'snippets/readthrough_form.html' with readthrough=None %}
|
||||
<div class="field is-grouped">
|
||||
|
@ -176,14 +205,15 @@
|
|||
</div>
|
||||
<div class="column is-one-fifth">
|
||||
{% if book.subjects %}
|
||||
<section class="content block">
|
||||
<h2 class="title is-5">{% trans "Subjects" %}</h2>
|
||||
<ul>
|
||||
{% for subject in book.subjects %}
|
||||
<li>{{ subject }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
<section class="content block">
|
||||
<h2 class="title is-5">{% trans "Subjects" %}</h2>
|
||||
|
||||
<ul>
|
||||
{% for subject in book.subjects %}
|
||||
<li itemprop="about">{{ subject }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if book.subject_places %}
|
||||
|
@ -229,43 +259,56 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="block" id="reviews">
|
||||
{% for review in reviews %}
|
||||
<div class="block">
|
||||
{% include 'snippets/status/status.html' with status=review hide_book=True depth=1 %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="block is-flex is-flex-wrap-wrap">
|
||||
{% for rating in ratings %}
|
||||
<div class="block mr-5">
|
||||
<div class="media">
|
||||
<div class="media-left">{% include 'snippets/avatar.html' with user=rating.user %}</div>
|
||||
<div class="media-content">
|
||||
<div>
|
||||
<a href="{{ rating.user.local_path }}">{{ rating.user.display_name }}</a>
|
||||
</div>
|
||||
<div class="is-flex">
|
||||
<p class="mr-1">{% trans "rated it" %}</p>
|
||||
{% include 'snippets/stars.html' with rating=rating.rating %}
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ rating.remote_id }}">{{ rating.published_date | naturaltime }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="block" id="reviews">
|
||||
{% for review in reviews %}
|
||||
<div
|
||||
class="block"
|
||||
itemprop="review"
|
||||
itemscope
|
||||
itemtype="https://schema.org/Review"
|
||||
>
|
||||
{% with status=review hide_book=True depth=1 %}
|
||||
{% include 'snippets/status/status.html' %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="block">
|
||||
{% include 'snippets/pagination.html' with page=reviews path=book.local_path anchor="#reviews" %}
|
||||
|
||||
<div class="block is-flex is-flex-wrap-wrap">
|
||||
{% for rating in ratings %}
|
||||
{% with user=rating.user %}
|
||||
<div class="block mr-5">
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
{% include 'snippets/avatar.html' %}
|
||||
</div>
|
||||
|
||||
<div class="media-content">
|
||||
<div>
|
||||
<a href="{{ user.local_path }}">{{ user.display_name }}</a>
|
||||
</div>
|
||||
<div class="is-flex">
|
||||
<p class="mr-1">{% trans "rated it" %}</p>
|
||||
|
||||
{% include 'snippets/stars.html' with rating=rating.rating %}
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ rating.remote_id }}">{{ rating.published_date | naturaltime }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="block">
|
||||
{% include 'snippets/pagination.html' with page=reviews path=book.local_path anchor="#reviews" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="/static/js/tabs.js"></script>
|
||||
<script src="/static/js/vendor/tabs.js"></script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
|
||||
<p class="mb-2">
|
||||
<label class="label" for="id_subtitle">{% trans "Subtitle:" %}</label>
|
||||
<input type="text" name="subtitle" value="{{ form.subtitle.value|default:'' }}" maxlength="255" class="input" required="" id="id_subtitle">
|
||||
<input type="text" name="subtitle" value="{{ form.subtitle.value|default:'' }}" maxlength="255" class="input" id="id_subtitle">
|
||||
</p>
|
||||
{% for error in form.subtitle.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
|
|
|
@ -1,24 +1,69 @@
|
|||
{% spaceless %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
<p>
|
||||
{% if book.physical_format and not book.pages %}
|
||||
{{ book.physical_format | title }}
|
||||
{% elif book.physical_format and book.pages %}
|
||||
{% blocktrans with format=book.physical_format|title pages=book.pages %}{{ format }}, {{ pages }} pages{% endblocktrans %}
|
||||
{% elif book.pages %}
|
||||
{% blocktrans with pages=book.pages %}{{ pages }} pages{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% with format=book.physical_format pages=book.pages %}
|
||||
{% if format %}
|
||||
{% comment %}
|
||||
@todo The bookFormat property is limited to a list of values whereas the book edition is free text.
|
||||
@see https://schema.org/bookFormat
|
||||
{% endcomment %}
|
||||
<meta itemprop="bookFormat" content="{{ format }}">
|
||||
{% endif %}
|
||||
|
||||
{% if pages %}
|
||||
<meta itemprop="numberOfPages" content="{{ pages }}">
|
||||
{% endif %}
|
||||
|
||||
{% if format and not pages %}
|
||||
{% blocktrans %}{{ format }}{% endblocktrans %}
|
||||
{% elif format and pages %}
|
||||
{% blocktrans %}{{ format }}, {{ pages }} pages{% endblocktrans %}
|
||||
{% elif pages %}
|
||||
{% blocktrans %}{{ pages }} pages{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</p>
|
||||
|
||||
{% if book.languages %}
|
||||
<p>
|
||||
{% blocktrans with languages=book.languages|join:", " %}{{ languages }} language{% endblocktrans %}
|
||||
</p>
|
||||
{% for language in book.languages %}
|
||||
<meta itemprop="inLanguage" content="{{ language }}">
|
||||
{% endfor %}
|
||||
|
||||
<p>
|
||||
{% with languages=book.languages|join:", " %}
|
||||
{% blocktrans %}{{ languages }} language{% endblocktrans %}
|
||||
{% endwith %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
{% if book.published_date and book.publishers %}
|
||||
{% blocktrans with date=book.published_date|date:'M jS Y' publisher=book.publishers|join:', ' %}Published {{ date }} by {{ publisher }}.{% endblocktrans %}
|
||||
{% elif book.published_date %}
|
||||
{% blocktrans with date=book.published_date|date:'M jS Y' %}Published {{ date }}{% endblocktrans %}
|
||||
{% elif book.publishers %}
|
||||
{% blocktrans with publisher=book.publishers|join:', ' %}Published by {{ publisher }}.{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% with date=book.published_date|date:'M jS Y' publisher=book.publishers|join:', ' %}
|
||||
{% if date or book.first_published_date %}
|
||||
<meta
|
||||
itemprop="datePublished"
|
||||
content="{{ book.first_published_date|default:book.published_date|date:'Y-m-d' }}"
|
||||
>
|
||||
{% endif %}
|
||||
|
||||
{% comment %}
|
||||
@todo The publisher property needs to be an Organization or a Person. We’ll be using Thing which is the more generic ancestor.
|
||||
@see https://schema.org/Publisher
|
||||
{% endcomment %}
|
||||
{% if book.publishers %}
|
||||
{% for publisher in book.publishers %}
|
||||
<meta itemprop="publisher" content="{{ publisher }}">
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if date and publisher %}
|
||||
{% blocktrans %}Published {{ date }} by {{ publisher }}.{% endblocktrans %}
|
||||
{% elif date %}
|
||||
{% blocktrans %}Published {{ date }}{% endblocktrans %}
|
||||
{% elif publisher %}
|
||||
{% blocktrans %}Published by {{ publisher }}.{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</p>
|
||||
{% endspaceless %}
|
||||
|
|
|
@ -1,13 +1,34 @@
|
|||
{% spaceless %}
|
||||
{% load bookwyrm_tags %}
|
||||
|
||||
{% with 0|uuid as uuid %}
|
||||
<div class="dropdown control{% if right %} is-right{% endif %}" id="menu-{{ uuid }}">
|
||||
<button type="button" class="button dropdown-trigger pulldown-menu {{ class }}" aria-expanded="false" class="pulldown-menu" aria-haspopup="true" aria-controls="menu-options-{{ uuid }}" data-controls="menu-{{ uuid }}">
|
||||
<div
|
||||
id="menu-{{ uuid }}"
|
||||
class="
|
||||
dropdown control
|
||||
{% if right %}is-right{% endif %}
|
||||
"
|
||||
>
|
||||
<button
|
||||
class="button dropdown-trigger pulldown-menu {{ class }}"
|
||||
type="button"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-controls="menu-options-{{ uuid }}"
|
||||
data-controls="menu-{{ uuid }}"
|
||||
>
|
||||
{% block dropdown-trigger %}{% endblock %}
|
||||
</button>
|
||||
|
||||
<div class="dropdown-menu">
|
||||
<ul class="dropdown-content" role="menu" id="menu-options-{{ uuid }}">
|
||||
<ul
|
||||
id="menu-options-{{ uuid }}"
|
||||
class="dropdown-content"
|
||||
role="menu"
|
||||
>
|
||||
{% block dropdown-list %}{% endblock %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endspaceless %}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% load i18n %}
|
||||
<section class="card hidden {{ class }}" id="{{ controls_text }}{% if controls_uid %}-{{ controls_uid }}{% endif %}">
|
||||
<section class="card is-hidden {{ class }}" id="{{ controls_text }}{% if controls_uid %}-{{ controls_uid }}{% endif %}">
|
||||
<header class="card-header has-background-white-ter">
|
||||
<h2 class="card-header-title" tabindex="0" id="{{ controls_text }}{% if controls_uid %}-{{ controls_uid }}{% endif %}-header">
|
||||
{% block header %}{% endblock %}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% load i18n %}
|
||||
<div
|
||||
role="dialog"
|
||||
class="modal hidden"
|
||||
class="modal is-hidden"
|
||||
id="{{ controls_text }}-{{ controls_uid }}"
|
||||
aria-labelledby="modal-card-title-{{ controls_text }}-{{ controls_uid }}"
|
||||
aria-modal="true"
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
{# announcements and system messages #}
|
||||
{% if not activities.number > 1 %}
|
||||
<a href="{{ request.path }}" class="transition-y hidden notification is-primary is-block" data-poll-wrapper>
|
||||
<a href="{{ request.path }}" class="transition-y is-hidden notification is-primary is-block" data-poll-wrapper>
|
||||
{% blocktrans %}load <span data-poll="stream/{{ tab }}">0</span> unread status(es){% endblocktrans %}
|
||||
</a>
|
||||
|
||||
|
|
|
@ -104,5 +104,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="/static/js/tabs.js"></script>
|
||||
<script src="/static/js/vendor/tabs.js"></script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
{% if user == request.user %}
|
||||
<div class="block">
|
||||
{% now 'Y' as year %}
|
||||
<section class="card {% if goal %}hidden{% endif %}" id="show-edit-goal">
|
||||
<section class="card {% if goal %}is-hidden{% endif %}" id="show-edit-goal">
|
||||
<header class="card-header">
|
||||
<h2 class="card-header-title has-background-primary has-text-white" tabindex="0" id="edit-form-header">
|
||||
<span class="icon icon-book is-size-3 mr-2" aria-hidden="true"></span> {% blocktrans %}{{ year }} Reading Goal{% endblocktrans %}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
<head>
|
||||
<title>{% block title %}BookWyrm{% endblock %} | {{ site.name }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link type="text/css" rel="stylesheet" href="/static/css/bulma.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="/static/css/format.css">
|
||||
<link type="text/css" rel="stylesheet" href="/static/css/icons.css">
|
||||
<link rel="stylesheet" href="/static/css/vendor/bulma.min.css">
|
||||
<link rel="stylesheet" href="/static/css/vendor/icons.css">
|
||||
<link rel="stylesheet" href="/static/css/bookwyrm.css">
|
||||
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{% if site.favicon %}/images/{{ site.favicon }}{% else %}/static/images/favicon.ico{% endif %}">
|
||||
|
||||
|
@ -134,7 +134,7 @@
|
|||
<span class="is-sr-only">{% trans "Notifications" %}</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="{% if not request.user|notification_count %}hidden {% endif %}tag is-danger is-medium transition-x" data-poll-wrapper>
|
||||
<span class="{% if not request.user|notification_count %}is-hidden {% endif %}tag is-danger is-medium transition-x" data-poll-wrapper>
|
||||
<span data-poll="notifications">{{ request.user | notification_count }}</span>
|
||||
</span>
|
||||
</a>
|
||||
|
@ -212,7 +212,7 @@
|
|||
<script>
|
||||
var csrf_token = '{{ csrf_token }}';
|
||||
</script>
|
||||
<script src="/static/js/shared.js"></script>
|
||||
<script src="/static/js/bookwyrm.js"></script>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="{% if local_results.results %}hidden{% endif %}" id="more-results">
|
||||
<div class="{% if local_results.results %}is-hidden{% endif %}" id="more-results">
|
||||
{% for result_set in book_results|slice:"1:" %}
|
||||
{% if result_set.results %}
|
||||
<section class="block">
|
||||
|
|
|
@ -1 +1,17 @@
|
|||
{% for author in book.authors.all %}<a href="/author/{{ author.id }}" class="author">{{ author.name }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}
|
||||
{% spaceless %}
|
||||
{% comment %}
|
||||
@todo The author property needs to be an Organization or a Person. We’ll be using Thing which is the more generic ancestor.
|
||||
@see https://schema.org/Author
|
||||
{% endcomment %}
|
||||
{% for author in book.authors.all %}
|
||||
<a
|
||||
href="/author/{{ author.id }}"
|
||||
class="author"
|
||||
itemprop="author"
|
||||
itemscope
|
||||
itemtype="https://schema.org/Thing"
|
||||
><span
|
||||
itemprop="name"
|
||||
>{{ author.name }}<span></a>{% if not forloop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
{% endspaceless %}
|
||||
|
|
|
@ -1,13 +1,29 @@
|
|||
{% spaceless %}
|
||||
|
||||
{% load bookwyrm_tags %}
|
||||
{% load i18n %}
|
||||
|
||||
<div class="cover-container is-{{ size }}">
|
||||
{% if book.cover %}
|
||||
<img class="book-cover" src="/images/{{ book.cover }}" alt="{{ book.alt_text }}" title="{{ book.alt_text }}">
|
||||
{% else %}
|
||||
<div class="no-cover book-cover">
|
||||
<img class="book-cover" src="/static/images/no_cover.jpg" alt="No cover">
|
||||
<div>
|
||||
<p>{{ book.alt_text }}</p>
|
||||
{% if book.cover %}
|
||||
<img
|
||||
class="book-cover"
|
||||
src="/images/{{ book.cover }}"
|
||||
alt="{{ book.alt_text }}"
|
||||
title="{{ book.alt_text }}"
|
||||
itemprop="thumbnailUrl"
|
||||
>
|
||||
{% else %}
|
||||
<div class="no-cover book-cover">
|
||||
<img
|
||||
class="book-cover"
|
||||
src="/static/images/no_cover.jpg"
|
||||
alt="{% trans "No cover" %}"
|
||||
>
|
||||
|
||||
<div>
|
||||
<p>{{ book.alt_text }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endspaceless %}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% with status.id|uuid as uuid %}
|
||||
<form name="boost" action="/boost/{{ status.id }}" method="post" class="interaction boost-{{ status.id }}-{{ uuid }} {% if request.user|boosted:status %}hidden{% endif %}" data-id="boost-{{ status.id }}-{{ uuid }}">
|
||||
<form name="boost" action="/boost/{{ status.id }}" method="post" class="interaction boost-{{ status.id }}-{{ uuid }} {% if request.user|boosted:status %}is-hidden{% endif %}" data-id="boost-{{ status.id }}-{{ uuid }}">
|
||||
{% csrf_token %}
|
||||
<button class="button is-small" type="submit" {% if not status.boostable %}disabled{% endif %}>
|
||||
<span class="icon icon-boost" title="{% trans 'Boost status' %}">
|
||||
|
@ -10,7 +10,7 @@
|
|||
</span>
|
||||
</button>
|
||||
</form>
|
||||
<form name="unboost" action="/unboost/{{ status.id }}" method="post" class="interaction boost-{{ status.id }}-{{ uuid }} active {% if not request.user|boosted:status %}hidden{% endif %}" data-id="boost-{{ status.id }}-{{ uuid }}">
|
||||
<form name="unboost" action="/unboost/{{ status.id }}" method="post" class="interaction boost-{{ status.id }}-{{ uuid }} active {% if not request.user|boosted:status %}is-hidden{% endif %}" data-id="boost-{{ status.id }}-{{ uuid }}">
|
||||
{% csrf_token %}
|
||||
<button class="button is-small is-primary" type="submit">
|
||||
<span class="icon icon-boost" title="{% trans 'Un-boost status' %}">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% load i18n %}
|
||||
<div class="control{% if not parent_status.content_warning and not draft.content_warning %} hidden{% endif %}" id="spoilers-{{ uuid }}">
|
||||
<div class="control{% if not parent_status.content_warning and not draft.content_warning %} is-hidden{% endif %}" id="spoilers-{{ uuid }}">
|
||||
<label class="is-sr-only" for="id_content_warning-{{ uuid }}">{% trans "Spoiler alert:" %}</label>
|
||||
<input
|
||||
type="text"
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<input type="checkbox" class="hidden" name="sensitive" id="id_show_spoilers-{{ uuid }}" {% if draft.content_warning or status.content_warning %}checked{% endif %} aria-hidden="true">
|
||||
<input type="checkbox" class="is-hidden" name="sensitive" id="id_show_spoilers-{{ uuid }}" {% if draft.content_warning or status.content_warning %}checked{% endif %} aria-hidden="true">
|
||||
{# bottom bar #}
|
||||
<div class="columns pt-1">
|
||||
<div class="field has-addons column">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% load bookwyrm_tags %}
|
||||
{% load i18n %}
|
||||
{% with status.id|uuid as uuid %}
|
||||
<form name="favorite" action="/favorite/{{ status.id }}" method="POST" class="interaction fav-{{ status.id }}-{{ uuid }} {% if request.user|liked:status %}hidden{% endif %}" data-id="fav-{{ status.id }}-{{ uuid }}">
|
||||
<form name="favorite" action="/favorite/{{ status.id }}" method="POST" class="interaction fav-{{ status.id }}-{{ uuid }} {% if request.user|liked:status %}is-hidden{% endif %}" data-id="fav-{{ status.id }}-{{ uuid }}">
|
||||
{% csrf_token %}
|
||||
<button class="button is-small" type="submit">
|
||||
<span class="icon icon-heart" title="{% trans 'Like status' %}">
|
||||
|
@ -9,7 +9,7 @@
|
|||
</span>
|
||||
</button>
|
||||
</form>
|
||||
<form name="unfavorite" action="/unfavorite/{{ status.id }}" method="POST" class="interaction fav-{{ status.id }}-{{ uuid }} active {% if not request.user|liked:status %}hidden{% endif %}" data-id="fav-{{ status.id }}-{{ uuid }}">
|
||||
<form name="unfavorite" action="/unfavorite/{{ status.id }}" method="POST" class="interaction fav-{{ status.id }}-{{ uuid }} active {% if not request.user|liked:status %}is-hidden{% endif %}" data-id="fav-{{ status.id }}-{{ uuid }}">
|
||||
{% csrf_token %}
|
||||
<button class="button is-primary is-small" type="submit">
|
||||
<span class="icon icon-heart" title="{% trans 'Un-like status' %}">
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</span>
|
||||
</h2>
|
||||
|
||||
<form class="hidden mt-3" id="filters" method="get" action="{{ request.path }}" tabindex="0">
|
||||
<form class="is-hidden mt-3" id="filters" method="get" action="{{ request.path }}" tabindex="0">
|
||||
{% if sort %}
|
||||
<input type="hidden" name="sort" value="{{ sort }}">
|
||||
{% endif %}
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
<div class="field{% if not minimal %} has-addons{% else %} mb-0{% endif %}">
|
||||
<div class="control">
|
||||
<form action="{% url 'follow' %}" method="POST" class="interaction follow-{{ user.id }} {% if request.user in user.followers.all or request.user in user.follower_requests.all %}hidden{%endif %}" data-id="follow-{{ user.id }}">
|
||||
<form action="{% url 'follow' %}" method="POST" class="interaction follow-{{ user.id }} {% if request.user in user.followers.all or request.user in user.follower_requests.all %}is-hidden{%endif %}" data-id="follow-{{ user.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ user.username }}">
|
||||
<button class="button is-small{% if not minimal %} is-link{% endif %}" type="submit">{% trans "Follow" %}</button>
|
||||
</form>
|
||||
<form action="{% url 'unfollow' %}" method="POST" class="interaction follow-{{ user.id }} {% if not request.user in user.followers.all and not request.user in user.follower_requests.all %}hidden{%endif %}" data-id="follow-{{ user.id }}">
|
||||
<form action="{% url 'unfollow' %}" method="POST" class="interaction follow-{{ user.id }} {% if not request.user in user.followers.all and not request.user in user.follower_requests.all %}is-hidden{%endif %}" data-id="follow-{{ user.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ user.username }}">
|
||||
{% if user.manually_approves_followers and request.user not in user.followers.all %}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
{% include 'snippets/form_rate_stars.html' with book=book classes='mb-1 has-text-warning-dark' default_rating=book|user_rating:request.user %}
|
||||
|
||||
<div class="field has-addons hidden">
|
||||
<div class="field has-addons is-hidden">
|
||||
<div class="control">
|
||||
{% include 'snippets/privacy_select.html' with class="is-small" %}
|
||||
</div>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
{% if readthrough.progress %}
|
||||
{% trans "Show all updates" as button_text %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with text=button_text controls_text="updates" controls_uid=readthrough.id class="is-small" %}
|
||||
<ul id="updates-{{ readthrough.id }}" class="hidden">
|
||||
<ul id="updates-{{ readthrough.id }}" class="is-hidden">
|
||||
{% for progress_update in readthrough.progress_updates %}
|
||||
<li>
|
||||
<form name="delete-update" action="/delete-progressupdate" method="POST">
|
||||
|
@ -67,7 +67,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box hidden" id="edit-readthrough-{{ readthrough.id }}" tabindex="0">
|
||||
<div class="box is-hidden" id="edit-readthrough-{{ readthrough.id }}" tabindex="0">
|
||||
<h3 class="title is-5">{% trans "Edit read dates" %}</h3>
|
||||
<form name="edit-readthrough" action="/edit-readthrough" method="post">
|
||||
{% include 'snippets/readthrough_form.html' with readthrough=readthrough %}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% for shelf in shelves %}
|
||||
{% comparison_bool shelf.identifier active_shelf.shelf.identifier as is_current %}
|
||||
{% if dropdown %}<li role="menuitem">{% endif %}
|
||||
<div class="{% if dropdown %}dropdown-item pt-0 pb-0{% elif active_shelf.shelf.identifier|next_shelf != shelf.identifier %}hidden{% endif %}">
|
||||
<div class="{% if dropdown %}dropdown-item pt-0 pb-0{% elif active_shelf.shelf.identifier|next_shelf != shelf.identifier %}is-hidden{% endif %}">
|
||||
{% if shelf.identifier == 'reading' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %}
|
||||
{% trans "Start reading" as button_text %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="start-reading" controls_uid=button_uuid focus="modal-title-start-reading" disabled=is_current %}
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
{% block card-bonus %}
|
||||
{% if request.user.is_authenticated and not moderation_mode %}
|
||||
{% with status.id|uuid as uuid %}
|
||||
<section class="hidden" id="show-comment-{{ status.id }}">
|
||||
<section class="is-hidden" id="show-comment-{{ status.id }}">
|
||||
<div class="card-footer">
|
||||
<div class="card-footer-item">
|
||||
{% include 'snippets/create_status_form.html' with reply_parent=status type="reply" %}
|
||||
|
|
|
@ -1,68 +1,137 @@
|
|||
{% spaceless %}
|
||||
|
||||
{% load bookwyrm_tags %}
|
||||
{% load i18n %}
|
||||
<div class="block">
|
||||
{% if status.status_type == 'Review' or status.status_type == 'Rating' %}
|
||||
<div>
|
||||
{% if status.name %}
|
||||
<h3 class="title is-5 has-subtitle" dir="auto">
|
||||
{{ status.name|escape }}
|
||||
</h3>
|
||||
{% endif %}
|
||||
{% include 'snippets/stars.html' with rating=status.rating %}
|
||||
</div>
|
||||
|
||||
{% with status_type=status.status_type %}
|
||||
<div
|
||||
class="block"
|
||||
|
||||
{% if status_type == 'Review' %}
|
||||
{% firstof "reviewBody" as body_prop %}
|
||||
{% firstof 'itemprop="reviewRating" itemscope itemtype="https://schema.org/Rating"' as rating_type %}
|
||||
{% endif %}
|
||||
|
||||
{% if status_type == 'Rating' %}
|
||||
itemprop="rating"
|
||||
itemtype="https://schema.org/Rating"
|
||||
{% endif %}
|
||||
>
|
||||
{% if status_type == 'Review' or status_type == 'Rating' %}
|
||||
<div>
|
||||
{% if status.name %}
|
||||
<h3
|
||||
class="title is-5 has-subtitle"
|
||||
dir="auto"
|
||||
itemprop="name"
|
||||
>
|
||||
{{ status.name|escape }}
|
||||
</h3>
|
||||
{% endif %}
|
||||
|
||||
<span
|
||||
class="is-sr-only"
|
||||
{{ rating_type }}
|
||||
>
|
||||
<meta itemprop="ratingValue" content="{{ status.rating|floatformat }}">
|
||||
|
||||
{% if status_type == 'Rating' %}
|
||||
{# @todo Is it possible to not hard-code the value? #}
|
||||
<meta itemprop="bestRating" content="5">
|
||||
{% endif %}
|
||||
</span>
|
||||
|
||||
{% include 'snippets/stars.html' with rating=status.rating %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if status.content_warning %}
|
||||
<div>
|
||||
<p>{{ status.content_warning }}</p>
|
||||
{% trans "Show more" as button_text %}
|
||||
{% include 'snippets/toggle/open_button.html' with text=button_text class="is-small" controls_text="show-status-cw" controls_uid=status.id %}
|
||||
</div>
|
||||
<div>
|
||||
<p>{{ status.content_warning }}</p>
|
||||
|
||||
{% trans "Show more" as button_text %}
|
||||
|
||||
{% with text=button_text class="is-small" controls_text="show-status-cw" controls_uid=status.id %}
|
||||
{% include 'snippets/toggle/open_button.html' %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div{% if status.content_warning %} class="hidden" id="show-status-cw-{{ status.id }}"{% endif %}>
|
||||
<div
|
||||
{% if status.content_warning %}
|
||||
{% trans "Show less" as button_text %}
|
||||
{% include 'snippets/toggle/close_button.html' with text=button_text class="is-small" controls_text="show-status-cw" controls_uid=status.id %}
|
||||
id="show-status-cw-{{ status.id }}"
|
||||
class="is-hidden"
|
||||
{% endif %}
|
||||
>
|
||||
{% if status.content_warning %}
|
||||
{% trans "Show less" as button_text %}
|
||||
|
||||
{% with text=button_text class="is-small" controls_text="show-status-cw" controls_uid=status.id %}
|
||||
{% include 'snippets/toggle/close_button.html' %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% if status.quote %}
|
||||
<div class="quote block">
|
||||
<blockquote dir="auto" class="mb-2">{{ status.quote | safe }}</blockquote>
|
||||
<div class="quote block">
|
||||
<blockquote dir="auto" class="content mb-2">{{ status.quote | safe }}</blockquote>
|
||||
|
||||
<p> — {% include 'snippets/book_titleby.html' with book=status.book %}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if status.content and status.status_type != 'GeneratedNote' and status.status_type != 'Announce' %}
|
||||
{% include 'snippets/trimmed_text.html' with full=status.content|safe no_trim=status.content_warning %}
|
||||
{% endif %}
|
||||
{% if status.attachments.exists %}
|
||||
<div class="block">
|
||||
<div class="columns">
|
||||
{% for attachment in status.attachments.all %}
|
||||
<div class="column is-narrow">
|
||||
<figure class="image is-128x128">
|
||||
<a href="/images/{{ attachment.image }}" target="_blank" aria-label="{% trans 'Open image in new window' %}">
|
||||
<img src="/images/{{ attachment.image }}"{% if attachment.caption %} alt="{{ attachment.caption }}" title="{{ attachment.caption }}"{% endif %}>
|
||||
</a>
|
||||
</figure>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<p> — {% include 'snippets/book_titleby.html' with book=status.book %}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if status.content and status_type != 'GeneratedNote' and status_type != 'Announce' %}
|
||||
{% with full=status.content|safe no_trim=status.content_warning itemprop=body_prop %}
|
||||
{% include 'snippets/trimmed_text.html' %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% if status.attachments.exists %}
|
||||
<div class="block">
|
||||
<div class="columns">
|
||||
{% for attachment in status.attachments.all %}
|
||||
<div class="column is-narrow">
|
||||
<figure class="image is-128x128">
|
||||
<a
|
||||
href="/images/{{ attachment.image }}"
|
||||
target="_blank"
|
||||
aria-label="{% trans 'Open image in new window' %}"
|
||||
>
|
||||
<img
|
||||
src="/images/{{ attachment.image }}"
|
||||
|
||||
{% if attachment.caption %}
|
||||
alt="{{ attachment.caption }}"
|
||||
title="{{ attachment.caption }}"
|
||||
{% endif %}
|
||||
>
|
||||
</a>
|
||||
</figure>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not hide_book %}
|
||||
{% if status.book or status.mention_books.count %}
|
||||
<div class="{% if status.status_type != 'GeneratedNote' %}box has-background-white-bis{% endif %}">
|
||||
{% if status.book %}
|
||||
{% include 'snippets/status/book_preview.html' with book=status.book %}
|
||||
{% elif status.mention_books.count %}
|
||||
{% include 'snippets/status/book_preview.html' with book=status.mention_books.first %}
|
||||
{% if status.book or status.mention_books.count %}
|
||||
<div
|
||||
{% if status_type != 'GeneratedNote' %}
|
||||
class="box has-background-white-bis"
|
||||
{% endif %}
|
||||
>
|
||||
{% if status.book %}
|
||||
{% with book=status.book %}
|
||||
{% include 'snippets/status/book_preview.html' %}
|
||||
{% endwith %}
|
||||
{% elif status.mention_books.count %}
|
||||
{% with book=status.mention_books.first %}
|
||||
{% include 'snippets/status/book_preview.html' %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endspaceless %}
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
{% load bookwyrm_tags %}
|
||||
{% load i18n %}
|
||||
<a href="{{ status.user.local_path }}">
|
||||
{% include 'snippets/avatar.html' with user=status.user ariaHide="true" %}
|
||||
{{ status.user.display_name }}
|
||||
</a>
|
||||
<span
|
||||
itemprop="author"
|
||||
itemscope
|
||||
itemtype="https://schema.org/Person"
|
||||
>
|
||||
<a
|
||||
href="{{ status.user.local_path }}"
|
||||
itemprop="url"
|
||||
>
|
||||
{% include 'snippets/avatar.html' with user=status.user ariaHide="true" %}
|
||||
|
||||
<span itemprop="name">{{ status.user.display_name }}</span>
|
||||
</a>
|
||||
</span>
|
||||
|
||||
{% if status.status_type == 'GeneratedNote' %}
|
||||
{{ status.content | safe }}
|
||||
|
|
|
@ -1,40 +1,49 @@
|
|||
{% spaceless %}
|
||||
{% load bookwyrm_tags %}
|
||||
{% load i18n %}
|
||||
|
||||
{% with 0|uuid as uuid %}
|
||||
{% if full %}
|
||||
{% with full|to_markdown|safe as full %}
|
||||
{% if full %}
|
||||
{% with full|to_markdown|safe as full %}
|
||||
{% with full|to_markdown|safe|truncatewords_html:60 as trimmed %}
|
||||
{% if not no_trim and trimmed != full %}
|
||||
<div id="hide-full-{{ uuid }}">
|
||||
<div class="content" id="trimmed-{{ uuid }}">
|
||||
<div dir="auto">{{ trimmed }}</div>
|
||||
|
||||
{% with full|to_markdown|safe|truncatewords_html:60 as trimmed %}
|
||||
{% if not no_trim and trimmed != full %}
|
||||
<div id="hide-full-{{ uuid }}">
|
||||
<div class="content" id="trimmed-{{ uuid }}">
|
||||
<div dir="auto">{{ trimmed }}</div>
|
||||
<div>
|
||||
{% trans "Show more" as button_text %}
|
||||
{% include 'snippets/toggle/open_button.html' with text=button_text controls_text="full" controls_uid=uuid class="is-small" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="full-{{ uuid }}" class="is-hidden">
|
||||
<div class="content">
|
||||
<div
|
||||
dir="auto"
|
||||
{% if itemprop %}itemprop="{{ itemprop }}{% endif %}"
|
||||
>
|
||||
{{ full }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{% trans "Show more" as button_text %}
|
||||
{% include 'snippets/toggle/open_button.html' with text=button_text controls_text="full" controls_uid=uuid class="is-small" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="full-{{ uuid }}" class="hidden">
|
||||
<div class="content">
|
||||
<div dir="auto">{{ full }}</div>
|
||||
|
||||
<div>
|
||||
{% trans "Show less" as button_text %}
|
||||
{% include 'snippets/toggle/close_button.html' with text=button_text controls_text="full" controls_uid=uuid class="is-small" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="content">
|
||||
<div dir="auto">{{ full }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div>
|
||||
{% trans "Show less" as button_text %}
|
||||
{% include 'snippets/toggle/close_button.html' with text=button_text controls_text="full" controls_uid=uuid class="is-small" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="content">
|
||||
<div
|
||||
dir="auto"
|
||||
{% if itemprop %}itemprop="{{ itemprop }}{% endif %}"
|
||||
>
|
||||
{{ full }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% endspaceless %}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
{% block panel %}
|
||||
<section class="block content">
|
||||
<form name="create-list" method="post" action="{% url 'lists' %}" class="box hidden" id="create-list">
|
||||
<form name="create-list" method="post" action="{% url 'lists' %}" class="box is-hidden" id="create-list">
|
||||
<header class="columns">
|
||||
<h3 class="title column">{% trans "Create list" %}</h3>
|
||||
<div class="column is-narrow">
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
""" the good stuff! the books! """
|
||||
from datetime import datetime
|
||||
from uuid import uuid4
|
||||
|
||||
from dateutil.parser import parse as dateparse
|
||||
|
@ -175,18 +174,18 @@ class EditBook(View):
|
|||
data["confirm_mode"] = True
|
||||
# this isn't preserved because it isn't part of the form obj
|
||||
data["remove_authors"] = request.POST.getlist("remove_authors")
|
||||
# we have to make sure the dates are passed in as datetime, they're currently a string
|
||||
# make sure the dates are passed in as datetime, they're currently a string
|
||||
# QueryDicts are immutable, we need to copy
|
||||
formcopy = data["form"].data.copy()
|
||||
try:
|
||||
formcopy["first_published_date"] = dateparse(
|
||||
formcopy["first_published_date"]
|
||||
)
|
||||
except MultiValueDictKeyError:
|
||||
except (MultiValueDictKeyError, ValueError):
|
||||
pass
|
||||
try:
|
||||
formcopy["published_date"] = dateparse(formcopy["published_date"])
|
||||
except MultiValueDictKeyError:
|
||||
except (MultiValueDictKeyError, ValueError):
|
||||
pass
|
||||
data["form"].data = formcopy
|
||||
return TemplateResponse(request, "book/edit_book.html", data)
|
||||
|
|
|
@ -20,7 +20,8 @@ EMAIL_HOST = env("EMAIL_HOST")
|
|||
EMAIL_PORT = env("EMAIL_PORT")
|
||||
EMAIL_HOST_USER = env("EMAIL_HOST_USER")
|
||||
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD")
|
||||
EMAIL_USE_TLS = env("EMAIL_USE_TLS")
|
||||
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS")
|
||||
EMAIL_USE_SSL = env.bool("EMAIL_USE_SSL", False)
|
||||
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,12 @@
|
|||
{
|
||||
"scripts": {
|
||||
"watch:static": "yarn watch \"./bw-dev collectstatic\" bookwyrm/static/**"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.23.0",
|
||||
"stylelint": "^13.12.0",
|
||||
"stylelint-config-standard": "^21.0.0",
|
||||
"stylelint-order": "^4.1.0"
|
||||
"stylelint-order": "^4.1.0",
|
||||
"watch": "^1.0.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
celery==4.4.2
|
||||
Django==3.1.6
|
||||
Django==3.1.8
|
||||
django-model-utils==4.0.0
|
||||
environs==7.2.0
|
||||
flower==0.9.4
|
||||
|
|
22
yarn.lock
22
yarn.lock
|
@ -768,6 +768,13 @@ esutils@^2.0.2:
|
|||
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
|
||||
integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==
|
||||
|
||||
exec-sh@^0.2.0:
|
||||
version "0.2.2"
|
||||
resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.2.2.tgz#2a5e7ffcbd7d0ba2755bdecb16e5a427dfbdec36"
|
||||
integrity sha512-FIUCJz1RbuS0FKTdaAafAByGS0CPvU3R0MeHxgtl+djzCc//F8HakL8GzmVNZanasTbTAY/3DRFA0KpVqj/eAw==
|
||||
dependencies:
|
||||
merge "^1.2.0"
|
||||
|
||||
execall@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/execall/-/execall-2.0.0.tgz#16a06b5fe5099df7d00be5d9c06eecded1663b45"
|
||||
|
@ -1368,6 +1375,11 @@ merge2@^1.3.0:
|
|||
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
|
||||
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
|
||||
|
||||
merge@^1.2.0:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.1.tgz#38bebf80c3220a8a487b6fcfb3941bb11720c145"
|
||||
integrity sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==
|
||||
|
||||
micromark@~2.11.0:
|
||||
version "2.11.4"
|
||||
resolved "https://registry.yarnpkg.com/micromark/-/micromark-2.11.4.tgz#d13436138eea826383e822449c9a5c50ee44665a"
|
||||
|
@ -1405,7 +1417,7 @@ minimist-options@4.1.0:
|
|||
is-plain-obj "^1.1.0"
|
||||
kind-of "^6.0.3"
|
||||
|
||||
minimist@^1.2.5:
|
||||
minimist@^1.2.0, minimist@^1.2.5:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||
|
@ -2183,6 +2195,14 @@ vfile@^4.0.0:
|
|||
unist-util-stringify-position "^2.0.0"
|
||||
vfile-message "^2.0.0"
|
||||
|
||||
watch@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/watch/-/watch-1.0.2.tgz#340a717bde765726fa0aa07d721e0147a551df0c"
|
||||
integrity sha1-NApxe952Vyb6CqB9ch4BR6VR3ww=
|
||||
dependencies:
|
||||
exec-sh "^0.2.0"
|
||||
minimist "^1.2.0"
|
||||
|
||||
which@^1.3.1:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
|
||||
|
|
Loading…
Reference in a new issue