Compare commits

...

4 Commits

Author SHA1 Message Date
mrlan 43c719b6b2 Merge pull request 'Fix bug 501 - 特殊字符&加入生词库后删除按钮失效' (#81) from Bug501-Hui into master
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/81
2023-01-31 16:45:50 +08:00
Hui Lan a1955341c6 Fix bug 501 - 特殊字符&加入生词库后删除按钮失效 2023-01-31 16:39:11 +08:00
mrlan 92a8b4a994 Lanhui-update-README2 (#80)
Co-authored-by: Lan Hui <1348141770@qq.com>
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/80
Co-authored-by: mrlan <mrlan@noreply.121.4.94.30>
Co-committed-by: mrlan <mrlan@noreply.121.4.94.30>
2023-01-30 15:44:01 +08:00
王志豪 e10dbf9d67 Bug507-WuWenZhuo (#70)
### 修复了生词簿为空时,双击文章单词无法高亮的问题
通过增加一个判断,判断生词簿为空时,不把生词簿的内容进行处理,仅处理选中单词。

### 修复了生词簿为空时,取消高亮后,导致文章格式混乱的问题
原代码中,从数据库提取文章放到网页上时,使用的是.innerText的方法,导致原文章里包含的<br>标签丢失,导致文章格式混乱的问题。

Co-authored-by: unknown <Alcatraz@qq.com>
Co-authored-by: Hui Lan <lanhui@zjnu.edu.cn>
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/70
Co-authored-by: 王志豪 <1594799762@qq.com>
Co-committed-by: 王志豪 <1594799762@qq.com>
2023-01-29 12:48:52 +08:00
4 changed files with 48 additions and 41 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -11,15 +11,14 @@ Hui Lan <hui.lan@cantab.net>
EnglishPal allows the user to build his list of new English words
picked from articles selected for him according his vocabulary level.
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 it on a local machine
## Run on your own laptop
`python3 main.py`
Make sure you have the SQLite database file in `app/static` (see below).
Make sure you have put the SQLite database file in the path `app/static` (see below).
## Run it as a Docker container
@ -29,32 +28,32 @@ Assuming that docker has been installed and that you are a sudo user (i.e., sudo
`sudo ./build.sh`
Open your favourite Internet browser and enter this URL address: `http://ip-address:90`.
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 the server.
My steps for deploying English on a Ubuntu server.
- ssh to ubuntu@118.*.*.118
- cd to /home/lanhui/englishpal2/EnglishPal
- 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 after the code gets updated: `sudo docker build -t englishpal .`
- 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 use `sudo docker run -d -p 90:80 -t englishpal`, data will be lost after terminating the program.
- 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 use `sudo 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` after `docker run`.
- Save space: `sudo docker system prune -a -f`
- 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
#### Other useful docker commands
- `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 and run the web application.
- `sudo docker logs image_name`, where `image_name` could be obtained from `sudo docker ps`.
@ -68,6 +67,10 @@ All articles are stored in the `article` table in a SQLite file called
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:
@ -92,33 +95,31 @@ sqlite3 wordfreqapp.db`. Delete wordfreqapp.db first if it exists.
### Uploading wordfreqapp.db to the server
`pscp wordfreqapp.db lanhui@118.*.*.118:/home/lanhui/englishpal/app/static`
`pscp wordfreqapp.db lanhui@118.*.*.118:/home/lanhui/englishpal2/EnglishPal/app/static`
## Feedback
We welcome feedback on EnglishPal.
We welcome feedback on EnglishPal. Feedback examples:
### Respondent 1
### Feedback 1
- "Need a phone app. I use phone a lot. You cannot ask students to use computers."
"Need a phone app. I use phone a lot. You cannot ask students to use computers."
Can take a picture for text. Automatic translation.
### Respondent 2
### Feedback 2
“成为会员”改成“注册”
- “成为会员”改成“注册”
“登出”改成“退出”
- “登出”改成“退出”
“收集生词吧”改成“生词收集栏”
- “收集生词吧”改成“生词收集栏”
“不要自动显示下一篇”
- 不要自动显示下一篇
需要有“上一篇”、“下一篇”
- 需要有“上一篇”、“下一篇”按钮。
@ -137,7 +138,7 @@ EnglishPal's bugs and improvement suggestions are recorded in [Bugzilla](http://
- Usability testing
## Improvements made by contributors
## Improvements made by contributors (incomplete list)
### 朱文绮
@ -159,7 +160,6 @@ 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.
More information at: http://118.25.96.118/kanboard/?controller=TaskViewController&action=readonly&task_id=736&token=81a561da57ff7a172da17a480f0d421ff3bc69efbd29437daef90b1b8959
### 占健豪
@ -188,7 +188,7 @@ 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
Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=489
*Last modified on 2021-10-17*
*Last modified on 2023-01-30*

View File

@ -22,11 +22,17 @@ function getWord() {
function highLight() {
if (!isHighlight) return;
let articleContent = document.getElementById("article").innerText;
let articleContent = document.getElementById("article").innerText; //将原来的.innerText改为.innerHtml使用innerText会把原文章中所包含的<br>标签去除,导致处理后的文章内容失去了原来的格式
let pickedWords = document.getElementById("selected-words"); // words picked to the text area
let dictionaryWords = document.getElementById("selected-words2"); // words appearing in the user's new words list
let allWords = pickedWords.value + " " + dictionaryWords.value;
const list = allWords.split(" ");
let allWords = ""; //初始化allWords的值避免进入判断后编译器认为allWords未初始化的问题
if(dictionaryWords != null){//增加一个判断检查生词本里面是否为空如果为空allWords只添加选中的单词
allWords = pickedWords.value + " " + dictionaryWords.value;
}
else{
allWords = pickedWords.value + " ";
}
const list = allWords.split(" ");//将所有的生词放入一个list中用于后续处理
for (let i = 0; i < list.length; ++i) {
list[i] = list[i].replace(/(^\s*)|(\s*$)/g, ""); //消除单词两边的空字符
list[i] = list[i].replace('|', "");
@ -40,15 +46,15 @@ function highLight() {
}
function cancelHighlighting() {
let articleContent = document.getElementById("article").innerText;
let articleContent = document.getElementById("article").innerText;//将原来的.innerText改为.innerHtml原因同上
let pickedWords = document.getElementById("selected-words");
const dictionaryWords = document.getElementById("selected-words2");
const list = pickedWords.value.split(" ");
if (pickedWords != null) {
for (let i = 0; i < list.length; ++i) {
list[i] = list[i].replace(/(^\s*)|(\s*$)/g, "");
if (list[i] !== "") {
articleContent = articleContent.replace("<mark>" + list[i] + "</mark>", "list[i]");
if (list[i] !== "") { //原来判断的代码中替换的内容为“list[i]”这个字符串这明显是错误的我们需要替换的是list[i]里的内容
articleContent = articleContent.replace(new RegExp("<mark>"+list[i]+"</mark>", "g"), list[i]);
}
}
}
@ -57,8 +63,8 @@ function cancelHighlighting() {
for (let i = 0; i < list2.length; ++i) {
list2 = dictionaryWords.value.split(" ");
list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, "");
if (list2[i] !== "") {
articleContent = articleContent.replace("<mark>" + list[i] + "</mark>", "list[i]");
if (list2[i] !== "") { //原来代码中替换的内容为“list[i]”这个字符串这明显是错误的我们需要替换的是list[i]里的内容
articleContent = articleContent.replace(new RegExp("<mark>"+list2[i]+"</mark>", "g"), list2[i]);
}
}
}

View File

@ -47,7 +47,7 @@ function unfamiliar(theWord) {
function delete_word(theWord) {
let username = $("#username").text();
let word = $("#word_" + theWord).text();
let word = theWord.replace('&amp;', '&');
$.ajax({
type:"GET",
url:"/" + username + "/" + word + "/del",
@ -104,6 +104,7 @@ function wordTemplate(word) {
*/
function removeWord(word) {
// 根据词频信息删除元素
word = word.replace('&amp;', '&');
const element_to_remove = document.getElementById(`p_${word}`);
if (element_to_remove != null) {
element_to_remove.remove();