From b9bbb60fc77a640b73bdf0b7ac8827f12534c7b3 Mon Sep 17 00:00:00 2001 From: doubaniux Date: Sun, 29 Nov 2020 13:33:13 +0100 Subject: [PATCH 1/4] fix sharing issue --- books/views.py | 2 +- movies/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/books/views.py b/books/views.py index 5a79c6c4..113dad8c 100644 --- a/books/views.py +++ b/books/views.py @@ -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']) diff --git a/movies/views.py b/movies/views.py index 8fe6e14d..1c8149d7 100644 --- a/movies/views.py +++ b/movies/views.py @@ -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']) From 0e198653e84b4c15c91813d84192dc9ef20c4031 Mon Sep 17 00:00:00 2001 From: doubaniux Date: Mon, 7 Dec 2020 15:07:31 +0100 Subject: [PATCH 2/4] minor modifications --- common/scraper.py | 8 ++++---- mastodon/api.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/scraper.py b/common/scraper.py index 89bdb363..02770ab2 100644 --- a/common/scraper.py +++ b/common/scraper.py @@ -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): diff --git a/mastodon/api.py b/mastodon/api.py index 0de77994..f7a1678d 100644 --- a/mastodon/api.py +++ b/mastodon/api.py @@ -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 From 54484e88533993c81f5c9df19a0b4ba3206bb321 Mon Sep 17 00:00:00 2001 From: doubaniux Date: Mon, 7 Dec 2020 15:47:49 +0100 Subject: [PATCH 3/4] fix enum value type inconsistency --- common/static/js/detail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/static/js/detail.js b/common/static/js/detail.js index 9b14f98a..a4548c3a 100644 --- a/common/static/js/detail.js +++ b/common/static/js/detail.js @@ -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(); } From e2c6dfe0303cd53bf04f016ac84b9d5a6471a827 Mon Sep 17 00:00:00 2001 From: doubaniux Date: Mon, 7 Dec 2020 16:24:39 +0100 Subject: [PATCH 4/4] fix safari search issue | close #60 --- common/templates/partial/_navbar.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/templates/partial/_navbar.html b/common/templates/partial/_navbar.html index d39addc2..a129a7ab 100644 --- a/common/templates/partial/_navbar.html +++ b/common/templates/partial/_navbar.html @@ -9,7 +9,7 @@ -