From 81e1e795be46fe1d021b49701aabfea80239c7f2 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 20:25:58 +0800 Subject: [PATCH 1/7] 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 ### -- 2.17.1 From 0efd2b420bf1d04ad307c89f0c3d6fe2d58fc622 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 21:09:38 +0800 Subject: [PATCH 2/7] 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 -- 2.17.1 From 704351872198b6ddebbb05b160bdea01ef94be49 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 21:12:15 +0800 Subject: [PATCH 3/7] 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']) -- 2.17.1 From c71b1562037cac099df593460cccf0daa23dfd32 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 21:22:45 +0800 Subject: [PATCH 4/7] 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', '
') -- 2.17.1 From 6e56c1b418813ad37fa5db35cd0d0ef81ed42d29 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 21:25:13 +0800 Subject: [PATCH 5/7] 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'])) -- 2.17.1 From d08d8a85940c8d7ae9516a439aa793dddda974fd Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 22:03:27 +0800 Subject: [PATCH 6/7] 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 -- 2.17.1 From b6209bdde6f74931988c6add0fea0a3240cf6b2d Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Sun, 1 Aug 2021 22:10:23 +0800 Subject: [PATCH 7/7] 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): -- 2.17.1