add: journal.css special note
This commit is contained in:
parent
f0d1a1e8e4
commit
dc50f3a8af
8 changed files with 125 additions and 13 deletions
|
@ -49,6 +49,20 @@ pub async fn get_request(
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn get_css_request(
|
||||
Path(id): Path<usize>,
|
||||
Extension(data): Extension<State>,
|
||||
) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
|
||||
let note = match data.get_note_by_journal_title(id, "journal.css").await {
|
||||
Ok(x) => x,
|
||||
Err(e) => return ([("Content-Type", "text/plain")], format!("/* {e} */")),
|
||||
};
|
||||
|
||||
([("Content-Type", "text/css")], note.content)
|
||||
}
|
||||
|
||||
pub async fn list_request(jar: CookieJar, Extension(data): Extension<State>) -> impl IntoResponse {
|
||||
let data = &(data.read().await).0;
|
||||
let user = match get_user_from_token!(jar, data, oauth::AppScope::UserReadJournals) {
|
||||
|
|
|
@ -551,6 +551,7 @@ pub fn routes() -> Router {
|
|||
.route("/journals", post(journals::create_request))
|
||||
.route("/journals/{id}", get(journals::get_request))
|
||||
.route("/journals/{id}", delete(journals::delete_request))
|
||||
.route("/journals/{id}/journal.css", get(journals::get_css_request))
|
||||
.route("/journals/{id}/title", post(journals::update_title_request))
|
||||
.route(
|
||||
"/journals/{id}/privacy",
|
||||
|
|
|
@ -116,7 +116,7 @@ pub async fn view_request(
|
|||
}
|
||||
|
||||
// if we don't have a selected journal, we shouldn't be here probably
|
||||
if selected_journal.is_empty() {
|
||||
if selected_journal.is_empty() | (selected_note == "journal.css") {
|
||||
return Err(Html(
|
||||
render_error(Error::NotAllowed, &jar, &data, &user).await,
|
||||
));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue