Merge branch 'master' into multi-source

This commit is contained in:
doubaniux 2020-12-07 17:53:29 +01:00
commit 31f8a22fb2
6 changed files with 13 additions and 13 deletions

View file

@ -311,7 +311,7 @@ def create_update_mark(request):
visibility = TootVisibilityEnum.UNLISTED
url = "https://" + request.get_host() + reverse("books:retrieve",
args=[book.id])
words = BookMarkStatusTranslator(int(form.cleaned_data['status'])) +\
words = BookMarkStatusTranslator(form.cleaned_data['status']) +\
f"{book.title}" + \
rating_to_emoji(form.cleaned_data['rating'])

View file

@ -46,7 +46,7 @@ scraper_registry = {}
def log_url(func):
"""
Catch exceptions and log then pass the exceptions.
First postion argument of decorated function must be the url.
First postion argument (except cls/self) of decorated function must be the url.
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
@ -54,7 +54,7 @@ def log_url(func):
return func(*args, **kwargs)
except Exception as e:
# log the url
logger.error(f"Scrape Failed URL: {args[0]}")
logger.error(f"Scrape Failed URL: {args[1]}")
logger.error(str(e))
raise e
@ -102,10 +102,10 @@ class AbstractScraper:
@classmethod
def get_effective_url(cls, raw_url):
url = cls.regex.findall(raw_url)[0]
url = cls.regex.findall(raw_url)
if not url:
raise ValueError("not valid url")
return url
return url[0]
@classmethod
def download_page(cls, url, headers):

View file

@ -75,7 +75,7 @@ $(document).ready( function() {
});
// hide rating star when select wish
const WISH_CODE = 1;
const WISH_CODE = "wish";
if ($("#statusSelection input[type='radio']:checked").val() == WISH_CODE) {
$(".mark-modal .rating-star-edit").hide();
}

View file

@ -9,7 +9,7 @@
<a href="{% url 'common:home' %}" class="navbar__logo">
<img src="{% static 'img/logo.svg' %}" alt="" class="navbar__logo-img">
</a>
<form action="#" οnsubmit="" class="navbar__search-box">
<div class="navbar__search-box">
<!-- <input type="search" class="" name="q" id="searchInput" required="true" value="{% for v in request.GET.values %}{{ v }}{% endfor %}" -->
<input type="search" class="" name="q" id="searchInput" required="true" value="{% if request.GET.q %}{{ request.GET.q }}{% endif %}"
placeholder="搜索书影音">
@ -18,7 +18,7 @@
<option value="book" {% if request.GET.c and request.GET.c == 'book' %}selected{% endif %}>{% trans '书籍' %}</option>
<option value="movie" {% if request.GET.c and request.GET.c == 'movie' %}selected{% endif %}>{% trans '电影' %}</option>
</select>
</form>
</div>
<button class="navbar__dropdown-btn">• • •</button>
<ul class="navbar__link-list">
@ -41,7 +41,7 @@
</nav>
<script>
$("#searchInput").on('keyup', function (e) {
e.preventDefault();
// e.preventDefault();
if (e.keyCode === 13) {
let q = $(this).val();
let c = $("#searchCategory").val();

View file

@ -4,7 +4,7 @@ import random
import functools
from django.core.exceptions import ObjectDoesNotExist
from boofilsic.settings import MASTODON_TIMEOUT
from boofilsic.settings import CLIENT_NAME, APP_WEBSITE
from boofilsic.settings import CLIENT_NAME, APP_WEBSITE, REDIRECT_URIS
from .models import CrossSiteUserInfo
# See https://docs.joinmastodon.org/methods/accounts/
@ -98,13 +98,13 @@ def create_app(domain_name):
payload = {
'client_name': CLIENT_NAME,
'scopes': 'read write follow',
'redirect_uris': f'{APP_WEBSITE}/users/OAuth2_login/',
'redirect_uris': REDIRECT_URIS,
'website': APP_WEBSITE
}
from boofilsic.settings import DEBUG
if DEBUG:
payload['redirect_uris'] = 'http://localhost/users/OAuth2_login/'
payload['redirect_uris'] = 'http://localhost/users/OAuth2_login/\nurn:ietf:wg:oauth:2.0:oob'
response = post(url, data=payload)
return response

View file

@ -313,7 +313,7 @@ def create_update_mark(request):
visibility = TootVisibilityEnum.UNLISTED
url = "https://" + request.get_host() + reverse("movies:retrieve",
args=[movie.id])
words = MovieMarkStatusTranslator(int(form.cleaned_data['status'])) +\
words = MovieMarkStatusTranslator(form.cleaned_data['status']) +\
f"{movie.title}" + \
rating_to_emoji(form.cleaned_data['rating'])