forked from mrlan/EnglishPal
Update main.py
添加熟悉和不熟悉按钮功能,如果点熟悉,就将生词簿中该单词后面记录的添加次数减一,直至减为0,就将该单词从生词簿中移除;如果点不熟悉,就将生词簿中该单词后面记录的添加次数加1。Lanhui-add-articles
parent
843ed03d4f
commit
9b7b5279db
17
app/main.py
17
app/main.py
|
@ -270,6 +270,17 @@ def user_mark_word(username):
|
||||||
return 'Under construction'
|
return 'Under construction'
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/<username>/<word>/unfamiliar", methods=['GET', 'POST'])
|
||||||
|
def unfamiliar(username,word):
|
||||||
|
user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
|
||||||
|
pickle_idea.unfamiliar(user_freq_record,word)
|
||||||
|
return redirect(url_for('userpage', username=username))
|
||||||
|
|
||||||
|
@app.route("/<username>/<word>/familiar", methods=['GET', 'POST'])
|
||||||
|
def familiar(username,word):
|
||||||
|
user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
|
||||||
|
pickle_idea.familiar(user_freq_record,word)
|
||||||
|
return redirect(url_for('userpage', username=username))
|
||||||
|
|
||||||
@app.route("/<username>", methods=['GET', 'POST'])
|
@app.route("/<username>", methods=['GET', 'POST'])
|
||||||
def userpage(username):
|
def userpage(username):
|
||||||
|
@ -345,13 +356,11 @@ def userpage(username):
|
||||||
freq = x[1]
|
freq = x[1]
|
||||||
if isinstance(d[word], list): # d[word] is a list of dates
|
if isinstance(d[word], list): # d[word] is a list of dates
|
||||||
if freq > 1:
|
if freq > 1:
|
||||||
page += '<p class="new-word"> <a href="%s">%s</a> (<a title="%s">%d</a>) </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq)
|
page += '<p class="new-word"> <a href="%s">%s</a>(<a title="%s">%d</a>) <a href="%s/%s/familiar">熟悉</a> <a href="%s/%s/unfamiliar">不熟悉</a> </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word)
|
||||||
else:
|
else:
|
||||||
page += '<p class="new-word"> <a href="%s">%s</a> <font color="white">(<a title="%s">%d</a>)</font> </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq)
|
page += '<p class="new-word"> <a href="%s">%s</a>(<a title="%s">%d</a>) <a href="%s/%s/familiar">熟悉</a> <a href="%s/%s/unfamiliar">不熟悉</a> </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word)
|
||||||
elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format.
|
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)
|
page += '<a href="%s">%s</a>%d\n' % (youdao_link(word), word, freq)
|
||||||
|
|
||||||
|
|
||||||
return page
|
return page
|
||||||
|
|
||||||
### Sign-up, login, logout ###
|
### Sign-up, login, logout ###
|
||||||
|
|
Loading…
Reference in New Issue