From 5c85041135020001c2163f129e6940da2bb31639 Mon Sep 17 00:00:00 2001 From: renyu <1154817144@qq.com> Date: Fri, 25 Nov 2022 15:42:37 +0800 Subject: [PATCH 01/15] =?UTF-8?q?Bug=20512=20-=20=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=9C=97=E8=AF=BB=E9=97=AE=E9=A2=98=20=E5=9C=A8fillwowrd.js?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86stopRead()=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=B0=86=E5=85=B6=E6=B7=BB=E5=8A=A0=E7=BB=99?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E6=8C=89=E9=92=AE=E6=88=96=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E4=BB=A5=E7=BB=88=E6=AD=A2=E6=9C=97=E8=AF=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/fillword.js | 4 ++++ app/templates/userpage_get.html | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/static/js/fillword.js b/app/static/js/fillword.js index 505808e..ba249dd 100644 --- a/app/static/js/fillword.js +++ b/app/static/js/fillword.js @@ -62,3 +62,7 @@ function onReadClick() { function onChooseClick() { isChoose = !isChoose; } + +function stopRead() { + reader.cancel(); +} \ No newline at end of file diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index 9e3891b..24bff60 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -23,15 +23,15 @@

English Pal for {{ username }} - 退出 - 重设密码 + 退出 + 重设密码

{{ flashed_messages|safe }} - 下一篇 Next Article + 下一篇 Next Article {% if session.get('articleID') != session.get('old_articleID') %} {% if session.get('old_articleID') != None %} - 上一篇 Previous Article + 上一篇 Previous Article {% endif%} {% endif %} @@ -52,7 +52,7 @@

收集生词吧 (可以在正文中划词,也可以复制黏贴)


- +
{% if session.get['thisWord'] %} From 3609421976313c1dd9e9551d65a11f445d32c632 Mon Sep 17 00:00:00 2001 From: Rui <603992850@qq.com> Date: Tue, 29 Nov 2022 16:53:59 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E5=AF=B9=E7=A1=AE=E8=AE=A4=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E9=83=A8=E5=88=86=E4=BF=9D=E8=AF=81=E6=9C=89=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=AF=BB=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/signup.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/signup.html b/app/templates/signup.html index bbc653a..55881ff 100644 --- a/app/templates/signup.html +++ b/app/templates/signup.html @@ -126,7 +126,7 @@ h1{

-

+

From 7e3004a2e68d1affff03daa45fb344bde91b19c2 Mon Sep 17 00:00:00 2001 From: Rui <603992850@qq.com> Date: Tue, 29 Nov 2022 16:55:48 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E6=92=A4=E5=9B=9E=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/signup.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/signup.html b/app/templates/signup.html index 55881ff..64eb28d 100644 --- a/app/templates/signup.html +++ b/app/templates/signup.html @@ -126,7 +126,7 @@ h1{

-

+

From b65ffa6054a416122340148d96e4e07353989ca8 Mon Sep 17 00:00:00 2001 From: LiangLiGang <3103167775@qq.com> Date: Thu, 1 Dec 2022 21:04:12 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=95=E8=AF=8D?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=8B=BE=E9=80=89,=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/userpage_post.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/userpage_post.html b/app/templates/userpage_post.html index 725ee09..1163787 100644 --- a/app/templates/userpage_post.html +++ b/app/templates/userpage_post.html @@ -20,7 +20,7 @@ EnglishPal Study Room for {{username}} -

勾选不认识的单词

+

取消勾选认识的单词

{% for x in lst %} @@ -30,7 +30,7 @@ : {{word}} ({{x[1]}}) - +

{% endfor %} From 89c12337d54147a3874255def57e8dbe3ff14ba8 Mon Sep 17 00:00:00 2001 From: Rui <603992850@qq.com> Date: Fri, 2 Dec 2022 15:48:45 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E5=9C=A8README=E4=B8=AD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index ec92598..fb70948 100644 --- a/README.md +++ b/README.md @@ -181,4 +181,14 @@ Demo video link: https://b23.tv/QuB77m 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 2021-10-17* \ No newline at end of file From d58dacd71cc4a0a693b9d8a123f5ea24375dd8c1 Mon Sep 17 00:00:00 2001 From: ShumTin <970206989@qq.com> Date: Tue, 6 Dec 2022 14:40:50 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug508,=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E5=B8=A6=E6=9C=89=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6?= =?UTF-8?q?|=E7=9A=84=E5=8D=95=E8=AF=8D=E5=9C=A8=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E9=AB=98=E4=BA=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/highlight.js | 2 ++ app/wordfreqCMD.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index 1003918..7b3cab2 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -29,6 +29,8 @@ function highLight() { const list = allWords.split(" "); for (let i = 0; i < list.length; ++i) { list[i] = list[i].replace(/(^\s*)|(\s*$)/g, ""); //消除单词两边的空字符 + list[i] = list[i].replace('|', ""); + list[i] = list[i].replace('?', ""); if (list[i] !== "" && "".indexOf(list[i]) === -1 && "".indexOf(list[i]) === -1) { //将文章中所有出现该单词word的地方改为:" " + word + " "。 正则表达式RegExp()中,"\\s"代表单词前后必须要有空格,以防止只对单词中的部分字符高亮的情况出现。 articleContent = articleContent.replace(new RegExp("\\s"+list[i]+"\\s", "g"), " " + list[i] + " "); diff --git a/app/wordfreqCMD.py b/app/wordfreqCMD.py index 9ee7e56..7c3f186 100644 --- a/app/wordfreqCMD.py +++ b/app/wordfreqCMD.py @@ -39,7 +39,7 @@ def file2str(fname):#文件转字符 def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。 - special_characters = '_©~=+[]*&$%^@.,?!:;#()"“”—‘’' # 把里面的字符都去掉 + special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}' # 把里面的字符都去掉 for c in special_characters: s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况 s = s.replace('--', ' ') From 6327b117110e2c41e7888d16c1e8fa46298124ff Mon Sep 17 00:00:00 2001 From: MR LAN <1348141770@qq.com> Date: Tue, 6 Dec 2022 16:06:13 +0800 Subject: [PATCH 07/15] Made folder 'frequency' under folder 'static', and added a README file under folder 'frequency' --- app/static/frequency/README.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/static/frequency/README.txt diff --git a/app/static/frequency/README.txt b/app/static/frequency/README.txt new file mode 100644 index 0000000..3a9c1f9 --- /dev/null +++ b/app/static/frequency/README.txt @@ -0,0 +1,5 @@ +This folder holds users' vocabulary files. +Each file ends with .pickle. +For example, mrlan.pickle is the vocabulary file for user mrlan. + + From f37ea182f64e0484541b0a27fb317acb97e4ea07 Mon Sep 17 00:00:00 2001 From: ShumTin <970206989@qq.com> Date: Tue, 6 Dec 2022 17:02:59 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=94=9F=E8=AF=8D?= =?UTF-8?q?=E5=BA=93=E8=BF=87=E6=BB=A4|?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/wordfreqCMD.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/wordfreqCMD.py b/app/wordfreqCMD.py index 7c3f186..c4f8a63 100644 --- a/app/wordfreqCMD.py +++ b/app/wordfreqCMD.py @@ -39,7 +39,7 @@ def file2str(fname):#文件转字符 def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。 - special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}' # 把里面的字符都去掉 + special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}|' # 把里面的字符都去掉 for c in special_characters: s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况 s = s.replace('--', ' ') From 086dfcb6eb3cb8aae63e93b21ca071381bb24b41 Mon Sep 17 00:00:00 2001 From: np1717 <1004186200@qq.com> Date: Mon, 19 Dec 2022 17:54:10 +0800 Subject: [PATCH 09/15] fix bug 489 --- .DS_Store | Bin 0 -> 6148 bytes app/templates/signup.html | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7b9e3399d7747d6de8838936b3d6673c4464d460 GIT binary patch literal 6148 zcmeHK%Wl&^6g|@f>NG;i0;Fy#Sz=p-RE1Wk8#km2kl54+7Jx!r8*0_@gxDdKqDWc8 zKky4|`4awx6`Xlgic`8_flxG8nmKo7?wRX3)_6PsM0XPJ0WAO?i^BRAt3Q|;SLK>* z*d8?~)Ex3G%4Ecrn$DS1z$x&*E1>pn4FilYdYV=C?=eT(zqIK^*r;e)jO;G|9*wfJ zC_9}WVxv~Sb$ip>^qSt=@LW#Aa!^i+?qK{{wO&Y>MOXeHdYLBEe(UZNnU{k!PsW;% z#tB2-yh`&}PP=lF$A#vGX25HBjecu;HrspD+4c7yAIx|C+2JAmhx-TfdBeMR|H08| z{~{aa^0N_L@SCLVj>RkZLdUM=Q#j5unSWr9iuMp;f)p8Iv{B%EMU!ugS=M9=JxHA4 z0tv==ubD}eBX(9eO*~_CPEN|YxPhgfaXC{1r#Qhe^F1fFF+{wQ=jRHe#V1PeQLjgN zL!Gr`#x_b^qO9^cH}G}oeY5Fotrf8Q!)vbfD&69o0#1RyQ9ykkd=`a)#f3rr>0qU= z0K_`Gwb9o<|3qJP5Ce+~gY2ORLnRujuvZLW?+(JyIUd;fg+W7y(3v@p%`EHvBoKj-xvs)*8l(j literal 0 HcmV?d00001 diff --git a/app/templates/signup.html b/app/templates/signup.html index 64eb28d..e070d8f 100644 --- a/app/templates/signup.html +++ b/app/templates/signup.html @@ -125,8 +125,8 @@ h1{

-

-

+

+

From 03353d49b151ea730c1396077c10dde48cc81a32 Mon Sep 17 00:00:00 2001 From: mrlan Date: Sun, 29 Jan 2023 10:57:58 +0800 Subject: [PATCH 10/15] Bug525-Hui (#79) Co-authored-by: Hui Lan Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/79 Co-authored-by: mrlan Co-committed-by: mrlan --- app/Login.py | 4 ++-- app/templates/expiry.html | 2 +- app/user_service.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Login.py b/app/Login.py index 1ada0af..8e0030b 100644 --- a/app/Login.py +++ b/app/Login.py @@ -1,6 +1,6 @@ import hashlib import string -from datetime import datetime +from datetime import datetime, timedelta from UseSqlite import InsertQuery, RecordQuery path_prefix = '/var/www/wordfreq/wordfreq/' @@ -23,7 +23,7 @@ def verify_user(username, password): def add_user(username, password): start_date = datetime.now().strftime('%Y%m%d') - expiry_date = '20221230' + expiry_date = (datetime.now() + timedelta(days=30)).strftime('%Y%m%d') # will expire after 30 days # 将用户名和密码一起加密,以免暴露不同用户的相同密码 password = md5(username + password) rq = InsertQuery(path_prefix + 'static/wordfreqapp.db') diff --git a/app/templates/expiry.html b/app/templates/expiry.html index 797a109..9464325 100644 --- a/app/templates/expiry.html +++ b/app/templates/expiry.html @@ -5,7 +5,7 @@ 账号过期 -

您的账号{{ username }}过期。

+

您的账号过期(过期日 {{expiry_date}})。

为了提高服务质量,English Pal 收取会员费用, 每天1元。

请决定你要试用的时间长度,扫描下面支付宝二维码支付。 支付时请注明English Pal Membership Fee。 我们会于12小时内激活账号。

支付宝二维码

diff --git a/app/user_service.py b/app/user_service.py index 79c7888..2d10404 100644 --- a/app/user_service.py +++ b/app/user_service.py @@ -107,7 +107,7 @@ def userpage(username): # 用户过期 user_expiry_date = session.get('expiry_date') if datetime.now().strftime('%Y%m%d') > user_expiry_date: - return render_template('expiry.html') + return render_template('expiry.html', expiry_date=user_expiry_date) # 获取session里的用户名 username = session.get('username') From 972a1a5524dde8fcdea9ad3b63f7e397ebba504a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=A7=8B=E4=BC=9F?= <2658626578@qq.com> Date: Sun, 29 Jan 2023 11:49:27 +0800 Subject: [PATCH 11/15] Bug490-ChenQiuwei (#63) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复Bug-490,使注册时确认密码能够发挥作用,在确认密码与所设置密码不一致时,能够提示“确认密码与输入密码不一致”。 Co-authored-by: 2658626578 <2658626578@qq.com> Co-authored-by: Hui Lan Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/63 Co-authored-by: 陈秋伟 <2658626578@qq.com> Co-committed-by: 陈秋伟 <2658626578@qq.com> --- app/account_service.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/account_service.py b/app/account_service.py index dc854a3..9b1c46b 100644 --- a/app/account_service.py +++ b/app/account_service.py @@ -5,7 +5,6 @@ from Login import check_username_availability, verify_user, add_user, get_expiry # 初始化蓝图 accountService = Blueprint("accountService", __name__) - ### Sign-up, login, logout ### @accountService.route("/signup", methods=['GET', 'POST']) def signup(): @@ -20,6 +19,7 @@ def signup(): # POST方法需判断是否注册成功,再根据结果返回不同的内容 username = escape(request.form['username']) password = escape(request.form['password']) + password2 = escape(request.form['password2']) #! 添加如下代码为了过滤注册时的非法字符 warn = WarningMessage(username) @@ -32,6 +32,8 @@ def signup(): return render_template('signup.html') elif len(password.strip()) < 4: # 密码过短 return '密码过于简单。' + elif password != password2: + return '确认密码与输入密码不一致!' else: # 添加账户信息 add_user(username, password) verified = verify_user(username, password) @@ -48,6 +50,7 @@ def signup(): return '用户名密码验证失败。' + @accountService.route("/login", methods=['GET', 'POST']) def login(): ''' From 9cdc9c6f7fe06fcdb485c9ca038f953a67cf30e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9B=A8=E5=B3=B0?= <1141730046@qq.com> Date: Sun, 29 Jan 2023 12:01:19 +0800 Subject: [PATCH 12/15] Bug521-LiYuFeng-Refactor (#72) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @mrlan 蓝老师: 本次改进内容如下: 1. 对生词居中问题进行修改,现在已经不会居中了。 2. 对于单词数量基数大而导致的排序速度慢的问题,我们进行了优化,提升了排序的速度。 3. 对用户交互进行了优化,当用户点击“熟悉”或“不熟悉”之后,会自动进行排序,并会跳转到那个单词的位置,用抖动的效果来提示用户。 Co-authored-by: isaac <1141730046@qq.com> Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/72 Co-authored-by: 李雨峰 <1141730046@qq.com> Co-committed-by: 李雨峰 <1141730046@qq.com> --- app/static/js/word_operation.js | 139 ++++++++++++++++++++++++++++++-- app/templates/userpage_get.html | 64 ++++++++++----- 2 files changed, 177 insertions(+), 26 deletions(-) diff --git a/app/static/js/word_operation.js b/app/static/js/word_operation.js index a55fb6e..a9af300 100644 --- a/app/static/js/word_operation.js +++ b/app/static/js/word_operation.js @@ -7,10 +7,20 @@ function familiar(theWord) { url:"/" + username + "/" + word + "/familiar", success:function(response){ let new_freq = freq - 1; - if(new_freq <1) { - $("#p_" + theWord).remove(); + const allow_move = document.getElementById("move_dynamiclly").checked; + if (allow_move) { + + if (new_freq <= 0) { + removeWord(theWord); + } else { + renderWord({ word: theWord, freq: new_freq }); + } } else { - $("#freq_" + theWord).text(new_freq); + if(new_freq <1) { + $("#p_" + theWord).remove(); + } else { + $("#freq_" + theWord).text(new_freq); + } } } }); @@ -25,7 +35,12 @@ function unfamiliar(theWord) { url:"/" + username + "/" + word + "/unfamiliar", success:function(response){ let new_freq = parseInt(freq) + 1; - $("#freq_" + theWord).text(new_freq); + const allow_move = document.getElementById("move_dynamiclly").checked; + if (allow_move) { + renderWord({ word: theWord, freq: new_freq }); + } else { + $("#freq_" + theWord).text(new_freq); + } } }); } @@ -37,7 +52,121 @@ function delete_word(theWord) { type:"GET", url:"/" + username + "/" + word + "/del", success:function(response){ - $("#p_" + theWord).remove(); + const allow_move = document.getElementById("move_dynamiclly").checked; + if (allow_move) { + removeWord(theWord); + } else { + $("#p_" + theWord).remove(); + } } }); } + +/* + * interface Word { + * word: string, + * freq: number + * } +* */ + +/** + * 传入一个词频HTML元素,将其解析为Word类型的对象 + */ +function parseWord(element) { + const word = element + .querySelector("a.btn.btn-light[role=button]") // 获取当前词频元素的词汇元素 + .innerText // 获取词汇值; + const freq = Number.parseInt(element.querySelector(`#freq_${word}`).innerText); // 获取词汇的数量 + return { + word, + freq + }; +} + +/** + * 使用模板将传入的单词转换为相应的HTML字符串 +*/ +function wordTemplate(word) { + // 这个模板应当与 templates/userpage_get.html 中的

...

保持一致 + return `

+ ${word.word} + ( ${word.freq} ) + 熟悉 + 不熟悉 + 删除 +

`; +} + +/** + * 删除某一词频元素 + * 此处word为词频元素对应的单词 + */ +function removeWord(word) { + // 根据词频信息删除元素 + const element_to_remove = document.getElementById(`p_${word}`); + if (element_to_remove != null) { + element_to_remove.remove(); + } +} + +function renderWord(word) { + const container = document.querySelector(".word-container"); + // 删除原有元素 + removeWord(word.word); + // 插入新元素 + let inserted = false; + const new_element = elementFromString(wordTemplate(word)); + for (const current of container.children) { + const cur_word = parseWord(current); + // 找到第一个词频比它小的元素,插入到这个元素前面 + if (compareWord(cur_word, word) == -1) { + container.insertBefore(new_element, current); + inserted = true; + break; + } + } + // 当word就是词频最小的词时,把他补回去 + if (!inserted) { + container.appendChild(new_element); + } + // 让发生变化的元素抖动 + new_element.classList.add("shaking"); + // 移动到该元素 + new_element.scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"}); + // 抖动完毕后删除抖动类 + setTimeout(() => { + new_element.classList.remove("shaking"); + }, 1600); +} + +/** + * 从string中创建一个HTML元素并返回 + */ +function elementFromString(string) { + const d = document.createElement('div'); + d.innerHTML = string; + return d.children.item(0); +} + +/** + * 对比两个单词: + * 当first小于second时返回-1 + * 当first等于second时返回0 + * 当first大于second时返回1 + */ +function compareWord(first, second) { + if (first.freq < second.freq) { + return -1; + } + if (first.freq > second.freq) { + return 1; + } + if (first.word < second.word) { + return -1; + } + if (first.word > second.word) { + return 1; + } + return 0; +} \ No newline at end of file diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index 24bff60..dc0d497 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -19,19 +19,33 @@ {% endif %} EnglishPal Study Room for {{ username }} + +

English Pal for {{ username }} - 退出 - 重设密码 + 退出 + 重设密码

{{ flashed_messages|safe }} - 下一篇 Next Article + 下一篇 Next Article {% if session.get('articleID') != session.get('old_articleID') %} {% if session.get('old_articleID') != None %} - 上一篇 Previous Article + 上一篇 Previous Article {% endif%} {% endif %} @@ -52,7 +66,7 @@

收集生词吧 (可以在正文中划词,也可以复制黏贴)


- +
{% if session.get['thisWord'] %} @@ -67,22 +81,30 @@ {% endif %} {% if d_len > 0 %} -

我的生词簿

- {% for x in lst3 %} - {% set word = x[0] %} - {% set freq = x[1] %} - {% if session.get('thisWord') == x[0] and session.get('time') == 1 %} - - {% endif %} -

- {{ word }} - ( {{ freq }} ) - 熟悉 - 不熟悉 - 删除 -

- {% endfor %} +

+ 我的生词簿 + +

+ +
+ {% for x in lst3 %} + {% set word = x[0] %} + {% set freq = x[1] %} + {% if session.get('thisWord') == x[0] and session.get('time') == 1 %} + {% endif %} +

+ {{ word }} + ( {{ freq }} ) + 熟悉 + 不熟悉 + 删除 +

+ {% endfor %} +
{% endif %}
From e10dbf9d67114e36e77bb773b631435844b3655c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BF=97=E8=B1=AA?= <1594799762@qq.com> Date: Sun, 29 Jan 2023 12:48:52 +0800 Subject: [PATCH 13/15] Bug507-WuWenZhuo (#70) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### 修复了生词簿为空时,双击文章单词无法高亮的问题 通过增加一个判断,判断生词簿为空时,不把生词簿的内容进行处理,仅处理选中单词。 ### 修复了生词簿为空时,取消高亮后,导致文章格式混乱的问题 原代码中,从数据库提取文章放到网页上时,使用的是.innerText的方法,导致原文章里包含的
标签丢失,导致文章格式混乱的问题。 Co-authored-by: unknown Co-authored-by: Hui Lan Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/70 Co-authored-by: 王志豪 <1594799762@qq.com> Co-committed-by: 王志豪 <1594799762@qq.com> --- README.md | 3 +++ app/static/js/highlight.js | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index fb70948..c12fc0b 100644 --- a/README.md +++ b/README.md @@ -191,4 +191,7 @@ 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 +======= +实验3,添加我的组名:WuWenZhuo + *Last modified on 2021-10-17* \ No newline at end of file diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index 7b3cab2..5ec9663 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -22,11 +22,17 @@ function getWord() { function highLight() { if (!isHighlight) return; - let articleContent = document.getElementById("article").innerText; + let articleContent = document.getElementById("article").innerText; //将原来的.innerText改为.innerHtml,使用innerText会把原文章中所包含的
标签去除,导致处理后的文章内容失去了原来的格式 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 = pickedWords.value + " " + dictionaryWords.value; - const list = allWords.split(" "); + let allWords = ""; //初始化allWords的值,避免进入判断后编译器认为allWords未初始化的问题 + if(dictionaryWords != null){//增加一个判断,检查生词本里面是否为空,如果为空,allWords只添加选中的单词 + allWords = pickedWords.value + " " + dictionaryWords.value; + } + else{ + allWords = pickedWords.value + " "; + } + const list = allWords.split(" ");//将所有的生词放入一个list中,用于后续处理 for (let i = 0; i < list.length; ++i) { list[i] = list[i].replace(/(^\s*)|(\s*$)/g, ""); //消除单词两边的空字符 list[i] = list[i].replace('|', ""); @@ -40,15 +46,15 @@ function highLight() { } function cancelHighlighting() { - let articleContent = document.getElementById("article").innerText; + let articleContent = document.getElementById("article").innerText;//将原来的.innerText改为.innerHtml,原因同上 let pickedWords = document.getElementById("selected-words"); const dictionaryWords = document.getElementById("selected-words2"); const list = pickedWords.value.split(" "); if (pickedWords != null) { for (let i = 0; i < list.length; ++i) { list[i] = list[i].replace(/(^\s*)|(\s*$)/g, ""); - if (list[i] !== "") { - articleContent = articleContent.replace("" + list[i] + "", "list[i]"); + if (list[i] !== "") { //原来判断的代码中,替换的内容为“list[i]”这个字符串,这明显是错误的,我们需要替换的是list[i]里的内容 + articleContent = articleContent.replace(new RegExp(""+list[i]+"", "g"), list[i]); } } } @@ -57,8 +63,8 @@ function cancelHighlighting() { for (let i = 0; i < list2.length; ++i) { list2 = dictionaryWords.value.split(" "); list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, ""); - if (list2[i] !== "") { - articleContent = articleContent.replace("" + list[i] + "", "list[i]"); + if (list2[i] !== "") { //原来代码中,替换的内容为“list[i]”这个字符串,这明显是错误的,我们需要替换的是list[i]里的内容 + articleContent = articleContent.replace(new RegExp(""+list2[i]+"", "g"), list2[i]); } } } From 92a8b4a9944b9509e52cd09a7eb35aa4ccb052b4 Mon Sep 17 00:00:00 2001 From: mrlan Date: Mon, 30 Jan 2023 15:44:01 +0800 Subject: [PATCH 14/15] Lanhui-update-README2 (#80) Co-authored-by: Lan Hui <1348141770@qq.com> Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/80 Co-authored-by: mrlan Co-committed-by: mrlan --- .DS_Store | Bin 6148 -> 0 bytes README.md | 65 ++++++++++++++++++++++++++---------------------------- 2 files changed, 31 insertions(+), 34 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 7b9e3399d7747d6de8838936b3d6673c4464d460..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%Wl&^6g|@f>NG;i0;Fy#Sz=p-RE1Wk8#km2kl54+7Jx!r8*0_@gxDdKqDWc8 zKky4|`4awx6`Xlgic`8_flxG8nmKo7?wRX3)_6PsM0XPJ0WAO?i^BRAt3Q|;SLK>* z*d8?~)Ex3G%4Ecrn$DS1z$x&*E1>pn4FilYdYV=C?=eT(zqIK^*r;e)jO;G|9*wfJ zC_9}WVxv~Sb$ip>^qSt=@LW#Aa!^i+?qK{{wO&Y>MOXeHdYLBEe(UZNnU{k!PsW;% z#tB2-yh`&}PP=lF$A#vGX25HBjecu;HrspD+4c7yAIx|C+2JAmhx-TfdBeMR|H08| z{~{aa^0N_L@SCLVj>RkZLdUM=Q#j5unSWr9iuMp;f)p8Iv{B%EMU!ugS=M9=JxHA4 z0tv==ubD}eBX(9eO*~_CPEN|YxPhgfaXC{1r#Qhe^F1fFF+{wQ=jRHe#V1PeQLjgN zL!Gr`#x_b^qO9^cH}G}oeY5Fotrf8Q!)vbfD&69o0#1RyQ9ykkd=`a)#f3rr>0qU= z0K_`Gwb9o<|3qJP5Ce+~gY2ORLnRujuvZLW?+(JyIUd;fg+W7y(3v@p%`EHvBoKj-xvs)*8l(j diff --git a/README.md b/README.md index c12fc0b..29e74dd 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,14 @@ Hui Lan EnglishPal allows the user to build his list of new English words -picked from articles selected for him according his vocabulary level. +picked from articles selected for him to read according his vocabulary level. EnglishPal will determine a user's vocabulary level based on his picked words. After that, it will recommend articles for him to read, in order to booster his English vocabulary furthermore. -## Run it on a local machine - +## Run on your own laptop `python3 main.py` -Make sure you have the SQLite database file in `app/static` (see below). +Make sure you have put the SQLite database file in the path `app/static` (see below). ## Run it as a Docker container @@ -29,32 +28,32 @@ Assuming that docker has been installed and that you are a sudo user (i.e., sudo `sudo ./build.sh` -Open your favourite Internet browser and enter this URL address: `http://ip-address:90`. +Open your favourite Internet browser and enter this URL address: `http://ip-address:90`. Note: you must update the variable `DEPLOYMENT_DIR` in `build.sh`. ### Explanation on the commands in build.sh -My steps for deploying English on the server. +My steps for deploying English on a Ubuntu server. - ssh to ubuntu@118.*.*.118 -- cd to /home/lanhui/englishpal2/EnglishPal +- cd to `/home/lanhui/englishpal2/EnglishPal` - Stop all docker service: `sudo service docker restart`. If you know the docker container ID, then the above command is an overkill. Use the following command instead: `sudo docker stop ContainerID`. You could get all container IDs with the following command: `sudo docker ps` -- Rebuild container. Run the following command to rebuild a docker image after the code gets updated: `sudo docker build -t englishpal .` +- Rebuild container. Run the following command to rebuild a docker image each time after the source code gets updated: `sudo docker build -t englishpal .` -- Run the application: `sudo docker run -d -p 90:80 -v /home/lanhui/englishpal2/EnglishPal/app/static/frequency:/app/static/frequency -t englishpal`. If you use `sudo docker run -d -p 90:80 -t englishpal`, data will be lost after terminating the program. +- Run the application: `sudo docker run -d -p 90:80 -v /home/lanhui/englishpal2/EnglishPal/app/static/frequency:/app/static/frequency -t englishpal`. If you use `sudo docker run -d -p 90:80 -t englishpal`, data will be lost after terminating the program. If you want to automatically restart the docker image after each system reboot, add the option `--restart=always` after `docker run`. -- Save space: `sudo docker system prune -a -f` +- Save disk space: `sudo docker system prune -a -f` + +`build.sh` contains all the above commands. Run "sudo ./build.sh" to rebuild and start the web application. -### Other useful docker commands +#### Other useful docker commands - `sudo docker ps -a` -- `sudo docker logs image_name`, where image_name could be obtained from `sudo docker ps`. - -`build.sh` contains all the above commands. Run "sudo ./build.sh" to rebuild and run the web application. +- `sudo docker logs image_name`, where `image_name` could be obtained from `sudo docker ps`. @@ -68,6 +67,10 @@ All articles are stored in the `article` table in a SQLite file called To add articles, open and edit `app/static/wordfreqapp.db` using DB Browser for SQLite (https://sqlitebrowser.org). +### Extending an account's expiry date + +By default, an account's expiry is 30 days after first sign-up. To extend account's expiry date, open and edit `user` table in `app/static/wordfreqapp.db`. Simply update field `expiry_date`. + ### Exporting the database Export wordfreqapp.db to wordfreqapp.sql using the following commands: @@ -92,33 +95,31 @@ sqlite3 wordfreqapp.db`. Delete wordfreqapp.db first if it exists. ### Uploading wordfreqapp.db to the server -`pscp wordfreqapp.db lanhui@118.*.*.118:/home/lanhui/englishpal/app/static` +`pscp wordfreqapp.db lanhui@118.*.*.118:/home/lanhui/englishpal2/EnglishPal/app/static` ## Feedback -We welcome feedback on EnglishPal. +We welcome feedback on EnglishPal. Feedback examples: -### Respondent 1 +### Feedback 1 + +- "Need a phone app. I use phone a lot. You cannot ask students to use computers." -"Need a phone app. I use phone a lot. You cannot ask students to use computers." - -Can take a picture for text. Automatic translation. - -### Respondent 2 +### Feedback 2 -“成为会员”改成“注册” +- “成为会员”改成“注册” -“登出”改成“退出” +- “登出”改成“退出” -“收集生词吧”改成“生词收集栏” +- “收集生词吧”改成“生词收集栏” -“不要自动显示下一篇” +- 不要自动显示下一篇 -需要有“上一篇”、“下一篇” +- 需要有“上一篇”、“下一篇”按钮。 @@ -137,7 +138,7 @@ EnglishPal's bugs and improvement suggestions are recorded in [Bugzilla](http:// - Usability testing -## Improvements made by contributors +## Improvements made by contributors (incomplete list) ### 朱文绮 @@ -159,7 +160,6 @@ too many words that they already know, on the other hand, it can reduce unnecessary memory occupied by the database, in addition, it can also improve the simplicity of the page. -More information at: http://118.25.96.118/kanboard/?controller=TaskViewController&action=readonly&task_id=736&token=81a561da57ff7a172da17a480f0d421ff3bc69efbd29437daef90b1b8959 ### 占健豪 @@ -188,10 +188,7 @@ 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 +Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=489 -======= -实验3,添加我的组名:WuWenZhuo - -*Last modified on 2021-10-17* \ No newline at end of file +*Last modified on 2023-01-30* \ No newline at end of file From a1955341c6c2495dd7c8f73727d341b780c38a6c Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Tue, 31 Jan 2023 16:39:11 +0800 Subject: [PATCH 15/15] =?UTF-8?q?Fix=20bug=20501=20-=20=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=AD=97=E7=AC=A6&=E5=8A=A0=E5=85=A5=E7=94=9F=E8=AF=8D?= =?UTF-8?q?=E5=BA=93=E5=90=8E=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE=E5=A4=B1?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/word_operation.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/static/js/word_operation.js b/app/static/js/word_operation.js index a9af300..ea6a6e8 100644 --- a/app/static/js/word_operation.js +++ b/app/static/js/word_operation.js @@ -47,7 +47,7 @@ function unfamiliar(theWord) { function delete_word(theWord) { let username = $("#username").text(); - let word = $("#word_" + theWord).text(); + let word = theWord.replace('&', '&'); $.ajax({ type:"GET", url:"/" + username + "/" + word + "/del", @@ -104,6 +104,7 @@ function wordTemplate(word) { */ function removeWord(word) { // 根据词频信息删除元素 + word = word.replace('&', '&'); const element_to_remove = document.getElementById(`p_${word}`); if (element_to_remove != null) { element_to_remove.remove(); @@ -169,4 +170,4 @@ function compareWord(first, second) { return 1; } return 0; -} \ No newline at end of file +}