Browse Source

feat: show count info at login page

master
欧醚 3 years ago
parent
commit
41e4ecf04c
3 changed files with 23 additions and 41 deletions
  1. +4
    -0
      app.py
  2. +17
    -1
      gen_wechat_html.py
  3. +2
    -40
      static/login/index.html

+ 4
- 0
app.py View File

@ -104,6 +104,10 @@ def login_required(allow_guest=True):
def login():
return app.send_static_file('login/index.html')
@app.route('/pastExam/login/count-info.html')
def login_count_info():
return app.send_static_file('login/count-info.html')
@app.route('/pastExam/logout')
def logout():
session.pop('username', None)

+ 17
- 1
gen_wechat_html.py View File

@ -28,6 +28,19 @@ html_text = '''
</html>
'''
local_html_text = '''
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
</head>
<body style="font-size:22px;text-align:center">
<p>{nc}{np}<br></p>
</body>
</html>
'''
def check_and_update(last_number):
np = Paper.query.count()
if np != last_number:
@ -38,6 +51,9 @@ def check_and_update(last_number):
ssh.load_system_host_keys()
ssh.connect(host, username=username)
with open('static/login/count-info.html', 'w') as f:
f.write(local_html_text.format(nc=nc, np=np, target_host=target_host))
with SCPClient(ssh.get_transport()) as scp:
fl = io.BytesIO()
fl.write(bytes(html_text.format(time=t.strftime("%Y-%m-%d %H:%M"), nc=nc, np=np, target_host=target_host), encoding='utf-8'))
@ -47,7 +63,7 @@ def check_and_update(last_number):
return np
n = 0
n = check_and_update(0)
while True:
try:
print(str(datetime.now()), 'start ------')

+ 2
- 40
static/login/index.html View File

@ -45,29 +45,6 @@
color: inherit;
text-decoration: underline;
}
.wechat-mask {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
text-align: center;
padding-top: 50px;
background: #000e;
display: none;
}
.wechat-mask p {
position: relative;
top: 36%;
transform: translateY(-50%);
color: white;
font-size: 28px;;
font-family: 'Noto Serif SC', serif;
font-weight: 700;
}
</style>
</head>
@ -93,17 +70,13 @@
<div class="text-center">
<p>消除信息不对等,追求更有意义的评价体系</p>
</div>
<iframe src="count-info.html" style="border:none;width:100%;height:200px"></iframe>
</div>
<div class="wechat-mask">
<p>检测到处于非规范环境<br>(如微信内置浏览器)<br><br>
如需使用请点击右上角<br>“在浏览器中打开”<br><br>
如需在微信中传播分享<br>可直接分享本页面
</p>
</body>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script>
function load_guest_form() {
var ifr = $('iframe');
var ifr = $('.guest-login-form');
if(ifr.is(':visible')) {
ifr.hide();
return;
@ -114,17 +87,6 @@
ifr.attr("src", "guest/");
ifr.show();
}
$(document).ready(function () {
if(navigator.userAgent.search('MicroMessenger') == -1) {
if(window.location.host == 'closed.social') {
window.location.host = '_.closed.social:9443';
}
}
else {
$('.wechat-mask').show();
}
});
</script>
</html>

Loading…
Cancel
Save