mirror of https://github.com/raftario/filite.git
Removed highlight field for tets
This commit is contained in:
parent
e60e3d625f
commit
2888af37e4
|
@ -1,6 +1,5 @@
|
||||||
CREATE TABLE texts (
|
CREATE TABLE texts (
|
||||||
id INTEGER NOT NULL PRIMARY KEY,
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
contents TEXT NOT NULL,
|
contents TEXT NOT NULL,
|
||||||
highlight INTEGER NOT NULL,
|
|
||||||
created INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
|
created INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
|
||||||
);
|
);
|
||||||
|
|
|
@ -63,8 +63,6 @@ pub mod texts {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
/// Text contents
|
/// Text contents
|
||||||
pub contents: String,
|
pub contents: String,
|
||||||
/// Whether to use syntax highlighting or not when serving that text
|
|
||||||
pub highlight: i32,
|
|
||||||
/// Creation date and time as a UNIX timestamp
|
/// Creation date and time as a UNIX timestamp
|
||||||
pub created: i32,
|
pub created: i32,
|
||||||
}
|
}
|
||||||
|
@ -77,7 +75,5 @@ pub mod texts {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
/// Text contents
|
/// Text contents
|
||||||
pub contents: &'a str,
|
pub contents: &'a str,
|
||||||
/// Whether to use syntax highlighting or not when serving that text
|
|
||||||
pub highlight: i32,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,20 +174,11 @@ pub mod texts {
|
||||||
find!(texts, Text);
|
find!(texts, Text);
|
||||||
|
|
||||||
/// REPLACE a text entry
|
/// REPLACE a text entry
|
||||||
pub fn replace(
|
pub fn replace(r_id: i32, r_contents: &str, pool: Data<Pool>) -> QueryResult<Text> {
|
||||||
r_id: i32,
|
|
||||||
r_contents: &str,
|
|
||||||
r_highlight: bool,
|
|
||||||
pool: Data<Pool>,
|
|
||||||
) -> QueryResult<Text> {
|
|
||||||
let conn: &SqliteConnection = &pool.get().unwrap();
|
let conn: &SqliteConnection = &pool.get().unwrap();
|
||||||
let new_text = NewText {
|
let new_text = NewText {
|
||||||
id: r_id,
|
id: r_id,
|
||||||
contents: r_contents,
|
contents: r_contents,
|
||||||
highlight: match r_highlight {
|
|
||||||
true => 1,
|
|
||||||
false => 2,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
diesel::replace_into(table)
|
diesel::replace_into(table)
|
||||||
.values(&new_text)
|
.values(&new_text)
|
||||||
|
|
|
@ -461,7 +461,6 @@ pub mod texts {
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct PutText {
|
pub struct PutText {
|
||||||
pub contents: String,
|
pub contents: String,
|
||||||
pub highlight: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// PUT a new text entry
|
/// PUT a new text entry
|
||||||
|
@ -476,10 +475,8 @@ pub mod texts {
|
||||||
future::result(auth(identity, request, &token_hash))
|
future::result(auth(identity, request, &token_hash))
|
||||||
.and_then(move |_| future::result(parse_id(&path)))
|
.and_then(move |_| future::result(parse_id(&path)))
|
||||||
.and_then(move |id| {
|
.and_then(move |id| {
|
||||||
web::block(move || {
|
web::block(move || queries::texts::replace(id, &body.contents, pool))
|
||||||
queries::texts::replace(id, &body.contents, body.highlight, pool)
|
.then(|result| match_replace_result(result))
|
||||||
})
|
|
||||||
.then(|result| match_replace_result(result))
|
|
||||||
})
|
})
|
||||||
.from_err()
|
.from_err()
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ table! {
|
||||||
texts (id) {
|
texts (id) {
|
||||||
id -> Integer,
|
id -> Integer,
|
||||||
contents -> Text,
|
contents -> Text,
|
||||||
highlight -> Integer,
|
|
||||||
created -> Integer,
|
created -> Integer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue