Compare commits

..

5 Commits

6 changed files with 67 additions and 54 deletions

View File

@ -18,7 +18,7 @@ picked from articles selected for him to read according his vocabulary level. E
`python3 main.py` `python3 main.py`
Make sure you have put the SQLite database file in the path `app/db` (see below). Make sure you have put the SQLite database file in the path `app/static` (see below).
## Run it as a Docker container ## Run it as a Docker container
@ -214,5 +214,5 @@ 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 2026-03-12* *Last modified on 2023-01-30*

View File

@ -106,7 +106,7 @@ def get_today_article(user_word_list, visited_articles):
text_level = text_difficulty_level(d['text'], d3) text_level = text_difficulty_level(d['text'], d3)
result_of_generate_article = "found" result_of_generate_article = "found"
today_article = {} today_article = None
if d: if d:
oxford_words = load_oxford_words(oxford_words_path) oxford_words = load_oxford_words(oxford_words_path)
oxford_word_count, total_words = count_oxford_words(d['text'],oxford_words) oxford_word_count, total_words = count_oxford_words(d['text'],oxford_words)

View File

@ -144,8 +144,8 @@ if __name__ == '__main__':
运行程序 运行程序
''' '''
# app.secret_key = os.urandom(16) # app.secret_key = os.urandom(16)
app.run(debug=True, port=5000) # app.run(debug=False, port='6000')
# app.run(debug=True) app.run(host='127.0.0.1', port=5000, debug=True)
# app.run(debug=True, port='6000') # app.run(debug=True, port='6000')
# app.run(host='0.0.0.0', debug=True, port='6000') # app.run(host='0.0.0.0', debug=True, port='6000')
# print(mod5('123')) # print(mod5('123'))

View File

@ -11,7 +11,7 @@ function containsDigitsLettersSpecialCharacters(s) {
resultL = /[a-z]/i.test(s); resultL = /[a-z]/i.test(s);
// Special charater test // Special charater test
'+-*/,.:;/\[]<>$%&()!?^~'.split('').forEach((x) => { '+-*/,.:;/\[]<>$%&()!?^~@'.split('').forEach((x) => {
if (s.includes(x)) if (s.includes(x))
resultS = 1; resultS = 1;
}); });

View File

@ -31,7 +31,7 @@
<p><a href="/login">登录</a> <a href="/signup">注册</a> <a href="/static/usr/instructions.html">使用说明</a></p > <p><a href="/login">登录</a> <a href="/signup">注册</a> <a href="/static/usr/instructions.html">使用说明</a></p >
<p><b> {{ random_ads }}。 <a href="/signup">试试</a>吧!</b></p> <p><b> {{ random_ads }}。 <a href="/signup">试试</a>吧!</b></p>
{% endif %} {% endif %}
<div class="alert alert-success" role="alert">共有文章 <span class="badge bg-success"> {{ number_of_essays }} </span> 篇,Oxford 5000 单词占比 <span class="badge bg-success"> {{ (ratio * 100) | int }}% </span> </div> <div class="alert alert-success" role="alert">共有文章 <span class="badge bg-success"> {{ number_of_essays }} </span> 篇,覆盖 <span class="badge bg-success"> {{ (ratio * 100) | int }}% </span> 的 Oxford5000 单词</div>
<p>粘贴1篇文章 (English only)</p> <p>粘贴1篇文章 (English only)</p>
<form method="post" action="/"> <form method="post" action="/">
<textarea name="content" id="article" rows="10" cols="120"></textarea><br/> <textarea name="content" id="article" rows="10" cols="120"></textarea><br/>

View File

@ -87,7 +87,18 @@
<div id="text-content"> <div id="text-content">
<div id="found"> <div id="found">
<div class="alert alert-success" role="alert">According to your word list, your level is <span class="text-decoration-underline" id="user_level">{{ today_article["user_level"] }}</span> and we have chosen an article with a difficulty level of <span class="text-decoration-underline" id="text_level">{{ today_article["text_level"] }}</span> for you. <span class="text-decoration-underline" id="ratio">{{ (today_article["ratio"] * 100) | int }}%</span> of the words in this article are in Oxford Word 5000.</div> {% if today_article and today_article["ratio"] is not none %}
<div class="alert alert-success" role="alert">
According to your word list, your level is
<span class="text-decoration-underline" id="user_level">{{ today_article["user_level"] }}</span>
and we have chosen an article with a difficulty level of
<span class="text-decoration-underline" id="text_level">{{ today_article["text_level"] }}</span>
for you. The Oxford word coverage is
<span class="text-decoration-underline" id="ratio">{{ (today_article["ratio"] * 100) | int }}%.</span>
</div>
{% else %}
<div class="alert alert-warning">No article or article is incomplete.</div>
{% endif %}
<p class="text-muted" id="date">Article added on: {{ today_article["date"] }}</p><br/> <p class="text-muted" id="date">Article added on: {{ today_article["date"] }}</p><br/>
<button onclick="saveArticle()" >标记文章</button> <button onclick="saveArticle()" >标记文章</button>
@ -114,11 +125,13 @@
} }
</script> </script>
<button onclick="toggle_visibility('answer');">ANSWER</button> <button onclick="toggle_visibility('answer');">ANSWER</button>
<div id="answer" style="display:none;">{{ today_article['answer'] }}</div><br/> <div id="answer" style="display:none;">
{{ today_article['answer'] }}
</div><br/>
</div> </div>
<div id="tooltip"></div> <div id="tooltip"></div>
</div> </div>
<div class="alert alert-success" role="alert" id="not_found" style="display:none;"> <div class="alert alert-success" role="alert" id="not_found" style="display:none;" >
<p class="text-muted"><span class="badge bg-success">Notes:</span><br>No article is currently available for you. You can try again a few times or mark new words in the passage to improve your level.</p> <p class="text-muted"><span class="badge bg-success">Notes:</span><br>No article is currently available for you. You can try again a few times or mark new words in the passage to improve your level.</p>
</div> </div>
<div class="alert alert-success" role="alert" id="read_all" style="display:none;"> <div class="alert alert-success" role="alert" id="read_all" style="display:none;">
@ -367,7 +380,7 @@
savedArticlesDropdown.appendChild(option); savedArticlesDropdown.appendChild(option);
localStorage.setItem(articleTitle, articleJSON); // 以文章标题为键序列化的JSON字符串为值存储 localStorage.setItem(articleTitle, articleJSON); // 以文章标题为键序列化的JSON字符串为值存储
} }
function loadSelectedArticle() { function loadSelectedArticle() {
const selectedOption = document.getElementById('saved_articles_dropdown'); const selectedOption = document.getElementById('saved_articles_dropdown');
const selectedTitle = selectedOption.options[selectedOption.selectedIndex].text; const selectedTitle = selectedOption.options[selectedOption.selectedIndex].text;
const articleJSON = localStorage.getItem(selectedTitle); const articleJSON = localStorage.getItem(selectedTitle);
@ -378,7 +391,7 @@
} }
} }
window.onload = function() { window.onload = function() {
const savedArticlesDropdown = document.getElementById('saved_articles_dropdown'); const savedArticlesDropdown = document.getElementById('saved_articles_dropdown');
savedArticlesDropdown.addEventListener('change', loadSelectedArticle); savedArticlesDropdown.addEventListener('change', loadSelectedArticle);