Compare commits
2 Commits
master
...
Bug566-Sun
| Author | SHA1 | Date |
|---|---|---|
|
|
de5ffccd85 | |
|
|
8e8de286e0 |
|
|
@ -18,7 +18,7 @@ picked from articles selected for him to read according his vocabulary level. E
|
|||
|
||||
`python3 main.py`
|
||||
|
||||
Make sure you have put the SQLite database file in the path `app/db` (see below).
|
||||
Make sure you have put the SQLite database file in the path `app/static` (see below).
|
||||
|
||||
|
||||
## Run it as a Docker container
|
||||
|
|
@ -214,5 +214,5 @@ Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=215
|
|||
Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=489
|
||||
|
||||
|
||||
*Last modified on 2026-03-12*
|
||||
*Last modified on 2023-01-30*
|
||||
|
||||
|
|
|
|||
|
|
@ -9,32 +9,10 @@ from flask import Flask, request, redirect, render_template, url_for, session, a
|
|||
from difficulty import get_difficulty_level_for_user, text_difficulty_level, user_difficulty_level
|
||||
from model.article import get_all_articles, get_article_by_id, get_number_of_articles
|
||||
import logging
|
||||
import re
|
||||
|
||||
path_prefix = './'
|
||||
db_path_prefix = './db/' # comment this line in deployment
|
||||
oxford_words_path='./db/oxford_words.txt'
|
||||
|
||||
def count_oxford_words(text, oxford_words):
|
||||
words = re.findall(r'\b\w+\b', text.lower())
|
||||
total_words = len(words)
|
||||
oxford_word_count = sum(1 for word in words if word in oxford_words)
|
||||
return oxford_word_count, total_words
|
||||
|
||||
def calculate_ratio(oxford_word_count, total_words):
|
||||
if total_words == 0:
|
||||
return 0
|
||||
return oxford_word_count / total_words
|
||||
|
||||
def load_oxford_words(file_path):
|
||||
oxford_words = {}
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
for line in file:
|
||||
parts = line.strip().split()
|
||||
word = parts[0]
|
||||
pos = parts[1]
|
||||
level = parts[2]
|
||||
oxford_words[word] = {'pos': pos, 'level': level}
|
||||
return oxford_words
|
||||
|
||||
def total_number_of_essays():
|
||||
return get_number_of_articles()
|
||||
|
|
@ -106,11 +84,8 @@ def get_today_article(user_word_list, visited_articles):
|
|||
text_level = text_difficulty_level(d['text'], d3)
|
||||
result_of_generate_article = "found"
|
||||
|
||||
today_article = {}
|
||||
today_article = None
|
||||
if d:
|
||||
oxford_words = load_oxford_words(oxford_words_path)
|
||||
oxford_word_count, total_words = count_oxford_words(d['text'],oxford_words)
|
||||
ratio = calculate_ratio(oxford_word_count,total_words)
|
||||
today_article = {
|
||||
"user_level": '%4.1f' % user_level,
|
||||
"text_level": '%4.1f' % text_level,
|
||||
|
|
@ -119,8 +94,7 @@ def get_today_article(user_word_list, visited_articles):
|
|||
"article_body": get_article_body(d['text']),
|
||||
"source": d["source"],
|
||||
"question": get_question_part(d['question']),
|
||||
"answer": get_answer_part(d['question']),
|
||||
"ratio" : ratio
|
||||
"answer": get_answer_part(d['question'])
|
||||
}
|
||||
|
||||
return visited_articles, today_article, result_of_generate_article
|
||||
|
|
|
|||
65
app/Login.py
65
app/Login.py
|
|
@ -1,8 +1,6 @@
|
|||
import hashlib
|
||||
import string
|
||||
from datetime import datetime, timedelta
|
||||
import unicodedata
|
||||
|
||||
|
||||
def md5(s):
|
||||
'''
|
||||
|
|
@ -13,13 +11,16 @@ def md5(s):
|
|||
h = hashlib.md5(s.encode(encoding='utf-8'))
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
# import model.user after the defination of md5(s) to avoid circular import
|
||||
from model.user import get_user_by_username, insert_user, update_password_by_username
|
||||
|
||||
path_prefix = '/var/www/wordfreq/wordfreq/'
|
||||
path_prefix = './' # comment this line in deployment
|
||||
|
||||
def verify_pass(newpass,oldpass):
|
||||
if(newpass==oldpass):
|
||||
return True
|
||||
|
||||
|
||||
def verify_user(username, password):
|
||||
user = get_user_by_username(username)
|
||||
|
|
@ -29,7 +30,7 @@ def verify_user(username, password):
|
|||
|
||||
def add_user(username, password):
|
||||
start_date = datetime.now().strftime('%Y%m%d')
|
||||
expiry_date = (datetime.now() + timedelta(days=30)).strftime('%Y%m%d') # will expire after 30 days
|
||||
expiry_date = (datetime.now() + timedelta(days=30)).strftime('%Y%m%d') # will expire after 30 days
|
||||
# 将用户名和密码一起加密,以免暴露不同用户的相同密码
|
||||
password = md5(username + password)
|
||||
insert_user(username=username, password=password, start_date=start_date, expiry_date=expiry_date)
|
||||
|
|
@ -49,12 +50,12 @@ def change_password(username, old_password, new_password):
|
|||
:return: 修改成功:True 否则:False
|
||||
'''
|
||||
if not verify_user(username, old_password): # 旧密码错误
|
||||
return {'error':'Old password is wrong.', 'username':username}
|
||||
return False
|
||||
# 将用户名和密码一起加密,以免暴露不同用户的相同密码
|
||||
if new_password == old_password: #新旧密码一致
|
||||
return {'error':'New password cannot be the same as the old password.', 'username':username}
|
||||
if verify_pass(new_password,old_password): #新旧密码一致
|
||||
return False
|
||||
update_password_by_username(username, new_password)
|
||||
return {'success':'Password changed', 'username':username}
|
||||
return True
|
||||
|
||||
|
||||
def get_expiry_date(username):
|
||||
|
|
@ -64,64 +65,30 @@ def get_expiry_date(username):
|
|||
else:
|
||||
return user.expiry_date
|
||||
|
||||
|
||||
class UserName:
|
||||
def __init__(self, username):
|
||||
self.username = username
|
||||
|
||||
def contains_chinese(self):
|
||||
for char in self.username:
|
||||
# Check if the character is in the CJK (Chinese, Japanese, Korean) Unicode block
|
||||
if unicodedata.name(char).startswith('CJK UNIFIED IDEOGRAPH'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def validate(self):
|
||||
if len(self.username) > 20:
|
||||
return f'{self.username} is too long. The user name cannot exceed 20 characters.'
|
||||
if self.username.startswith('.'): # a user name must not start with a dot
|
||||
if self.username.startswith('.'): # a user name must not start with a dot
|
||||
return 'Period (.) is not allowed as the first letter in the user name.'
|
||||
if ' ' in self.username: # a user name must not include a whitespace
|
||||
if ' ' in self.username: # a user name must not include a whitespace
|
||||
return 'Whitespace is not allowed in the user name.'
|
||||
for c in self.username: # a user name must not include special characters, except non-leading periods or underscores
|
||||
for c in self.username: # a user name must not include special characters, except non-leading periods or underscores
|
||||
if c in string.punctuation and c != '.' and c != '_':
|
||||
return f'{c} is not allowed in the user name.'
|
||||
if self.username in ['signup', 'login', 'logout', 'reset', 'mark', 'back', 'unfamiliar', 'familiar', 'del',
|
||||
'admin']:
|
||||
if self.username in ['signup', 'login', 'logout', 'reset', 'mark', 'back', 'unfamiliar', 'familiar', 'del', 'admin']:
|
||||
return 'You used a restricted word as your user name. Please come up with a better one.'
|
||||
if self.contains_chinese():
|
||||
return 'Chinese characters are not allowed in the user name.'
|
||||
return 'OK'
|
||||
|
||||
|
||||
class Password:
|
||||
def __init__(self, password):
|
||||
self.password = password
|
||||
|
||||
def contains_chinese(self):
|
||||
for char in self.password:
|
||||
# Check if the character is in the CJK (Chinese, Japanese, Korean) Unicode block
|
||||
if unicodedata.name(char).startswith('CJK UNIFIED IDEOGRAPH'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def validate(self):
|
||||
if len(self.password) < 4:
|
||||
return 'Password must be at least 4 characters long.'
|
||||
if ' ' in self.password:
|
||||
return 'Password cannot contain spaces.'
|
||||
if self.contains_chinese():
|
||||
return 'Chinese characters are not allowed in the password.'
|
||||
return 'OK'
|
||||
|
||||
|
||||
class WarningMessage:
|
||||
def __init__(self, s, type='username'):
|
||||
def __init__(self, s):
|
||||
self.s = s
|
||||
self.type = type
|
||||
|
||||
def __str__(self):
|
||||
if self.type == 'username':
|
||||
return UserName(self.s).validate()
|
||||
if self.type == 'password':
|
||||
return Password(self.s).validate()
|
||||
return UserName(self.s).validate()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from flask import *
|
|||
from markupsafe import escape
|
||||
from Login import check_username_availability, verify_user, add_user, get_expiry_date, change_password, WarningMessage
|
||||
|
||||
|
||||
# 初始化蓝图
|
||||
accountService = Blueprint("accountService", __name__)
|
||||
|
||||
|
|
@ -43,6 +44,7 @@ def signup():
|
|||
return jsonify({'status': '1'})
|
||||
|
||||
|
||||
|
||||
@accountService.route("/login", methods=['GET', 'POST'])
|
||||
def login():
|
||||
'''
|
||||
|
|
@ -58,48 +60,17 @@ def login():
|
|||
username = escape(request.form['username'])
|
||||
password = escape(request.form['password'])
|
||||
verified = verify_user(username, password)
|
||||
#读black.txt文件判断用户是否在黑名单中
|
||||
with open('black.txt') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if username == line:
|
||||
return jsonify({'status': '5'})
|
||||
with open('black.txt', 'a+') as f:
|
||||
f.seek(0)
|
||||
lines = f.readlines()
|
||||
line=[]
|
||||
for i in lines:
|
||||
line.append(i.strip('\n'))
|
||||
#读black.txt文件判断用户是否在黑名单中
|
||||
if verified and username not in line: #TODO: 一个用户名是另外一个用户名的子串怎么办?
|
||||
# 登录成功,写入session
|
||||
session['logged_in'] = True
|
||||
session[username] = username
|
||||
session['username'] = username
|
||||
user_expiry_date = get_expiry_date(username)
|
||||
session['expiry_date'] = user_expiry_date
|
||||
session['visited_articles'] = None
|
||||
f.close()
|
||||
return jsonify({'status': '1'})
|
||||
elif verified==0 and password!='黑名单':
|
||||
#输入错误密码次数小于5次
|
||||
return jsonify({'status': '0'})
|
||||
else:
|
||||
#输入错误密码次数达到5次
|
||||
with open('black.txt', 'a+') as f:
|
||||
f.seek(0)
|
||||
lines = f.readlines()
|
||||
line = []
|
||||
for i in lines:
|
||||
line.append(i.strip('\n'))
|
||||
if username in line:
|
||||
return jsonify({'status': '5'})
|
||||
else:
|
||||
f.write(username)
|
||||
f.write('\n')
|
||||
return jsonify({'status': '5'})
|
||||
|
||||
|
||||
if verified:
|
||||
# 登录成功,写入session
|
||||
session['logged_in'] = True
|
||||
session[username] = username
|
||||
session['username'] = username
|
||||
user_expiry_date = get_expiry_date(username)
|
||||
session['expiry_date'] = user_expiry_date
|
||||
session['visited_articles'] = None
|
||||
return jsonify({'status': '1'})
|
||||
else:
|
||||
return jsonify({'status': '0'})
|
||||
|
||||
|
||||
@accountService.route("/logout", methods=['GET', 'POST'])
|
||||
|
|
@ -113,7 +84,6 @@ def logout():
|
|||
return redirect(url_for('mainpage'))
|
||||
|
||||
|
||||
|
||||
@accountService.route("/reset", methods=['GET', 'POST'])
|
||||
def reset():
|
||||
'''
|
||||
|
|
@ -133,7 +103,9 @@ def reset():
|
|||
# POST请求用于提交修改后信息
|
||||
old_password = escape(request.form['old-password'])
|
||||
new_password = escape(request.form['new-password'])
|
||||
result = change_password(username, old_password, new_password)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
flag = change_password(username, old_password, new_password) # flag表示是否修改成功
|
||||
if flag:
|
||||
session['logged_in'] = False
|
||||
return jsonify({'status':'1'}) # 修改成功
|
||||
else:
|
||||
return jsonify({'status':'2'}) # 修改失败
|
||||
|
|
|
|||
|
|
@ -79,18 +79,18 @@ def article():
|
|||
"username": session.get("username"),
|
||||
}
|
||||
|
||||
if request.method == "POST":
|
||||
|
||||
if request.method == "GET":
|
||||
try:
|
||||
delete_id = int(request.args.get("delete_id", 0))
|
||||
except:
|
||||
return "Delete article ID must be integer!"
|
||||
if delete_id: # delete article
|
||||
delete_article_by_id(delete_id)
|
||||
_update_context()
|
||||
|
||||
elif request.method == "POST":
|
||||
data = request.form
|
||||
|
||||
if "delete_id" in data:
|
||||
try:
|
||||
delete_id = int(data["delete_id"]) # 转成int型
|
||||
delete_article_by_id(delete_id) # 根据id删除article
|
||||
flash(f'Article ID {delete_id} deleted successfully.') # 刷新页首提示语
|
||||
_update_context()
|
||||
except ValueError:
|
||||
flash('Invalid article ID for deletion.') # 刷新页首提示语
|
||||
|
||||
content = data.get("content", "")
|
||||
source = data.get("source", "")
|
||||
question = data.get("question", "")
|
||||
|
|
@ -99,9 +99,9 @@ def article():
|
|||
if level not in ['1', '2', '3', '4']:
|
||||
return "Level must be between 1 and 4."
|
||||
add_article(content, source, level, question)
|
||||
_update_context()
|
||||
title = content.split('\n')[0]
|
||||
flash(f'Article added. Title: {title}')
|
||||
_update_context() # 这行应在flash之后 否则会发生新建的文章即点即删
|
||||
|
||||
return render_template("admin_manage_article.html", **context)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
from flask import *
|
||||
from flask_httpauth import HTTPTokenAuth
|
||||
from Article import load_freq_history
|
||||
|
||||
path_prefix = '/var/www/wordfreq/wordfreq/'
|
||||
path_prefix = './' # comment this line in deployment
|
||||
|
||||
apiService = Blueprint('site',__name__)
|
||||
|
||||
auth = HTTPTokenAuth(scheme='Bearer')
|
||||
|
||||
tokens = {
|
||||
"token": "token",
|
||||
"secret-token": "lanhui" # token, username
|
||||
}
|
||||
|
||||
|
||||
@auth.verify_token
|
||||
def verify_token(token):
|
||||
if token in tokens:
|
||||
return tokens[token]
|
||||
|
||||
|
||||
@apiService.route('/api/mywords') # HTTPie usage: http -A bearer -a secret-token http://127.0.0.1:5000/api/mywords
|
||||
@auth.login_required
|
||||
def show():
|
||||
username = auth.current_user()
|
||||
word_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
|
||||
d = load_freq_history(word_freq_record)
|
||||
return jsonify(d)
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
hsy
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import pickle
|
||||
import math
|
||||
from wordfreqCMD import remove_punctuation, freq, sort_in_descending_order, sort_in_ascending_order, map_percentages_to_levels
|
||||
from wordfreqCMD import remove_punctuation, freq, sort_in_descending_order, sort_in_ascending_order
|
||||
import snowballstemmer
|
||||
|
||||
|
||||
|
|
@ -94,58 +94,30 @@ def revert_dict(d):
|
|||
return d2
|
||||
|
||||
|
||||
def user_difficulty_level(d_user, d, calc_func=0):
|
||||
'''
|
||||
two ways to calculate difficulty_level
|
||||
set calc_func!=0 to use sqrt, otherwise use weighted average
|
||||
'''
|
||||
if calc_func != 0:
|
||||
# calculation function 1: sqrt
|
||||
d_user2 = revert_dict(d_user) # key is date, and value is a list of words added in that date
|
||||
geometric = 0
|
||||
count = 0
|
||||
for date in sorted(d_user2.keys(),
|
||||
reverse=True): # most recently added words are more important while determining user's level
|
||||
lst = d_user2[date] # a list of words
|
||||
lst2 = [] # a list of tuples, (word, difficulty level)
|
||||
for word in lst:
|
||||
if word in d:
|
||||
lst2.append((word, d[word]))
|
||||
|
||||
lst3 = sort_in_ascending_order(lst2) # easiest tuple first
|
||||
# print(lst3)
|
||||
for t in lst3:
|
||||
word = t[0]
|
||||
hard = t[1]
|
||||
# print('WORD %s HARD %4.2f' % (word, hard))
|
||||
geometric = geometric + math.log(hard)
|
||||
count += 1
|
||||
return math.exp(geometric / max(count, 1))
|
||||
|
||||
# calculation function 2: weighted average
|
||||
def user_difficulty_level(d_user, d):
|
||||
d_user2 = revert_dict(d_user) # key is date, and value is a list of words added in that date
|
||||
count = {} # number of all kinds of words
|
||||
percentages = {} # percentages of all kinds of difficulties
|
||||
total = 0 # total words
|
||||
for date in d_user2.keys():
|
||||
count = 0
|
||||
geometric = 1
|
||||
for date in sorted(d_user2.keys(),
|
||||
reverse=True): # most recently added words are more important while determining user's level
|
||||
lst = d_user2[date] # a list of words
|
||||
lst2 = [] # a list of tuples, (word, difficulty level)
|
||||
for word in lst:
|
||||
if word in d:
|
||||
if d[word] not in count:
|
||||
count[d[word]] = 0
|
||||
count[d[word]] += 1
|
||||
total += 1
|
||||
lst2.append((word, d[word]))
|
||||
|
||||
if total == 0:
|
||||
return 1
|
||||
for k in count.keys():
|
||||
percentages[k] = count[k] / total
|
||||
weight = map_percentages_to_levels(percentages)
|
||||
sum = 0
|
||||
for k in weight.keys():
|
||||
sum += weight[k] * k
|
||||
return sum
|
||||
lst3 = sort_in_ascending_order(lst2) # easiest tuple first
|
||||
# print(lst3)
|
||||
for t in lst3:
|
||||
word = t[0]
|
||||
hard = t[1]
|
||||
# print('WORD %s HARD %4.2f' % (word, hard))
|
||||
geometric = geometric * (hard)
|
||||
count += 1
|
||||
if count >= 10:
|
||||
return geometric ** (1 / count)
|
||||
|
||||
return geometric ** (1 / max(count, 1))
|
||||
|
||||
|
||||
def text_difficulty_level(s, d):
|
||||
|
|
|
|||
44
app/main.py
44
app/main.py
|
|
@ -2,19 +2,15 @@
|
|||
# Copyright 2019 (C) Hui Lan <hui.lan@cantab.net>
|
||||
# Written permission must be obtained from the author for commercial uses.
|
||||
###########################################################################
|
||||
from flask import abort, jsonify
|
||||
from flask import abort
|
||||
from markupsafe import escape
|
||||
from collections import Counter
|
||||
from Login import *
|
||||
from Article import *
|
||||
import Yaml
|
||||
from user_service import userService
|
||||
from account_service import accountService
|
||||
from admin_service import adminService, ADMIN_NAME
|
||||
from api_service import apiService
|
||||
import os
|
||||
from translate import *
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.urandom(32)
|
||||
|
|
@ -23,7 +19,6 @@ app.secret_key = os.urandom(32)
|
|||
app.register_blueprint(userService)
|
||||
app.register_blueprint(accountService)
|
||||
app.register_blueprint(adminService)
|
||||
app.register_blueprint(apiService)
|
||||
|
||||
path_prefix = '/var/www/wordfreq/wordfreq/'
|
||||
path_prefix = './' # comment this line in deployment
|
||||
|
|
@ -59,12 +54,6 @@ def appears_in_test(word, d):
|
|||
else:
|
||||
return ','.join(d[word])
|
||||
|
||||
|
||||
def good_word(word):
|
||||
return len(word) < len('Pneumonoultramicroscopicsilicovolcanoconiosis') \
|
||||
and Counter(word).most_common(1)[0][1] <= 4
|
||||
|
||||
|
||||
@app.route("/mark", methods=['GET', 'POST'])
|
||||
def mark_word():
|
||||
'''
|
||||
|
|
@ -90,23 +79,10 @@ def mainpage():
|
|||
根据GET或POST方法来返回不同的主界面
|
||||
:return: 主界面
|
||||
'''
|
||||
|
||||
article_text = get_all_articles()
|
||||
texts = [item['text'] for item in article_text]
|
||||
oxford_words = load_oxford_words(oxford_words_path)
|
||||
|
||||
# 提取所有单词
|
||||
all_words = []
|
||||
for text in texts:
|
||||
words = re.findall(r'\b\w+\b', text.lower())
|
||||
all_words.extend(words)
|
||||
oxford_word_count = sum(1 for word in all_words if word in oxford_words)
|
||||
ratio = calculate_ratio(oxford_word_count, len(all_words))
|
||||
|
||||
if request.method == 'POST': # when we submit a form
|
||||
content = escape(request.form['content'])
|
||||
f = WordFreq(content)
|
||||
lst = [ t for t in f.get_freq() if good_word(t[0]) ] # only keep normal words
|
||||
lst = f.get_freq()
|
||||
# save history
|
||||
d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
|
||||
lst_history = pickle_idea.dict2lst(d)
|
||||
|
|
@ -126,17 +102,7 @@ def mainpage():
|
|||
d_len=d_len,
|
||||
lst=lst,
|
||||
yml=Yaml.yml,
|
||||
number_of_essays=number_of_essays,
|
||||
ratio = ratio)
|
||||
|
||||
@app.route("/translate", methods=['POST'])
|
||||
def translate_word():
|
||||
data = request.get_json()
|
||||
word = data.get('word', '')
|
||||
from_lang = data.get('from_lang', 'en') # 假设默认源语言是英语
|
||||
to_lang = data.get('to_lang', 'zh') # 假设默认目标语言是中文
|
||||
result = translate(word, from_lang, to_lang)
|
||||
return jsonify({'translation': result})
|
||||
number_of_essays=number_of_essays)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
@ -144,8 +110,8 @@ if __name__ == '__main__':
|
|||
运行程序
|
||||
'''
|
||||
# app.secret_key = os.urandom(16)
|
||||
app.run(debug=True, port=5000)
|
||||
# app.run(debug=True)
|
||||
# app.run(debug=False, port='6000')
|
||||
app.run(debug=True)
|
||||
# app.run(debug=True, port='6000')
|
||||
# app.run(host='0.0.0.0', debug=True, port='6000')
|
||||
# print(mod5('123'))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
# Purpose: dictionary & pickle as a simple means of database.
|
||||
# Task: incorporate the functions into wordfreqCMD.py such that it will also show cumulative frequency.
|
||||
|
||||
import os
|
||||
import pickle
|
||||
from datetime import datetime
|
||||
|
||||
|
|
@ -56,13 +55,11 @@ def save_frequency_to_pickle(d, pickle_fname):
|
|||
f.close()
|
||||
|
||||
def unfamiliar(path,word):
|
||||
if not os.path.exists(path):
|
||||
return None
|
||||
with open(path,"rb") as f:
|
||||
dic = pickle.load(f)
|
||||
dic[word] += [datetime.now().strftime('%Y%m%d%H%M')]
|
||||
with open(path,"wb") as fp:
|
||||
pickle.dump(dic,fp)
|
||||
f = open(path,"rb")
|
||||
dic = pickle.load(f)
|
||||
dic[word] += [datetime.now().strftime('%Y%m%d%H%M')]
|
||||
fp = open(path,"wb")
|
||||
pickle.dump(dic,fp)
|
||||
|
||||
def familiar(path,word):
|
||||
f = open(path,"rb")
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ def load_record(pickle_fname):
|
|||
|
||||
def save_frequency_to_pickle(d, pickle_fname):
|
||||
f = open(pickle_fname, 'wb')
|
||||
exclusion_lst = ['one', 'no', 'has', 'had', 'do', 'that', 'have', 'by', 'not', 'but', 'we', 'this', 'my', 'him', 'so', 'or', 'as', 'are', 'it', 'from', 'with', 'be', 'can', 'for', 'an', 'if', 'who', 'whom', 'whose', 'which', 'the', 'to', 'a', 'of', 'and', 'you', 'i', 'he', 'she', 'they', 'me', 'was', 'were', 'is', 'in', 'at', 'on', 'their', 'his', 'her', 's', 'said', 'all', 'did', 'been', 'w']
|
||||
d2 = {}
|
||||
for k in d:
|
||||
if not k in exclusion_lst and not k.isnumeric() and not len(k) < 2:
|
||||
|
|
@ -72,7 +73,6 @@ def save_frequency_to_pickle(d, pickle_fname):
|
|||
f.close()
|
||||
|
||||
|
||||
exclusion_lst = ['one', 'no', 'has', 'had', 'do', 'that', 'have', 'by', 'not', 'but', 'we', 'this', 'my', 'him', 'so', 'or', 'as', 'are', 'it', 'from', 'with', 'be', 'can', 'for', 'an', 'if', 'who', 'whom', 'whose', 'which', 'the', 'to', 'a', 'of', 'and', 'you', 'i', 'he', 'she', 'they', 'me', 'was', 'were', 'is', 'in', 'at', 'on', 'their', 'his', 'her', 's', 'said', 'all', 'did', 'been', 'w']
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
/* 按钮(上一篇,下一篇)样式 */
|
||||
.pagination {
|
||||
padding: 20px;
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
margin-right: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #007BFF; /* 按钮背景颜色 */
|
||||
border: none;
|
||||
color: #FFF; /* 按钮文字颜色 */
|
||||
padding: 5px 12px;
|
||||
font-size: 20px;
|
||||
border-radius: 5px;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.arrow i {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.arrow:hover {
|
||||
background-color: #0056b3; /* 按钮悬停时的背景颜色 */
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.arrow:focus {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
|
||||
}
|
||||
|
||||
/* 为首页时按钮(Pre Article)的背景颜色 */
|
||||
.gray-background {
|
||||
background-color: #6c757d !important;
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
|
||||
#slider {
|
||||
margin: 20px auto;
|
||||
width: 200px;
|
||||
height: 40px;
|
||||
position: relative;
|
||||
border-radius: 5px;
|
||||
background-color: #dae2d0;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
#slider_bg {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
background-color: #7AC23C;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#label {
|
||||
width: 46px;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
height: 38px;
|
||||
line-height: 38px;
|
||||
border: 1px solid #cccccc;
|
||||
background: #fff;
|
||||
z-index: 3;
|
||||
cursor: move;
|
||||
color: #ff9e77;
|
||||
font-size: 16px;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
#labelTip {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 13px;
|
||||
font-family: 'Microsoft Yahei', serif;
|
||||
color: #787878;
|
||||
line-height: 38px;
|
||||
text-align: center;
|
||||
z-index: 2;
|
||||
}
|
||||
|
|
@ -21,19 +21,14 @@ function fillInWord() {
|
|||
localStorage.setItem('selectedWords', element.value);
|
||||
}
|
||||
|
||||
if (document.getElementById("text-content")) {
|
||||
document.getElementById("text-content").addEventListener("click", fillInWord, false);
|
||||
}
|
||||
document.getElementById("text-content").addEventListener("click", fillInWord, false);
|
||||
|
||||
const sliderValue = document.getElementById("rangeValue");
|
||||
const inputSlider = document.getElementById("rangeComponent");
|
||||
|
||||
if (inputSlider) {
|
||||
inputSlider.oninput = () => {
|
||||
let value = inputSlider.value;
|
||||
sliderValue.textContent = value + '×';
|
||||
};
|
||||
}
|
||||
inputSlider.oninput = () => {
|
||||
let value = inputSlider.value;
|
||||
sliderValue.textContent = value + '×';
|
||||
};
|
||||
|
||||
function onReadClick() {
|
||||
isRead = !isRead;
|
||||
|
|
|
|||
|
|
@ -9,83 +9,32 @@ function cancelBtnHandler() {
|
|||
}
|
||||
|
||||
function showBtnHandler() {
|
||||
if (document.getElementById("text-content")) {
|
||||
document.getElementById("text-content").removeEventListener("click", fillInWord2, false);
|
||||
document.getElementById("text-content").removeEventListener("touchstart", fillInWord2, false);
|
||||
document.getElementById("text-content").addEventListener("click", fillInWord, false);
|
||||
document.getElementById("text-content").addEventListener("touchstart", fillInWord, false);
|
||||
highLight();
|
||||
}
|
||||
}
|
||||
function replaceWords(str, word) {
|
||||
let count = 0;
|
||||
|
||||
const regex = new RegExp(`(^|\\s)${word}(?=\\s|$)`, 'g');
|
||||
|
||||
let result = str.replace(regex, (match, p1) => {
|
||||
count++;
|
||||
// p1 保留前导空格(如果有),仅第一个匹配保留,后续匹配替换为空字符串
|
||||
return count === 1 ? match : p1;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function countWords(str, word) {
|
||||
// 使用正则表达式匹配目标单词的整个单词边界情况,包括前后空格、行首和行尾
|
||||
const regex = new RegExp(`(^|\\s)${word}(?=\\s|$)`, 'g');
|
||||
let match;
|
||||
let count = 0;
|
||||
|
||||
// 迭代匹配所有符合条件的单词
|
||||
while ((match = regex.exec(str)) !== null) {
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
//用于替换单词
|
||||
function replaceAllWords(str, word, replacement) {
|
||||
const regex = new RegExp(`(^|\\s)${word}(?=\\s|$)`, 'gi');
|
||||
let result = str.replace(regex, (match, p1) => {
|
||||
return p1 + replacement;
|
||||
});
|
||||
|
||||
return result;
|
||||
document.getElementById("text-content").removeEventListener("click", fillInWord2, false);
|
||||
document.getElementById("text-content").removeEventListener("touchstart", fillInWord2, false);
|
||||
document.getElementById("text-content").addEventListener("click", fillInWord, false);
|
||||
document.getElementById("text-content").addEventListener("touchstart", fillInWord, false);
|
||||
highLight();
|
||||
}
|
||||
|
||||
function getWord() {
|
||||
return window.getSelection ? window.getSelection().toString() : document.selection.createRange().text;
|
||||
return window.getSelection ? window.getSelection() : document.selection.createRange().text;
|
||||
}
|
||||
|
||||
function highLight() {
|
||||
if (!isHighlight) return;
|
||||
let word = (getWord() + "").trim().replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g, "");
|
||||
let word = (getWord() + "").trim();
|
||||
let articleContent = document.getElementById("article").innerHTML; // innerHTML保留HTML标签来保持部分格式,且适配不同的浏览器
|
||||
let pickedWords = document.getElementById("selected-words"); // words picked to the text area
|
||||
let dictionaryWords = document.getElementById("selected-words2"); // words appearing in the user's new words list
|
||||
let allWords = dictionaryWords === null ? pickedWords.value + " " : pickedWords.value + " " + dictionaryWords.value;
|
||||
let highlightWords = document.getElementById("selected-words3");
|
||||
highlightWords = document.getElementById("selected-words3");
|
||||
allWords = highlightWords == null ? allWords : allWords + " " + highlightWords.value;
|
||||
const list = allWords.split(" "); // 将所有的生词放入一个list中
|
||||
if(word !== null && word !== "" && word !== " "){
|
||||
let articleContent_fb2 = articleContent;
|
||||
if(localStorage.getItem("nowWords").indexOf(word) !== -1 || localStorage.getItem("nowWords").indexOf(word.toLowerCase()) !== -1){
|
||||
articleContent = articleContent.replace(new RegExp('<span class="highlighted">' + word + '</span>', "g"), word);
|
||||
|
||||
let count=countWords(pickedWords.value,word)
|
||||
let currentWords=localStorage.getItem("nowWords")+" "+word
|
||||
localStorage.setItem("nowWords",currentWords)
|
||||
//
|
||||
if(count>0){
|
||||
if(count==1){
|
||||
localStorage.setItem("nowWords",replaceWords(currentWords,word))
|
||||
}else{
|
||||
localStorage.setItem("nowWords",replaceAllWords(currentWords,word,""))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pickedWords.value = localStorage.getItem("nowWords")
|
||||
articleContent = articleContent.replace(new RegExp('<span class="highlighted">' + word + '</span>', "gi"), word);
|
||||
pickedWords.value = localStorage.getItem("nowWords").replace(word,"");
|
||||
document.getElementById("article").innerHTML = articleContent;
|
||||
return;
|
||||
}
|
||||
|
|
@ -109,7 +58,6 @@ function highLight() {
|
|||
articleContent = articleContent.replace(new RegExp("\\b" + word + "\\b", "g"), "<span class='highlighted'>" + word + "</span>");
|
||||
}
|
||||
document.getElementById("article").innerHTML = articleContent;
|
||||
addClickEventToHighlightedWords();
|
||||
}
|
||||
|
||||
function cancelHighlighting() {
|
||||
|
|
@ -135,62 +83,7 @@ function toggleHighlighting() {
|
|||
isHighlight = true;
|
||||
highLight();
|
||||
}
|
||||
localStorage.setItem('highlightChecked', isHighlight);
|
||||
}
|
||||
|
||||
function showWordMeaning(event) {
|
||||
const word = event.target.innerText.trim().replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g, "").toLowerCase();
|
||||
const apiUrl = '/translate';
|
||||
const rect = event.target.getBoundingClientRect();
|
||||
const tooltipX = rect.left + window.scrollX;
|
||||
const tooltipY = rect.top + window.scrollY + rect.height;
|
||||
// 发送POST请求
|
||||
fetch(apiUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ word: word }), // 发送的JSON数据
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json(); // 解析JSON响应
|
||||
})
|
||||
.then(data => {
|
||||
// 假设data.translation是翻译结果
|
||||
const tooltip = document.getElementById('tooltip');
|
||||
if (!tooltip) {
|
||||
console.error('Tooltip element not found');
|
||||
return;
|
||||
}
|
||||
|
||||
tooltip.textContent = data.translation || '没有找到该单词的中文意思';
|
||||
tooltip.style.left = `${tooltipX}px`;
|
||||
tooltip.style.top = `${tooltipY}px`;
|
||||
tooltip.style.display = 'block';
|
||||
tooltip.style.position = 'absolute';
|
||||
tooltip.style.background = 'yellow';
|
||||
|
||||
// 可以在这里添加点击事件监听器来隐藏tooltip,但注意避免内存泄漏
|
||||
document.addEventListener('click', function handler(e) {
|
||||
if (!tooltip.contains(e.target)) {
|
||||
tooltip.style.display = 'none';
|
||||
document.removeEventListener('click', handler);
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with your fetch operation:', error);
|
||||
});
|
||||
}
|
||||
|
||||
function addClickEventToHighlightedWords() {
|
||||
const highlightedWords = document.querySelectorAll('.highlighted');
|
||||
highlightedWords.forEach(word => {
|
||||
word.addEventListener('click', showWordMeaning);
|
||||
});
|
||||
localStorage.setItem('highlightChecked', isHighlight);
|
||||
}
|
||||
|
||||
showBtnHandler();
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,200 +0,0 @@
|
|||
/**
|
||||
* jquery plugin -- jquery.slideunlock.js
|
||||
* Description: a slideunlock plugin based on jQuery
|
||||
* Version: 1.1
|
||||
* Author: Dong Yuhao
|
||||
* created: March 27, 2016
|
||||
*/
|
||||
|
||||
;(function ($,window,document,undefined) {
|
||||
function SliderUnlock(elm, options, success){
|
||||
var me = this;
|
||||
var $elm = me.checkElm(elm) ? $(elm) : $;
|
||||
success = me.checkFn(success) ? success : function(){};
|
||||
|
||||
var opts = {
|
||||
successLabelTip: "Successfully Verified",
|
||||
duration: 200,
|
||||
swipestart: false,
|
||||
min: 0,
|
||||
max: $elm.width(),
|
||||
index: 0,
|
||||
isOk: false,
|
||||
lableIndex: 0
|
||||
};
|
||||
|
||||
opts = $.extend(opts, options||{});
|
||||
|
||||
//$elm
|
||||
me.elm = $elm;
|
||||
//opts
|
||||
me.opts = opts;
|
||||
//是否开始滑动
|
||||
me.swipestart = opts.swipestart;
|
||||
//最小值
|
||||
me.min = opts.min;
|
||||
//最大值
|
||||
me.max = opts.max;
|
||||
//当前滑动条所处的位置
|
||||
me.index = opts.index;
|
||||
//是否滑动成功
|
||||
me.isOk = opts.isOk;
|
||||
//滑块宽度
|
||||
me.labelWidth = me.elm.find('#label').width();
|
||||
//滑块背景
|
||||
me.sliderBg = me.elm.find('#slider_bg');
|
||||
//鼠标在滑动按钮的位置
|
||||
me.lableIndex = opts.lableIndex;
|
||||
//success
|
||||
me.success = success;
|
||||
}
|
||||
|
||||
SliderUnlock.prototype.init = function () {
|
||||
var me = this;
|
||||
|
||||
me.updateView();
|
||||
me.elm.find("#label").on("mousedown", function (event) {
|
||||
var e = event || window.event;
|
||||
me.lableIndex = e.clientX - this.offsetLeft;
|
||||
me.handerIn();
|
||||
}).on("mousemove", function (event) {
|
||||
me.handerMove(event);
|
||||
}).on("mouseup", function (event) {
|
||||
me.handerOut();
|
||||
}).on("mouseout", function (event) {
|
||||
me.handerOut();
|
||||
}).on("touchstart", function (event) {
|
||||
var e = event || window.event;
|
||||
me.lableIndex = e.originalEvent.touches[0].pageX - this.offsetLeft;
|
||||
me.handerIn();
|
||||
}).on("touchmove", function (event) {
|
||||
me.handerMove(event, "mobile");
|
||||
}).on("touchend", function (event) {
|
||||
me.handerOut();
|
||||
});
|
||||
};
|
||||
SliderUnlock.prototype.getIsOk = function() {
|
||||
return this.isOk;
|
||||
};
|
||||
|
||||
/**
|
||||
* 鼠标/手指接触滑动按钮
|
||||
*/
|
||||
SliderUnlock.prototype.handerIn = function () {
|
||||
var me = this;
|
||||
me.swipestart = true;
|
||||
me.min = 0;
|
||||
me.max = me.elm.width();
|
||||
};
|
||||
|
||||
/**
|
||||
* 鼠标/手指移出
|
||||
*/
|
||||
SliderUnlock.prototype.handerOut = function () {
|
||||
var me = this;
|
||||
//停止
|
||||
me.swipestart = false;
|
||||
//me.move();
|
||||
if (me.index < me.max) {
|
||||
me.reset();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 鼠标/手指移动
|
||||
* @param event
|
||||
* @param type
|
||||
*/
|
||||
SliderUnlock.prototype.handerMove = function (event, type) {
|
||||
var me = this;
|
||||
if (me.swipestart) {
|
||||
event.preventDefault();
|
||||
event = event || window.event;
|
||||
if (type == "mobile") {
|
||||
me.index = event.originalEvent.touches[0].pageX - me.lableIndex;
|
||||
} else {
|
||||
me.index = event.clientX - me.lableIndex;
|
||||
}
|
||||
me.move();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 鼠标/手指移动过程
|
||||
*/
|
||||
SliderUnlock.prototype.move = function () {
|
||||
var me = this;
|
||||
if ((me.index + me.labelWidth) >= me.max) {
|
||||
me.index = me.max - me.labelWidth -2;
|
||||
//停止
|
||||
me.swipestart = false;
|
||||
//解锁
|
||||
me.isOk = true;
|
||||
}
|
||||
if (me.index < 0) {
|
||||
me.index = me.min;
|
||||
//未解锁
|
||||
me.isOk = false;
|
||||
}
|
||||
if (me.index+me.labelWidth+2 == me.max && me.max > 0 && me.isOk) {
|
||||
//解锁默认操作
|
||||
$('#label').unbind().next('#labelTip').
|
||||
text(me.opts.successLabelTip).css({'color': '#fff'});
|
||||
|
||||
me.success();
|
||||
}
|
||||
me.updateView();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 更新视图
|
||||
*/
|
||||
SliderUnlock.prototype.updateView = function () {
|
||||
var me = this;
|
||||
|
||||
me.sliderBg.css('width', me.index);
|
||||
me.elm.find("#label").css("left", me.index + "px")
|
||||
};
|
||||
|
||||
/**
|
||||
* 重置slide的起点
|
||||
*/
|
||||
SliderUnlock.prototype.reset = function () {
|
||||
var me = this;
|
||||
|
||||
me.index = 0;
|
||||
me.sliderBg .animate({'width':0},me.opts.duration);
|
||||
me.elm.find("#label").animate({left: me.index}, me.opts.duration)
|
||||
.next("#lableTip").animate({opacity: 1}, me.opts.duration);
|
||||
me.updateView();
|
||||
};
|
||||
|
||||
/**
|
||||
* 检测元素是否存在
|
||||
* @param elm
|
||||
* @returns {boolean}
|
||||
*/
|
||||
SliderUnlock.prototype.checkElm = function (elm) {
|
||||
if($(elm).length > 0){
|
||||
return true;
|
||||
}else{
|
||||
throw "this element does not exist.";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 检测传入参数是否是function
|
||||
* @param fn
|
||||
* @returns {boolean}
|
||||
*/
|
||||
SliderUnlock.prototype.checkFn = function (fn) {
|
||||
if(typeof fn === "function"){
|
||||
return true;
|
||||
}else{
|
||||
throw "the param is not a function.";
|
||||
}
|
||||
};
|
||||
|
||||
window['SliderUnlock'] = SliderUnlock;
|
||||
})(jQuery, window, document);
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
function containsDigitsLettersSpecialCharacters(s) {
|
||||
let resultD = 0, resultL = 0, resultS = 0;
|
||||
|
||||
// Digit test
|
||||
'0123456789'.split('').forEach((x) => {
|
||||
if (s.includes(x))
|
||||
resultD = 1;
|
||||
});
|
||||
|
||||
// Letter test
|
||||
resultL = /[a-z]/i.test(s);
|
||||
|
||||
// Special charater test
|
||||
'+-*/,.:;/\[]<>$%&()!?^~'.split('').forEach((x) => {
|
||||
if (s.includes(x))
|
||||
resultS = 1;
|
||||
});
|
||||
|
||||
return resultD + resultL + resultS == 3;
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ var Reader = (function() {
|
|||
let current_position = 0;
|
||||
let original_position = 0;
|
||||
let to_speak = "";
|
||||
let current_rate = 1; // 添加这一行,设置默认速率为 1
|
||||
|
||||
function makeUtterance(str, rate) {
|
||||
let msg = new SpeechSynthesisUtterance(str);
|
||||
|
|
@ -25,24 +24,12 @@ var Reader = (function() {
|
|||
reader.speak(msg);
|
||||
}
|
||||
|
||||
function updateRate(rate) {
|
||||
// 停止当前的朗读
|
||||
stopRead();
|
||||
|
||||
// 更新当前速率
|
||||
current_rate = rate;
|
||||
|
||||
// 重新开始朗读
|
||||
read(to_speak, current_rate);
|
||||
}
|
||||
|
||||
function stopRead() {
|
||||
reader.cancel();
|
||||
}
|
||||
|
||||
return {
|
||||
read: read,
|
||||
stopRead: stopRead,
|
||||
updateRate: updateRate // 添加这一行,将 updateRate 方法暴露出去
|
||||
stopRead: stopRead
|
||||
};
|
||||
}) ();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
function familiar(theWord) {
|
||||
let username = $("#username").text();
|
||||
let word = document.getElementById(`word_${theWord}`).innerText;
|
||||
let freq = document.getElementById(`freq_${theWord}`).innerText;
|
||||
console.log(theWord);
|
||||
console.log(word);
|
||||
let word = $("#word_" + theWord).text();
|
||||
let freq = $("#freq_" + theWord).text();
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
url:"/" + username + "/" + word + "/familiar",
|
||||
|
|
@ -29,10 +27,8 @@ function familiar(theWord) {
|
|||
|
||||
function unfamiliar(theWord) {
|
||||
let username = $("#username").text();
|
||||
let word = document.getElementById(`word_${theWord}`).innerText;
|
||||
let freq = document.getElementById(`freq_${theWord}`).innerText;
|
||||
console.log(theWord);
|
||||
console.log(word);
|
||||
let word = $("#word_" + theWord).text();
|
||||
let freq = $("#freq_" + theWord).text();
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
url:"/" + username + "/" + word + "/unfamiliar",
|
||||
|
|
@ -61,12 +57,6 @@ function delete_word(theWord) {
|
|||
} else {
|
||||
$("#p_" + theWord).remove();
|
||||
}
|
||||
// remove highlighting for the word
|
||||
let highlightedWords = document.querySelectorAll('.highlighted');
|
||||
for (let x of highlightedWords) {
|
||||
if (x.innerHTML == word)
|
||||
x.replaceWith(x.innerHTML);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -78,7 +68,6 @@ function read_word(theWord) {
|
|||
Reader.read(to_speak, inputSlider.value);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* interface Word {
|
||||
* word: string,
|
||||
|
|
@ -93,9 +82,7 @@ function parseWord(element) {
|
|||
const word = element
|
||||
.querySelector("a.btn.btn-light[role=button]") // 获取当前词频元素的词汇元素
|
||||
.innerText // 获取词汇值;
|
||||
let freqId = `freq_${word}`;
|
||||
freqId = CSS.escape(freqId); // for fixing bug 580, escape the apostrophe in the word
|
||||
const freq = Number.parseInt(element.querySelector("#"+freqId).innerText); // 获取词汇的数量
|
||||
const freq = Number.parseInt(element.querySelector(`#freq_${word}`).innerText); // 获取词汇的数量
|
||||
return {
|
||||
word,
|
||||
freq
|
||||
|
|
@ -107,20 +94,16 @@ function parseWord(element) {
|
|||
*/
|
||||
function wordTemplate(word) {
|
||||
// 这个模板应当与 templates/userpage_get.html 中的 <p id='p_${word.word}' class="new-word" > ... </p> 保持一致
|
||||
return `<p id="p_${word.word}" class="new-word" >
|
||||
<a id="word_${word.word}" class="btn btn-light" href='http://youdao.com/w/eng/${word.word}/#keyfrom=dict2.index'
|
||||
role="button">${word.word}</a>
|
||||
( <a id="freq_${word.word}" title="${word.word}">${word.freq}</a> )
|
||||
<a class="btn btn-success" onclick=familiar("${word.word}") role="button">熟悉</a>
|
||||
<a class="btn btn-warning" onclick=unfamiliar("${word.word}") role="button">不熟悉</a>
|
||||
<a class="btn btn-danger" onclick=delete_word("${word.word}") role="button">删除</a>
|
||||
<a class="btn btn-info" onclick=read_word("${word.word}") role="button">朗读</a>
|
||||
<a class="btn btn-primary" onclick="addNote('{{ word }}'); saveNote('{{ word }}')" role="button">笔记</a> <!-- Modify to call addNote and then saveNote -->
|
||||
<input type="text" id="note_{{ word }}" class="note-input" placeholder="输入笔记内容" style="display:none;" oninput="saveNote('{{ word }}')"> <!-- Added oninput event -->
|
||||
return `<p id='p_${word.word}' class="new-word" >
|
||||
<img src="https://s2.loli.net/2024/07/02/6YNpMX7oPzWUhOZ.png" width="50" height="50" onclick="familiar('${word.word}')" title='熟悉'>
|
||||
<img src="https://s2.loli.net/2024/07/02/H4NeYAjhup6bs9m.png" width="50" height="50" onclick="unfamiliar('${word.word}')" title='不熟悉'>
|
||||
<a id="word_${word.word}" class="btn btn-light" href='http://youdao.com/w/eng/${word.word}/#keyfrom=dict2.index'
|
||||
role="button"><strong>${word.word}</strong></a>
|
||||
(<a id="freq_${word.word}" title="${word.word}">${word.freq}</a> )
|
||||
<img src="https://s2.loli.net/2024/07/03/5edBC3y7QhIZLTY.jpg" width="30" height="30" onclick="read_word('${word.word}')" title='朗读'>
|
||||
</p>`;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除某一词频元素
|
||||
* 此处word为词频元素对应的单词
|
||||
|
|
@ -188,59 +171,3 @@ function compareWord(first, second) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 生词csv导出 */
|
||||
function exportToCSV() {
|
||||
let csvContent = "data:text/csv;charset=utf-8,Word,Frequency\n";
|
||||
let rows = document.querySelectorAll(".new-word");
|
||||
|
||||
rows.forEach(row => {
|
||||
let word = row.querySelector("a.btn-light").innerText;
|
||||
let freq = row.querySelector("a[title]").innerText;
|
||||
csvContent += word + "," + freq + "\n";
|
||||
});
|
||||
|
||||
let encodedUri = encodeURI(csvContent);
|
||||
let link = document.createElement("a");
|
||||
link.setAttribute("href", encodedUri);
|
||||
link.setAttribute("download", "word_list.csv");
|
||||
document.body.appendChild(link);
|
||||
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 随机选取 10 个单词学习
|
||||
*/
|
||||
function random_select_word(word) {
|
||||
|
||||
// 获取所有带有 "word-container" 类的 <p> 标签
|
||||
const container = document.querySelector('.word-container');
|
||||
|
||||
console.log("container",container)
|
||||
|
||||
// 获取所有带有"new-word"类的<p>标签
|
||||
let wordContainers = container.querySelectorAll('.new-word');
|
||||
|
||||
// 检查是否存在带有"new-word"类的<p>标签
|
||||
if (wordContainers.length > 0) {
|
||||
// 将NodeList转换为数组
|
||||
let wordContainersArray = [...wordContainers];
|
||||
|
||||
// 随机打乱数组,乱序
|
||||
for (let i = wordContainersArray.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[wordContainersArray[i], wordContainersArray[j]] = [wordContainersArray[j], wordContainersArray[i]];
|
||||
}
|
||||
|
||||
wordContainersArray.forEach((p, index) => {
|
||||
if (index < 10) {
|
||||
p.style.display = 'block';
|
||||
} else {
|
||||
p.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
Binary file not shown.
|
|
@ -7,11 +7,6 @@
|
|||
content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" />
|
||||
<meta name="format-detection" content="telephone=no" />
|
||||
<link href="../static/css/bootstrap.css" rel="stylesheet">
|
||||
<script>
|
||||
function confirmDeletion(articleId, articleTitle) {
|
||||
return confirm(`确认删除文章 "${articleTitle}" (ID: ${articleId}) 吗?`);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="container" style="width: 800px; margin: auto; margin-top:24px;">
|
||||
|
|
@ -71,10 +66,9 @@
|
|||
<div class="list-group">
|
||||
{% for text in text_list %}
|
||||
<div class="list-group-item list-group-item-action" aria-current="true">
|
||||
<form action="/admin/article" method="post" style="display: inline;">
|
||||
<input type="hidden" name="delete_id" value="{{ text.article_id }}">
|
||||
<button type="submit" class="btn btn-outline-danger btn-sm" onclick="return confirmDeletion('{{ text.article_id }}', '{{ text.title }}')">删除</button>
|
||||
</form>
|
||||
<div>
|
||||
<a type="button" href="/admin/article?delete_id={{text.article_id}}" class="btn btn-outline-danger btn-sm">删除</a>
|
||||
</div>
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1">{{ text.title }}</h5>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,27 +8,7 @@
|
|||
<link rel="stylesheet" href="static/css/login_service.css">
|
||||
<script src="static/js/jquery.js"></script>
|
||||
<script>
|
||||
let blackList = [];
|
||||
|
||||
<!--function getBlack() {-->
|
||||
<!-- const fs = require('fs');-->
|
||||
<!-- global.blackFile = fs.readFileSync('black', 'utf8');-->
|
||||
<!-- const blackListTemp = blackFile.split('\n');-->
|
||||
<!-- global.blackList = blackListTemp.map(line => line.trim()).filter(line => line !== '');-->
|
||||
<!--}-->
|
||||
|
||||
function putUserIntoBlack(usernameTemp) {
|
||||
|
||||
blackList.push(usernameTemp);
|
||||
}
|
||||
|
||||
function ifUsernameInBlack(usernameTemp) {
|
||||
return blackList.includes(usernameTemp);
|
||||
}
|
||||
|
||||
count=0
|
||||
function login()
|
||||
{
|
||||
function login(){
|
||||
let username = $("#username").val();
|
||||
let password = $("#password").val();
|
||||
if (username === "" || password === ""){
|
||||
|
|
@ -39,56 +19,17 @@ function ifUsernameInBlack(usernameTemp) {
|
|||
alert('输入不能包含空格!');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$.post
|
||||
(
|
||||
"/login", {'username': username, 'password': password},
|
||||
|
||||
function (response)
|
||||
{
|
||||
|
||||
if(response.status === '5')
|
||||
{
|
||||
alert('已被加入黑名单,请联系管理员!');
|
||||
$.post(
|
||||
"/login", {'username': username, 'password': password},
|
||||
function (response) {
|
||||
if (response.status === '0') {
|
||||
alert('无法通过验证。');
|
||||
window.location.href = "/login";
|
||||
} else if (response.status === '1') {
|
||||
window.location.href = "/"+username+"/userpage";
|
||||
}
|
||||
else{
|
||||
if(!ifUsernameInBlack(username))
|
||||
{
|
||||
if (response.status === '0')
|
||||
{
|
||||
if(count<5)
|
||||
{
|
||||
alert('无法通过验证。');
|
||||
<!--window.location.href = "/login";-->
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
<!--输入错误密码次数超过5次-->
|
||||
alert('密码输入错误超过五次,已被加入黑名单!');
|
||||
putUserIntoBlack(username);
|
||||
console.log(ifUsernameInBlack(username));
|
||||
response.status=5;
|
||||
$("#password").val('黑名单');
|
||||
}
|
||||
}
|
||||
else if (response.status === '1')
|
||||
{
|
||||
window.location.href = "/"+username+"/userpage";
|
||||
}
|
||||
}
|
||||
else if(ifUsernameInBlack(username))
|
||||
{
|
||||
alert('已被加入黑名单!');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
}
|
||||
)
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<p><a href="/login">登录</a> <a href="/signup">注册</a> <a href="/static/usr/instructions.html">使用说明</a></p >
|
||||
<p><b> {{ random_ads }}。 <a href="/signup">试试</a>吧!</b></p>
|
||||
{% endif %}
|
||||
<div class="alert alert-success" role="alert">共有文章 <span class="badge bg-success"> {{ number_of_essays }} </span> 篇,Oxford 5000 单词占比 <span class="badge bg-success"> {{ (ratio * 100) | int }}% </span> </div>
|
||||
<div class="alert alert-success" role="alert">共有文章 <span class="badge bg-success"> {{ number_of_essays }} </span> 篇</div>
|
||||
<p>粘贴1篇文章 (English only)</p>
|
||||
<form method="post" action="/">
|
||||
<textarea name="content" id="article" rows="10" cols="120"></textarea><br/>
|
||||
|
|
@ -44,7 +44,9 @@
|
|||
<a href="http://youdao.com/w/eng/{{x[0]}}/#keyfrom=dict2.index">{{x[0]}}</a> {{x[1]}}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
<p class="text-muted">Version: 20240618</p>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||||
</div>
|
||||
{{ yml['footer'] | safe }}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes"/>
|
||||
<link rel="stylesheet" href="static/css/login_service.css">
|
||||
<script src="static/js/jquery.js"></script>
|
||||
<script src="static/js/password.js"></script>
|
||||
<script>
|
||||
function reset() {
|
||||
let old_password = $("#old-password").val();
|
||||
|
|
@ -25,19 +24,15 @@
|
|||
alert('密码过于简单。(密码长度至少4位)');
|
||||
return false;
|
||||
}
|
||||
if (!containsDigitsLettersSpecialCharacters(new_password)) {
|
||||
alert('密码过于简单。(密码要包括数字,字母,特殊符号)');
|
||||
return false;
|
||||
}
|
||||
$.post("/reset", {'old-password': old_password, 'new-password': new_password},
|
||||
function (response) {
|
||||
console.log(response);
|
||||
if ('success' in response) {
|
||||
alert('密码修改成功。');
|
||||
} else if ('error' in response) {
|
||||
alert(`密码修改失败 ${response.error}`);
|
||||
function (response) {
|
||||
if (response.status === '1') {
|
||||
alert('密码修改成功,请重新登录。');
|
||||
window.location.href = "/login";
|
||||
} else if (response.status === '2') {
|
||||
alert('密码修改失败');
|
||||
window.location.href = "/reset";
|
||||
}
|
||||
window.location.href = `/${response.username}/userpage`;
|
||||
}
|
||||
)
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,112 +1,72 @@
|
|||
{% block body %}
|
||||
{% if session['logged_in'] %}
|
||||
You're logged in already! <a href="/logout">Logout</a>.
|
||||
|
||||
You're logged in already! <a href="/logout">Logout</a>.
|
||||
|
||||
{% else %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" />
|
||||
<link rel="stylesheet" href="static/css/login_service.css">
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE-edge,chrome=1">
|
||||
<link href="static/css/slide-unlock.css" rel="stylesheet">
|
||||
<script src="static/js/password.js"></script>
|
||||
<script src="static/js/jquery.js"></script>
|
||||
<script src="static/js/jquery.slideunlock.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" />
|
||||
<link rel="stylesheet" href="static/css/login_service.css">
|
||||
<script src="static/js/jquery.js"></script>
|
||||
<script>
|
||||
var slider
|
||||
let username,password,password2
|
||||
$(document).ready(function() {
|
||||
slider = new SliderUnlock("#slider", {
|
||||
successLabelTip: "验证成功"
|
||||
}, function() {
|
||||
|
||||
});
|
||||
slider.init(); // 初始化滑块解锁功能
|
||||
});
|
||||
|
||||
function signup(){
|
||||
// 发起 AJAX 请求来处理注册
|
||||
username = $("#username").val().trim();
|
||||
password = $("#password").val().trim();
|
||||
password2 = $("#password2").val().trim();
|
||||
|
||||
// 基本表单验证
|
||||
if (username === "" || password === "" || password2 === "") {
|
||||
alert('输入不能为空!');
|
||||
return false;
|
||||
}
|
||||
if (password.includes(' ') || password2.includes(' ')) {
|
||||
alert('输入不能包含空格!');
|
||||
return false;
|
||||
}
|
||||
if (password !== password2) {
|
||||
alert('确认密码与输入密码不一致!');
|
||||
return false;
|
||||
}
|
||||
if (password.length < 4) {
|
||||
alert('密码过于简单。(密码长度至少4位)');
|
||||
return false;
|
||||
}
|
||||
if (!containsDigitsLettersSpecialCharacters(password)) {
|
||||
alert('密码过于简单。(密码要包括数字,字母,特殊符号)');
|
||||
return false;
|
||||
}
|
||||
is_ok = slider.getIsOk();
|
||||
if(!is_ok){
|
||||
alert('没有滑动验证');
|
||||
return false;
|
||||
}
|
||||
$.post("/signup", {
|
||||
'username': username,
|
||||
'password': password
|
||||
}, function(response) {
|
||||
if (response.status === '0') {
|
||||
alert('用户名' + username + '已经被注册。');
|
||||
window.location.href = "/signup";
|
||||
} else if (response.status === '1') {
|
||||
alert('用户名密码验证失败。');
|
||||
window.location.href = "/signup";
|
||||
} else if (response.status === '2') {
|
||||
var f = confirm("恭喜,你已成功注册,你的用户名是" + username + '.\n点击“确认”开始使用,或点击“取消”返回首页');
|
||||
if (f) {
|
||||
window.location.href = '/' + username + '/userpage';
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
}
|
||||
} else if (response.status === '3') {
|
||||
alert(response.warn);
|
||||
function signup() {
|
||||
let username = $("#username").val();
|
||||
let password = $("#password").val();
|
||||
let password2 = $("#password2").val();
|
||||
if (username === "" || password === "" || password2 === ""){
|
||||
alert('输入不能为空!');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<p>{{ get_flashed_messages()[0] | safe }}</p>
|
||||
|
||||
<div class="container">
|
||||
<section class="signin-heading">
|
||||
<h1>Sign up</h1>
|
||||
</section>
|
||||
|
||||
<form>
|
||||
<p><input type="text" id="username" placeholder="输入用户名" class="username"></p>
|
||||
<p><input type="password" id="password" placeholder="输入密码" class="password"></p>
|
||||
<p><input type="password" id="password2" placeholder="确认密码" class="password"></p>
|
||||
|
||||
<div id="slider">
|
||||
<div id="slider_bg"></div>
|
||||
<span id="label">>></span> <span id="labelTip">-----滑动验证你是不是人类</span>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn" onclick="signup()">注册</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Bind click event to the signup button
|
||||
$(".btn").click(function() {
|
||||
// Trigger slider unlock
|
||||
var slider = new SliderUnlock("#slider");
|
||||
slider.isOk();
|
||||
});
|
||||
if (password.includes(' ') || password2.includes(' ')) {
|
||||
alert('输入不能包含空格!');
|
||||
return false;
|
||||
}
|
||||
if (password !== password2) {
|
||||
alert('确认密码与输入密码不一致!');
|
||||
return false;
|
||||
}
|
||||
if (password.length < 4) {
|
||||
alert('密码过于简单。(密码长度至少4位)');
|
||||
return false;
|
||||
}
|
||||
$.post("/signup", {'username': username, 'password': password},
|
||||
function (response) {
|
||||
if (response.status === '0') {
|
||||
alert('用户名'+username+'已经被注册。');
|
||||
window.location.href = "/signup";
|
||||
} else if (response.status === '1') {
|
||||
alert('用户名密码验证失败。');
|
||||
window.location.href = "/signup";
|
||||
} else if (response.status === '2') {
|
||||
let f = confirm("恭喜,你已成功注册,你的用户名是"+username+'.\n点击“确认”开始使用,或点击“取消”返回首页');
|
||||
if (f) {
|
||||
window.location.href = '/'+username+'/userpage';
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
}
|
||||
} else if (response.status === '3') {
|
||||
alert(response.warn);
|
||||
}
|
||||
}
|
||||
)
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<p>{{ get_flashed_messages()[0] | safe }}</p>
|
||||
|
||||
|
||||
<div class="container">
|
||||
|
||||
<section class="signin-heading">
|
||||
<h1>Sign up</h1>
|
||||
</section>
|
||||
|
||||
<p><input type="username" id="username" placeholder="输入用户名" class="username"></p>
|
||||
<p><input type="password" id="password" placeholder="输入密码" class="password"></p>
|
||||
<p><input type="password" id="password2" placeholder="确认密码" class="password" ></p>
|
||||
<button type="button" class="btn" onclick="signup()">注册</button>
|
||||
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
|
@ -6,8 +6,6 @@
|
|||
content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes"/>
|
||||
<meta name="format-detection" content="telephone=no"/>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<link rel="stylesheet" href="../static/css/button.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
{{ yml['header'] | safe }}
|
||||
|
|
@ -74,28 +72,14 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="pagination">
|
||||
<button class="arrow" id="load_pre_article" onclick="load_pre_article();Reader.stopRead()" title="Previous Article">
|
||||
<i class="fas fa-chevron-left"></i> 上一篇
|
||||
</button>
|
||||
<button class="arrow" id="load_next_article" onclick="load_next_article();Reader.stopRead()" title="Next Article">
|
||||
下一篇 <i class="fas fa-chevron-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
<button class="arrow" id="load_next_article" onclick="load_next_article();Reader.stopRead()" title="下一篇 Next Article">⇨</button>
|
||||
<button class="arrow" id="load_pre_article" onclick="load_pre_article();Reader.stopRead()" style="display: none" title="上一篇 Previous Article">⇦</button>
|
||||
|
||||
<p><b>阅读文章并回答问题</b></p>
|
||||
|
||||
<div id="text-content">
|
||||
<div id="found">
|
||||
<div class="alert alert-success" role="alert">According to your word list, your level is <span class="text-decoration-underline" id="user_level">{{ today_article["user_level"] }}</span> and we have chosen an article with a difficulty level of <span class="text-decoration-underline" id="text_level">{{ today_article["text_level"] }}</span> for you. <span class="text-decoration-underline" id="ratio">{{ (today_article["ratio"] * 100) | int }}%</span> of the words in this article are in Oxford Word 5000.</div>
|
||||
<p class="text-muted" id="date">Article added on: {{ today_article["date"] }}</p><br/>
|
||||
|
||||
<button onclick="saveArticle()" >标记文章</button>
|
||||
<select id="saved_articles_dropdown">
|
||||
<!-- 这里将显示已经保存的文章 -->
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<div class="alert alert-success" role="alert">According to your word list, your level is <span class="text-decoration-underline" id="user_level">{{ today_article["user_level"] }}</span> and we have chosen an article with a difficulty level of <span class="text-decoration-underline" id="text_level">{{ today_article["text_level"] }}</span> for you.</div>
|
||||
<p class="text-muted" id="date">Article added on: {{ today_article["date"] }}</p><br/>
|
||||
<div class="p-3 mb-2 bg-light text-dark" style="margin: 0 0.5%;"><br/>
|
||||
<p class="display-6" id="article_title">{{ today_article["article_title"] }}</p><br/>
|
||||
<p class="lead"><font id="article">{{ today_article["article_body"] }}</font></p><br/>
|
||||
|
|
@ -116,7 +100,6 @@
|
|||
<button onclick="toggle_visibility('answer');">ANSWER</button>
|
||||
<div id="answer" style="display:none;">{{ today_article['answer'] }}</div><br/>
|
||||
</div>
|
||||
<div id="tooltip"></div>
|
||||
</div>
|
||||
<div class="alert alert-success" role="alert" id="not_found" style="display:none;">
|
||||
<p class="text-muted"><span class="badge bg-success">Notes:</span><br>No article is currently available for you. You can try again a few times or mark new words in the passage to improve your level.</p>
|
||||
|
|
@ -156,18 +139,12 @@
|
|||
|
||||
{% if d_len > 0 %}
|
||||
<p>
|
||||
|
||||
<b>我的生词簿</b>
|
||||
<label for="move_dynamiclly">
|
||||
<input type="checkbox" name="move_dynamiclly" id="move_dynamiclly" checked>
|
||||
允许动态调整顺序
|
||||
</label>
|
||||
<br>
|
||||
<a class="btn btn-primary btn-lg" onclick="random_select_word('{{ word }}')" role="button">随机选取10个</a>
|
||||
<a class="btn btn-primary btn-lg" onclick="location.reload();" role="button">显示所有生词</a>
|
||||
</p>
|
||||
<!--添加导出按钮-->
|
||||
<button class="btn btn-primary" onclick="exportToCSV()">导出</button>
|
||||
<a name="aaa"></a>
|
||||
<div class="word-container">
|
||||
{% for x in lst3 %}
|
||||
|
|
@ -176,50 +153,25 @@
|
|||
{% if session.get('thisWord') == x[0] and session.get('time') == 1 %}
|
||||
{% endif %}
|
||||
<p id='p_{{ word }}' class="new-word" >
|
||||
<img src="https://s2.loli.net/2024/07/02/6YNpMX7oPzWUhOZ.png" width="50" height="50" onclick="familiar('{{ word }}')" title='熟悉'>
|
||||
<img src="https://s2.loli.net/2024/07/02/H4NeYAjhup6bs9m.png" width="50" height="50" onclick="unfamiliar('{{ word }}')" title='不熟悉'>
|
||||
<a id="word_{{ word }}" class="btn btn-light" href='http://youdao.com/w/eng/{{ word }}/#keyfrom=dict2.index'
|
||||
role="button">{{ word }}</a>
|
||||
role="button"><strong>{{ word }}</strong></a>
|
||||
( <a id="freq_{{ word }}" title="{{ word }}">{{ freq }}</a> )
|
||||
<a class="btn btn-success" onclick=familiar("{{ word }}") role="button">熟悉</a>
|
||||
<a class="btn btn-warning" onclick=unfamiliar("{{ word }}") role="button">不熟悉</a>
|
||||
<a class="btn btn-danger" onclick=delete_word("{{ word }}") role="button">删除</a>
|
||||
<a class="btn btn-info" onclick=read_word("{{ word }}") role="button">朗读</a>
|
||||
<a class="btn btn-primary" onclick="addNote('{{ word }}'); saveNote('{{ word }}')" role="button">笔记</a> <!-- Modify to call addNote and then saveNote -->
|
||||
<input type="text" id="note_{{ word }}" class="note-input" placeholder="输入笔记内容" style="display:none;" oninput="saveNote('{{ word }}')"> <!-- Added oninput event -->
|
||||
<img src="https://s2.loli.net/2024/07/03/5edBC3y7QhIZLTY.jpg" width="30" height="30" onclick="read_word('{{ word }}')" title='朗读'>
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<input id="selected-words2" type="hidden" value="{{ words }}">
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
<label id="selected-words3" type="hidden"></label>
|
||||
{{ yml['footer'] | safe }}
|
||||
{% if yml['js']['bottom'] %}
|
||||
{% for js in yml['js']['bottom'] %}
|
||||
<script src="{{ js }}"></script>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
// Function to show/hide note input and load saved note content from localStorage
|
||||
function addNote(word) {
|
||||
var noteInput = document.getElementById("note_" + word);
|
||||
var savedNote = localStorage.getItem(word); // Get the saved note from localStorage
|
||||
if (savedNote) {
|
||||
noteInput.value = savedNote; // Set the saved note if it exists
|
||||
}
|
||||
noteInput.style.display = (noteInput.style.display === 'none') ? 'inline-block' : 'none'; // Toggle display
|
||||
}
|
||||
|
||||
// Example function to save the note to localStorage
|
||||
function saveNote(word) {
|
||||
var noteContent = document.getElementById("note_" + word).value;
|
||||
localStorage.setItem(word, noteContent); // Save the note content in localStorage
|
||||
console.log('Note saved for ' + word + ': ' + noteContent); // Log for debugging purposes
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
window.onload = function () { // 页面加载时执行
|
||||
const settings = {
|
||||
|
|
@ -245,12 +197,11 @@
|
|||
elements.chooseCheckbox.checked = settings.chooseChecked;
|
||||
elements.rangeComponent.value = settings.rangeValue;
|
||||
elements.rangeValueDisplay.textContent = `${settings.rangeValue}x`;
|
||||
<!-- elements.selectedWordsInput.value = settings.selectedWords;-->
|
||||
elements.selectedWordsInput.value = settings.selectedWords;
|
||||
|
||||
|
||||
// 刷新页面或进入页面时判断,若是首篇文章,则颜色为灰色
|
||||
if (sessionStorage.getItem('pre_page_button') === 'display' || !sessionStorage.getItem('pre_page_button')) {
|
||||
$('#load_pre_article').addClass('gray-background');
|
||||
// 刷新页面或进入页面时判断,若不是首篇文章,则上一篇按钮可见
|
||||
if (sessionStorage.getItem('pre_page_button') !== 'display' && sessionStorage.getItem('pre_page_button')) {
|
||||
$('#load_pre_article').show();
|
||||
}
|
||||
|
||||
// 事件监听器
|
||||
|
|
@ -278,13 +229,9 @@
|
|||
success: function(data) {
|
||||
// 更新页面内容
|
||||
if(data['today_article']){
|
||||
// answer不可见
|
||||
const e = document.getElementById('answer');
|
||||
e.style.display = 'none';
|
||||
update(data['today_article']);
|
||||
check_pre(data['visited_articles']);
|
||||
check_next(data['result_of_generate_article']);
|
||||
toggleHighlighting();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -296,12 +243,8 @@
|
|||
success: function(data) {
|
||||
// 更新页面内容
|
||||
if(data['today_article']){
|
||||
// answer不可见
|
||||
const e = document.getElementById('answer');
|
||||
e.style.display = 'none';
|
||||
update(data['today_article']);
|
||||
check_pre(data['visited_articles']);
|
||||
toggleHighlighting();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -315,18 +258,18 @@
|
|||
$('#source').html(today_article['source']);
|
||||
$('#question').html(today_article["question"]);
|
||||
$('#answer').html(today_article["answer"]);
|
||||
$('#ratio').html(Math.round(today_article["ratio"] * 100) + '%');
|
||||
document.querySelector('#text_level').classList.add('mark'); // highlight text difficult level for 2 seconds
|
||||
setTimeout(() => {document.querySelector('#text_level').classList.remove('mark');}, 2000);
|
||||
document.querySelector('#user_level').classList.add('mark'); // do the same thing for user difficulty level
|
||||
setTimeout(() => {document.querySelector('#user_level').classList.remove('mark');}, 2000);
|
||||
}
|
||||
<!-- 检查是否存在上一篇或下一篇,不存在则对应按钮隐藏-->
|
||||
function check_pre(visited_articles){
|
||||
if((visited_articles=='')||(visited_articles['index']<=0)){
|
||||
$('#load_pre_article').addClass('gray-background'); // 设置为灰色
|
||||
$('#load_pre_article').hide();
|
||||
sessionStorage.setItem('pre_page_button', 'display')
|
||||
}else{
|
||||
$('#load_pre_article').removeClass('gray-background'); // 设置为正常蓝色
|
||||
$('#load_pre_article').show();
|
||||
sessionStorage.setItem('pre_page_button', 'show')
|
||||
}
|
||||
}
|
||||
|
|
@ -344,90 +287,6 @@
|
|||
$('#read_all').show();
|
||||
}
|
||||
}
|
||||
function saveArticle() {
|
||||
const article = {
|
||||
user_level: document.getElementById('user_level').innerText,
|
||||
text_level: document.getElementById('text_level').innerText,
|
||||
date: document.getElementById('date').innerText.replace('Article added on: ', ''),
|
||||
article_title: document.getElementById('article_title').innerText,
|
||||
article_body: document.getElementById('article').innerText,
|
||||
source: document.getElementById('source').innerText,
|
||||
question: document.getElementById('question').innerText,
|
||||
answer: document.getElementById('answer').innerText
|
||||
};
|
||||
|
||||
const articleJSON = JSON.stringify(article);
|
||||
const articleTitle = article.article_title;
|
||||
const savedArticlesDropdown = document.getElementById('saved_articles_dropdown');
|
||||
|
||||
var option = document.createElement('option');
|
||||
option.text = articleTitle;
|
||||
option.value = articleJSON; // 存储序列化的JSON字符串
|
||||
option.title = article.article_title;
|
||||
savedArticlesDropdown.appendChild(option);
|
||||
localStorage.setItem(articleTitle, articleJSON); // 以文章标题为键,序列化的JSON字符串为值存储
|
||||
}
|
||||
function loadSelectedArticle() {
|
||||
const selectedOption = document.getElementById('saved_articles_dropdown');
|
||||
const selectedTitle = selectedOption.options[selectedOption.selectedIndex].text;
|
||||
const articleJSON = localStorage.getItem(selectedTitle);
|
||||
|
||||
if (articleJSON) {
|
||||
const today_article = JSON.parse(articleJSON); // 解析JSON字符串为对象
|
||||
update(today_article); // 使用解析出的对象更新页面
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
const savedArticlesDropdown = document.getElementById('saved_articles_dropdown');
|
||||
savedArticlesDropdown.addEventListener('change', loadSelectedArticle);
|
||||
|
||||
// 先清空dropdown,以防有多余的选项或重新加载页面时出现重复
|
||||
savedArticlesDropdown.innerHTML = '';
|
||||
|
||||
// 获取localStorage中最后一个(最新)的键值对
|
||||
let latestKey, latestValue;
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i);
|
||||
const value = localStorage.getItem(key);
|
||||
if (!latestKey) { // 第一次迭代时设置最新文章
|
||||
latestKey = key;
|
||||
latestValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
// 首先添加最新保存的文章到下拉菜单
|
||||
|
||||
if (latestKey && latestValue) {
|
||||
var latestOption = document.createElement('option');
|
||||
latestOption.text = latestKey;
|
||||
latestOption.value = latestValue;
|
||||
latestOption.title = latestValue;
|
||||
savedArticlesDropdown.appendChild(latestOption);
|
||||
}
|
||||
|
||||
// 接着遍历其余文章并添加到下拉菜单
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i);
|
||||
const value = localStorage.getItem(key);
|
||||
// 确保不重复添加最新文章
|
||||
if (key !== latestKey && key !== 'selectedWords') {
|
||||
var option = document.createElement('option');
|
||||
option.text = key;
|
||||
option.value = value;
|
||||
option.title = value;
|
||||
savedArticlesDropdown.appendChild(option);
|
||||
}
|
||||
}
|
||||
|
||||
savedArticlesDropdown.selectedIndex = -1;
|
||||
}
|
||||
|
||||
document.getElementById('rangeComponent').addEventListener('input', function() {
|
||||
var rate = this.value;
|
||||
Reader.updateRate(rate);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
<style>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,5 @@
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<script>window.history.replaceState(null, null, window.location.href);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,88 +0,0 @@
|
|||
from selenium.webdriver.common.alert import Alert
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
|
||||
|
||||
# 对用户名不能为中文进行测试
|
||||
def test_register_username_with_chinese(driver, URL):
|
||||
try:
|
||||
driver.get(URL + "/signup")
|
||||
|
||||
# 等待用户名输入框出现
|
||||
username_elem = WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.ID, 'username'))
|
||||
)
|
||||
username_elem.send_keys("测试用户") # 输入中文用户名
|
||||
|
||||
# 等待密码输入框出现
|
||||
password_elem = WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.ID, 'password'))
|
||||
)
|
||||
password_elem.send_keys("validPassword123") # 输入有效密码
|
||||
|
||||
# 等待确认密码输入框出现
|
||||
password2_elem = WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.ID, 'password2'))
|
||||
)
|
||||
password2_elem.send_keys("validPassword123") # 输入有效确认密码
|
||||
|
||||
# 等待注册按钮出现并点击
|
||||
signup_button = WebDriverWait(driver, 10).until(
|
||||
EC.element_to_be_clickable((By.XPATH, '//button[@onclick="signup()"]'))
|
||||
)
|
||||
signup_button.click()
|
||||
|
||||
# 等待警告框出现并接受
|
||||
WebDriverWait(driver, 10).until(EC.alert_is_present())
|
||||
alert = driver.switch_to.alert
|
||||
alert_text = alert.text
|
||||
print(f"警告文本: {alert_text}")
|
||||
assert alert_text == "Chinese characters are not allowed in the user name." # 根据实际的警告文本进行断言
|
||||
alert.accept()
|
||||
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
||||
raise
|
||||
|
||||
|
||||
# 对注册时密码不能是中文进行测试
|
||||
def test_register_password_with_chinese(driver, URL):
|
||||
try:
|
||||
driver.get(URL + "/signup")
|
||||
|
||||
# 等待用户名输入框出现
|
||||
username_elem = WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.ID, 'username'))
|
||||
)
|
||||
username_elem.send_keys("validUsername123") # 输入有效用户名
|
||||
|
||||
# 等待密码输入框出现
|
||||
password_elem = WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.ID, 'password'))
|
||||
)
|
||||
password_elem.send_keys("测试密码") # 输入中文密码
|
||||
|
||||
# 等待确认密码输入框出现
|
||||
password2_elem = WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.ID, 'password2'))
|
||||
)
|
||||
password2_elem.send_keys("测试密码") # 输入中文确认密码
|
||||
|
||||
# 等待注册按钮出现并点击
|
||||
signup_button = WebDriverWait(driver, 10).until(
|
||||
EC.element_to_be_clickable((By.XPATH, '//button[@onclick="signup()"]'))
|
||||
)
|
||||
signup_button.click()
|
||||
|
||||
# 等待警告框出现并接受
|
||||
WebDriverWait(driver, 10).until(EC.alert_is_present())
|
||||
alert = driver.switch_to.alert
|
||||
alert_text = alert.text
|
||||
print(f"警告文本: {alert_text}")
|
||||
assert alert_text == "Chinese characters are not allowed in the password." # 根据实际的警告文本进行断言
|
||||
alert.accept()
|
||||
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
||||
raise
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
import logging
|
||||
|
||||
from helper import signup
|
||||
|
||||
def login(driver, home, uname, password):
|
||||
driver.get(home)
|
||||
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, '登录'))).click()
|
||||
driver.find_element(By.ID, 'username').send_keys(uname)
|
||||
driver.find_element(By.ID, 'password').send_keys(password)
|
||||
driver.find_element(By.XPATH, '//button[text()="登录"]').click()
|
||||
WebDriverWait(driver, 10).until(EC.title_is(f"EnglishPal Study Room for {uname}"))
|
||||
|
||||
def logout(driver):
|
||||
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, '退出'))).click()
|
||||
|
||||
# 标记文章
|
||||
def collect_article(driver):
|
||||
driver.find_element(By.XPATH, '//button[text()="标记文章"]').click()
|
||||
|
||||
def test_collect_article(driver, URL):
|
||||
try:
|
||||
username, password = signup(URL, driver)
|
||||
title = driver.find_element(By.ID, 'article_title').text
|
||||
article = driver.find_element(By.ID, 'article').text
|
||||
|
||||
collect_article(driver)
|
||||
collected_title = driver.execute_script('return localStorage.getItem("articleTitle");')
|
||||
assert title == collected_title, "Unable to add the article to your collection."
|
||||
|
||||
# 退出登录
|
||||
logout(driver)
|
||||
|
||||
# 再次登录并检查收藏状态
|
||||
login(driver, URL, username, password)
|
||||
rechecked_title = driver.execute_script('return localStorage.getItem("articleTitle");')
|
||||
assert title == rechecked_title, "Collected article not found after re-login."
|
||||
|
||||
except Exception as e:
|
||||
# 输出异常信息
|
||||
logging.error(e)
|
||||
finally:
|
||||
driver.quit()
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
import time
|
||||
import pytest
|
||||
import uuid
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver import ActionChains
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.common.exceptions import UnexpectedAlertPresentException, NoAlertPresentException, NoSuchElementException, \
|
||||
TimeoutException
|
||||
from conftest import URL
|
||||
driver = webdriver.Chrome()
|
||||
def test_bug555():
|
||||
try:
|
||||
driver.maximize_window()
|
||||
base_url = "http://127.0.0.1:5000"
|
||||
driver.get(base_url)
|
||||
article = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'article')))
|
||||
perform_actions_on_article(driver, article)
|
||||
|
||||
next_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_next_article')))
|
||||
next_button.click()
|
||||
print("Clicked next article button.")
|
||||
|
||||
prev_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'load_pre_article')))
|
||||
prev_button.click()
|
||||
print("Clicked previous article button.")
|
||||
|
||||
except (TimeoutException, NoSuchElementException) as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
finally:
|
||||
driver.quit()
|
||||
print("Driver closed.")
|
||||
|
||||
def perform_actions_on_article(driver, article):
|
||||
actions = ActionChains(driver)
|
||||
actions.move_to_element(article)
|
||||
actions.click_and_hold()
|
||||
actions.move_by_offset(450, 200)
|
||||
actions.release()
|
||||
actions.perform()
|
||||
print("Performed actions on article.")
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
''' Contributed by Lin Junhong et al. 2023-06.'''
|
||||
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.common.exceptions import UnexpectedAlertPresentException, NoAlertPresentException
|
||||
import random, time
|
||||
import string
|
||||
|
||||
# 初始化webdriver
|
||||
# driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.CHROME)
|
||||
# driver.implicitly_wait(10)
|
||||
driver = webdriver.Chrome("C:\\Users\\12993\AppData\Local\Programs\Python\Python38\\chromedriver.exe")
|
||||
|
||||
|
||||
def test_next_article():
|
||||
try:
|
||||
driver.get("http://118.25.96.118:90")
|
||||
assert 'English Pal -' in driver.page_source
|
||||
# login
|
||||
elem = driver.find_element_by_link_text('登录')
|
||||
elem.click()
|
||||
|
||||
uname = 'abcdefg'
|
||||
password = 'abcdefg'
|
||||
elem = driver.find_element_by_id('username')
|
||||
elem.send_keys(uname)
|
||||
|
||||
elem = driver.find_element_by_id('password')
|
||||
elem.send_keys(password)
|
||||
elem = driver.find_element_by_xpath('/html/body/div/button') # 找到登录按钮
|
||||
elem.click()
|
||||
|
||||
time.sleep(0.5)
|
||||
assert 'EnglishPal Study Room for ' + uname in driver.title
|
||||
for i in range(50):
|
||||
time.sleep(0.1)
|
||||
# 找到固定按钮
|
||||
elem = driver.find_element_by_xpath('//*[@id="load_next_article"]')
|
||||
elem.click()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
def test_local_next_article():
|
||||
try:
|
||||
driver.get("http://127.0.0.1:5000")
|
||||
assert 'English Pal -' in driver.page_source
|
||||
# login
|
||||
elem = driver.find_element_by_link_text('注册')
|
||||
elem.click()
|
||||
|
||||
uname = 'abcdefg'
|
||||
password = 'abcdefg'
|
||||
elem = driver.find_element_by_id('username')
|
||||
elem.send_keys(uname)
|
||||
|
||||
elem = driver.find_element_by_id('password')
|
||||
elem.send_keys(password)
|
||||
|
||||
elem = driver.find_element_by_id('password2')
|
||||
elem.send_keys(password)
|
||||
|
||||
time.sleep(0.5)
|
||||
|
||||
elem = driver.find_element_by_class_name('btn') # 找到提交按钮
|
||||
elem.click()
|
||||
time.sleep(0.5)
|
||||
try:
|
||||
WebDriverWait(driver, 1).until(EC.alert_is_present())
|
||||
driver.switch_to.alert.accept()
|
||||
except (UnexpectedAlertPresentException, NoAlertPresentException):
|
||||
pass
|
||||
|
||||
time.sleep(0.5)
|
||||
assert 'EnglishPal Study Room for ' + uname in driver.title
|
||||
for i in range(50):
|
||||
time.sleep(0.1)
|
||||
# 找到固定按钮
|
||||
elem = driver.find_element_by_xpath('//*[@id="load_next_article"]')
|
||||
elem.click()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
import requests
|
||||
import hashlib
|
||||
import time
|
||||
from urllib.parse import urlencode
|
||||
|
||||
# 假设这是从某个配置文件中读取的
|
||||
class BaiduContent:
|
||||
APPID = '20240702002090356'
|
||||
SECRET = '3CcqcMAJdIIpgG0uMS_f'
|
||||
|
||||
def generate_sign(q, salt):
|
||||
"""生成百度翻译API所需的签名"""
|
||||
appid = BaiduContent.APPID
|
||||
secret = BaiduContent.SECRET
|
||||
appid_with_data = appid + q + salt + secret
|
||||
md5_obj = hashlib.md5(appid_with_data.encode('utf-8'))
|
||||
return md5_obj.hexdigest()
|
||||
|
||||
def translate(q, from_lang, to_lang):
|
||||
"""调用百度翻译API进行翻译"""
|
||||
salt = str(int(time.time())) # 生成一个时间戳作为salt
|
||||
sign = generate_sign(q, salt)
|
||||
|
||||
# 封装请求参数
|
||||
params = {
|
||||
'q': q,
|
||||
'from': from_lang,
|
||||
'to': to_lang,
|
||||
'appid': BaiduContent.APPID,
|
||||
'salt': salt,
|
||||
'sign': sign
|
||||
}
|
||||
|
||||
# 构造请求URL(百度翻译API使用POST请求,并将参数放在请求体中)
|
||||
url = "http://api.fanyi.baidu.com/api/trans/vip/translate"
|
||||
|
||||
# 发送POST请求
|
||||
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
|
||||
data = urlencode(params).encode('utf-8') # 注意:需要编码为bytes
|
||||
|
||||
response = requests.post(url, data=data, headers=headers)
|
||||
|
||||
# 检查响应状态码
|
||||
if response.status_code == 200:
|
||||
# 解析并返回JSON响应体中的翻译结果
|
||||
try:
|
||||
return response.json()['trans_result'][0]['dst']
|
||||
except (KeyError, IndexError):
|
||||
return "Invalid response from API"
|
||||
else:
|
||||
# 返回错误信息或状态码
|
||||
return {"error": f"Failed with status code {response.status_code}"}
|
||||
|
|
@ -178,17 +178,14 @@ def user_mark_word(username):
|
|||
d = load_freq_history(user_freq_record)
|
||||
lst_history = pickle_idea2.dict2lst(d)
|
||||
lst = []
|
||||
lst2 = []
|
||||
for word in request.form.getlist('marked'):
|
||||
if not word in pickle_idea2.exclusion_lst and len(word) > 2:
|
||||
lst.append((word, [get_time()]))
|
||||
lst2.append(word)
|
||||
lst.append((word, [get_time()]))
|
||||
d = pickle_idea2.merge_frequency(lst, lst_history)
|
||||
if len(lst_history) > 999:
|
||||
flash('You have way too many words in your difficult-words book. Delete some first.')
|
||||
else:
|
||||
pickle_idea2.save_frequency_to_pickle(d, user_freq_record)
|
||||
flash('Added %s.' % ', '.join(lst2))
|
||||
flash('Added %s.' % (', '.join(request.form.getlist('marked'))))
|
||||
return redirect(url_for('user_bp.userpage', username=username))
|
||||
else:
|
||||
return 'Under construction'
|
||||
|
|
|
|||
|
|
@ -10,32 +10,6 @@ import operator
|
|||
import os, sys # 引入模块sys,因为我要用里面的sys.argv列表中的信息来读取命令行参数。
|
||||
import pickle_idea
|
||||
|
||||
|
||||
def map_percentages_to_levels(percentages):
|
||||
'''
|
||||
功能:按照加权平均难度,给生词本计算难度分,计算权重的规则是(10 - 该词汇难度) * 该难度词汇占总词汇的比例,再进行归一化处理
|
||||
输入:难度占比字典,键代表难度3~8,值代表每种难度的单词的占比
|
||||
输出:权重字典,键代表难度3~8,值代表每种难度的单词的权重
|
||||
'''
|
||||
# 已排序的键
|
||||
sorted_keys = sorted(percentages.keys())
|
||||
|
||||
# 计算权重和权重总和
|
||||
sum = 0 # 总和
|
||||
levels_proportions = {}
|
||||
for k in sorted_keys:
|
||||
levels_proportions[k] = 10 - k
|
||||
for k in sorted_keys:
|
||||
levels_proportions[k] *= percentages[k]
|
||||
sum += levels_proportions[k]
|
||||
|
||||
# 归一化权重到权重总和为1
|
||||
for k in sorted_keys:
|
||||
levels_proportions[k] /= sum
|
||||
|
||||
return levels_proportions
|
||||
|
||||
|
||||
def freq(fruit):
|
||||
'''
|
||||
功能: 把字符串转成列表。 目的是得到每个单词的频率。
|
||||
|
|
@ -66,7 +40,7 @@ def file2str(fname):#文件转字符
|
|||
|
||||
|
||||
def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。
|
||||
special_characters = '\_©~<=>+/[]*&$%^@.,?!:;#()"“”—‘’{}|,。?!¥……()、《》【】:;·' # 把里面的字符都去掉
|
||||
special_characters = '\_©~<=>+/[]*&$%^@.,?!:;#()"“”—‘’{}|,。?!¥……()、《》:;·' # 把里面的字符都去掉
|
||||
s = html.unescape(s) # 将HTML实体转换为对应的字符,比如<会被识别为小于号
|
||||
for c in special_characters:
|
||||
s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况
|
||||
|
|
|
|||
|
|
@ -0,0 +1,391 @@
|
|||
[33mcommit 8cbc7c9a0ce543db48f80a743c4168ca847ca500[m[33m ([m[1;36mHEAD[m[33m -> [m[1;32mAlpha-snapshot20240618[m[33m, [m[1;31morigin/master[m[33m, [m[1;31morigin/HEAD[m[33m, [m[1;32mmaster[m[33m)[m
|
||||
Author: lisinan <1299311192@qq.com>
|
||||
Date: Fri May 24 22:00:08 2024 +0800
|
||||
|
||||
修复快速点击下一页按钮点击频率过快时页面跳转到未知名页面
|
||||
|
||||
[33mcommit ff6286cf01bccdda793ec626c66594e43d81cb16[m[33m ([m[1;31morigin/547[m[33m, [m[1;31morigin/542[m[33m)[m
|
||||
Author: 丁晟晔 <759539128@qq.com>
|
||||
Date: Mon May 6 11:42:32 2024 +0800
|
||||
|
||||
删除 app/test/test_bug551_DingZeYu.py
|
||||
|
||||
[33mcommit 1d7e61d7519342396bec9c64cdd8090c1515cec7[m
|
||||
Author: 丁晟晔 <759539128@qq.com>
|
||||
Date: Mon May 6 11:36:36 2024 +0800
|
||||
|
||||
上传文件至 app/test
|
||||
|
||||
[33mcommit 708a6a282102c2b60e3abfade633389bc1f03ddb[m[33m ([m[1;31morigin/Bosh[m[33m)[m
|
||||
Merge: 43c719b 688a198
|
||||
Author: 顾涵 <1554137355@qq.com>
|
||||
Date: Sun Jun 4 12:39:34 2023 +0800
|
||||
|
||||
Merge pull request 'WIP:Bug529-GuHan' (#88) from Bug529-GuHan into master
|
||||
|
||||
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/88
|
||||
|
||||
[33mcommit 688a19876823e818f3f312f865f4921f28f28c53[m[33m ([m[1;31morigin/Bug529-GuHan[m[33m)[m
|
||||
Merge: 030b897 1543b30
|
||||
Author: ghaa0920 <1554137355@qq.com>
|
||||
Date: Sun May 28 16:31:12 2023 +0800
|
||||
|
||||
已经与Alpha-snapshot20230525 分支同步,重新提交
|
||||
|
||||
[33mcommit 1543b3095dde2a295293af1ea7e495d6ba005f8d[m[33m ([m[1;31morigin/Refactor-XunYucan[m[33m, [m[1;31morigin/Alpha-snapshot20230525[m[33m)[m
|
||||
Merge: c6bf323 b41e104
|
||||
Author: Xunflash <xunflash@qq.com>
|
||||
Date: Thu May 25 22:30:06 2023 +0800
|
||||
|
||||
Merge remote-tracking branch 'origin/Alpha-snapshot20230519' into Refactor-XunYucan
|
||||
|
||||
[33mcommit c6bf323c6084255abcde0c47ae1a0504bd372475[m
|
||||
Author: Xunflash <xunflash@qq.com>
|
||||
Date: Thu May 25 21:23:25 2023 +0800
|
||||
|
||||
修改格式
|
||||
|
||||
[33mcommit 03ccb3527a94a3c463b4bffe24ba0f579f286d5f[m
|
||||
Author: Xunflash <xunflash@qq.com>
|
||||
Date: Thu May 25 17:35:31 2023 +0800
|
||||
|
||||
重构前端阅读js,新增阅读器全局对象,新增生词朗读按钮
|
||||
|
||||
[33mcommit b41e1044bce3e4d9169b7743ce9aad74c0fec7d7[m[33m ([m[1;31morigin/Alpha-snapshot20230519[m[33m)[m
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Wed May 24 10:12:44 2023 +0800
|
||||
|
||||
difficulty.py: add some stop words, hoping that getting the next article can be faster.
|
||||
|
||||
[33mcommit 67e921ba60df76640005fa2838d80808b311bc2d[m
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Tue May 23 22:25:40 2023 +0800
|
||||
|
||||
difficulty.py: todo.
|
||||
|
||||
[33mcommit a5c3564f15cea5ddb5f79ba15bf888a332698440[m
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Tue May 23 22:22:57 2023 +0800
|
||||
|
||||
difficulty.py: do not stem a word twice.
|
||||
|
||||
[33mcommit 1295616d5be485475b06e456458a3b8b7a092a50[m
|
||||
Merge: 3494881 c151a0e
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Tue May 23 19:50:30 2023 +0800
|
||||
|
||||
Merge branch 'Bug476-YuHuangtao' of http://121.4.94.30:3000/mrlan/EnglishPal into Alpha-snapshot20230519
|
||||
|
||||
[33mcommit c151a0efaa109aa806c40105cb86d1b3950458ea[m[33m ([m[1;31morigin/Bug476-YuHuangtao[m[33m)[m
|
||||
Author: PlutoCtx <chentingxian195467@163.com>
|
||||
Date: Tue May 23 19:40:33 2023 +0800
|
||||
|
||||
去掉了get_difficulty_level_for_user的多出的break
|
||||
|
||||
[33mcommit 030b89706e51a35d95eb6eafa7ae2b2fefac821b[m
|
||||
Author: ghaa0920 <1554137355@qq.com>
|
||||
Date: Sat May 20 15:29:12 2023 +0800
|
||||
|
||||
special_characters = '\_©~<=>+/[]*&$%^@.,?!:;#()"“”—‘’{}|' 用于过滤字符,我将其中的“-”删去,使连字符没有被过滤,实现录入例如fifty-six等组合词的功能。另外对于删除过滤是否会引发字符bug,答案是肯定的,但是这段代码中的过滤字符虽然多,但是并没有完全过滤掉所有字符,(过滤的只是键盘上能打出的字符,不包括输入法中能打出的特殊字符),所以字符bug本身就一直存在,我认为减少一个“-”字符对程序的过滤过程不会造成问题。
|
||||
|
||||
[33mcommit 349488167b3c1cbdf6116adff5798cf356d94af2[m
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Fri May 19 09:03:20 2023 +0800
|
||||
|
||||
requirements.txt: install snowballstemmer for better computing a word's difficulty level.
|
||||
|
||||
[33mcommit 39d96014d90892faf22b0830ad8d78aeaaa66d96[m
|
||||
Author: PlutoCtx <chentingxian195467@163.com>
|
||||
Date: Thu May 18 23:29:38 2023 +0800
|
||||
|
||||
pull最新的snapshot-20230511,后更新了difficulty.py和Article.py的部分代码,提交了新的pickle文件
|
||||
|
||||
[33mcommit acd8db6e3e1c498650f2e8cc3021828e6132e823[m
|
||||
Author: ghaa0920 <1554137355@qq.com>
|
||||
Date: Mon May 15 19:24:43 2023 +0800
|
||||
|
||||
special_characters = '\_©~<=>+/[]*&$%^@.,?!:;#()"“”—‘’{}|' 用于过滤字符,我将其中的“-”删去,使连字符没有被过滤,实现录入例如fifty-six等组合词的功能。另外对于删除过滤是否会引发字符bug,答案是肯定的,但是这段代码中的过滤字符虽然多,但是并没有完全过滤掉所有字符,(过滤的只是键盘上能打出的字符,不包括输入法中能打出的特殊字符),所以字符bug本身就一直存在,我认为减少一个对“1-”字符的过滤不会造成问题。
|
||||
|
||||
[33mcommit 9f3f5b43e1bc79e884091593b9b8f3d6a2164ea5[m
|
||||
Author: ghaa0920 <1554137355@qq.com>
|
||||
Date: Mon May 15 19:15:30 2023 +0800
|
||||
|
||||
special_characters = '\_©~<=>+/[]*&$%^@.,?!:;#()"“”—‘’{}|' 用于过滤字符,我将其中的“-”删去,使连字符没有被过滤,实现录入例如fifty-six等组合词的功能。另外对于删除过滤是否会引发字符bug,答案是肯定的,但是这段代码中的过滤字符虽然多,但是并没有完全过滤掉所有字符,(过滤的只是键盘上能打出的字符,不包括输入法中能打出的特殊字符),所以字符bug本身就一直存在,我认为减少一个对“-”字符的过滤不会造成问题。
|
||||
|
||||
[33mcommit d9f6df7fbe585395a19b9a08c411d841b6b89fd4[m[33m ([m[1;31morigin/Bug532-HuangDan[m[33m)[m
|
||||
Author: huangdan <2741654266@qq.com>
|
||||
Date: Thu May 11 15:51:10 2023 +0800
|
||||
|
||||
AJAX载入文章数据
|
||||
|
||||
[33mcommit 5039f5710e4575ecbd9c5bfcc2e349dbe6025bfa[m[33m ([m[1;31morigin/Alpha-snapshot20230507[m[33m)[m
|
||||
Author: huangdan <2741654266@qq.com>
|
||||
Date: Mon May 8 14:33:48 2023 +0800
|
||||
|
||||
AJAX载入文章数据
|
||||
|
||||
[33mcommit becef7e3436c93561ba581cff9b9ca9da118c888[m[33m ([m[1;31morigin/Alpha-snapshot20230506[m[33m)[m
|
||||
Merge: a4cc4fd 01ecc83
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Sun May 7 15:59:35 2023 +0800
|
||||
|
||||
Merge branch 'Bug502-YuGaoXiang' of http://121.4.94.30:3000/mrlan/EnglishPal into Alpha-snapshot20230506
|
||||
|
||||
[33mcommit 01ecc8376893404cb026e34e7f8fecbefcd082cf[m[33m ([m[1;31morigin/Bug502-YuGaoXiang[m[33m)[m
|
||||
Author: Awoodwhale <woodwhale@qq.com>
|
||||
Date: Sat May 6 17:42:04 2023 +0800
|
||||
|
||||
refactor: refactor the way to check article level
|
||||
|
||||
[33mcommit f64d06fbbf00255fc21f141d852d8995e588785e[m
|
||||
Author: Awoodwhale <woodwhale@qq.com>
|
||||
Date: Sat May 6 17:24:51 2023 +0800
|
||||
|
||||
fix: fix Bug 531 and use ES6 grammar
|
||||
|
||||
[33mcommit a4cc4fd011317f3daec2de456b95abca16841663[m
|
||||
Merge: 779dafe 18ca48b
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Sat May 6 17:16:08 2023 +0800
|
||||
|
||||
Merge branch 'Bug522-HuangZirui' of http://121.4.94.30:3000/mrlan/EnglishPal into Alpha-snapshot20230506
|
||||
|
||||
[33mcommit 18ca48b42214720f411937b01c20550a5f96580b[m
|
||||
Merge: a80b062 ce2e1f2
|
||||
Author: ZhuZhihao <1287365321@qq.com>
|
||||
Date: Fri May 5 17:21:49 2023 +0800
|
||||
|
||||
Merge branch 'Bug522-HuangZirui' of http://121.4.94.30:3000/mrlan/EnglishPal into Bug522-HuangZirui
|
||||
|
||||
[33mcommit a80b062b8707fb6a73554b8500b8c5ae17775ed3[m
|
||||
Author: ZhuZhihao <1287365321@qq.com>
|
||||
Date: Fri May 5 17:20:58 2023 +0800
|
||||
|
||||
refactor: remove variable 'count'
|
||||
|
||||
[33mcommit 779dafefe8a3ae5c40b3376d2b0309c0ddcd3273[m[33m ([m[1;31morigin/Alpha-snapshot20230427[m[33m)[m
|
||||
Merge: e118d92 d30a434
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Thu Apr 27 07:21:15 2023 +0800
|
||||
|
||||
Merge branch 'Bug509-XieQiuHan-WangZiming' of http://121.4.94.30:3000/mrlan/EnglishPal into Alpha-snapshot20230427
|
||||
|
||||
[33mcommit e118d92659911db4f3bd047a67865522c8b00c66[m
|
||||
Merge: ce2e1f2 5654fbf
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Thu Apr 27 07:20:21 2023 +0800
|
||||
|
||||
Merge branch 'Alpha-snapshot20230425' of http://121.4.94.30:3000/mrlan/EnglishPal into Alpha-snapshot20230427
|
||||
|
||||
[33mcommit 5654fbf9bc3ae85eec621a4e6e2ecd1f6c6c3b30[m[33m ([m[1;31morigin/Alpha-snapshot20230425[m[33m)[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Wed Apr 26 18:49:59 2023 +0800
|
||||
|
||||
修改:使用新的/<username>/userpage路由
|
||||
|
||||
[33mcommit d30a434b2a0dce5247bb005c5c245529d5a542d4[m[33m ([m[1;31morigin/Bug509-XieQiuHan-WangZiming[m[33m)[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Tue Apr 25 17:47:51 2023 +0800
|
||||
|
||||
修改变量名had_read_articles->visited_articles
|
||||
|
||||
[33mcommit b88bc8f36b395f3979d4a9b37993b88b8a9eb658[m
|
||||
Merge: ef78679 6be035f
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Tue Apr 25 11:40:42 2023 +0800
|
||||
|
||||
Merge branch 'Bug509-XieQiuHan-WangZiming' of http://121.4.94.30:3000/mrlan/EnglishPal into Alpha-snapshot20230425
|
||||
|
||||
[33mcommit 6be035f2828286b5cd59f15ec04336b86c3cb0fa[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Tue Apr 25 11:38:01 2023 +0800
|
||||
|
||||
修复当没有找到文章或者文章读完时,直接刷新页面或者session不关闭重新进入页面,导致的错误;
|
||||
|
||||
[33mcommit ef786795e27287502b5388e2e80aa83eac596c8d[m
|
||||
Merge: 21a77ef fc3e274
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Tue Apr 25 08:47:22 2023 +0800
|
||||
|
||||
Resolve merge conflict
|
||||
|
||||
[33mcommit 21a77ef2df5111ca4fb0103624ee0b68a15b2a06[m
|
||||
Merge: 58d7349 f3d609c
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Tue Apr 25 08:42:18 2023 +0800
|
||||
|
||||
Merge branch 'Alpha' of http://121.4.94.30:3000/mrlan/EnglishPal into Alpha
|
||||
|
||||
[33mcommit 58d7349afe69c5934754cb7a5145b33382326c37[m
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Tue Apr 25 08:40:26 2023 +0800
|
||||
|
||||
Change from bug359-zhangkeli
|
||||
|
||||
[33mcommit fc3e27488b3b55c1013a970e6abb95b88caff9aa[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Fri Apr 21 05:33:26 2023 +0800
|
||||
|
||||
给标签添加id,方便测试
|
||||
|
||||
[33mcommit 03145b57d98c29ae04948281e8e4e67512e75829[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Fri Apr 21 02:36:51 2023 +0800
|
||||
|
||||
修复边界值问题(当刚开始就没有找到文章或者就根本被没有文章的时候,会出现上一篇按钮)
|
||||
|
||||
[33mcommit 70917df47b91f7fbb16870b15f2a2ecdbdad6135[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Thu Apr 20 23:15:12 2023 +0800
|
||||
|
||||
删除测试代码
|
||||
|
||||
[33mcommit 8f132ed87bfc00e321214dd4a4d6ed2a3ff4a8cd[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Thu Apr 20 22:53:30 2023 +0800
|
||||
|
||||
添加了阅读完所有文章的提示
|
||||
|
||||
[33mcommit da13e5bbd5da2a1ceb838c5a4836a0cabd8bdf69[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Thu Apr 20 21:28:29 2023 +0800
|
||||
|
||||
修复Bug(没找到文章后立即上一篇会回到上上篇文章) & 标签添加id方便测试
|
||||
|
||||
[33mcommit 84affaeb69fdecb155cdf4daa4f57c4b29dbea55[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Thu Apr 20 20:30:14 2023 +0800
|
||||
|
||||
修改 /<username> 路由存在的问题(每次调用别的路由他都会被调用),新路由为 /<username>/userpage;同时因为修改了路由导致访问userpage_get的时候会导致静态文件路径生成错误,这里修改了\static\config.yml中的静态资源路径,修改后也都可以正常访问到的
|
||||
|
||||
[33mcommit 16de0a7fd99a26d331e23eac7c1fd22594b7c50f[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Thu Apr 20 15:40:11 2023 +0800
|
||||
|
||||
修改变量命名:existing_articles → had_read_articles
|
||||
|
||||
[33mcommit ce2e1f2978e68aac46a03e0d7bc5e27b78a1106a[m[33m ([m[1;31morigin/Alpha-snapshot20230426[m[33m)[m
|
||||
Merge: 11ae093 cc8ca47
|
||||
Author: zzhaofisher <10839192+zzhaofisher@user.noreply.gitee.com>
|
||||
Date: Tue Apr 18 21:52:28 2023 +0800
|
||||
|
||||
Merge branch 'DevLocal' into Bug522-HuangZirui
|
||||
|
||||
[33mcommit 11ae093fd7b714b37bd26f42ad9f5b042ae1dfc1[m
|
||||
Merge: 3bce450 f3d609c
|
||||
Author: zzhaofisher <10839192+zzhaofisher@user.noreply.gitee.com>
|
||||
Date: Tue Apr 18 21:52:01 2023 +0800
|
||||
|
||||
Merge branch 'Alpha' into Bug522-HuangZirui
|
||||
|
||||
[33mcommit cc8ca47f8c96eedaf2ce7ec61f5480123663953f[m
|
||||
Author: zzhaofisher <10839192+zzhaofisher@user.noreply.gitee.com>
|
||||
Date: Tue Apr 18 21:50:54 2023 +0800
|
||||
|
||||
refactor: remove sql sentences
|
||||
|
||||
[33mcommit 5d20e92061d3c43dab01e0ca9483779fc9b9a9a2[m
|
||||
Merge: f3d609c 3bce450
|
||||
Author: zzhaofisher <10839192+zzhaofisher@user.noreply.gitee.com>
|
||||
Date: Tue Apr 18 21:50:18 2023 +0800
|
||||
|
||||
Merge branch 'Bug522-HuangZirui' of http://121.4.94.30:3000/mrlan/EnglishPal into DevLocal
|
||||
|
||||
[33mcommit f3d609c92bfd27ed4ef70cab838a7d1362a5fb6b[m[33m ([m[1;31morigin/Alpha[m[33m)[m
|
||||
Merge: 688ed72 15bb925
|
||||
Author: Lan Hui <1348141770@qq.com>
|
||||
Date: Fri Apr 7 06:41:49 2023 +0800
|
||||
|
||||
Merge Wang Ziming's work and Wu Yuhan's work.
|
||||
|
||||
[33mcommit 15bb9250248aa6feb249be72c53d3fa6d7005d52[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Tue Apr 4 22:31:53 2023 +0800
|
||||
|
||||
将记录阅读过文章的数据结果改为字典,以及修改了flag的问题
|
||||
|
||||
[33mcommit 688ed724734fddb4a07e9dd0dc5b6b2ace16e645[m
|
||||
Author: Lan Hui <1348141770@qq.com>
|
||||
Date: Sat Apr 1 16:07:59 2023 +0800
|
||||
|
||||
Correct grammar。
|
||||
|
||||
[33mcommit 1f150fc847d0fc70947261ff45843ccc116117c2[m
|
||||
Author: Awoodwhale <woodwhale@qq.com>
|
||||
Date: Fri Mar 31 13:39:28 2023 +0800
|
||||
|
||||
refactor: use ajax to get expiry_date
|
||||
|
||||
[33mcommit 7107f634c2ec9fa12dd6bcbed9f4ee5c339928c7[m
|
||||
Merge: 6f1dd13 4417cf7
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Fri Mar 31 04:58:21 2023 +0800
|
||||
|
||||
Merge branch 'test' into dev-fixBug509-reconstruction
|
||||
|
||||
[33mcommit 6f1dd134193cb3f9fa1d3502b286d3be1f22c1ed[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Fri Mar 31 04:50:41 2023 +0800
|
||||
|
||||
测试的print忘删了
|
||||
|
||||
[33mcommit 4417cf7017d50f20d99e1a274b48ad5d3b32e8e6[m
|
||||
Author: Hui Lan <lanhui@zjnu.edu.cn>
|
||||
Date: Thu Mar 30 16:10:22 2023 +0800
|
||||
|
||||
Article.py: remove debug statement.
|
||||
|
||||
[33mcommit 0c16a4dc6f21849915cdad92c7189e37ccb9a289[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Wed Mar 29 20:53:38 2023 +0800
|
||||
|
||||
判断文章是否已经出现的语句写错位置了,改正下
|
||||
|
||||
[33mcommit 5b2f5199a82be7cdb7bb3ac57f7b54b5ea0f4034[m
|
||||
Author: 一问三不知 <178428409@qq.com>
|
||||
Date: Mon Mar 27 14:28:54 2023 +0800
|
||||
|
||||
1. 取消userpage_get.html中提示删除单词信息的代码 和 取消user_service.userpage中render_template的flashed_messages参数。因为删除单词操作已经是异步了,而提示信息的出现是同步执行,所以就注释了代码且没有产生太大影响。
|
||||
2. 修改取消user_service.deleteword中对注释flash代码的注释,根据上一步进行了重新解释。
|
||||
|
||||
[33mcommit 0ce1c6eb6e5707ccfb47113b2c58c9961f2eae48[m
|
||||
Author: Lan Hui <1348141770@qq.com>
|
||||
Date: Sun Mar 26 21:14:29 2023 +0800
|
||||
|
||||
文章管理页面:每篇文章中保留换行,方便查看。
|
||||
|
||||
[33mcommit d4ac7093859d400f77f24c7cf5b6d39dd67b2e9a[m
|
||||
Author: Lan Hui <1348141770@qq.com>
|
||||
Date: Sun Mar 26 21:05:05 2023 +0800
|
||||
|
||||
将删除按钮移到第一行,避免因为文章的标题过长跨行导致删除按钮形状改变。
|
||||
|
||||
[33mcommit 9eb5210d3f11211abe756597518d09b1cfd8f3e4[m
|
||||
Author: Lan Hui <1348141770@qq.com>
|
||||
Date: Sun Mar 26 20:58:37 2023 +0800
|
||||
|
||||
Level与Date的冒号后面加个空格,使得后面的信息更加看得清楚。
|
||||
|
||||
[33mcommit 0e257373816ee365d41e78b0b13ba807e0230aac[m
|
||||
Author: Lan Hui <1348141770@qq.com>
|
||||
Date: Sun Mar 26 20:56:08 2023 +0800
|
||||
|
||||
管理文章页面的文章列表中,每篇文章不再在内容部分重新显示标题。
|
||||
|
||||
[33mcommit b3b154a24f9bb267146712e6020903a6e574c976[m
|
||||
Author: Lan Hui <1348141770@qq.com>
|
||||
Date: Sun Mar 26 19:06:04 2023 +0800
|
||||
|
||||
简化管理文章与管理用户页面信息。
|
||||
|
||||
[33mcommit 4d99405bfaf2f87abdf4bfa1291083419c6df502[m
|
||||
Author: Lan Hui <1348141770@qq.com>
|
||||
Date: Sun Mar 26 18:59:15 2023 +0800
|
||||
|
||||
简化管理员页面信息。删除退出登录按钮,可以返回到前一页后再退出,不影响使用体验。删除'管理员您好'欢迎词,没啥意义。
|
||||
|
||||
[33mcommit 8d8b9197b614b595bbba1ecf95c189ea1389780c[m
|
||||
Author: Lan Hui <1348141770@qq.com>
|
||||
Date: Sun Mar 26 09:59:06 2023 +0800
|
||||
|
||||
手动输入的文字最高难度等级是4
|
||||
|
|
@ -4,6 +4,5 @@ PyYAML~=6.0
|
|||
pony==0.7.16
|
||||
snowballstemmer==2.2.0
|
||||
Werkzeug==2.2.2
|
||||
requests
|
||||
|
||||
pytest~=8.1.1
|
||||
Flask-HTTPAuth==4.4.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue