summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHui Lan <lanhui@zjnu.edu.cn>2020-08-13 09:55:23 +0800
committerHui Lan <lanhui@zjnu.edu.cn>2020-08-13 09:55:23 +0800
commit21ce86d2052f461ae4548c6894ff8eaa3a5ca915 (patch)
tree3c8e335c87c30b6cce383f58761dd17b3b6added
parenta13cf9f58aa30400770dd141f1ecbbe9cafadfcc (diff)
main.py and wordfreqWEB.py: do not show word frequency if it is 1.
-rw-r--r--app/README.md2
-rw-r--r--app/main.py5
-rw-r--r--app/wordfreqWEB.py5
3 files changed, 9 insertions, 3 deletions
diff --git a/app/README.md b/app/README.md
index ab7c217..124afa2 100644
--- a/app/README.md
+++ b/app/README.md
@@ -48,4 +48,4 @@ 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 the web application.
+build.sh contains all the above commands. Run "sudo ./build.sh" to rebuild the web application.
diff --git a/app/main.py b/app/main.py
index 52954fc..3368612 100644
--- a/app/main.py
+++ b/app/main.py
@@ -305,7 +305,10 @@ def userpage(username):
word = x[0]
freq = x[1]
if isinstance(d[word], list): # d[word] is a list of dates
- page += '<a href="%s">%s</a> (<a title="%s">%d</a>)\n' % (youdao_link(word), word, '; '.join(d[word]), freq)
+ if freq > 1:
+ page += '<a href="%s">%s</a> (<a title="%s">%d</a>)\n' % (youdao_link(word), word, '; '.join(d[word]), freq)
+ else:
+ page += '<a href="%s">%s</a>\n' % (youdao_link(word), word)
elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format.
page += '<a href="%s">%s</a>%d\n' % (youdao_link(word), word, freq)
diff --git a/app/wordfreqWEB.py b/app/wordfreqWEB.py
index 7107791..2c0e4be 100644
--- a/app/wordfreqWEB.py
+++ b/app/wordfreqWEB.py
@@ -269,7 +269,10 @@ def userpage(username):
word = x[0]
freq = x[1]
if isinstance(d[word], list): # d[word] is a list of dates
- page += '<a href="%s">%s</a> (<a title="%s">%d</a>)\n' % (youdao_link(word), word, '; '.join(d[word]), freq)
+ if freq > 1:
+ page += '<a href="%s">%s</a> (<a title="%s">%d</a>)\n' % (youdao_link(word), word, '; '.join(d[word]), freq)
+ else:
+ page += '<a href="%s">%s</a>\n' % (youdao_link(word), word)
elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format.
page += '<a href="%s">%s</a>%d\n' % (youdao_link(word), word, freq)