feat/add show images feat
This commit is contained in:
parent
d77f15df8e
commit
20be7160bd
14 changed files with 62 additions and 17 deletions
1
BDSM/static/css/lightbox.min.css
vendored
Normal file
1
BDSM/static/css/lightbox.min.css
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.lb-loader,.lightbox{text-align:center;line-height:0;position:absolute;left:0}body.lb-disable-scrolling{overflow:hidden}.lightboxOverlay{position:absolute;top:0;left:0;z-index:9999;background-color:#000;filter:alpha(Opacity=80);opacity:.8;display:none}.lightbox{width:100%;z-index:10000;font-weight:400;outline:0}.lightbox .lb-image{display:block;height:auto;max-width:inherit;max-height:none;border-radius:3px;border:4px solid #fff}.lightbox a img{border:none}.lb-outerContainer{position:relative;width:250px;height:250px;margin:0 auto;border-radius:4px;background-color:#fff}.lb-outerContainer:after{content:"";display:table;clear:both}.lb-loader{top:43%;height:25%;width:100%}.lb-cancel{display:block;width:32px;height:32px;margin:0 auto;background:url(../images/loading.gif) no-repeat}.lb-nav{position:absolute;top:0;left:0;height:100%;width:100%;z-index:10}.lb-container>.nav{left:0}.lb-nav a{outline:0;background-image:url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}.lb-next,.lb-prev{height:100%;cursor:pointer;display:block}.lb-nav a.lb-prev{width:34%;left:0;float:left;background:url(../images/prev.png) left 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-prev:hover{filter:alpha(Opacity=100);opacity:1}.lb-nav a.lb-next{width:64%;right:0;float:right;background:url(../images/next.png) right 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-next:hover{filter:alpha(Opacity=100);opacity:1}.lb-dataContainer{margin:0 auto;padding-top:5px;width:100%;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.lb-dataContainer:after{content:"";display:table;clear:both}.lb-data{padding:0 4px;color:#ccc}.lb-data .lb-details{width:85%;float:left;text-align:left;line-height:1.1em}.lb-data .lb-caption{font-size:13px;font-weight:700;line-height:1em}.lb-data .lb-caption a{color:#4ae}.lb-data .lb-number{display:block;clear:left;padding-bottom:1em;font-size:12px;color:#999}.lb-data .lb-close{display:block;float:right;width:30px;height:30px;background:url(../images/close.png) top right no-repeat;text-align:right;outline:0;filter:alpha(Opacity=70);opacity:.7;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.lb-data .lb-close:hover{cursor:pointer;filter:alpha(Opacity=100);opacity:1}
|
BIN
BDSM/static/images/close.png
Normal file
BIN
BDSM/static/images/close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 280 B |
1
BDSM/static/images/lightbox.min.map
Normal file
1
BDSM/static/images/lightbox.min.map
Normal file
File diff suppressed because one or more lines are too long
BIN
BDSM/static/images/loading.gif
Normal file
BIN
BDSM/static/images/loading.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
BIN
BDSM/static/images/next.png
Normal file
BIN
BDSM/static/images/next.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
BDSM/static/images/prev.png
Normal file
BIN
BDSM/static/images/prev.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
2
BDSM/static/js/jquery-3.6.1.min.js
vendored
Normal file
2
BDSM/static/js/jquery-3.6.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
15
BDSM/static/js/lightbox.min.js
vendored
Normal file
15
BDSM/static/js/lightbox.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
BDSM/static/js/lightbox.min.map
Normal file
1
BDSM/static/js/lightbox.min.map
Normal file
File diff suppressed because one or more lines are too long
|
@ -10,10 +10,12 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='/css/all.min.css') }}" type="text/css">
|
<link rel="stylesheet" href="{{ url_for('static', filename='/css/all.min.css') }}" type="text/css">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='/css/bootstrap.min.css') }}" type="text/css">
|
<link rel="stylesheet" href="{{ url_for('static', filename='/css/bootstrap.min.css') }}" type="text/css">
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='/css/lightbox.min.css') }}" type="text/css">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='/css/style.css') }}" type="text/css">
|
<link rel="stylesheet" href="{{ url_for('static', filename='/css/style.css') }}" type="text/css">
|
||||||
<script src="{{ url_for('static', filename='/js/bootstrap.bundle.min.js') }}"
|
<script src="{{ url_for('static', filename='/js/jquery-3.6.1.min.js') }}" crossorigin="anonymous"></script>
|
||||||
crossorigin="anonymous"></script>
|
<script src="{{ url_for('static', filename='/js/bootstrap.bundle.min.js') }}" crossorigin="anonymous"></script>
|
||||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
<script src="{{ url_for('static', filename='/js/lightbox.min.js') }}" crossorigin="anonymous"></script>
|
||||||
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>设置</h3>
|
<h3>设置</h3>
|
||||||
<form method="post" class="form-horizontal" role="form">
|
<form method="post" class="form-horizontal" role="form">
|
||||||
{% if settings is defined %}
|
{% if settings != None %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label">用户名</label>
|
<label class="col-sm-2 control-label">用户名</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
|
|
|
@ -23,6 +23,23 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{{ toot.content|safe }}
|
{{ toot.content|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="toot-media">
|
||||||
|
<div class="row">
|
||||||
|
{% if toot.medias %}
|
||||||
|
|
||||||
|
{% for media in toot.medias%}
|
||||||
|
{% if media.type == 'image' %}
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<a class="media-gallery__item-thumbnail"
|
||||||
|
href="{{ media.url }}" target="_blank" rel="noopener noreferrer" data-lightbox="{{ toot.id }}" data-title="{{ media.description }}">
|
||||||
|
<img src="{{ media.url }}" class="w-100 shadow-1-strong rounded" alt="{{ media.description }}"/></a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor%}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="icon-bar">
|
<div class="icon-bar">
|
||||||
{% if toot.replies_count > 1 %}
|
{% if toot.replies_count > 1 %}
|
||||||
<span><i class="fa-solid fa-reply-all"></i>{{ toot.replies_count }}</span>
|
<span><i class="fa-solid fa-reply-all"></i>{{ toot.replies_count }}</span>
|
||||||
|
|
14
BDSM/toot.py
14
BDSM/toot.py
|
@ -80,9 +80,9 @@ def archive_toot(url):
|
||||||
content = status['content']
|
content = status['content']
|
||||||
|
|
||||||
if status['media_attachments'] != []:
|
if status['media_attachments'] != []:
|
||||||
media_list = []
|
media_list = ""
|
||||||
for media_dict in status['media_attachments']:
|
for media_dict in status['media_attachments']:
|
||||||
media_list.append(media_dict['id'])
|
media_list += str(media_dict['id']) + ","
|
||||||
|
|
||||||
media = Media(id=media_dict['id'], type=media_dict['type'], url=media_dict['url'],
|
media = Media(id=media_dict['id'], type=media_dict['type'], url=media_dict['url'],
|
||||||
remote_url=media_dict['remote_url'], description=media_dict['description'])
|
remote_url=media_dict['remote_url'], description=media_dict['description'])
|
||||||
|
@ -91,8 +91,7 @@ def archive_toot(url):
|
||||||
# VALUES (?,?,?,?,?)''',(media_dict['id'], media_dict['type'], media_dict['url'], \
|
# VALUES (?,?,?,?,?)''',(media_dict['id'], media_dict['type'], media_dict['url'], \
|
||||||
# media_dict['remote_url'], media_dict['description']))
|
# media_dict['remote_url'], media_dict['description']))
|
||||||
else:
|
else:
|
||||||
media_list = []
|
media_list = ""
|
||||||
media_list = str(media_list)
|
|
||||||
|
|
||||||
spoiler_text = status['spoiler_text']
|
spoiler_text = status['spoiler_text']
|
||||||
|
|
||||||
|
@ -112,10 +111,10 @@ def archive_toot(url):
|
||||||
poll_id = None
|
poll_id = None
|
||||||
|
|
||||||
if status['emojis'] != []:
|
if status['emojis'] != []:
|
||||||
emoji_list = []
|
emoji_list = ""
|
||||||
for emoji in status['emojis']:
|
for emoji in status['emojis']:
|
||||||
shortcode = emoji['shortcode']
|
shortcode = emoji['shortcode']
|
||||||
emoji_list.append(shortcode)
|
emoji_list += shortcode + ","
|
||||||
counter = ':' + shortcode + ':'
|
counter = ':' + shortcode + ':'
|
||||||
count = content.count(counter)
|
count = content.count(counter)
|
||||||
|
|
||||||
|
@ -129,8 +128,7 @@ def archive_toot(url):
|
||||||
data.count += count
|
data.count += count
|
||||||
# cur.execute("UPDATE EMOJI SET count = ? WHERE shortcode = ?",(count, shortcode))
|
# cur.execute("UPDATE EMOJI SET count = ? WHERE shortcode = ?",(count, shortcode))
|
||||||
else:
|
else:
|
||||||
emoji_list = []
|
emoji_list = ""
|
||||||
emoji_list = str(emoji_list)
|
|
||||||
|
|
||||||
if status['tags'] != []:
|
if status['tags'] != []:
|
||||||
for tag in status['tags']:
|
for tag in status['tags']:
|
||||||
|
|
|
@ -3,7 +3,7 @@ import os
|
||||||
|
|
||||||
from flask import render_template, request, url_for, redirect, flash
|
from flask import render_template, request, url_for, redirect, flash
|
||||||
from BDSM import app, db
|
from BDSM import app, db
|
||||||
from BDSM.models import Settings, Toot
|
from BDSM.models import Media, Settings, Toot
|
||||||
from BDSM.toot import app_register, archive_toot
|
from BDSM.toot import app_register, archive_toot
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
|
|
||||||
|
@ -17,6 +17,16 @@ def index():
|
||||||
if toot.content == None:
|
if toot.content == None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if toot.media_list != "":
|
||||||
|
toot.medias = []
|
||||||
|
#media_list "1111,2222,333,"
|
||||||
|
media_list = toot.media_list[:-1].split(",")
|
||||||
|
|
||||||
|
for media_id in media_list:
|
||||||
|
media = Media.query.get(int(media_id))
|
||||||
|
if media != None:
|
||||||
|
toot.medias.append(media)
|
||||||
|
|
||||||
toots.append(toot)
|
toots.append(toot)
|
||||||
|
|
||||||
return render_template('view.html', toots=toots, pagination=toots_)
|
return render_template('view.html', toots=toots, pagination=toots_)
|
||||||
|
@ -45,11 +55,9 @@ def settings():
|
||||||
return redirect(url_for('settings'))
|
return redirect(url_for('settings'))
|
||||||
|
|
||||||
settings = Settings.query.first()
|
settings = Settings.query.first()
|
||||||
if settings == None:
|
|
||||||
flash('请输入用户名')
|
|
||||||
return render_template('settings.html')
|
|
||||||
|
|
||||||
app_init = os.path.isfile('pyBDSM_clientcred.secret') and os.path.isfile('user.secret')
|
app_init = os.path.isfile('pyBDSM_clientcred.secret') and os.path.isfile('user.secret')
|
||||||
|
if settings == None:
|
||||||
|
flash('请输入相关设置!')
|
||||||
|
|
||||||
return render_template('settings.html',settings=settings, app_init=app_init)
|
return render_template('settings.html',settings=settings, app_init=app_init)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue