change theme color
This commit is contained in:
parent
8b3784d5e0
commit
e810c1e241
13 changed files with 61 additions and 19 deletions
|
@ -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'
|
||||
|
|
|
@ -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 = [
|
||||
|
|
|
@ -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('<img src="#" alt="" id="previewImage" style="margin:10px 0; max-width:500px;"/>');
|
||||
});
|
||||
// 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]);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -47,10 +47,11 @@
|
|||
<iframe src="https://search.douban.com/book/subject_search{% if keywords %}?search_text={{ keywords }}{% endif %}" frameborder="0"></iframe>
|
||||
<div class="dividing-line"></div>
|
||||
<div id="scrapeForm">
|
||||
<form action="{% url 'books:create' %}" method="POST">
|
||||
<form action="{% url 'books:create' %}" method="POST" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
</form>
|
||||
<a href="{% url 'books:scrape' %}" id="submit" class="button add-button">{% trans '剽取!' %}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
12
common/mastodon/utils.py
Normal file
12
common/mastodon/utils.py
Normal file
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||
/* Global */
|
||||
|
||||
:root {
|
||||
--primary: #9b4dca;
|
||||
--primary: #00a1cc;
|
||||
--secondary: #606c76;
|
||||
--light: #ccc;
|
||||
--bright: rgb(250, 250, 250);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* Global */
|
||||
|
||||
:root {
|
||||
--primary: #9b4dca;
|
||||
--primary: #00a1cc;
|
||||
--secondary: #606c76;
|
||||
--light: #ccc;
|
||||
--bright: rgb(250, 250, 250);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 19 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.2 KiB |
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 102.13 41.38"><title>logo</title><path d="M1.73,32.77H4.26c1.63,0,2.83.49,2.83,1.95A1.77,1.77,0,0,1,6,36.43v0a1.81,1.81,0,0,1,1.52,1.88c0,1.59-1.3,2.33-3,2.33H1.73ZM4.14,36c1.1,0,1.57-.43,1.57-1.12s-.51-1.06-1.54-1.06h-1V36Zm.18,3.55c1.17,0,1.82-.41,1.82-1.3s-.63-1.2-1.82-1.2H3.14v2.5Z" style="fill:#9b4dca"/><path d="M13.87,36.7c0-2.57,1.43-4.08,3.5-4.08s3.49,1.52,3.49,4.08-1.43,4.13-3.49,4.13S13.87,39.26,13.87,36.7Zm5.55,0c0-1.78-.81-2.86-2.05-2.86s-2.05,1.08-2.05,2.86.8,2.91,2.05,2.91S19.42,38.47,19.42,36.7Z" style="fill:#9b4dca"/><path d="M27.37,36.7c0-2.57,1.43-4.08,3.49-4.08s3.5,1.52,3.5,4.08-1.43,4.13-3.5,4.13S27.37,39.26,27.37,36.7Zm5.54,0c0-1.78-.8-2.86-2-2.86s-2.05,1.08-2.05,2.86.81,2.91,2.05,2.91S32.91,38.47,32.91,36.7Z" style="fill:#9b4dca"/><path d="M41.28,32.77h4.79V34H42.69V36.2h2.88v1.18H42.69v3.31H41.28Z" style="fill:#9b4dca"/><path d="M52.78,32.77h1.41v7.92H52.78Z" style="fill:#9b4dca"/><path d="M61.53,32.77h1.41v6.74h3.29v1.18h-4.7Z" style="fill:#9b4dca"/><path d="M72.1,39.67l.82-1a3.1,3.1,0,0,0,2.06.9c.89,0,1.38-.4,1.38-1s-.51-.86-1.23-1.16L74.05,37a2.29,2.29,0,0,1-1.6-2.11,2.41,2.41,0,0,1,2.66-2.23,3.47,3.47,0,0,1,2.44,1l-.72.89a2.55,2.55,0,0,0-1.72-.68c-.75,0-1.24.35-1.24.93s.6.85,1.26,1.12l1.07.45a2.2,2.2,0,0,1,1.6,2.14c0,1.28-1.07,2.35-2.85,2.35A4.07,4.07,0,0,1,72.1,39.67Z" style="fill:#9b4dca"/><path d="M84.57,32.77H86v7.92h-1.4Z" style="fill:#9b4dca"/><path d="M92.9,36.75c0-2.59,1.62-4.13,3.63-4.13a3.18,3.18,0,0,1,2.28,1l-.75.91a2,2,0,0,0-1.5-.69c-1.29,0-2.21,1.09-2.21,2.87s.85,2.9,2.18,2.9a2.23,2.23,0,0,0,1.69-.81l.75.88a3.15,3.15,0,0,1-2.5,1.15C94.48,40.83,92.9,39.38,92.9,36.75Z" style="fill:#9b4dca"/><path d="M15.67,26.75h-.15L1.58,23.81A.7.7,0,0,1,1,23.12V2.72A.71.71,0,0,1,1.87,2L15.81,5a.72.72,0,0,1,.56.69v20.4a.74.74,0,0,1-.26.55A.71.71,0,0,1,15.67,26.75ZM2.42,22.56,15,25.19v-19L2.42,3.58Z" style="fill:#9b4dca"/><path d="M15.67,26.75a.74.74,0,0,1-.45-.15.73.73,0,0,1-.25-.55V5.65A.71.71,0,0,1,15.52,5L29.47,2a.68.68,0,0,1,.58.15.67.67,0,0,1,.26.54v20.4a.7.7,0,0,1-.56.69L15.81,26.74Zm.7-20.53v19l12.54-2.63v-19Zm13.24,16.9h0Z" style="fill:#9b4dca"/><path d="M87.93,26.88A13.17,13.17,0,1,1,101.1,13.71,13.18,13.18,0,0,1,87.93,26.88Zm0-24.94A11.77,11.77,0,1,0,99.7,13.71,11.78,11.78,0,0,0,87.93,1.94Z" style="fill:#9b4dca"/><path d="M87.93,18.78A5.07,5.07,0,1,1,93,13.71,5.08,5.08,0,0,1,87.93,18.78Zm0-8.74a3.67,3.67,0,1,0,3.68,3.67A3.67,3.67,0,0,0,87.93,10Z" style="fill:#9b4dca"/><path d="M60.82,23H36.4a.7.7,0,0,1-.7-.7V5.09a.7.7,0,0,1,.7-.7H60.82a.7.7,0,0,1,.7.7V22.33A.7.7,0,0,1,60.82,23ZM37.1,21.63h23V5.79h-23Z" style="fill:#9b4dca"/><path d="M69.36,23a.68.68,0,0,1-.31-.08L60.5,18.66a.69.69,0,0,1-.38-.62V9.38a.71.71,0,0,1,.38-.63l8.55-4.29a.72.72,0,0,1,.68,0,.7.7,0,0,1,.33.6V22.33a.7.7,0,0,1-.33.6A.79.79,0,0,1,69.36,23Zm-7.84-5.42,7.14,3.58v-15L61.52,9.81Z" style="fill:#9b4dca"/></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 101.25 37.29"><title>logo</title><path d="M.38,30.29H1.62l2.11,3.82.7,1.45h.05c-.06-.71-.16-1.57-.16-2.32v-3H5.47v6.79H4.23L2.12,33.26l-.7-1.45h0c.06.72.16,1.54.16,2.3v3H.38Z" style="fill:#606c76"/><path d="M12,30.29h1.2v6.79H12Z" style="fill:#606c76"/><path d="M19.35,33.71c0-2.23,1.39-3.55,3.11-3.55a2.73,2.73,0,0,1,2,.86l-.65.78a1.76,1.76,0,0,0-1.29-.59c-1.1,0-1.9.93-1.9,2.46s.74,2.49,1.88,2.49a1.93,1.93,0,0,0,1.45-.7l.64.76a2.71,2.71,0,0,1-2.14,1C20.7,37.21,19.35,36,19.35,33.71Z" style="fill:#606c76"/><path d="M30.48,30.29h4.09v1H31.68V33h2.45v1H31.68v2h3v1H30.48Z" style="fill:#606c76"/><path d="M40.85,30.29h1.81A3,3,0,0,1,46,33.66c0,2.25-1.23,3.42-3.25,3.42H40.85Zm1.74,5.82c1.36,0,2.15-.78,2.15-2.45s-.79-2.4-2.15-2.4h-.53v4.85Z" style="fill:#606c76"/><path d="M52.14,30.29h2.17c1.4,0,2.42.43,2.42,1.67a1.52,1.52,0,0,1-.94,1.47v0a1.57,1.57,0,0,1,1.3,1.62c0,1.36-1.11,2-2.61,2H52.14Zm2.06,2.8c.95,0,1.35-.37,1.35-1s-.44-.9-1.32-.9h-.89v1.86Zm.16,3c1,0,1.55-.35,1.55-1.12s-.54-1-1.55-1h-1v2.15Z" style="fill:#606c76"/><path d="M62.92,36.4a.77.77,0,1,1,1.54,0,.77.77,0,1,1-1.54,0Z" style="fill:#606c76"/><path d="M70.41,33.66c0-2.2,1.23-3.5,3-3.5s3,1.31,3,3.5-1.22,3.55-3,3.55S70.41,35.86,70.41,33.66Zm4.75,0c0-1.53-.69-2.45-1.75-2.45s-1.76.92-1.76,2.45.69,2.5,1.76,2.5S75.16,35.18,75.16,33.66Z" style="fill:#606c76"/><path d="M82.56,30.29h2.29c1.42,0,2.5.5,2.5,2s-1.08,2.13-2.5,2.13H83.77v2.65H82.56Zm2.17,3.17c.93,0,1.44-.38,1.44-1.16s-.51-1-1.44-1h-1v2.21Zm-.1.64.87-.71,2.12,3.69H86.27Z" style="fill:#606c76"/><path d="M93.14,33.71a3.22,3.22,0,0,1,3.22-3.55,2.82,2.82,0,0,1,2,.86l-.65.78a1.85,1.85,0,0,0-1.37-.59c-1.2,0-2,.93-2,2.46s.72,2.49,2.08,2.49a1.54,1.54,0,0,0,1-.3V34.39H96.15v-1h2.36v3a3.07,3.07,0,0,1-2.17.81C94.51,37.21,93.14,36,93.14,33.71Z" style="fill:#606c76"/><path d="M14.89,26.42h-.15L.8,23.48a.72.72,0,0,1-.56-.69V2.39A.74.74,0,0,1,.5,1.84a.73.73,0,0,1,.59-.14L15,4.63a.7.7,0,0,1,.56.69v20.4a.7.7,0,0,1-.26.54A.66.66,0,0,1,14.89,26.42ZM1.64,22.22l12.55,2.64v-19L1.64,3.25Z" style="fill:#00a1cc"/><path d="M14.89,26.42a.65.65,0,0,1-.44-.16.67.67,0,0,1-.26-.54V5.32a.7.7,0,0,1,.55-.69l14-2.93a.7.7,0,0,1,.84.69v20.4a.71.71,0,0,1-.55.69L15,26.41Zm.7-20.54v19l12.54-2.64v-19ZM28.83,22.79h0Z" style="fill:#00a1cc"/><path d="M87,26.55a13.17,13.17,0,1,1,13.17-13.17A13.19,13.19,0,0,1,87,26.55ZM87,1.61A11.77,11.77,0,1,0,98.73,13.38,11.78,11.78,0,0,0,87,1.61Z" style="fill:#00a1cc"/><path d="M87,18.45A5.08,5.08,0,1,1,92,13.38,5.08,5.08,0,0,1,87,18.45ZM87,9.7a3.68,3.68,0,1,0,3.68,3.68A3.68,3.68,0,0,0,87,9.7Z" style="fill:#00a1cc"/><path d="M60,22.7H35.62a.71.71,0,0,1-.7-.7V4.76a.7.7,0,0,1,.7-.7H60a.7.7,0,0,1,.7.7V22A.7.7,0,0,1,60,22.7ZM36.32,21.3h23V5.46h-23Z" style="fill:#00a1cc"/><path d="M68.58,22.7a.68.68,0,0,1-.31-.08l-8.54-4.29a.7.7,0,0,1-.39-.62V9.05a.7.7,0,0,1,.39-.63l8.54-4.29a.7.7,0,0,1,1,.63V22a.68.68,0,0,1-.33.59A.7.7,0,0,1,68.58,22.7Zm-7.84-5.42,7.14,3.58v-15L60.74,9.48Z" style="fill:#00a1cc"/></svg>
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.9 KiB |
|
@ -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();
|
||||
|
|
|
@ -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,<svg xmlns="http://www.w3.org/2000/svg" height="14" viewBox="0 0 29 14" width="29"><path fill="#9b4dca" d="M9.37727 3.625l5.08154 6.93523L19.54036 3.625"/></svg>');
|
||||
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="14" viewBox="0 0 29 14" width="29"><path fill="#00a1cc" d="M9.37727 3.625l5.08154 6.93523L19.54036 3.625"/></svg>');
|
||||
}
|
||||
|
||||
textarea {
|
||||
|
@ -445,7 +445,7 @@ input[type='radio'] {
|
|||
}
|
||||
|
||||
a {
|
||||
color: #9b4dca;
|
||||
color: #00a1cc;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue