From 6d8b30e6313ef49e6e7ee8e4ebdf43724b3369f5 Mon Sep 17 00:00:00 2001 From: Zjh-jc Date: Thu, 22 Jul 2021 00:11:06 +0800 Subject: [PATCH 01/38] fix the bug (After logging in, jump directly to the vocabulary, not to the article.) --- app/main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 043e668..e2ad1f7 100644 --- a/app/main.py +++ b/app/main.py @@ -275,6 +275,7 @@ def unfamiliar(username,word): user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) pickle_idea.unfamiliar(user_freq_record,word) session['thisWord'] = word # 1. put a word into session + session['time'] = 1 return redirect(url_for('userpage', username=username)) @app.route("///familiar", methods=['GET', 'POST']) @@ -282,6 +283,7 @@ def familiar(username,word): user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) pickle_idea.familiar(user_freq_record,word) session['thisWord'] = word # 1. put a word into session + session['time'] = 1 return redirect(url_for('userpage', username=username)) @app.route("/", methods=['GET', 'POST']) @@ -348,7 +350,12 @@ def userpage(username): if session.get('thisWord'): page += ''' ''' @@ -362,8 +369,9 @@ def userpage(username): for x in sort_in_descending_order(lst2): word = x[0] freq = x[1] - if session.get('thisWord') == x[0]: + if session.get('thisWord') == x[0] and session.get('time') == 1: page += '' # 3. anchor + session['time'] = 0 # discard anchor if isinstance(d[word], list): # d[word] is a list of dates if freq > 1: page += '

%s(%d) 熟悉 不熟悉

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word) From 936a3dd1e6147bf0b24f0ae0c8f68ff1a8346c36 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Fri, 30 Jul 2021 13:20:01 +0800 Subject: [PATCH 02/38] build.sh: fix error: container name EnglishPal already in use. --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index c7c3019..9ac3f1a 100755 --- a/build.sh +++ b/build.sh @@ -4,6 +4,7 @@ cd /home/lanhui/englishpal # Stop service sudo docker stop EnglishPal +sudo docker rm EnglishPal # Rebuild container. Run this after modifying the source code. sudo docker build -t englishpal . From 29f0d02327c1c81b1f90793147ee13b6a20846f3 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 20:54:19 +0800 Subject: [PATCH 03/38] app/main.py: bootstrap elements. --- app/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index b13df3e..2d0237f 100644 --- a/app/main.py +++ b/app/main.py @@ -110,7 +110,7 @@ def get_today_article(user_word_list, articleID): d = reading break - s = '

According to your word list, your level is %4.2f and we have chosen an article with a difficulty level of %4.2f for you.

' % (user_level, text_level) + s = '

According to your word list, your level is %4.2f and we have chosen an article with a difficulty level of %4.2f for you.

' % (user_level, text_level) s += '

%s

' % (d['date']) s += '

%s

' % (d['text']) s += '

%s

' % (d['source']) @@ -336,6 +336,7 @@ def userpage(username): page = '\n' page += '\n' page += '\n' # forbid treating numbers as cell numbers in smart phones + page += '' page += 'EnglishPal Study Room for %s' % (username) page += '

English Pal for %s 登出

' % (username) page += '

下一篇

' % (username) @@ -393,6 +394,7 @@ def userpage(username): page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format. page += '%s%d\n' % (youdao_link(word), word, freq) + page += '' return page ### Sign-up, login, logout ### From adfc2796dac1b6b1b5d9d7d26a91e3a00174b341 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 20:59:08 +0800 Subject: [PATCH 04/38] app/main.py: use a different color for badge. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 2d0237f..6049ba6 100644 --- a/app/main.py +++ b/app/main.py @@ -110,7 +110,7 @@ def get_today_article(user_word_list, articleID): d = reading break - s = '

According to your word list, your level is %4.2f and we have chosen an article with a difficulty level of %4.2f for you.

