Edit blogs, and add blog icons and banners #460

Злито
elegaanz злито 14 комітів з blog-edit до master 5 роки тому
elegaanz прокоментував(ла) 5 роки тому (Перенесено з github.com)

Also adds a parameter to md_to_html to only render inline elements (so that we don't have titles or images in blog descriptions). And moves the delete button for the blog on the edition page.

I still have to update the SQLite migration once others PRs with migrations will be merged.

Also, there will be a problem when you edit a blog while not owning its banner or icon: when validating they will be reset to their default values… I don't see a good solution to this until we have a better way to handle uploads with Rocket (the same is probably happening for articles btw).

And the icon/banner are not federated yet, I don't know if I should add it to this PR or if it can come after?

image
image

Fixes #453
Fixes #454

Also adds a parameter to `md_to_html` to only render inline elements (so that we don't have titles or images in blog descriptions). And moves the delete button for the blog on the edition page. I still have to update the SQLite migration once others PRs with migrations will be merged. Also, there will be a problem when you edit a blog while not owning its banner or icon: when validating they will be reset to their default values… I don't see a good solution to this until we have a better way to handle uploads with Rocket (the same is probably happening for articles btw). And the icon/banner are not federated yet, I don't know if I should add it to this PR or if it can come after? ![image](https://user-images.githubusercontent.com/16254623/53894510-7d853300-4030-11e9-8a2c-f5c0b0c7f512.png) ![image](https://user-images.githubusercontent.com/16254623/53894539-8b3ab880-4030-11e9-8113-685a27be8d7c.png) Fixes #453 Fixes #454
codecov[bot] прокоментував(ла) 5 роки тому (Перенесено з github.com)

Codecov Report

Merging #460 into master will increase coverage by 0.05%.
The diff coverage is 25.26%.

@@            Coverage Diff             @@
##           master     #460      +/-   ##
==========================================
+ Coverage   26.83%   26.89%   +0.05%     
==========================================
  Files          65       65              
  Lines        8746     8966     +220     
==========================================
+ Hits         2347     2411      +64     
- Misses       6399     6555     +156
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/460?src=pr&el=h1) Report > Merging [#460](https://codecov.io/gh/Plume-org/Plume/pull/460?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/6cd9c8a01ad8b664fe361f543bc9c6b2caf59e4a?src=pr&el=desc) will **increase** coverage by `0.05%`. > The diff coverage is `25.26%`. ```diff @@ Coverage Diff @@ ## master #460 +/- ## ========================================== + Coverage 26.83% 26.89% +0.05% ========================================== Files 65 65 Lines 8746 8966 +220 ========================================== + Hits 2347 2411 +64 - Misses 6399 6555 +156 ```
igalic (Перенесено з github.com) рецензовано 5 роки тому
igalic (Перенесено з github.com) додав коментар

👀

👀
igalic (Перенесено з github.com) прокоментував(ла) 5 роки тому

or all three?

or all three?
@ -33,0 +47,4 @@
<a class="author p-author" href="@uri!(user::details: name = &author.fqn)">@author.name()</a>}
</p>
@Html(blog.summary_html.clone())
</main>
igalic (Перенесено з github.com) прокоментував(ла) 5 роки тому

isn't the Avatar also optional?

isn't the Avatar also optional?
trinity-1686a рецензовано 5 роки тому
@ -33,0 +47,4 @@
<a class="author p-author" href="@uri!(user::details: name = &author.fqn)">@author.name()</a>}
</p>
@Html(blog.summary_html.clone())
</main>
trinity-1686a прокоментував(ла) 5 роки тому
Власник

