diff --git a/boofilsic/settings.py b/boofilsic/settings.py
index a72782ce..32780254 100644
--- a/boofilsic/settings.py
+++ b/boofilsic/settings.py
@@ -86,7 +86,7 @@ if DEBUG:
'NAME': 'test',
'USER': 'donotban',
'PASSWORD': 'donotbansilvousplait',
- 'HOST': '192.168.144.2',
+ 'HOST': '192.168.13.70',
'OPTIONS': {
'client_encoding': 'UTF8',
# 'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_DEFAULT,
@@ -158,6 +158,12 @@ MASTODON_DOMAIN_NAME = 'cmx-im.work'
# Timeout of requests to Mastodon, in seconds
MASTODON_TIMEOUT = 30
+# Emoji code in mastodon
+# note the white spaces
+STAR_SOLID = ' :star_solid: '
+STAR_HALF = ' :star_half: '
+STAR_EMPTY = ' :star_empty: '
+
# Default password for each user. since assword is not used any way,
# any string that is not empty is ok
DEFAULT_PASSWORD = 'eBRM1DETkYgiqPgq'
diff --git a/books/forms.py b/books/forms.py
index b605924c..2a5d3614 100644
--- a/books/forms.py
+++ b/books/forms.py
@@ -66,6 +66,11 @@ class BookForm(forms.ModelForm):
# 'cover': forms.FileInput(),
}
+ def clean_isbn(self):
+ isbn = self.cleaned_data.get('isbn')
+ if isbn:
+ isbn = isbn.strip()
+ return isbn
class BookMarkForm(forms.ModelForm):
IS_PRIVATE_CHOICES = [
diff --git a/books/static/js/scrape.js b/books/static/js/scrape.js
index b36d2468..f051343f 100644
--- a/books/static/js/scrape.js
+++ b/books/static/js/scrape.js
@@ -4,4 +4,20 @@ $(document).ready( function() {
$("#scrapeForm form").submit();
});
+ // assume there is only one input[file] on page
+ $("input[type='file']").each(function() {
+ $(this).after('
');
+ });
+ // preview uploaded pic})
+ $("input[type='file']").change(function() {
+ if (this.files && this.files[0]) {
+ var reader = new FileReader();
+
+ reader.onload = function (e) {
+ $('#previewImage').attr('src', e.target.result);
+ }
+
+ reader.readAsDataURL(this.files[0]);
+ }
+ });
});
\ No newline at end of file
diff --git a/books/templates/books/scrape.html b/books/templates/books/scrape.html
index f65e919f..71507acd 100644
--- a/books/templates/books/scrape.html
+++ b/books/templates/books/scrape.html
@@ -47,10 +47,11 @@
diff --git a/books/views.py b/books/views.py
index 098e9331..34ca2e28 100644
--- a/books/views.py
+++ b/books/views.py
@@ -8,6 +8,7 @@ from django.utils import timezone
from django.core.paginator import Paginator
from common.mastodon import mastodon_request_included
from common.mastodon.api import check_visibility, post_toot, TootVisibilityEnum
+from common.mastodon.utils import rating_to_emoji
from .models import *
from .forms import *
from .forms import BookMarkStatusTranslator
@@ -213,7 +214,8 @@ def create_update_mark(request):
else:
visibility = TootVisibilityEnum.PUBLIC
url = "https://" + request.get_host() + reverse("books:retrieve", args=[book.id])
- words = BookMarkStatusTranslator(int(form.cleaned_data['status'])) + f"《{book.title}》"
+ words = BookMarkStatusTranslator(int(form.cleaned_data['status'])) +\
+ f"《{book.title}》" + rating_to_emoji(form.cleaned_data['rating'])
content = words + '\n' + url + '\n' + form.cleaned_data['text']
post_toot(content, visibility, request.session['oauth_token'])
else:
diff --git a/common/mastodon/utils.py b/common/mastodon/utils.py
new file mode 100644
index 00000000..1a37c0f2
--- /dev/null
+++ b/common/mastodon/utils.py
@@ -0,0 +1,12 @@
+from boofilsic.settings import STAR_EMPTY, STAR_HALF, STAR_SOLID
+
+
+def rating_to_emoji(score):
+ """ convert score to mastodon star emoji code """
+ if score is None or score == '' or score == 0:
+ return ''
+ solid_stars = score // 2
+ half_star = int(bool(score % 2))
+ empty_stars = 5 - solid_stars if not half_star else 5 - solid_stars - 1
+ emoji_code = STAR_SOLID * solid_stars + STAR_HALF * half_star + STAR_SOLID * empty_stars
+ return emoji_code
\ No newline at end of file
diff --git a/common/static/css/boofilsic_browse.css b/common/static/css/boofilsic_browse.css
index c975143f..9657aea9 100644
--- a/common/static/css/boofilsic_browse.css
+++ b/common/static/css/boofilsic_browse.css
@@ -1,7 +1,7 @@
/* Global */
:root {
- --primary: #9b4dca;
+ --primary: #00a1cc;
--secondary: #606c76;
--light: #ccc;
--bright: rgb(250, 250, 250);
diff --git a/common/static/css/boofilsic_edit.css b/common/static/css/boofilsic_edit.css
index 56d81ef2..82b2d211 100644
--- a/common/static/css/boofilsic_edit.css
+++ b/common/static/css/boofilsic_edit.css
@@ -1,7 +1,7 @@
/* Global */
:root {
- --primary: #9b4dca;
+ --primary: #00a1cc;
--secondary: #606c76;
--light: #ccc;
--bright: rgb(250, 250, 250);
diff --git a/common/static/img/default.jpg b/common/static/img/default.jpg
deleted file mode 100644
index 16f522c1..00000000
Binary files a/common/static/img/default.jpg and /dev/null differ
diff --git a/common/static/img/default_avatar.jpg b/common/static/img/default_avatar.jpg
deleted file mode 100644
index 48ab2cb2..00000000
Binary files a/common/static/img/default_avatar.jpg and /dev/null differ
diff --git a/common/static/img/logo.svg b/common/static/img/logo.svg
index e911380a..92810da0 100644
--- a/common/static/img/logo.svg
+++ b/common/static/img/logo.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/common/static/js/create_update.js b/common/static/js/create_update.js
index db88a427..32a35c08 100644
--- a/common/static/js/create_update.js
+++ b/common/static/js/create_update.js
@@ -8,7 +8,7 @@ $(document).ready( function() {
$("input[required]").each(function() {
$(this).prev().prepend("*");
})
-
+ // preview uploaded pic
$("input[type='file']").change(function() {
if (this.files && this.files[0]) {
var reader = new FileReader();
diff --git a/common/static/lib/css/milligram.css b/common/static/lib/css/milligram.css
index 13fbaabd..be254df8 100644
--- a/common/static/lib/css/milligram.css
+++ b/common/static/lib/css/milligram.css
@@ -46,8 +46,8 @@ button,
input[type='button'],
input[type='reset'],
input[type='submit'] {
- background-color: #9b4dca;
- border: 0.1rem solid #9b4dca;
+ background-color: #00a1cc;
+ border: 0.1rem solid #00a1cc;
border-radius: .4rem;
color: #fff;
cursor: pointer;
@@ -97,8 +97,8 @@ input[type='reset'][disabled]:focus,
input[type='reset'][disabled]:hover,
input[type='submit'][disabled]:focus,
input[type='submit'][disabled]:hover {
- background-color: #9b4dca;
- border-color: #9b4dca;
+ background-color: #00a1cc;
+ border-color: #00a1cc;
}
.button.button-outline,
@@ -107,7 +107,7 @@ input[type='button'].button-outline,
input[type='reset'].button-outline,
input[type='submit'].button-outline {
background-color: transparent;
- color: #9b4dca;
+ color: #00a1cc;
}
.button.button-outline:focus, .button.button-outline:hover,
@@ -134,7 +134,7 @@ input[type='reset'].button-outline[disabled]:hover,
input[type='submit'].button-outline[disabled]:focus,
input[type='submit'].button-outline[disabled]:hover {
border-color: inherit;
- color: #9b4dca;
+ color: #00a1cc;
}
.button.button-clear,
@@ -144,7 +144,7 @@ input[type='reset'].button-clear,
input[type='submit'].button-clear {
background-color: transparent;
border-color: transparent;
- color: #9b4dca;
+ color: #00a1cc;
}
.button.button-clear:focus, .button.button-clear:hover,
@@ -170,7 +170,7 @@ input[type='reset'].button-clear[disabled]:focus,
input[type='reset'].button-clear[disabled]:hover,
input[type='submit'].button-clear[disabled]:focus,
input[type='submit'].button-clear[disabled]:hover {
- color: #9b4dca;
+ color: #00a1cc;
}
code {
@@ -184,7 +184,7 @@ code {
pre {
background: #f4f5f6;
- border-left: 0.3rem solid #9b4dca;
+ border-left: 0.3rem solid #00a1cc;
overflow-y: hidden;
}
@@ -232,7 +232,7 @@ input[type='text']:focus,
input[type='url']:focus,
textarea:focus,
select:focus {
- border-color: #9b4dca;
+ border-color: #00a1cc;
outline: 0;
}
@@ -242,7 +242,7 @@ select {
}
select:focus {
- background-image: url('data:image/svg+xml;utf8,');
+ background-image: url('data:image/svg+xml;utf8,');
}
textarea {
@@ -445,7 +445,7 @@ input[type='radio'] {
}
a {
- color: #9b4dca;
+ color: #00a1cc;
text-decoration: none;
}