' % (user_level, text_level) + s = '

According to your word list, your level is %4.2f and we have chosen an article with a difficulty level of %4.2f for you.

' % (user_level, text_level) s += '

%s

' % (d['date']) s += '

%s

' % (d['text']) s += '

%s

' % (d['source']) From 1936d2aec5327c1e8ea30c0eaa46f47e0e9fec4f Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:02:17 +0800 Subject: [PATCH 05/38] app/main.py: use alert while showing vocabulary level. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 6049ba6..2f8822a 100644 --- a/app/main.py +++ b/app/main.py @@ -110,7 +110,7 @@ def get_today_article(user_word_list, articleID): d = reading break - s = '

According to your word list, your level is %4.2f and we have chosen an article with a difficulty level of %4.2f for you.

' % (user_level, text_level) + s = '' % (user_level, text_level) s += '

%s

' % (d['date']) s += '

%s

' % (d['text']) s += '

%s

' % (d['source']) From e9c7d0fc00bd402c2a23d45f23c4848ffc61949a Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:03:57 +0800 Subject: [PATCH 06/38] app/main.py: use a green alert bar. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 2f8822a..5ba9f9b 100644 --- a/app/main.py +++ b/app/main.py @@ -110,7 +110,7 @@ def get_today_article(user_word_list, articleID): d = reading break - s = '' % (user_level, text_level) + s = '' % (user_level, text_level) s += '

%s

' % (d['date']) s += '

%s

' % (d['text']) s += '

%s

' % (d['source']) From fbf054d1740849b34ad5a043edac9acad699edcf Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:10:27 +0800 Subject: [PATCH 07/38] =?UTF-8?q?app/main.py:=20move=20alert=20bar=20above?= =?UTF-8?q?=20=E9=98=85=E8=AF=BB=E6=96=87=E7=AB=A0=E5=B9=B6=E5=9B=9E?= =?UTF-8?q?=E7=AD=94=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 5ba9f9b..0cc0233 100644 --- a/app/main.py +++ b/app/main.py @@ -340,8 +340,8 @@ def userpage(username): page += 'EnglishPal Study Room for %s' % (username) page += '

English Pal for %s 登出

' % (username) page += '

下一篇

' % (username) - page += '

阅读文章并回答问题

\n' page += '
%s
' % (get_today_article(user_freq_record, session['articleID'])) + page += '

阅读文章并回答问题

\n' page += '

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

' page += '
' % (username) page += '
' From 22af30bc88817af38a4be0800d8fb3056c6b2819 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:12:04 +0800 Subject: [PATCH 08/38] =?UTF-8?q?app/main.py:=20move=20alert=20bar=20above?= =?UTF-8?q?=20=E9=98=85=E8=AF=BB=E6=96=87=E7=AB=A0=E5=B9=B6=E5=9B=9E?= =?UTF-8?q?=E7=AD=94=E9=97=AE=E9=A2=98=20(revision).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 0cc0233..188cd84 100644 --- a/app/main.py +++ b/app/main.py @@ -339,9 +339,9 @@ def userpage(username): page += '' page += 'EnglishPal Study Room for %s' % (username) page += '

English Pal for %s 登出

' % (username) + page += '

阅读文章并回答问题

\n' page += '

下一篇

' % (username) page += '
%s
' % (get_today_article(user_freq_record, session['articleID'])) - page += '

阅读文章并回答问题

\n' page += '

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

' page += '' % (username) page += '
' From aad7f8016e3dd210eccc70ca9e58de47838cbc45 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:16:38 +0800 Subject: [PATCH 09/38] app/main.py: change link to button. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 188cd84..eb9d1e2 100644 --- a/app/main.py +++ b/app/main.py @@ -340,7 +340,7 @@ def userpage(username): page += 'EnglishPal Study Room for %s' % (username) page += '

English Pal for %s 登出

' % (username) page += '

