We want to return a Result<Blog>, instead of a QueryResult<Blog>.
We can use map_err() to map it to the desired error type.
thanks to review from @BaptisteGelez & @fdb-hiroshima.
we can use "first()" instead of limit(1).load().etc…
since on a UNIQUE field, we only expect 1 result.
first() returns QueryResult, which is Result<T, diesel::Error>, so we
need to implement a converter for that error type.
This commit addresses @fdb-hiroshima's review.
how this works: we use find_by_host() to find the Host in question, the
defer to the existing function!
Caveat: Currently, we, in that function, we do another lookup DB lookup
for the Blog, even thou we already know it.
It might be wise, to have both of those another wrapper here?!
this rewrites the URL to /custom_domain/<url>
(we have no route handlers for this path yet)
Lots of help from @fdb-hiroshima & @BaptisteGelez in dealing with the
borrow checker — thank you 💜️
we can use this to handle rocket Requests (from_request)
but we still have to figure out how to automatically assign the type to
custom_domain: Optional<Host>, and public_domain: Host.
* add enum containing all successful route returns
This enum derives `Responder`, so it can be used as route result.
We also implement `From`, so it can be converted
* disable clippy warning about this enum
There's no use trying to chase this warning.
The next warning will be about `Redirect`, which itself is 360 byte,
according to @fdb-hiroshima (thanks for the research!)
So, if anything, we can try to get Rocket to work on that!
* refactor routes/posts to only use one level of Result
* admin settings error is not an ErrorPage, so dont use Result<>
* refactor: use early return to remove indent of main logic
This diff is absolutely atrocious.
but the resulting readability is worth it
* refactor routes/post for early returns & RespondOrRedirect
* refactor routes/session for early returns & use RespondOrRedirect
* refactor routes/user -- add another field to enum
* refactor routes/blogs for early returns & RespondOrRedirect
* refactor routes/blogs for early returns & RespondOrRedirect
This is a final refactor of `pub fn update()` for readability.
We're removing at least one indentation level.
* add shrinkwraprs and implement Id thru it
This also means we can automatically convert Id to String without using
.into()!
* cleanup with the help of clippy!
* cleanup with the help of cargo fmt!
* remove extra block
* Shrinkwrap Page, ContentLen and RemoteForm
* translations
We add clippy as our build — also rectifying the missing `plume-cli` build!
In the next step we follow clippy's advise and fix some of the "simple" mistakes in our code, such as style or map usage.
Finally, we refactor some hard bits that need extraction of new types, or refactoring of function call-types, especially those that thread thru macros, and, of course functions with ~15 parameters should probably be rethought.
we move our PostgreSQL specific migrations to a subdirectory.
The SQLite migrations have been created by running `diesel` against a
copy, and then fixing what's broken.
In the end i reduced all modifications to a single create, since we
*are* starting out fresh with SQLite.
n.b.: i'm not entirely happy with the results yet, because diesel
heavily modifies our `plume-models/src/schema.rs`.
I'll keep fiddling until we have the same types between the two
databases.
follow review from @pwoolcoc, and do not use
SafeString::new(&<String>::new())
since this makes an allocation which will then just be thrown away.
Instead, we pass ""
long_description & short_description's documentation say they can be
Markdown, but they are String, not SafeString.
This led to escaped strings being printed in the editor
https://github.com/Plume-org/Plume/issues/220