Compare commits
No commits in common. "4c45fba5f614ae71df4bbd7c0af35563f9302c89" and "0de83070c7e5f8d89a526e30b2459da748347034" have entirely different histories.
4c45fba5f6
...
0de83070c7
1179
Cargo.lock
generated
1179
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
10
src/views.rs
10
src/views.rs
@ -12,15 +12,15 @@ use crate::language::Language;
|
||||
use crate::FRONTEND_DIR;
|
||||
|
||||
#[get("/")]
|
||||
pub fn frontend() -> content::RawHtml<String> {
|
||||
pub fn frontend() -> content::Html<String> {
|
||||
match fs::read_to_string(&format!("{}/{}", FRONTEND_DIR, "index.html")) {
|
||||
Ok(file) => content::RawHtml(file),
|
||||
Err(_) => content::RawHtml(String::from("<h1>No web frontend installed.</h1>"))
|
||||
Ok(file) => content::Html(file),
|
||||
Err(_) => content::Html(String::from("<h1>No web frontend installed.</h1>"))
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/langs/<lang>/words/<word>")]
|
||||
pub fn get_entries(db: &State<WordDb>, lang: &str, word: &str) -> status::Custom<content::RawJson<String>> {
|
||||
pub fn get_entries(db: &State<WordDb>, lang: &str, word: &str) -> status::Custom<content::Json<String>> {
|
||||
let conn = db.connect();
|
||||
|
||||
let mut statement = conn.prepare(&format!(
|
||||
@ -46,7 +46,7 @@ pub fn get_entries(db: &State<WordDb>, lang: &str, word: &str) -> status::Custom
|
||||
}
|
||||
words.push(']');
|
||||
|
||||
status::Custom(Status::Ok, content::RawJson(words))
|
||||
status::Custom(Status::Ok, content::Json(words))
|
||||
}
|
||||
|
||||
#[get("/langs/<lang>/words?<like>&<limit>&<offset>")]
|
||||
|
@ -184,12 +184,7 @@ $(document).ready(() => {
|
||||
html += `<h1>Not found: <mark>${decodeURIComponent(word)}</mark></h1>`;
|
||||
} else {
|
||||
data.forEach(entry => {
|
||||
html += `<h1>${entry.word} <span class="pos">(${entry.pos})</span></h1>`
|
||||
|
||||
if('sounds' in entry) {
|
||||
html += `<p>${entry.sounds.map(sound => sound.ipa).join(', ')}</p>`;
|
||||
}
|
||||
|
||||
html += `<h1>${entry.word} <span class="pos">${entry.sounds[0].ipa} (${entry.pos})</span></h1>`
|
||||
if('senses' in entry) {
|
||||
let tags = [];
|
||||
entry.senses.forEach(sense => {
|
||||
@ -233,7 +228,7 @@ $(document).ready(() => {
|
||||
if('forms' in entry) {
|
||||
if(entry.pos === 'verb') {
|
||||
let conjugation = entry.forms.filter(form =>
|
||||
'source' in form && form.source === 'conjugation');
|
||||
'source' in form && form.source === 'Conjugation');
|
||||
|
||||
if(conjugation.length > 0) {
|
||||
html += '<h2>Conjugation</h2>';
|
||||
@ -242,7 +237,7 @@ $(document).ready(() => {
|
||||
}
|
||||
} else {
|
||||
let declension = entry.forms.filter(form =>
|
||||
'source' in form && form.source === 'declension');
|
||||
'source' in form && form.source === 'Declension');
|
||||
|
||||
if(declension.length > 0) {
|
||||
html += '<h2>Declension</h2>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user