阅读文章并回答问题

\n' - page += '

下一篇

' % (username) + page += '

下一篇

' % (username) page += '
%s
' % (get_today_article(user_freq_record, session['articleID'])) page += '

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

' page += '' % (username) From 20386033bccab4266a2e9cab6136f44fc970ebca Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:18:35 +0800 Subject: [PATCH 10/38] app/main.py: green button may look better, more consistent. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index eb9d1e2..efd0f2c 100644 --- a/app/main.py +++ b/app/main.py @@ -340,7 +340,7 @@ def userpage(username): page += 'EnglishPal Study Room for %s' % (username) page += '

English Pal for %s 登出

' % (username) page += '

阅读文章并回答问题

\n' - page += '

下一篇

' % (username) + page += '

下一篇

' % (username) page += '
%s
' % (get_today_article(user_freq_record, session['articleID'])) page += '

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

' page += '' % (username) From bef218953be33d83dfe80371d3aae779355afdd8 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:22:09 +0800 Subject: [PATCH 11/38] app/main.py: adjust badge color. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index efd0f2c..2e9e7f7 100644 --- a/app/main.py +++ b/app/main.py @@ -110,7 +110,7 @@ def get_today_article(user_word_list, articleID): d = reading break - s = '' % (user_level, text_level) + s = '' % (user_level, text_level) s += '

%s

' % (d['date']) s += '

%s

' % (d['text']) s += '

%s

' % (d['source']) From 61a848e7d4bf7d6d6588021e71345d5a597c1446 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:30:19 +0800 Subject: [PATCH 12/38] app/main.py: use alert for total number of articles. --- app/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 2e9e7f7..db06ced 100644 --- a/app/main.py +++ b/app/main.py @@ -230,6 +230,8 @@ def mainpage(): + + EnglishPal 英文单词高效记 @@ -242,7 +244,7 @@ def mainpage(): page += '

登录 成为会员 使用说明

\n' #page += '

advertisement

' % (get_random_image(path_prefix + 'static/img/')) page += '

%s

' % (get_random_ads()) - page += '

共有文章%d篇' % (total_number_of_essays()) + page += '

' % (total_number_of_essays()) page += '

粘帖1篇文章 (English only)

' page += '' page += '
' @@ -257,6 +259,7 @@ def mainpage(): break page += '%s %d\n' % (youdao_link(x[0]), x[0], x[1]) + page += ' ' page += '' return page From e65b443f014a1708ad4860db3145dea57c8d27b4 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:41:55 +0800 Subject: [PATCH 13/38] app/main.py: use buttons instead of links for familiar, unfamiliar and delete. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index db06ced..e6d50cb 100644 --- a/app/main.py +++ b/app/main.py @@ -392,7 +392,7 @@ def userpage(username): session['time'] = 0 # discard anchor if isinstance(d[word], list): # d[word] is a list of dates if freq > 1: - page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) + page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) else: page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format. From c40f9b61a3952e28267cf5da42f60982c81cf914 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:43:42 +0800 Subject: [PATCH 14/38] app/main.py: use buttons instead of links for familiar, unfamiliar and delete (for all words). --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index e6d50cb..42b4397 100644 --- a/app/main.py +++ b/app/main.py @@ -394,7 +394,7 @@ def userpage(username): if freq > 1: page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) else: - page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) + page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format. page += '%s%d\n' % (youdao_link(word), word, freq) page += '' From 58383a51ad3afc2ecd7b53224e0a4e759a2f6366 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sat, 31 Jul 2021 21:51:48 +0800 Subject: [PATCH 15/38] app/main.py: use buttons for all words (strange?). --- app/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 42b4397..634338a 100644 --- a/app/main.py +++ b/app/main.py @@ -392,9 +392,9 @@ def userpage(username): session['time'] = 0 # discard anchor if isinstance(d[word], list): # d[word] is a list of dates if freq > 1: - page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) + page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) else: - page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) + page += '

