forked from mirrors/bookwyrm
keep saved version of bio and description field as markdown
This commit is contained in:
parent
60738011a2
commit
689cc65790
4 changed files with 22 additions and 11 deletions
|
@ -6,18 +6,18 @@
|
|||
{% if trimmed != full %}
|
||||
<div>
|
||||
<input type="radio" name="show-hide-{{ uuid }}" id="show-{{ uuid }}" class="toggle-control" checked>
|
||||
<blockquote class="content toggle-content hidden">{{ trimmed | safe }}
|
||||
<blockquote class="content toggle-content hidden">{{ trimmed | to_markdown | safe }}
|
||||
<label class="button is-small" for="hide-{{ uuid }}"><div role="button" tabindex="0">show more</div></label>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" name="show-hide-{{ uuid }}" id="hide-{{ uuid }}" class="toggle-control">
|
||||
<blockquote class="content toggle-content hidden">{{ full | safe }}
|
||||
<blockquote class="content toggle-content hidden">{{ full | to_markdown | safe }}
|
||||
<label class="button is-small" for="show-{{ uuid }}"><div role="button" tabindex="0">show less</div></label>
|
||||
</blockquote>
|
||||
</div>
|
||||
{% else %}
|
||||
<blockquote class="content">{{ full | safe }}</blockquote>
|
||||
<blockquote class="content">{{ full | to_markdown | safe }}</blockquote>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
|
|
|
@ -23,7 +23,14 @@
|
|||
|
||||
<div class="column">
|
||||
{% if user.summary %}
|
||||
<blockquote><span class="icon icon-quote-open"></span>{{ user.summary | safe }}</blockquote>
|
||||
<div class="columns">
|
||||
<div class="column is-narrow">
|
||||
<span class="icon icon-quote-open"></span>
|
||||
</div>
|
||||
<div class="column">
|
||||
<blockquote>{{ user.summary | to_markdown | safe }}</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,6 +7,7 @@ from django import template
|
|||
from django.utils import timezone
|
||||
|
||||
from bookwyrm import models
|
||||
from bookwyrm.outgoing import to_markdown
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
@ -132,6 +133,13 @@ def time_since(date):
|
|||
return '%ds' % delta.seconds
|
||||
|
||||
|
||||
@register.filter(name="to_markdown")
|
||||
def get_markdown(content):
|
||||
''' convert markdown to html '''
|
||||
if content:
|
||||
return to_markdown(content)
|
||||
return None
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def active_shelf(context, book):
|
||||
''' check what shelf a user has a book on, if any '''
|
||||
|
|
|
@ -17,10 +17,8 @@ from django.template.response import TemplateResponse
|
|||
from django.utils import timezone
|
||||
from django.views.decorators.http import require_GET, require_POST
|
||||
|
||||
from bookwyrm import books_manager
|
||||
from bookwyrm import books_manager, forms, models, outgoing, goodreads_import
|
||||
from bookwyrm.broadcast import broadcast
|
||||
from bookwyrm import forms, models, outgoing
|
||||
from bookwyrm import goodreads_import
|
||||
from bookwyrm.emailing import password_reset_email
|
||||
from bookwyrm.settings import DOMAIN
|
||||
from bookwyrm.views import get_user_from_username
|
||||
|
@ -208,7 +206,7 @@ def edit_profile(request):
|
|||
ContentFile(output.getvalue())
|
||||
)
|
||||
|
||||
request.user.summary = outgoing.to_markdown(form.data['summary'])
|
||||
request.user.summary = form.data['summary']
|
||||
request.user.manually_approves_followers = \
|
||||
form.cleaned_data['manually_approves_followers']
|
||||
request.user.save()
|
||||
|
@ -244,9 +242,7 @@ def edit_book(request, book_id):
|
|||
'form': form
|
||||
}
|
||||
return TemplateResponse(request, 'edit_book.html', data)
|
||||
book = form.save(commit=False)
|
||||
book.description = outgoing.to_markown(book.description)
|
||||
book.save()
|
||||
book = form.save()
|
||||
|
||||
outgoing.handle_update_book(request.user, book)
|
||||
return redirect('/book/%s' % book.id)
|
||||
|
|
Loading…
Reference in a new issue