钱骏琪
ea16ea6673
1. 补充module docstring,即文档顶部的简要说明 (我做的说明很简陋,只是为了通过pylint的检查而为之) 2. 优化了if-else-return,即删除了不必要的elif或else 3. 拆分了所有在同一行的模块引用(不同模块的引用需要放在不同行,以便理解和阅读) 4. 删除了部分没有被使用的引用(有的引用在文件A中被使用了,但import却写在了文件B,且文件B没有使用这些引用,而文件A引用了文件B,导致文件B的所有引用也被A引用,这似乎并不合理) 5. 修改了引用的顺序(os、random等系统引用应放在自定义模块引用的上方) 6. 修改了过长的代码,注释除外(每行限制在100个字符以内) 7. 优化了条件判断的判断符号: is和is not 用于判断两个变量是否指向同一个位置 == 和 !=用于比较两个变量 8. 为每个py文件添加了"last new line",删除了多余的尾部空行 Pylint提示了但是没有进行的操作: 1. 将字符串改为f-string的格式 因为f-string需要python3.6以上的版本,为了防止出现版本问题,故不做修改 2. 将所有函数内的return内容改为一致的类型 因为原有的代码逻辑已经确定,修改return的类型会导致方法的无法使用,故不做修改 3. 将标识符的格式改为"snake_case naming style" 标识符的修改内容过于庞大,且可能出现程序不可预见的错误,在pylint中重要等级为0,故不做修改 JSLint Part: 1. 提高代码的可读性:将部分超过80个字符的代码行拆解开(由于文字注释的存在,很多语句仅注释就超过了80个字符,此类型的语句行不做修改) 2. 用===与!==代替==与!=的判断 3. 将i++改为i+=1 4. 分离for循环中的let与var到其他行中,以适应JSLint在循环语句中对var和let的偏好 5. 给三元表达式外围添加圆括号,避免出现优先级的问题 6. 将正则表达式修改为JSLint要求的多行模式 疑问: 形如: for (let i = 0; i < list.length; i+=1) { 的语句,JSLint报错: [JSLint was unable to finish] Unexpected 'let'. 但是网上搜索到的结果是ES6是支持let的使用的,暂且不做修改。 |
||
---|---|---|
app | ||
.gitignore | ||
Dockerfile | ||
Jenkinsfile | ||
README.md | ||
build.sh | ||
requirements.txt |
README.md
EnglishPal - Learn English Words Smartly
Hui Lan hui.lan@cantab.net
1 November 2019
What is it?
EnglishPal allows the user to build his list of new English words picked from articles selected for him to read according his vocabulary level. EnglishPal will determine a user's vocabulary level based on his picked words. After that, it will recommend articles for him to read, in order to booster his English vocabulary furthermore.
Run on your own laptop
python3 main.py
Make sure you have put the SQLite database file in the path app/static
(see below).
Run it as a Docker container
Assuming that docker has been installed and that you are a sudo user (i.e., sudoer), start the program by typing the following command in directory EnglishPal
:
sudo ./build.sh
Open your favourite Internet browser and enter this URL address: http://ip-address:90
. Note: you must update the variable DEPLOYMENT_DIR
in build.sh
.
Explanation on the commands in build.sh
My steps for deploying English on a Ubuntu server.
-
ssh to ubuntu@118...118
-
cd to
/home/lanhui/englishpal2/EnglishPal
-
Stop all docker service:
sudo service docker restart
. If you know the docker container ID, then the above command is an overkill. Use the following command instead:sudo docker stop ContainerID
. You could get all container IDs with the following command:sudo docker ps
-
Rebuild container. Run the following command to rebuild a docker image each time after the source code gets updated:
sudo docker build -t englishpal .
-
Run the application:
sudo docker run -d -p 90:80 -v /home/lanhui/englishpal2/EnglishPal/app/static/frequency:/app/static/frequency -t englishpal
. If you usesudo docker run -d -p 90:80 -t englishpal
, data will be lost after terminating the program. If you want to automatically restart the docker image after each system reboot, add the option--restart=always
afterdocker run
. -
Save disk space:
sudo docker system prune -a -f
build.sh
contains all the above commands. Run "sudo ./build.sh" to rebuild and start the web application.
Other useful docker commands
-
sudo docker ps -a
-
sudo docker logs image_name
, whereimage_name
could be obtained fromsudo docker ps
.
Importing articles
All articles are stored in the article
table in a SQLite file called
app/static/wordfreqapp.db
.
Adding new articles
To add articles, open and edit app/static/wordfreqapp.db
using DB Browser for SQLite (https://sqlitebrowser.org).
Extending an account's expiry date
By default, an account's expiry is 30 days after first sign-up. To extend account's expiry date, open and edit user
table in app/static/wordfreqapp.db
. Simply update field expiry_date
.
Exporting the database
Export wordfreqapp.db to wordfreqapp.sql using the following commands:
-
sqlite3 wordfreqapp.db
-
.output wordfreqapp.sql
-
.dump
-
.exit
Put wordfreqapp.sql (not wordfreqapp.db) under version control.
Creating SQLite file from wordfreqapp.sql
Create wordfreqapp.db using this command: cat wordfreqapp.sql | sqlite3 wordfreqapp.db
. Delete wordfreqapp.db first if it exists.
Uploading wordfreqapp.db to the server
pscp wordfreqapp.db lanhui@118.*.*.118:/home/lanhui/englishpal2/EnglishPal/app/static
Feedback
We welcome feedback on EnglishPal. Feedback examples:
Feedback 1
- "Need a phone app. I use phone a lot. You cannot ask students to use computers."
Feedback 2
-
“成为会员”改成“注册”
-
“登出”改成“退出”
-
“收集生词吧”改成“生词收集栏”
-
不要自动显示下一篇
-
需要有“上一篇”、“下一篇”按钮。
Bug tracking
EnglishPal's bugs and improvement suggestions are recorded in Bugzilla. Send (lanhui at zjnu.edu.cn) an email message for opening a Bugzilla account or reporting a bug.
TODO
-
Fix Bug: Internal server error when register using an email address.
-
Usability testing
Improvements made by contributors (incomplete list)
朱文绮
在生词簿每个单词后面,加上两个按钮,熟悉与不熟悉:
-
如果点熟悉,就将生词簿中该单词后面记录的添加次数减一,直至减为0,就将该单词从生词簿中移除。
-
如果点不熟悉,就将生词簿中该单词后面记录的添加次数加一。
李康恬
Add the function of "Delete already known and well-known words from the words' library", on the one hand, it can conform to the usage habits of some users, who do not like that their words' libraries have too many words that they already know, on the other hand, it can reduce unnecessary memory occupied by the database, in addition, it can also improve the simplicity of the page.
占健豪
Click the Familiar or Unfamiliar button (current word frequency>1), the current word position is displayed at the top of the page;
Click the Familiar or Unfamiliar button (current word frequency is 1), and the page will be displayed as the top of the entire page.
Demo video link: https://b23.tv/QuB77m
张小飞
修复了以下漏洞。
漏洞:用 ‘ or ‘1’=‘1’
这段字符可以作为任何账号的密码登录。
Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=215
丁锐
修复了以下漏洞
漏洞:新用户在创建账号时,不需要输入确定密码也可以注册成功,并且新账户可以正常使用。
Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=489
Last modified on 2023-01-30