%s(%d) 熟悉 不熟悉 删除

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format. page += '%s%d\n' % (youdao_link(word), word, freq) page += '' From 81e1e795be46fe1d021b49701aabfea80239c7f2 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 20:25:58 +0800 Subject: [PATCH 16/38] app/main.py: use container, and use a button for logout. --- app/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 634338a..4653cbd 100644 --- a/app/main.py +++ b/app/main.py @@ -341,9 +341,10 @@ def userpage(username): page += '\n' # forbid treating numbers as cell numbers in smart phones page += '' page += 'EnglishPal Study Room for %s' % (username) - page += '

English Pal for %s 登出

' % (username) + page += '
' + page += '

English Pal for %s 登出

' % (username) page += '

阅读文章并回答问题

\n' - page += '

下一篇

' % (username) + page += '

下一篇 Next Article

' % (username) page += '
%s
' % (get_today_article(user_freq_record, session['articleID'])) page += '

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

' page += '' % (username) @@ -398,6 +399,7 @@ def userpage(username): elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format. page += '%s%d\n' % (youdao_link(word), word, freq) page += '' + page += '
' return page ### Sign-up, login, logout ### From 0efd2b420bf1d04ad307c89f0c3d6fe2d58fc622 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 21:09:38 +0800 Subject: [PATCH 17/38] app/main.py: light grey background for the article. --- app/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 4653cbd..d460ab3 100644 --- a/app/main.py +++ b/app/main.py @@ -111,12 +111,14 @@ def get_today_article(user_word_list, articleID): break s = '' % (user_level, text_level) - s += '

%s

' % (d['date']) + s += '

Article added on: %s

' % (d['date']) + s += '
' s += '

%s

' % (d['text']) s += '

%s

' % (d['source']) s += '

%s

' % (get_question_part(d['question'])) s = s.replace('\n', '
') s += '%s' % (get_answer_part(d['question'])) + s += '
' session['articleID'] = d['article_id'] return s From 704351872198b6ddebbb05b160bdea01ef94be49 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 21:12:15 +0800 Subject: [PATCH 18/38] app/main.py: use lighter color for article date. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index d460ab3..496724c 100644 --- a/app/main.py +++ b/app/main.py @@ -111,7 +111,7 @@ def get_today_article(user_word_list, articleID): break s = '' % (user_level, text_level) - s += '

Article added on: %s

' % (d['date']) + s += '

Article added on: %s

' % (d['date']) s += '
' s += '

%s

' % (d['text']) s += '

%s

' % (d['source']) From c71b1562037cac099df593460cccf0daa23dfd32 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 21:22:45 +0800 Subject: [PATCH 19/38] app/main.py: larger font for article title. --- app/main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 496724c..c342a16 100644 --- a/app/main.py +++ b/app/main.py @@ -81,6 +81,14 @@ def within_range(x, y, r): return x > y and abs(x - y) <= r +def get_article_title(s): + return s.split('\n')[0] + + +def get_article_body(s): + return '\n'.join(s.split('\n')[1:-1]) # remove the first line + + def get_today_article(user_word_list, articleID): rq = RecordQuery(path_prefix + 'static/wordfreqapp.db') @@ -113,7 +121,10 @@ def get_today_article(user_word_list, articleID): s = '' % (user_level, text_level) s += '

Article added on: %s

' % (d['date']) s += '
' - s += '

%s

' % (d['text']) + article_title = get_article_title(d['text']) + article_body = get_article_body(d['text']) + s += '

%s

' % (article_title) + s += '

%s

' % (article_body) s += '

%s

' % (d['source']) s += '

%s