icon_url returns either the blog avatar, or the default one (see https://github.com/Plume-org/Plume/pull/460/files#diff-a4a32b57517e9459ff561610609f8044R364 )

icon_url returns either the blog avatar, or the default one (see https://github.com/Plume-org/Plume/pull/460/files#diff-a4a32b57517e9459ff561610609f8044R364 )
elegaanz (Перенесено з github.com) рецензовано 5 роки тому
elegaanz (Перенесено з github.com) прокоментував(ла) 5 роки тому

Yes, at the time I wrote the comment summary_html was not here yet. 😁

Yes, at the time I wrote the comment `summary_html` was not here yet. :grin:
igalic (Перенесено з github.com) рецензовано 5 роки тому
@ -33,0 +47,4 @@
<a class="author p-author" href="@uri!(user::details: name = &author.fqn)">@author.name()</a>}
</p>
@Html(blog.summary_html.clone())
</main>
igalic (Перенесено з github.com) прокоментував(ла) 5 роки тому

duh, thanks!

duh, thanks!
trinity-1686a рецензовано 5 роки тому
trinity-1686a прокоментував(ла) 5 роки тому
Власник

👀

:eyes:
trinity-1686a прокоментував(ла) 5 роки тому
Власник

I find it a bit strange that one function return a default String and the other an Option (also, unwrap_or(xxx.to_string()), @igalic would get mad if it reached master

I find it a bit strange that one function return a default String and the other an Option (also, `unwrap_or(xxx.to_string())`, @igalic would get mad if it reached master
trinity-1686a прокоментував(ла) 5 роки тому
Власник

I'm not sure comments should be allowed to contain pictures and titles

I'm not sure comments should be allowed to contain pictures and titles
@ -173,0 +282,4 @@
blog.summary = form.summary.clone();
blog.summary_html = SafeString::new(&utils::md_to_html(&form.summary, "", true).0);
blog.icon_id = form.icon;
blog.banner_id = form.banner;
trinity-1686a прокоментував(ла) 5 роки тому
Власник

user can provide the id of a media they don't own, or of a non-picture media

user can provide the id of a media they don't own, or of a non-picture media
trinity-1686a прокоментував(ла) 5 роки тому
Власник

if let Some(banner) = blog.banner_url(ctx0) would make more sense here, so there is no unwrap_or_default

`if let Some(banner) = blog.banner_url(ctx0)` would make more sense here, so there is no unwrap_or_default
igalic (Перенесено з github.com) рецензовано 5 роки тому
igalic (Перенесено з github.com) прокоментував(ла) 5 роки тому

not if my pr gets merged first

not if my pr gets merged first
elegaanz (Перенесено з github.com) рецензовано 5 роки тому
elegaanz (Перенесено з github.com) прокоментував(ла) 5 роки тому

It makes sense to me that they don't have the same return type: in one case we provide a fallback URL, in the other case we just want to not display any image.

And I don't know what would be the correct way to replace this unwrap_or😅

It makes sense to me that they don't have the same return type: in one case we provide a fallback URL, in the other case we just want to not display any image. And I don't know what would be the correct way to replace this `unwrap_or`… :sweat_smile:
trinity-1686a рецензовано 5 роки тому
trinity-1686a прокоментував(ла) 5 роки тому
Власник

unwrap_or_else because you're calling a function, so let's not call it if it's not necessary

`unwrap_or_else` because you're calling a function, so let's not call it if it's not necessary
trinity-1686a рецензовано 5 роки тому
trinity-1686a прокоментував(ла) 5 роки тому
Власник

Does this function actually do what it says it does?

Does this function actually do what it says it does?
elegaanz (Перенесено з github.com) рецензовано 5 роки тому
elegaanz (Перенесено з github.com) прокоментував(ла) 5 роки тому

Looks like I pushed too fast… 😅

Looks like I pushed too fast… :sweat_smile:
trinity-1686a прокоментував(ла) 5 роки тому
Власник

There is no way to remove pictures once you set theme, you can just replace with something else

There is no way to remove pictures once you set theme, you can just replace with something else
trinity-1686a зміни затверджено 5 роки тому
trinity-1686a додав коментар
Власник

👍

:+1:
@ -47,3 +51,4 @@
pub banner_id: Option<i32>,
}
#[derive(Default, Insertable)]
trinity-1686a прокоментував(ла) 5 роки тому
Власник

I don't understand what this does, but apparently it did the trick

I don't understand what this does, but apparently it did the trick
elegaanz (Перенесено з github.com) рецензовано 5 роки тому
@ -47,3 +51,4 @@
pub banner_id: Option<i32>,
}
#[derive(Default, Insertable)]
elegaanz (Перенесено з github.com) прокоментував(ла) 5 роки тому

It is an option for the #[derive(AsChangeset)], that tells diesel to consider Option fields that are None to be considered as NULL in SQL, instead of not being included in the query at all.

It is an option for the `#[derive(AsChangeset)]`, that tells diesel to consider `Option` fields that are `None` to be considered as `NULL` in SQL, instead of not being included in the query at all.
trinity-1686a рецензовано 5 роки тому
@ -47,3 +51,4 @@
pub banner_id: Option<i32>,
}
#[derive(Default, Insertable)]
trinity-1686a прокоментував(ла) 5 роки тому
Власник

Ok, doesn't this potentially break other things that relied on it before in our code?

Ok, doesn't this potentially break other things that relied on it before in our code?
igalic (Перенесено з github.com) рецензовано 5 роки тому
@ -47,3 +51,4 @@
pub banner_id: Option<i32>,
}
#[derive(Default, Insertable)]
igalic (Перенесено з github.com) прокоментував(ла) 5 роки тому

not according to our extensive tests

not according to our extensive tests
trinity-1686a рецензовано 5 роки тому
@ -47,3 +51,4 @@
pub banner_id: Option<i32>,
}
#[derive(Default, Insertable)]
trinity-1686a прокоментував(ла) 5 роки тому
Власник

Test in production ™️

Test in production :tm:
elegaanz (Перенесено з github.com) рецензовано 5 роки тому
@ -47,3 +51,4 @@
pub banner_id: Option<i32>,
}
#[derive(Default, Insertable)]
elegaanz (Перенесено з github.com) прокоментував(ла) 5 роки тому

Ok, doesn't this potentially break other things that relied on it before in our code?

It only affects the AsChangeset implementation, which is used when UPDATEing blogs, so I think it is the only place we are doing that.

> Ok, doesn't this potentially break other things that relied on it before in our code? It only affects the `AsChangeset` implementation, which is used when `UPDATE`ing blogs, so I think it is the only place we are doing that.

Рецензенти

trinity-1686a зміни затверджено 5 роки тому
Запит на злиття був влитиий як bdfad844d7.
Також можна переглянути інструкції для командного рядка.

Крок 1:

У репозиторії вашого проєкту перевірте нову гілку і протестуйте зміни.
git checkout -b blog-edit master
git pull origin blog-edit

Крок 2:

Об'єднати зміни і оновити на Forgejo.
git checkout master
git merge --no-ff blog-edit
git push origin master
Підпишіться щоб приєднатися до обговорення.
Немає рецензентів
Етап відсутній
Немає виконавця
2 учасників
Сповіщення
Дата завершення
Термін дії не дійсний або знаходиться за межами допустимого діапазону. Будь ласка використовуйте формат 'yyyy-mm-dd'.

Термін виконання не встановлений.

Залежності

No dependencies set.

Reference: Plume/Plume#460
Завантаження…
Тут ще немає жодного змісту.