decidim-feeds 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-AGPLv3.txt +661 -0
  3. data/README.md +39 -0
  4. data/Rakefile +9 -0
  5. data/app/cells/decidim/feeds/content_blocks/feeds_settings_form/show.erb +3 -0
  6. data/app/cells/decidim/feeds/content_blocks/feeds_settings_form_cell.rb +23 -0
  7. data/app/cells/decidim/feeds/feed_cell.rb +24 -0
  8. data/app/cells/decidim/feeds/feed_dropdown_metadata_cell.rb +19 -0
  9. data/app/cells/decidim/feeds/feed_g_cell.rb +33 -0
  10. data/app/cells/decidim/feeds/feed_metadata_g_cell.rb +25 -0
  11. data/app/cells/decidim/feeds/feed_s_cell.rb +13 -0
  12. data/app/commands/decidim/feeds/admin/create_feed.rb +90 -0
  13. data/app/commands/decidim/feeds/admin/update_feed.rb +85 -0
  14. data/app/commands/decidim/feeds/create_feed.rb +90 -0
  15. data/app/commands/decidim/feeds/update_feed.rb +73 -0
  16. data/app/constraints/decidim/feeds/current_component.rb +28 -0
  17. data/app/constraints/decidim/feeds/current_feed.rb +43 -0
  18. data/app/controllers/concerns/decidim/feeds/feed_breadcrumb.rb +36 -0
  19. data/app/controllers/decidim/feeds/admin/application_controller.rb +26 -0
  20. data/app/controllers/decidim/feeds/admin/components_controller.rb +14 -0
  21. data/app/controllers/decidim/feeds/admin/concerns/feed_admin.rb +51 -0
  22. data/app/controllers/decidim/feeds/admin/feeds_controller.rb +92 -0
  23. data/app/controllers/decidim/feeds/application_controller.rb +37 -0
  24. data/app/controllers/decidim/feeds/feeds_controller.rb +137 -0
  25. data/app/forms/decidim/feeds/admin/feed_form.rb +102 -0
  26. data/app/forms/decidim/feeds/feed_form.rb +70 -0
  27. data/app/helpers/decidim/feeds/admin/feeds_admin_menu_helper.rb +10 -0
  28. data/app/helpers/decidim/feeds/application_helper.rb +16 -0
  29. data/app/helpers/decidim/feeds/feeds_helper.rb +38 -0
  30. data/app/models/decidim/feeds/application_record.rb +10 -0
  31. data/app/models/decidim/feeds/feed.rb +113 -0
  32. data/app/packs/entrypoints/decidim_feeds.js +5 -0
  33. data/app/packs/entrypoints/decidim_feeds.scss +1 -0
  34. data/app/packs/images/decidim/feeds/decidim_feeds.svg +1 -0
  35. data/app/packs/images/decidim/feeds/icon.svg +1 -0
  36. data/app/packs/src/decidim/feeds/feeds.js +0 -0
  37. data/app/packs/stylesheets/decidim/feeds/_variables.scss +10 -0
  38. data/app/packs/stylesheets/decidim/feeds/feeds.scss +3 -0
  39. data/app/permissions/decidim/feeds/permissions.rb +53 -0
  40. data/app/presenters/decidim/feeds/admin_log/feed_presenter.rb +46 -0
  41. data/app/queries/decidim/feeds/admin/admin_users.rb +60 -0
  42. data/app/queries/decidim/feeds/organization_feeds.rb +16 -0
  43. data/app/views/decidim/feeds/admin/feeds/_form.html.erb +66 -0
  44. data/app/views/decidim/feeds/admin/feeds/edit.html.erb +20 -0
  45. data/app/views/decidim/feeds/admin/feeds/index.html.erb +65 -0
  46. data/app/views/decidim/feeds/admin/feeds/new.html.erb +20 -0
  47. data/app/views/decidim/feeds/feeds/_form.html.erb +18 -0
  48. data/app/views/decidim/feeds/feeds/edit.html.erb +10 -0
  49. data/app/views/decidim/feeds/feeds/index.html.erb +5 -0
  50. data/app/views/decidim/feeds/feeds/new.html.erb +20 -0
  51. data/app/views/decidim/feeds/feeds/show.html.erb +33 -0
  52. data/app/views/layouts/decidim/admin/_manage_feeds.html.erb +11 -0
  53. data/app/views/layouts/decidim/admin/feed.html.erb +17 -0
  54. data/app/views/layouts/decidim/admin/feeds.html.erb +17 -0
  55. data/app/views/layouts/decidim/feed.html.erb +18 -0
  56. data/config/assets.rb +9 -0
  57. data/config/i18n-tasks.yml +10 -0
  58. data/config/locales/bs.yml +75 -0
  59. data/config/locales/de.yml +77 -0
  60. data/config/locales/en.yml +75 -0
  61. data/config/locales/hr.yml +75 -0
  62. data/config/locales/it.yml +75 -0
  63. data/config/locales/sr.yml +75 -0
  64. data/config/locales/tr.yml +75 -0
  65. data/lib/decidim/api/feed_type.rb +30 -0
  66. data/lib/decidim/feeds/admin.rb +10 -0
  67. data/lib/decidim/feeds/admin_engine.rb +81 -0
  68. data/lib/decidim/feeds/api.rb +9 -0
  69. data/lib/decidim/feeds/content_blocks/content_blocks_homepage.rb +19 -0
  70. data/lib/decidim/feeds/engine.rb +83 -0
  71. data/lib/decidim/feeds/menu.rb +106 -0
  72. data/lib/decidim/feeds/participatory_space.rb +52 -0
  73. data/lib/decidim/feeds/seeds.rb +47 -0
  74. data/lib/decidim/feeds/test/factories.rb +17 -0
  75. data/lib/decidim/feeds/version.rb +9 -0
  76. data/lib/decidim/feeds.rb +13 -0
  77. metadata +142 -0
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Feeds
5
+ class Menu
6
+ # def self.register_menu!
7
+ # Decidim.menu :menu do |menu|
8
+ # menu.add_item :feeds,
9
+ # I18n.t("menu.feeds", scope: "decidim"),
10
+ # decidim_feeds.feeds_path,
11
+ # position: 2.2,
12
+ # # if: OrganizationPublishedFeeds.new(current_organization, current_user).any?,
13
+ # active: :inclusive
14
+ # end
15
+ # end
16
+
17
+ # def self.register_home_content_block_menu!
18
+ # Decidim.menu :home_content_block_menu do |menu|
19
+ # menu.add_item :feeds,
20
+ # I18n.t("menu.feeds", scope: "decidim"),
21
+ # decidim_feeds.feeds_path,
22
+ # position: 20,
23
+ # # if: OrganizationPublishedFeeds.new(current_organization, current_user).any?,
24
+ # active: :inclusive
25
+ # end
26
+ # end
27
+
28
+ def self.register_admin_menu_modules!
29
+ Decidim.menu :admin_menu_modules do |menu|
30
+ menu.add_item :feeds,
31
+ I18n.t("menu.feeds", scope: "decidim.admin"),
32
+ decidim_admin_feeds.feeds_path,
33
+ icon_name: "government-line",
34
+ position: 2.2,
35
+ active: is_active_link?(decidim_admin_feeds.feeds_path)
36
+ # if: allowed_to?(:enter, :space_area, space_name: :feeds)
37
+ end
38
+ end
39
+
40
+ def self.register_admin_feeds_components_menu!
41
+ Decidim.menu :admin_feeds_components_menu do |menu|
42
+ current_participatory_space.components.each do |component|
43
+ caption = decidim_escape_translated(component.name)
44
+ caption += content_tag(:span, component.primary_stat, class: "component-counter") if component.primary_stat.present?
45
+
46
+ menu.add_item [component.manifest_name, component.id].join("_"),
47
+ caption.html_safe,
48
+ manage_component_path(component),
49
+ active: is_active_link?(manage_component_path(component)) ||
50
+ is_active_link?(decidim_admin_feeds.edit_component_path(current_participatory_space, component)) ||
51
+ is_active_link?(decidim_admin_feeds.edit_component_permissions_path(current_participatory_space, component)) ||
52
+ participatory_space_active_link?(component),
53
+ if: component.manifest.admin_engine && user_role_config.component_is_accessible?(component.manifest_name)
54
+ end
55
+ end
56
+ end
57
+
58
+ def self.register_admin_feed_menu!
59
+ Decidim.menu :admin_feed_menu do |menu|
60
+ menu.add_item :edit_feed,
61
+ I18n.t("info", scope: "decidim.admin.menu.feeds_submenu"),
62
+ decidim_admin_feeds.edit_feed_path(current_participatory_space),
63
+ position: 1,
64
+ icon_name: "information-line",
65
+ if: allowed_to?(:update, :feed, feed: current_participatory_space)
66
+
67
+ menu.add_item :components,
68
+ I18n.t("components", scope: "decidim.admin.menu.feeds_submenu"),
69
+ decidim_admin_feeds.components_path(current_participatory_space),
70
+ icon_name: "tools-line",
71
+ active: is_active_link?(decidim_admin_feeds.components_path(current_participatory_space), ["decidim/feeds/admin/components", %w(index new edit)]),
72
+ if: allowed_to?(:read, :component, feed: current_participatory_space),
73
+ submenu: { target_menu: :admin_feeds_components_menu }
74
+ end
75
+ end
76
+
77
+ def self.register_admin_feeds_menu!
78
+ Decidim.menu :admin_feeds_menu do |menu|
79
+ menu.add_item :feeds,
80
+ I18n.t("menu.feeds", scope: "decidim.admin"),
81
+ decidim_admin_feeds.feeds_path,
82
+ position: 1,
83
+ active: is_active_link?(decidim_admin_feeds.feeds_path),
84
+ icon_name: "government-line",
85
+ if: allowed_to?(:read, :feed_list)
86
+
87
+ # menu.add_item :import_feed,
88
+ # I18n.t("actions.import_feed", scope: "decidim.admin"),
89
+ # decidim_admin_feeds.new_import_path,
90
+ # position: 2,
91
+ # active: is_active_link?(decidim_admin_feeds.new_import_path),
92
+ # icon_name: "price-tag-3-line",
93
+ # if: allowed_to?(:import, :feed)
94
+
95
+ # menu.add_item :feeds_types,
96
+ # I18n.t("menu.feeds_types", scope: "decidim.admin"),
97
+ # decidim_admin_feeds.feeds_types_path,
98
+ # position: 3,
99
+ # active: is_active_link?(decidim_admin_feeds.feeds_types_path),
100
+ # icon_name: "government-line",
101
+ # if: allowed_to?(:manage, :feeds_type)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ Decidim.register_participatory_space(:feeds) do |participatory_space|
4
+ participatory_space.icon = "media/images/decidim_feeds.svg"
5
+ participatory_space.model_class_name = "Decidim::Feeds::Feed"
6
+ # participatory_space.content_blocks_scope_name = "feed_homepage"
7
+
8
+ participatory_space.participatory_spaces do |organization|
9
+ Decidim::Feeds::OrganizationFeeds.new(organization).query
10
+ end
11
+
12
+ participatory_space.permissions_class_name = "Decidim::Feeds::Permissions"
13
+
14
+ participatory_space.query_type = "Decidim::Feeds::FeedType"
15
+
16
+ participatory_space.breadcrumb_cell = "decidim/feeds/feed_dropdown_metadata"
17
+
18
+ participatory_space.register_resource(:feed) do |resource|
19
+ resource.model_class_name = "Decidim::Feeds::Feed"
20
+ resource.card = "decidim/feeds/feed"
21
+ resource.searchable = true
22
+ end
23
+
24
+ participatory_space.context(:public) do |context|
25
+ context.engine = Decidim::Feeds::Engine
26
+ context.layout = "layouts/decidim/feed"
27
+ end
28
+
29
+ participatory_space.context(:admin) do |context|
30
+ context.engine = Decidim::Feeds::AdminEngine
31
+ context.layout = "layouts/decidim/admin/feed"
32
+ end
33
+
34
+ # participatory_space.exports :feeds do |export|
35
+ # export.collection do |feed|
36
+ # Decidim::Feeds::Feed.where(id: feed.id)
37
+ # end
38
+
39
+ # export.serializer Decidim::Feeds::FeedSerializer
40
+ # end
41
+
42
+ # participatory_space.register_on_destroy_account do |user|
43
+ # Decidim::AssemblyUserRole.where(user:).destroy_all
44
+ # Decidim::AssemblyMember.where(user:).destroy_all
45
+ # end
46
+
47
+ participatory_space.seeds do
48
+ require "decidim/feeds/seeds"
49
+
50
+ Decidim::Feeds::Seeds.new.call
51
+ end
52
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/seeds"
4
+
5
+ module Decidim
6
+ module Feeds
7
+ class Seeds < Decidim::Seeds
8
+ def call
9
+ # create_content_block!
10
+
11
+ feed = create_feed!
12
+
13
+ seed_components_manifests!(participatory_space: current_feed)
14
+
15
+ # Decidim::ContentBlocksCreator.new(current_feed).create_default!
16
+ end
17
+
18
+ # def create_content_block!
19
+ # Decidim::ContentBlock.create(
20
+ # organization:,
21
+ # weight: 32,
22
+ # scope_name: :homepage,
23
+ # manifest_name: :highlighted_feeds,
24
+ # published_at: Time.current
25
+ # )
26
+ # end
27
+
28
+ def create_feed!
29
+ params = {
30
+ title: Decidim::Faker::Localized.sentence(word_count: 5),
31
+ slug: Decidim::Faker::Internet.unique.slug(words: nil, glue: "-"),
32
+ organization:,
33
+ created_by: "others",
34
+ }
35
+
36
+ Decidim.traceability.perform_action!(
37
+ "publish",
38
+ Decidim::Feeds::Feed,
39
+ organization.users.first,
40
+ visibility: "all"
41
+ ) do
42
+ Decidim::Feeds::Feed.create!(params)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/faker/localized"
4
+ require "decidim/dev"
5
+
6
+ FactoryBot.define do
7
+ sequence(:feed_slug) do |n|
8
+ "#{Decidim::Faker::Internet.slug(words: nil, glue: "-")}-#{n}"
9
+ end
10
+
11
+ factory :feed, class: "Decidim::Feed" do
12
+ title { generate_localized_title(:feed_title, skip_injection:) }
13
+ slug { generate(:feed_slug) }
14
+ organization
15
+ created_by { "others" }
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This holds the decidim-meetings version.
5
+ module Feeds
6
+ VERSION = "1.0.0"
7
+ COMPAT_DECIDIM_VERSION = [">= 0.28.0", "< 0.29"].freeze
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/feeds/admin"
4
+ require "decidim/feeds/api"
5
+ require "decidim/feeds/engine"
6
+ require "decidim/feeds/admin_engine"
7
+ require "decidim/feeds/participatory_space"
8
+
9
+ module Decidim
10
+ # This namespace holds the logic of the `Feeds` Participatory Space.
11
+ module Feeds
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: decidim-feeds
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Rusa
8
+ - Piero Chiussi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2024-10-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: decidim-core
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 0.28.0
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '0.29'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: 0.28.0
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.29'
34
+ description: A new participatory space for Decidim that is ideal for decidim-posts.
35
+ email:
36
+ - alex@rusa.at
37
+ - info@webchroma.de
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - LICENSE-AGPLv3.txt
43
+ - README.md
44
+ - Rakefile
45
+ - app/cells/decidim/feeds/content_blocks/feeds_settings_form/show.erb
46
+ - app/cells/decidim/feeds/content_blocks/feeds_settings_form_cell.rb
47
+ - app/cells/decidim/feeds/feed_cell.rb
48
+ - app/cells/decidim/feeds/feed_dropdown_metadata_cell.rb
49
+ - app/cells/decidim/feeds/feed_g_cell.rb
50
+ - app/cells/decidim/feeds/feed_metadata_g_cell.rb
51
+ - app/cells/decidim/feeds/feed_s_cell.rb
52
+ - app/commands/decidim/feeds/admin/create_feed.rb
53
+ - app/commands/decidim/feeds/admin/update_feed.rb
54
+ - app/commands/decidim/feeds/create_feed.rb
55
+ - app/commands/decidim/feeds/update_feed.rb
56
+ - app/constraints/decidim/feeds/current_component.rb
57
+ - app/constraints/decidim/feeds/current_feed.rb
58
+ - app/controllers/concerns/decidim/feeds/feed_breadcrumb.rb
59
+ - app/controllers/decidim/feeds/admin/application_controller.rb
60
+ - app/controllers/decidim/feeds/admin/components_controller.rb
61
+ - app/controllers/decidim/feeds/admin/concerns/feed_admin.rb
62
+ - app/controllers/decidim/feeds/admin/feeds_controller.rb
63
+ - app/controllers/decidim/feeds/application_controller.rb
64
+ - app/controllers/decidim/feeds/feeds_controller.rb
65
+ - app/forms/decidim/feeds/admin/feed_form.rb
66
+ - app/forms/decidim/feeds/feed_form.rb
67
+ - app/helpers/decidim/feeds/admin/feeds_admin_menu_helper.rb
68
+ - app/helpers/decidim/feeds/application_helper.rb
69
+ - app/helpers/decidim/feeds/feeds_helper.rb
70
+ - app/models/decidim/feeds/application_record.rb
71
+ - app/models/decidim/feeds/feed.rb
72
+ - app/packs/entrypoints/decidim_feeds.js
73
+ - app/packs/entrypoints/decidim_feeds.scss
74
+ - app/packs/images/decidim/feeds/decidim_feeds.svg
75
+ - app/packs/images/decidim/feeds/icon.svg
76
+ - app/packs/src/decidim/feeds/feeds.js
77
+ - app/packs/stylesheets/decidim/feeds/_variables.scss
78
+ - app/packs/stylesheets/decidim/feeds/feeds.scss
79
+ - app/permissions/decidim/feeds/permissions.rb
80
+ - app/presenters/decidim/feeds/admin_log/feed_presenter.rb
81
+ - app/queries/decidim/feeds/admin/admin_users.rb
82
+ - app/queries/decidim/feeds/organization_feeds.rb
83
+ - app/views/decidim/feeds/admin/feeds/_form.html.erb
84
+ - app/views/decidim/feeds/admin/feeds/edit.html.erb
85
+ - app/views/decidim/feeds/admin/feeds/index.html.erb
86
+ - app/views/decidim/feeds/admin/feeds/new.html.erb
87
+ - app/views/decidim/feeds/feeds/_form.html.erb
88
+ - app/views/decidim/feeds/feeds/edit.html.erb
89
+ - app/views/decidim/feeds/feeds/index.html.erb
90
+ - app/views/decidim/feeds/feeds/new.html.erb
91
+ - app/views/decidim/feeds/feeds/show.html.erb
92
+ - app/views/layouts/decidim/admin/_manage_feeds.html.erb
93
+ - app/views/layouts/decidim/admin/feed.html.erb
94
+ - app/views/layouts/decidim/admin/feeds.html.erb
95
+ - app/views/layouts/decidim/feed.html.erb
96
+ - config/assets.rb
97
+ - config/i18n-tasks.yml
98
+ - config/locales/bs.yml
99
+ - config/locales/de.yml
100
+ - config/locales/en.yml
101
+ - config/locales/hr.yml
102
+ - config/locales/it.yml
103
+ - config/locales/sr.yml
104
+ - config/locales/tr.yml
105
+ - lib/decidim/api/feed_type.rb
106
+ - lib/decidim/feeds.rb
107
+ - lib/decidim/feeds/admin.rb
108
+ - lib/decidim/feeds/admin_engine.rb
109
+ - lib/decidim/feeds/api.rb
110
+ - lib/decidim/feeds/content_blocks/content_blocks_homepage.rb
111
+ - lib/decidim/feeds/engine.rb
112
+ - lib/decidim/feeds/menu.rb
113
+ - lib/decidim/feeds/participatory_space.rb
114
+ - lib/decidim/feeds/seeds.rb
115
+ - lib/decidim/feeds/test/factories.rb
116
+ - lib/decidim/feeds/version.rb
117
+ homepage: https://github.com/DecidimAustria/decidim-module-feeds/
118
+ licenses:
119
+ - AGPL-3.0
120
+ metadata:
121
+ bug_tracker_uri: https://github.com/DecidimAustria/decidim-module-feeds/issues
122
+ source_code_uri: https://github.com/DecidimAustria/decidim-module-feeds/
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '3.1'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubygems_version: 3.3.27
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: A social feeds participatory space for Decidim.
142
+ test_files: []