forked from mrlan/EnglishPal
parent
843ed03d4f
commit
0379c7e978
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
</module>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||||
|
<component name="PyCharmProfessionalAdvertiser">
|
||||||
|
<option name="shown" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/englishpal.iml" filepath="$PROJECT_DIR$/.idea/englishpal.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
10
app/main.py
10
app/main.py
|
@ -269,7 +269,11 @@ def user_mark_word(username):
|
||||||
else:
|
else:
|
||||||
return 'Under construction'
|
return 'Under construction'
|
||||||
|
|
||||||
|
@app.route("/<username>/<word>/del", methods=['GET', 'POST'])
|
||||||
|
def deleteword(username,word):
|
||||||
|
user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
|
||||||
|
pickle_idea2.deleteRecord(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,9 +349,9 @@ 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/del">删除</a> </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq,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/del" >删除</a></p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq,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)
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,15 @@ def lst2dict(lst, d):
|
||||||
else:
|
else:
|
||||||
d[word] += dates
|
d[word] += dates
|
||||||
|
|
||||||
|
def deleteRecord(path,word):
|
||||||
|
with open(path, 'rb') as f:
|
||||||
|
db = pickle.load(f)
|
||||||
|
try:
|
||||||
|
db.pop(word)
|
||||||
|
except KeyError:
|
||||||
|
print("sorry")
|
||||||
|
with open(path, 'wb') as ff:
|
||||||
|
pickle.dump(db, ff)
|
||||||
|
|
||||||
def dict2lst(d):
|
def dict2lst(d):
|
||||||
if len(d) > 0:
|
if len(d) > 0:
|
||||||
|
|
Loading…
Reference in New Issue