| 96 |
96 |
|
AuthUser(user): AuthUser,
|
| 97 |
97 |
|
session: Session,
|
| 98 |
98 |
|
) -> Result<Response> {
|
| 99 |
|
- |
let target = user_target(&state, user.id, &user.username.to_string()).await?;
|
|
99 |
+ |
let target = user_target(&state, user.id, user.username.as_ref()).await?;
|
| 100 |
100 |
|
render_editor(&state, &session, target).await
|
| 101 |
101 |
|
}
|
| 102 |
102 |
|
|
| 105 |
105 |
|
AuthUser(user): AuthUser,
|
| 106 |
106 |
|
Form(form): Form<CustomPageForm>,
|
| 107 |
107 |
|
) -> Result<Response> {
|
| 108 |
|
- |
let target = user_target(&state, user.id, &user.username.to_string()).await?;
|
|
108 |
+ |
let target = user_target(&state, user.id, user.username.as_ref()).await?;
|
| 109 |
109 |
|
save(&state, target, form).await
|
| 110 |
110 |
|
}
|
| 111 |
111 |
|
|
| 114 |
114 |
|
AuthUser(user): AuthUser,
|
| 115 |
115 |
|
Form(form): Form<CustomPageForm>,
|
| 116 |
116 |
|
) -> Result<Response> {
|
| 117 |
|
- |
let target = user_target(&state, user.id, &user.username.to_string()).await?;
|
|
117 |
+ |
let target = user_target(&state, user.id, user.username.as_ref()).await?;
|
| 118 |
118 |
|
autosave(&state, target, form).await
|
| 119 |
119 |
|
}
|
| 120 |
120 |
|
|
| 121 |
121 |
|
pub async fn user_reset(State(state): State<AppState>, AuthUser(user): AuthUser) -> Result<Response> {
|
| 122 |
|
- |
let target = user_target(&state, user.id, &user.username.to_string()).await?;
|
|
122 |
+ |
let target = user_target(&state, user.id, user.username.as_ref()).await?;
|
| 123 |
123 |
|
reset(&state, target).await
|
| 124 |
124 |
|
}
|
| 125 |
125 |
|
|
| 129 |
129 |
|
session: Session,
|
| 130 |
130 |
|
Path(slug): Path<String>,
|
| 131 |
131 |
|
) -> Result<Response> {
|
| 132 |
|
- |
let target = project_target(&state, user.id, &user.username.to_string(), &slug).await?;
|
|
132 |
+ |
let target = project_target(&state, user.id, user.username.as_ref(), &slug).await?;
|
| 133 |
133 |
|
render_editor(&state, &session, target).await
|
| 134 |
134 |
|
}
|
| 135 |
135 |
|
|
| 139 |
139 |
|
Path(slug): Path<String>,
|
| 140 |
140 |
|
Form(form): Form<CustomPageForm>,
|
| 141 |
141 |
|
) -> Result<Response> {
|
| 142 |
|
- |
let target = project_target(&state, user.id, &user.username.to_string(), &slug).await?;
|
|
142 |
+ |
let target = project_target(&state, user.id, user.username.as_ref(), &slug).await?;
|
| 143 |
143 |
|
save(&state, target, form).await
|
| 144 |
144 |
|
}
|
| 145 |
145 |
|
|
| 149 |
149 |
|
Path(slug): Path<String>,
|
| 150 |
150 |
|
Form(form): Form<CustomPageForm>,
|
| 151 |
151 |
|
) -> Result<Response> {
|
| 152 |
|
- |
let target = project_target(&state, user.id, &user.username.to_string(), &slug).await?;
|
|
152 |
+ |
let target = project_target(&state, user.id, user.username.as_ref(), &slug).await?;
|
| 153 |
153 |
|
autosave(&state, target, form).await
|
| 154 |
154 |
|
}
|
| 155 |
155 |
|
|
| 158 |
158 |
|
AuthUser(user): AuthUser,
|
| 159 |
159 |
|
Path(slug): Path<String>,
|
| 160 |
160 |
|
) -> Result<Response> {
|
| 161 |
|
- |
let target = project_target(&state, user.id, &user.username.to_string(), &slug).await?;
|
|
161 |
+ |
let target = project_target(&state, user.id, user.username.as_ref(), &slug).await?;
|
| 162 |
162 |
|
reset(&state, target).await
|
| 163 |
163 |
|
}
|
| 164 |
164 |
|
|
| 223 |
223 |
|
let preview_url = format!("{}/preview/{}", user_pages_origin(state), draft.id);
|
| 224 |
224 |
|
let csrf_token = get_csrf_token(session).await;
|
| 225 |
225 |
|
|
| 226 |
|
- |
Ok(EditorTemplate {
|
|
226 |
+ |
EditorTemplate {
|
| 227 |
227 |
|
csrf_token,
|
| 228 |
228 |
|
heading: target.heading,
|
| 229 |
229 |
|
html_value: draft.custom_html,
|
| 236 |
236 |
|
}
|
| 237 |
237 |
|
.render()
|
| 238 |
238 |
|
.map(|h| Html(h).into_response())
|
| 239 |
|
- |
.map_err(|_| AppError::Internal(anyhow::anyhow!("template render failed")))?)
|
|
239 |
+ |
.map_err(|_| AppError::Internal(anyhow::anyhow!("template render failed")))
|
| 240 |
240 |
|
}
|
| 241 |
241 |
|
|
| 242 |
242 |
|
async fn save(state: &AppState, target: Target, form: CustomPageForm) -> Result<Response> {
|