decidim-blogs 0.27.5 → 0.28.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/blogs/content_blocks/highlighted_posts/content.erb +17 -0
- data/app/cells/decidim/blogs/content_blocks/highlighted_posts_cell.rb +52 -0
- data/app/cells/decidim/blogs/post_activity_cell.rb +1 -4
- data/app/cells/decidim/blogs/post_cell.rb +9 -2
- data/app/cells/decidim/blogs/post_g_cell.rb +31 -0
- data/app/cells/decidim/blogs/post_l_cell.rb +35 -0
- data/app/cells/decidim/blogs/post_metadata_cell.rb +29 -0
- data/app/cells/decidim/blogs/post_metadata_g_cell.rb +14 -0
- data/app/cells/decidim/blogs/post_s_cell.rb +15 -0
- data/app/commands/decidim/blogs/admin/create_post.rb +1 -0
- data/app/commands/decidim/blogs/admin/update_post.rb +10 -1
- data/app/controllers/decidim/blogs/admin/posts_controller.rb +2 -2
- data/app/controllers/decidim/blogs/posts_controller.rb +16 -4
- data/app/forms/decidim/blogs/admin/post_form.rb +2 -1
- data/app/helpers/decidim/blogs/admin/posts_helper.rb +11 -1
- data/app/helpers/decidim/blogs/application_helper.rb +4 -0
- data/app/helpers/decidim/blogs/posts_helper.rb +2 -4
- data/app/models/decidim/blogs/post.rb +14 -3
- data/app/packs/entrypoints/decidim_blogs.js +3 -0
- data/app/packs/stylesheets/blogs.scss +53 -0
- data/app/presenters/decidim/blogs/admin_log/post_presenter.rb +2 -2
- data/app/views/decidim/blogs/admin/posts/_form.html.erb +19 -13
- data/app/views/decidim/blogs/admin/posts/edit.html.erb +16 -6
- data/app/views/decidim/blogs/admin/posts/index.html.erb +60 -52
- data/app/views/decidim/blogs/admin/posts/new.html.erb +17 -6
- data/app/views/decidim/blogs/posts/_actions.html.erb +18 -0
- data/app/views/decidim/blogs/posts/index.html.erb +22 -9
- data/app/views/decidim/blogs/posts/show.html.erb +37 -47
- data/config/locales/ar.yml +2 -20
- data/config/locales/ca.yml +15 -17
- data/config/locales/cs.yml +17 -17
- data/config/locales/de.yml +15 -17
- data/config/locales/el.yml +7 -18
- data/config/locales/en.yml +15 -17
- data/config/locales/es-MX.yml +15 -17
- data/config/locales/es-PY.yml +15 -17
- data/config/locales/es.yml +15 -17
- data/config/locales/eu.yml +16 -18
- data/config/locales/fi-plain.yml +15 -17
- data/config/locales/fi.yml +15 -17
- data/config/locales/fr-CA.yml +15 -17
- data/config/locales/fr.yml +15 -17
- data/config/locales/ga-IE.yml +0 -9
- data/config/locales/gl.yml +0 -21
- data/config/locales/hu.yml +12 -18
- data/config/locales/id-ID.yml +0 -19
- data/config/locales/is-IS.yml +0 -13
- data/config/locales/it.yml +0 -21
- data/config/locales/ja.yml +14 -17
- data/config/locales/lb.yml +0 -21
- data/config/locales/lt.yml +12 -18
- data/config/locales/lv.yml +0 -21
- data/config/locales/nl.yml +0 -21
- data/config/locales/no.yml +0 -21
- data/config/locales/pl.yml +0 -21
- data/config/locales/pt-BR.yml +12 -26
- data/config/locales/pt.yml +0 -21
- data/config/locales/ro-RO.yml +7 -18
- data/config/locales/ru.yml +12 -18
- data/config/locales/sk.yml +0 -21
- data/config/locales/sr-CS.yml +0 -5
- data/config/locales/sv.yml +5 -20
- data/config/locales/tr-TR.yml +0 -21
- data/config/locales/uk.yml +0 -17
- data/config/locales/zh-CN.yml +0 -21
- data/config/locales/zh-TW.yml +3 -14
- data/db/migrate/20220812122940_add_published_at_to_decidim_blogs_posts.rb +17 -0
- data/lib/decidim/api/blogs_type.rb +14 -2
- data/lib/decidim/api/post_type.rb +1 -0
- data/lib/decidim/blogs/admin_engine.rb +2 -2
- data/lib/decidim/blogs/component.rb +4 -60
- data/lib/decidim/blogs/engine.rb +16 -1
- data/lib/decidim/blogs/seeds.rb +76 -0
- data/lib/decidim/blogs/test/factories.rb +2 -1
- data/lib/decidim/blogs/version.rb +1 -1
- metadata +38 -28
- data/app/cells/decidim/blogs/post_m/footer.erb +0 -5
- data/app/cells/decidim/blogs/post_m_cell.rb +0 -21
- data/app/views/decidim/blogs/posts/_datetime.html.erb +0 -1
- data/app/views/decidim/blogs/posts/_posts.html.erb +0 -24
- data/app/views/decidim/blogs/posts/_sidebar_blog.html.erb +0 -21
- data/config/environment.rb +0 -3
data/config/locales/ru.yml
CHANGED
@@ -26,49 +26,43 @@ ru:
|
|
26
26
|
new: Создать новый пост
|
27
27
|
title: Действия
|
28
28
|
admin:
|
29
|
-
models:
|
30
|
-
post:
|
31
|
-
name: Пост
|
32
29
|
posts:
|
33
30
|
create:
|
34
|
-
invalid: При попытке добавить этот пост произошла
|
35
|
-
success: Пост успешно
|
31
|
+
invalid: При попытке добавить этот пост произошла ошибка.
|
32
|
+
success: Пост успешно создан.
|
36
33
|
destroy:
|
37
|
-
success: Пост успешно
|
34
|
+
success: Пост успешно удален.
|
38
35
|
edit:
|
39
36
|
save: Обновить
|
40
37
|
title: Изменить пост
|
41
38
|
index:
|
39
|
+
not_published_yet: Пока не опубликовано.
|
42
40
|
title: Посты
|
43
41
|
new:
|
44
42
|
create: Создать
|
45
43
|
title: Создать пост
|
46
44
|
update:
|
47
45
|
invalid: При попытке сохранить пост произошли ошибки.
|
48
|
-
success: Пост успешно
|
46
|
+
success: Пост успешно сохранен.
|
49
47
|
admin_log:
|
50
48
|
post:
|
51
49
|
create: "%{user_name} создал пост %{resource_name} в %{space_name}"
|
52
50
|
delete: "%{user_name} удалил пост %{resource_name} в %{space_name}"
|
53
51
|
update: "%{user_name} обновил пост %{resource_name} в %{space_name}"
|
52
|
+
content_blocks:
|
53
|
+
highlighted_posts:
|
54
|
+
last_published: Последние опубликованные
|
55
|
+
name: Посты
|
56
|
+
see_all: Посмотреть все посты
|
54
57
|
last_activity:
|
55
|
-
|
58
|
+
new_post: 'Новый пост:'
|
56
59
|
models:
|
57
60
|
post:
|
58
61
|
fields:
|
59
62
|
author: Автор
|
60
63
|
body: Основной текст
|
61
|
-
|
64
|
+
published_at: Время публикации
|
62
65
|
title: Название
|
63
|
-
posts:
|
64
|
-
show:
|
65
|
-
back: Назад к списку
|
66
|
-
comments: Комментарии
|
67
|
-
view: Посмотреть
|
68
|
-
sidebar_blog:
|
69
|
-
comments: комментарии
|
70
|
-
most_commented_posts: Наиболее комментируемые посты
|
71
|
-
read_more: Читать подробнее
|
72
66
|
components:
|
73
67
|
blogs:
|
74
68
|
actions:
|
data/config/locales/sk.yml
CHANGED
@@ -19,15 +19,7 @@ sk:
|
|
19
19
|
new: Nový príspevok
|
20
20
|
title: Akcie
|
21
21
|
admin:
|
22
|
-
models:
|
23
|
-
post:
|
24
|
-
name: Príspevok
|
25
22
|
posts:
|
26
|
-
create:
|
27
|
-
invalid: Vyskytol sa problém s vytváraním príspevku
|
28
|
-
success: Príspevok úspešne vytvorený
|
29
|
-
destroy:
|
30
|
-
success: Príspevok úspešne odstránený
|
31
23
|
edit:
|
32
24
|
save: Aktualizovať
|
33
25
|
index:
|
@@ -37,24 +29,11 @@ sk:
|
|
37
29
|
title: Vytvort príspevok
|
38
30
|
update:
|
39
31
|
invalid: Vyskytol sa problém s ukladaním príspevku.
|
40
|
-
success: Príspevok úspešne uložený
|
41
|
-
last_activity:
|
42
|
-
new_post_at_html: "<span>Nový príspevok na %{link}</span>"
|
43
32
|
models:
|
44
33
|
post:
|
45
34
|
fields:
|
46
35
|
author: Autor
|
47
36
|
body: Telo textu
|
48
|
-
created_at: Vytvorené
|
49
|
-
posts:
|
50
|
-
show:
|
51
|
-
back: Späť na zoznam
|
52
|
-
comments: Komentáre
|
53
|
-
view: Zobraziť
|
54
|
-
sidebar_blog:
|
55
|
-
comments: komentáre
|
56
|
-
most_commented_posts: Najviac komentované príspevky
|
57
|
-
read_more: Čítať ďalej
|
58
37
|
components:
|
59
38
|
blogs:
|
60
39
|
name: Blog
|
data/config/locales/sr-CS.yml
CHANGED
data/config/locales/sv.yml
CHANGED
@@ -23,15 +23,7 @@ sv:
|
|
23
23
|
new: Nytt inlägg
|
24
24
|
title: Åtgärder
|
25
25
|
admin:
|
26
|
-
models:
|
27
|
-
post:
|
28
|
-
name: Publicera
|
29
26
|
posts:
|
30
|
-
create:
|
31
|
-
invalid: Det gick inte att skapa inlägget
|
32
|
-
success: Inlägget har skapats
|
33
|
-
destroy:
|
34
|
-
success: Inlägget har raderats
|
35
27
|
edit:
|
36
28
|
save: Uppdatera
|
37
29
|
title: Redigera inlägg
|
@@ -42,26 +34,19 @@ sv:
|
|
42
34
|
title: Skapa inlägg
|
43
35
|
update:
|
44
36
|
invalid: Det gick inte att spara inlägget.
|
45
|
-
|
37
|
+
content_blocks:
|
38
|
+
highlighted_posts:
|
39
|
+
name: Inlägg
|
40
|
+
see_all: Se alla inlägg
|
46
41
|
last_activity:
|
47
|
-
|
42
|
+
new_post: 'Nytt inlägg:'
|
48
43
|
models:
|
49
44
|
post:
|
50
45
|
fields:
|
51
46
|
author: Författare
|
52
47
|
body: Innehåll
|
53
|
-
created_at: Skapad
|
54
48
|
official_blog_post: Officiellt inlägg
|
55
49
|
title: Titel
|
56
|
-
posts:
|
57
|
-
show:
|
58
|
-
back: Tillbaka till listan
|
59
|
-
comments: Kommentarer
|
60
|
-
view: Visa
|
61
|
-
sidebar_blog:
|
62
|
-
comments: kommentarer
|
63
|
-
most_commented_posts: Mest kommenterade inlägg
|
64
|
-
read_more: Läs mer
|
65
50
|
components:
|
66
51
|
blogs:
|
67
52
|
actions:
|
data/config/locales/tr-TR.yml
CHANGED
@@ -23,15 +23,7 @@ tr:
|
|
23
23
|
new: Yeni posta
|
24
24
|
title: Eylemler
|
25
25
|
admin:
|
26
|
-
models:
|
27
|
-
post:
|
28
|
-
name: posta
|
29
26
|
posts:
|
30
|
-
create:
|
31
|
-
invalid: Bu yayını oluştururken bir sorun oluştu
|
32
|
-
success: Yayın başarıyla oluşturuldu
|
33
|
-
destroy:
|
34
|
-
success: Yayın başarıyla silindi
|
35
27
|
edit:
|
36
28
|
save: Güncelleştirme
|
37
29
|
title: Gönderiyi düzenle
|
@@ -42,24 +34,11 @@ tr:
|
|
42
34
|
title: Gönderi oluştur
|
43
35
|
update:
|
44
36
|
invalid: Gönderiyi kaydederken bir sorun oluştu.
|
45
|
-
success: Yayın başarıyla kaydedildi
|
46
|
-
last_activity:
|
47
|
-
new_post_at_html: "<span> %{link}</span>yeni gönderi"
|
48
37
|
models:
|
49
38
|
post:
|
50
39
|
fields:
|
51
40
|
author: Yazar
|
52
41
|
body: Vücut
|
53
|
-
created_at: Adresinde düzenlendi
|
54
|
-
posts:
|
55
|
-
show:
|
56
|
-
back: Listeye geri dön
|
57
|
-
comments: Yorumlar
|
58
|
-
view: Görünüm
|
59
|
-
sidebar_blog:
|
60
|
-
comments: yorumlar
|
61
|
-
most_commented_posts: En çok yorum yapılan yazılar
|
62
|
-
read_more: Daha fazla oku
|
63
42
|
components:
|
64
43
|
blogs:
|
65
44
|
name: Blog
|
data/config/locales/uk.yml
CHANGED
@@ -19,15 +19,7 @@ uk:
|
|
19
19
|
new: Створити новий допис
|
20
20
|
title: Дії
|
21
21
|
admin:
|
22
|
-
models:
|
23
|
-
post:
|
24
|
-
name: Допис
|
25
22
|
posts:
|
26
|
-
create:
|
27
|
-
invalid: При спробі додати цей допис сталася помилка
|
28
|
-
success: Допис успішно додано
|
29
|
-
destroy:
|
30
|
-
success: Допис успішно видалено
|
31
23
|
edit:
|
32
24
|
save: Оновити
|
33
25
|
index:
|
@@ -37,20 +29,11 @@ uk:
|
|
37
29
|
title: Створити допис
|
38
30
|
update:
|
39
31
|
invalid: При спробі збереження цього допису сталися помилки.
|
40
|
-
success: Допис успішно збережено
|
41
32
|
models:
|
42
33
|
post:
|
43
34
|
fields:
|
44
35
|
author: Автор
|
45
36
|
body: Основний текст
|
46
|
-
created_at: 'Створено:'
|
47
|
-
posts:
|
48
|
-
show:
|
49
|
-
view: Переглянути
|
50
|
-
sidebar_blog:
|
51
|
-
comments: коментарі
|
52
|
-
most_commented_posts: Найбільш коментовані дописи
|
53
|
-
read_more: Читати далі
|
54
37
|
components:
|
55
38
|
blogs:
|
56
39
|
name: Блог
|
data/config/locales/zh-CN.yml
CHANGED
@@ -16,15 +16,7 @@ zh-CN:
|
|
16
16
|
new: 新建帖子
|
17
17
|
title: 行动
|
18
18
|
admin:
|
19
|
-
models:
|
20
|
-
post:
|
21
|
-
name: 帖子
|
22
19
|
posts:
|
23
|
-
create:
|
24
|
-
invalid: 创建这个帖子时出错
|
25
|
-
success: 帖子创建成功
|
26
|
-
destroy:
|
27
|
-
success: 帖子已成功删除
|
28
20
|
edit:
|
29
21
|
save: 更新
|
30
22
|
index:
|
@@ -34,24 +26,11 @@ zh-CN:
|
|
34
26
|
title: 创建帖子
|
35
27
|
update:
|
36
28
|
invalid: 保存帖子时出错。
|
37
|
-
success: 帖子保存成功
|
38
|
-
last_activity:
|
39
|
-
new_post_at_html: "<span>在 %{link}的新帖</span>"
|
40
29
|
models:
|
41
30
|
post:
|
42
31
|
fields:
|
43
32
|
author: 作者
|
44
33
|
body: 正文内容
|
45
|
-
created_at: 创建于
|
46
|
-
posts:
|
47
|
-
show:
|
48
|
-
back: 返回列表
|
49
|
-
comments: 评论
|
50
|
-
view: 查看
|
51
|
-
sidebar_blog:
|
52
|
-
comments: 评论
|
53
|
-
most_commented_posts: 评论最多的帖子
|
54
|
-
read_more: 阅读更多
|
55
34
|
components:
|
56
35
|
blogs:
|
57
36
|
name: 博客
|
data/config/locales/zh-TW.yml
CHANGED
@@ -23,9 +23,6 @@ zh-TW:
|
|
23
23
|
new: 新貼文
|
24
24
|
title: 操作
|
25
25
|
admin:
|
26
|
-
models:
|
27
|
-
post:
|
28
|
-
name: 文章
|
29
26
|
posts:
|
30
27
|
create:
|
31
28
|
invalid: 建立此文章時出現問題
|
@@ -36,6 +33,7 @@ zh-TW:
|
|
36
33
|
save: 更新
|
37
34
|
title: 编辑文章
|
38
35
|
index:
|
36
|
+
not_published_yet: 尚未發布
|
39
37
|
title: 貼文
|
40
38
|
new:
|
41
39
|
create: 建立
|
@@ -49,24 +47,15 @@ zh-TW:
|
|
49
47
|
delete: "%{user_name} 從 %{space_name} 刪除了 %{resource_name} 部落格文章。"
|
50
48
|
update: "%{user_name} 在 %{space_name} 更新了 %{resource_name} 部落格文章"
|
51
49
|
last_activity:
|
52
|
-
|
50
|
+
new_post: '新貼文:'
|
53
51
|
models:
|
54
52
|
post:
|
55
53
|
fields:
|
56
54
|
author: 作者
|
57
55
|
body: 正文
|
58
|
-
created_at: 建立於
|
59
56
|
official_blog_post: 官方文章
|
57
|
+
published_at: 發布時間
|
60
58
|
title: 標題
|
61
|
-
posts:
|
62
|
-
show:
|
63
|
-
back: 返回列表
|
64
|
-
comments: 評論
|
65
|
-
view: 檢視
|
66
|
-
sidebar_blog:
|
67
|
-
comments: 評論
|
68
|
-
most_commented_posts: 最多留言的帖子
|
69
|
-
read_more: 閱讀變多
|
70
59
|
components:
|
71
60
|
blogs:
|
72
61
|
actions:
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddPublishedAtToDecidimBlogsPosts < ActiveRecord::Migration[6.1]
|
4
|
+
class Post < ApplicationRecord
|
5
|
+
self.table_name = :decidim_blogs_posts
|
6
|
+
end
|
7
|
+
|
8
|
+
def change
|
9
|
+
add_column :decidim_blogs_posts, :published_at, :datetime
|
10
|
+
|
11
|
+
reversible do |direction|
|
12
|
+
direction.up do
|
13
|
+
Post.update_all("published_at = created_at") # rubocop:disable Rails/SkipsModelValidations
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -18,11 +18,23 @@ module Decidim
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def posts(filter: {}, order: {})
|
21
|
-
Decidim::Core::ComponentListBase.new(model_class: Post).call(object, { filter
|
21
|
+
base_query = Decidim::Core::ComponentListBase.new(model_class: Post).call(object, { filter:, order: }, context)
|
22
|
+
if context[:current_user]&.admin?
|
23
|
+
base_query
|
24
|
+
else
|
25
|
+
base_query.published
|
26
|
+
end
|
22
27
|
end
|
23
28
|
|
24
29
|
def post(id:)
|
25
|
-
|
30
|
+
scope =
|
31
|
+
if context[:current_user]&.admin?
|
32
|
+
Post
|
33
|
+
else
|
34
|
+
Post.published
|
35
|
+
end
|
36
|
+
|
37
|
+
Decidim::Core::ComponentFinderBase.new(model_class: scope).call(object, { id: }, context)
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
@@ -16,6 +16,7 @@ module Decidim
|
|
16
16
|
field :id, GraphQL::Types::ID, "The internal ID of this post", null: false
|
17
17
|
field :title, Decidim::Core::TranslatedFieldType, "The title for this post", null: true
|
18
18
|
field :body, Decidim::Core::TranslatedFieldType, "The body of this post", null: true
|
19
|
+
field :published_at, Decidim::Core::DateTimeType, "The time this page was published", null: false
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -1,17 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "decidim/components/namer"
|
4
|
-
|
5
3
|
Decidim.register_component(:blogs) do |component|
|
6
4
|
component.engine = Decidim::Blogs::Engine
|
7
5
|
component.admin_engine = Decidim::Blogs::AdminEngine
|
8
6
|
component.icon = "media/images/decidim_blogs.svg"
|
7
|
+
component.icon_key = "pen-nib-line"
|
9
8
|
component.permissions_class_name = "Decidim::Blog::Permissions"
|
10
9
|
|
11
10
|
component.query_type = "Decidim::Blogs::BlogsType"
|
12
11
|
|
13
12
|
component.on(:before_destroy) do |instance|
|
14
|
-
raise StandardError, "
|
13
|
+
raise StandardError, "Cannot remove this component" if Decidim::Blogs::Post.where(component: instance).any?
|
15
14
|
end
|
16
15
|
|
17
16
|
component.register_stat :posts_count, primary: true, priority: Decidim::StatsRegistry::MEDIUM_PRIORITY do |components, _start_at, _end_at|
|
@@ -41,63 +40,8 @@ Decidim.register_component(:blogs) do |component|
|
|
41
40
|
end
|
42
41
|
|
43
42
|
component.seeds do |participatory_space|
|
44
|
-
|
45
|
-
organization: participatory_space.organization,
|
46
|
-
email: "admin@example.org"
|
47
|
-
)
|
48
|
-
|
49
|
-
step_settings = if participatory_space.allows_steps?
|
50
|
-
{ participatory_space.active_step.id => { comments_enabled: true, comments_blocked: false } }
|
51
|
-
else
|
52
|
-
{}
|
53
|
-
end
|
54
|
-
|
55
|
-
params = {
|
56
|
-
name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :blogs).i18n_name,
|
57
|
-
manifest_name: :blogs,
|
58
|
-
published_at: Time.current,
|
59
|
-
participatory_space: participatory_space,
|
60
|
-
settings: {
|
61
|
-
vote_limit: 0
|
62
|
-
},
|
63
|
-
step_settings: step_settings
|
64
|
-
}
|
65
|
-
|
66
|
-
component = Decidim.traceability.perform_action!(
|
67
|
-
"publish",
|
68
|
-
Decidim::Component,
|
69
|
-
admin_user,
|
70
|
-
visibility: "all"
|
71
|
-
) do
|
72
|
-
Decidim::Component.create!(params)
|
73
|
-
end
|
74
|
-
|
75
|
-
6.times do |n|
|
76
|
-
author = if n >= 3
|
77
|
-
Decidim::User.where(organization: component.organization).order(Arel.sql("RANDOM()")).first
|
78
|
-
elsif n <= 1
|
79
|
-
Decidim::UserGroup.where(organization: component.organization).order(Arel.sql("RANDOM()")).first
|
80
|
-
else
|
81
|
-
component.organization
|
82
|
-
end
|
83
|
-
|
84
|
-
params = {
|
85
|
-
component: component,
|
86
|
-
title: Decidim::Faker::Localized.sentence(word_count: 5),
|
87
|
-
body: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
88
|
-
Decidim::Faker::Localized.paragraph(sentence_count: 20)
|
89
|
-
end,
|
90
|
-
author: author
|
91
|
-
}
|
92
|
-
|
93
|
-
post = Decidim.traceability.create!(
|
94
|
-
Decidim::Blogs::Post,
|
95
|
-
author,
|
96
|
-
params,
|
97
|
-
visibility: "all"
|
98
|
-
)
|
43
|
+
require "decidim/blogs/seeds"
|
99
44
|
|
100
|
-
|
101
|
-
end
|
45
|
+
Decidim::Blogs::Seeds.new(participatory_space:).call
|
102
46
|
end
|
103
47
|
end
|
data/lib/decidim/blogs/engine.rb
CHANGED
@@ -15,7 +15,14 @@ module Decidim
|
|
15
15
|
|
16
16
|
routes do
|
17
17
|
resources :posts, only: [:index, :show]
|
18
|
-
|
18
|
+
scope "/posts" do
|
19
|
+
root to: "posts#index"
|
20
|
+
end
|
21
|
+
get "/", to: redirect("posts", status: 301)
|
22
|
+
end
|
23
|
+
|
24
|
+
initializer "decidim_blogs.register_icons" do
|
25
|
+
Decidim.icons.register(name: "Decidim::Blogs::Post", icon: "pen-nib-line", description: "Blogs post", category: "activity", engine: :core)
|
19
26
|
end
|
20
27
|
|
21
28
|
initializer "decidim_blogs.add_cells_view_paths" do
|
@@ -26,6 +33,14 @@ module Decidim
|
|
26
33
|
initializer "decidim_blogs.webpacker.assets_path" do
|
27
34
|
Decidim.register_assets_path File.expand_path("app/packs", root)
|
28
35
|
end
|
36
|
+
|
37
|
+
initializer "decidim_blogs.authorization_transfer" do
|
38
|
+
config.to_prepare do
|
39
|
+
Decidim::AuthorizationTransfer.register(:blogs) do |transfer|
|
40
|
+
transfer.move_records(Decidim::Blogs::Post, :decidim_author_id)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
29
44
|
end
|
30
45
|
end
|
31
46
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/components/namer"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Blogs
|
7
|
+
class Seeds
|
8
|
+
attr_reader :participatory_space
|
9
|
+
|
10
|
+
def initialize(participatory_space:)
|
11
|
+
@participatory_space = participatory_space
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
admin_user = Decidim::User.find_by(
|
16
|
+
organization: participatory_space.organization,
|
17
|
+
email: "admin@example.org"
|
18
|
+
)
|
19
|
+
|
20
|
+
step_settings = if participatory_space.allows_steps?
|
21
|
+
{ participatory_space.active_step.id => { comments_enabled: true, comments_blocked: false } }
|
22
|
+
else
|
23
|
+
{}
|
24
|
+
end
|
25
|
+
|
26
|
+
params = {
|
27
|
+
name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :blogs).i18n_name,
|
28
|
+
manifest_name: :blogs,
|
29
|
+
published_at: Time.current,
|
30
|
+
participatory_space:,
|
31
|
+
settings: {
|
32
|
+
vote_limit: 0
|
33
|
+
},
|
34
|
+
step_settings:
|
35
|
+
}
|
36
|
+
|
37
|
+
component = Decidim.traceability.perform_action!(
|
38
|
+
"publish",
|
39
|
+
Decidim::Component,
|
40
|
+
admin_user,
|
41
|
+
visibility: "all"
|
42
|
+
) do
|
43
|
+
Decidim::Component.create!(params)
|
44
|
+
end
|
45
|
+
|
46
|
+
6.times do |n|
|
47
|
+
author = if n >= 3
|
48
|
+
Decidim::User.where(organization: component.organization).sample
|
49
|
+
elsif n <= 1
|
50
|
+
Decidim::UserGroup.where(organization: component.organization).sample
|
51
|
+
else
|
52
|
+
component.organization
|
53
|
+
end
|
54
|
+
|
55
|
+
params = {
|
56
|
+
component:,
|
57
|
+
title: Decidim::Faker::Localized.sentence(word_count: 5),
|
58
|
+
body: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
59
|
+
Decidim::Faker::Localized.paragraph(sentence_count: 20)
|
60
|
+
end,
|
61
|
+
author:
|
62
|
+
}
|
63
|
+
|
64
|
+
post = Decidim.traceability.create!(
|
65
|
+
Decidim::Blogs::Post,
|
66
|
+
author,
|
67
|
+
params,
|
68
|
+
visibility: "all"
|
69
|
+
)
|
70
|
+
|
71
|
+
Decidim::Comments::Seed.comments_for(post)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "decidim/components/namer"
|
3
4
|
require "decidim/faker/localized"
|
4
5
|
require "decidim/core/test/factories"
|
5
6
|
require "decidim/participatory_processes/test/factories"
|
@@ -8,7 +9,7 @@ FactoryBot.define do
|
|
8
9
|
factory :post_component, parent: :component do
|
9
10
|
name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :blogs).i18n_name }
|
10
11
|
manifest_name { :blogs }
|
11
|
-
participatory_space { create(:participatory_process, :with_steps, organization:
|
12
|
+
participatory_space { create(:participatory_process, :with_steps, organization:) }
|
12
13
|
end
|
13
14
|
|
14
15
|
factory :post, class: "Decidim::Blogs::Post" do
|