Rewrite article publication with the REST API
- Add a default App and ApiToken for each user, that is used by the front-end - Add an API route to update an article (CSRF had to be disabled because of a bug in rocket_csrf) - Use AJAX to publish and edit articles in the new editor, instead of weird hacks with HTML forms
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DELETE FROM apps WHERE name = 'Plume web interface';
|
||||
@@ -0,0 +1,35 @@
|
||||
-- Your SQL goes here
|
||||
--#!|conn: &Connection, path: &Path| {
|
||||
--#! use plume_common::utils::random_hex;
|
||||
--#!
|
||||
--#! let client_id = random_hex();
|
||||
--#! let client_secret = random_hex();
|
||||
--#! let app = crate::apps::App::insert(
|
||||
--#! &*conn,
|
||||
--#! crate::apps::NewApp {
|
||||
--#! name: "Plume web interface".into(),
|
||||
--#! client_id,
|
||||
--#! client_secret,
|
||||
--#! redirect_uri: None,
|
||||
--#! website: Some("https://joinplu.me".into()),
|
||||
--#! },
|
||||
--#! ).unwrap();
|
||||
--#!
|
||||
--#! for i in 0..=(crate::users::User::count_local(conn).unwrap() as i32 / 20) {
|
||||
--#! if let Ok(page) = crate::users::User::get_local_page(conn, (i * 20, (i + 1) * 20)) {
|
||||
--#! for user in page {
|
||||
--#! crate::api_tokens::ApiToken::insert(
|
||||
--#! conn,
|
||||
--#! crate::api_tokens::NewApiToken {
|
||||
--#! app_id: app.id,
|
||||
--#! user_id: user.id,
|
||||
--#! value: random_hex(),
|
||||
--#! scopes: "read+write".into(),
|
||||
--#! },
|
||||
--#! ).unwrap();
|
||||
--#! }
|
||||
--#! }
|
||||
--#! }
|
||||
--#!
|
||||
--#! Ok(())
|
||||
--#!}
|
||||
Reference in New Issue
Block a user