' % (get_question_part(d['question'])) s = s.replace('\n', '
') From 6e56c1b418813ad37fa5db35cd0d0ef81ed42d29 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 21:25:13 +0800 Subject: [PATCH 20/38] app/main.py: use smaller, ligter font for source. --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index c342a16..5f7cd5b 100644 --- a/app/main.py +++ b/app/main.py @@ -125,7 +125,7 @@ def get_today_article(user_word_list, articleID): article_body = get_article_body(d['text']) s += '

%s

' % (article_title) s += '

%s

' % (article_body) - s += '

%s

' % (d['source']) + s += '

%s

' % (d['source']) s += '

%s

' % (get_question_part(d['question'])) s = s.replace('\n', '
') s += '%s' % (get_answer_part(d['question'])) From d08d8a85940c8d7ae9516a439aa793dddda974fd Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 22:03:27 +0800 Subject: [PATCH 21/38] app/main.py: use a container for the front page. --- app/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/main.py b/app/main.py index 5f7cd5b..e86ebab 100644 --- a/app/main.py +++ b/app/main.py @@ -250,6 +250,7 @@ def mainpage(): ''' + page += '
' page += '

English Pal - Learn English smartly!

' if session.get('logged_in'): page += ' %s

\n' % (session['username'], session['username']) @@ -273,6 +274,7 @@ def mainpage(): page += '%s %d\n' % (youdao_link(x[0]), x[0], x[1]) page += ' ' + page += '
' page += '' return page From b6209bdde6f74931988c6add0fea0a3240cf6b2d Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 22:10:23 +0800 Subject: [PATCH 22/38] app/main.py: the secnd line and after (if any) should also show. --- app/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index e86ebab..3818ea6 100644 --- a/app/main.py +++ b/app/main.py @@ -86,8 +86,9 @@ def get_article_title(s): def get_article_body(s): - return '\n'.join(s.split('\n')[1:-1]) # remove the first line - + lst = s.split('\n') + lst.pop(0) # remove the first line + return '\n'.join(lst) def get_today_article(user_word_list, articleID): From 451feb7bbad40060cd6dc724190af1e03a5e9144 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 2 Aug 2021 16:52:02 +0800 Subject: [PATCH 23/38] app/main.py: flash a message after deleting a word from the new word list. --- app/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/main.py b/app/main.py index 3818ea6..024bac9 100644 --- a/app/main.py +++ b/app/main.py @@ -192,6 +192,15 @@ def get_answer_part(s): return html_code +def get_flashed_messages_if_any(): + messages = get_flashed_messages() + if messages == []: + return '' + s = '
    ' + for message in messages: + s += 'f
  • {message}
  • ' + return s + '
' + @app.route("//reset", methods=['GET', 'POST']) def user_reset(username): @@ -317,6 +326,7 @@ def familiar(username,word): def deleteword(username,word): user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) pickle_idea2.deleteRecord(user_freq_record,word) + flash(f'Congratulations! {word} is no longer in your word list.') return redirect(url_for('userpage', username=username)) @app.route("/", methods=['GET', 'POST']) @@ -359,6 +369,7 @@ def userpage(username): page += 'EnglishPal Study Room for %s' % (username) page += '
' page += '

English Pal for %s 登出

' % (username) + page += get_flashed_messages_if_any() page += '

阅读文章并回答问题

\n' page += '

下一篇 Next Article

' % (username) page += '
%s
' % (get_today_article(user_freq_record, session['articleID'])) From f5086732f39e5e3539b68f1d70c427ef008528f9 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 2 Aug 2021 17:07:01 +0800 Subject: [PATCH 24/38] app/main.py: flash a message after deleting a word from the new word list (fix error). --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 024bac9..bc0be1b 100644 --- a/app/main.py +++ b/app/main.py @@ -369,7 +369,7 @@ def userpage(username): page += 'EnglishPal Study Room for %s' % (username) page += '
' page += '

English Pal for %s 登出

' % (username) - page += get_flashed_messages_if_any() + #page += get_flashed_messages_if_any() page += '

阅读文章并回答问题

\n' page += '

下一篇 Next Article

' % (username) page += '
%s
' % (get_today_article(user_freq_record, session['articleID'])) From 8abbf458a2788f8220ce3201481823f6a90e5641 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 2 Aug 2021 17:10:05 +0800 Subject: [PATCH 25/38] app/main.py: flash a message after deleting a word from the new word list (fix error - import get_flashed_messages). --- app/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index bc0be1b..ac49b5d 100644 --- a/app/main.py +++ b/app/main.py @@ -13,7 +13,7 @@ import pickle_idea, pickle_idea2 import os import random, glob from datetime import datetime -from flask import Flask, request, redirect, render_template, url_for, session, abort, flash +from flask import Flask, request, redirect, render_template, url_for, session, abort, flash, get_flashed_messages from difficulty import get_difficulty_level, text_difficulty_level, user_difficulty_level app = Flask(__name__) @@ -369,7 +369,7 @@ def userpage(username): page += 'EnglishPal Study Room for %s' % (username) page += '
' page += '

English Pal for %s 登出

' % (username) - #page += get_flashed_messages_if_any() + page += get_flashed_messages_if_any() page += '

阅读文章并回答问题

\n' page += '

下一篇 Next Article

' % (username) page += '
%s
' % (get_today_article(user_freq_record, session['articleID'])) From 4773a6d131c6fc74a871cb330d870ceea8e1323f Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 2 Aug 2021 17:26:35 +0800 Subject: [PATCH 26/38] app/main.py: flash a message after deleting a word from the new word list (put f in the right place). --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index ac49b5d..6776f49 100644 --- a/app/main.py +++ b/app/main.py @@ -198,7 +198,7 @@ def get_flashed_messages_if_any(): return '' s = '
    ' for message in messages: - s += 'f
  • {message}
  • ' + s += f'
  • {message}
  • ' return s + '
' From 08bb7e0c40958d8e997177cffa24fdd1840d4582 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 2 Aug 2021 19:11:53 +0800 Subject: [PATCH 27/38] app/main.py: flash a message after deleting a word (use bootstrap alerts). --- app/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index 6776f49..5af6819 100644 --- a/app/main.py +++ b/app/main.py @@ -194,12 +194,12 @@ def get_answer_part(s): def get_flashed_messages_if_any(): messages = get_flashed_messages() - if messages == []: - return '' - s = '
    ' + s = '' for message in messages: - s += f'
  • {message}
  • ' - return s + '
' + s += '' + return s @app.route("//reset", methods=['GET', 'POST']) From 3d5130d68dee15f7c4a011a3803c63b35ce9eef4 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 2 Aug 2021 19:17:54 +0800 Subject: [PATCH 28/38] app/main.py: flash a message after deleting a word (use bootstrap alerts -- add additional content, e.g., a bolder congratulations). --- app/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 5af6819..44e2801 100644 --- a/app/main.py +++ b/app/main.py @@ -197,6 +197,7 @@ def get_flashed_messages_if_any(): s = '' for message in messages: s += '' return s @@ -326,7 +327,7 @@ def familiar(username,word): def deleteword(username,word): user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) pickle_idea2.deleteRecord(user_freq_record,word) - flash(f'Congratulations! {word} is no longer in your word list.') + flash(f'{word} is no longer in your word list.') return redirect(url_for('userpage', username=username)) @app.route("/", methods=['GET', 'POST']) From c3dcc62879eee842dba0c9c53478c93cbdf59bab Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 2 Aug 2021 19:21:41 +0800 Subject: [PATCH 29/38] app/main.py: flash a message after deleting a word (use bootstrap alerts -- make the alert dismissable). --- app/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 44e2801..fea64c6 100644 --- a/app/main.py +++ b/app/main.py @@ -196,9 +196,12 @@ def get_flashed_messages_if_any(): messages = get_flashed_messages() s = '' for message in messages: - s += '