decidim-blogs 0.11.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +30 -0
  3. data/Rakefile +3 -0
  4. data/app/assets/images/decidim/blogs/icon.svg +3 -0
  5. data/app/commands/decidim/blogs/admin/create_post.rb +50 -0
  6. data/app/commands/decidim/blogs/admin/update_post.rb +44 -0
  7. data/app/controllers/decidim/blogs/admin/application_controller.rb +22 -0
  8. data/app/controllers/decidim/blogs/admin/posts_controller.rb +64 -0
  9. data/app/controllers/decidim/blogs/application_controller.rb +14 -0
  10. data/app/controllers/decidim/blogs/posts_controller.rb +35 -0
  11. data/app/events/decidim/blogs/create_post_event.rb +8 -0
  12. data/app/forms/decidim/blogs/admin/post_form.rb +18 -0
  13. data/app/helpers/decidim/blogs/admin/posts_helper.rb +25 -0
  14. data/app/helpers/decidim/blogs/application_helper.rb +13 -0
  15. data/app/helpers/decidim/blogs/posts_helper.rb +25 -0
  16. data/app/models/decidim/blogs/application_record.rb +10 -0
  17. data/app/models/decidim/blogs/post.rb +44 -0
  18. data/app/presenters/decidim/module/blogs/post_presenter.rb +14 -0
  19. data/app/views/decidim/blogs/admin/posts/_form.html.erb +13 -0
  20. data/app/views/decidim/blogs/admin/posts/edit.html.erb +7 -0
  21. data/app/views/decidim/blogs/admin/posts/index.html.erb +53 -0
  22. data/app/views/decidim/blogs/admin/posts/new.html.erb +7 -0
  23. data/app/views/decidim/blogs/posts/_author_data.html.erb +7 -0
  24. data/app/views/decidim/blogs/posts/_datetime.html.erb +1 -0
  25. data/app/views/decidim/blogs/posts/_posts.html.erb +20 -0
  26. data/app/views/decidim/blogs/posts/_sidebar_blog.html.erb +21 -0
  27. data/app/views/decidim/blogs/posts/index.html.erb +10 -0
  28. data/app/views/decidim/blogs/posts/show.html.erb +23 -0
  29. data/config/locales/ca.yml +69 -0
  30. data/config/locales/en.yml +70 -0
  31. data/config/locales/es.yml +69 -0
  32. data/config/locales/eu.yml +69 -0
  33. data/config/locales/fi.yml +69 -0
  34. data/config/locales/fr.yml +69 -0
  35. data/config/locales/gl.yml +69 -0
  36. data/config/locales/it.yml +69 -0
  37. data/config/locales/nl.yml +69 -0
  38. data/config/locales/pl.yml +69 -0
  39. data/config/locales/pt-BR.yml +69 -0
  40. data/config/locales/pt.yml +69 -0
  41. data/config/locales/ru.yml +5 -0
  42. data/config/locales/sv.yml +69 -0
  43. data/config/locales/uk.yml +6 -0
  44. data/db/migrate/20171129131353_create_decidim_blogs_posts.rb +12 -0
  45. data/db/migrate/20171211084630_add_author_to_decidim_blogs_posts.rb +7 -0
  46. data/lib/decidim/blogs.rb +13 -0
  47. data/lib/decidim/blogs/admin.rb +10 -0
  48. data/lib/decidim/blogs/admin_engine.rb +22 -0
  49. data/lib/decidim/blogs/component.rb +65 -0
  50. data/lib/decidim/blogs/engine.rb +24 -0
  51. data/lib/decidim/blogs/test/factories.rb +20 -0
  52. data/lib/decidim/blogs/version.rb +10 -0
  53. metadata +235 -0
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Blogs
5
+ #
6
+ # Decorator for posts
7
+ #
8
+ class PostPresenter < SimpleDelegator
9
+ def author
10
+ @author ||= Decidim::UserPresenter.new(super)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title"><%= title %></h2>
4
+ </div>
5
+ <div class="card-section">
6
+ <div class="row column">
7
+ <%= form.translated :text_field, :title, autofocus: true %>
8
+ </div>
9
+ <div class="row column">
10
+ <%= form.translated :editor, :body, toolbar: :full, lines: 30, label: t("models.components.body", scope: "decidim.blogs.admin") %>
11
+ </div>
12
+ </div>
13
+ </div>
@@ -0,0 +1,7 @@
1
+ <%= decidim_form_for(@form, html: { class: "form edit_post" }) do |f| %>
2
+ <%= render partial: "form", object: f %>
3
+
4
+ <div class="button--double form-general-submit">
5
+ <%= f.submit t(".save") %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,53 @@
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title">
4
+ <%= t(".title") %>
5
+ <%= link_to t("actions.new", scope: "decidim.blogs", name: t("models.post.name", scope: "decidim.blogs.admin")), new_post_path, class: "button tiny button--title" if can? :manage, current_component %>
6
+ </h2>
7
+ </div>
8
+
9
+ <div class="card-section">
10
+ <div class="table-scroll">
11
+ <table class="table-list">
12
+ <thead>
13
+ <tr>
14
+ <th><%= t("models.post.fields.title", scope: "decidim.blogs") %></th>
15
+ <th><%= t("models.post.fields.body", scope: "decidim.blogs") %></th>
16
+ <th><%= t("models.post.fields.author", scope: "decidim.blogs") %></th>
17
+ <th><%= t("models.post.fields.created_at", scope: "decidim.blogs") %></th>
18
+ <th class="actions"><%= t("actions.title", scope: "decidim.blogs") %></th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% posts.created_at_desc.each do |post| %>
23
+
24
+ <tr data-id="<%= post.id %>">
25
+ <td>
26
+ <%= translated_attribute(post.title) %><br />
27
+ </td>
28
+ <td>
29
+ <%= sanitize post_description_admin(post) %>
30
+ </td>
31
+ <td>
32
+ <%= post.try(:author).try(:name) %>
33
+ </td>
34
+ <td>
35
+ <%= l post.created_at, format: "%d/%m/%Y - %H:%M" %>
36
+ </td>
37
+ <td class="table-list__actions">
38
+ <% if can? :update, current_component %>
39
+ <%= icon_link_to "pencil", edit_post_path(post), t("actions.edit", scope: "decidim.blogs"), class: "action-icon--edit" %>
40
+ <% end %>
41
+
42
+ <% if can? :destroy, current_component %>
43
+ <%= icon_link_to "circle-x", post_path(post), t("actions.destroy", scope: "decidim.blogs"), method: :delete, class: "action-icon--remove", data: { confirm: t("actions.confirm_destroy", scope: "decidim.blogs") } %>
44
+ <% end %>
45
+ </td>
46
+ </tr>
47
+ <% end %>
48
+ </tbody>
49
+ </table>
50
+ <%= paginate posts, theme: "decidim" %>
51
+ </div>
52
+ </div>
53
+ <div>
@@ -0,0 +1,7 @@
1
+ <%= decidim_form_for(@form, html: { class: "form new_post" }) do |f| %>
2
+ <%= render partial: "form", object: f, locals: { title: t(".title") } %>
3
+
4
+ <div class="button--double form-general-submit">
5
+ <%= f.submit t(".create") %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= cell "decidim/author_box", present(post.author), extra: (capture do %>
2
+ <%= render partial: "datetime", locals: { post: post } %> &nbsp;&nbsp;·&nbsp;&nbsp;
3
+ <%= link_to "#{post_path(post)}#comments", title: t(".comments") do %>
4
+ <%= icon "comment-square", class: "icon--small", aria_label: "#{t(".comments")}", role: "img" %>
5
+ <%= post.comments.count %> <%= t(".comments") %>
6
+ <% end %>
7
+ <% end) %>
@@ -0,0 +1 @@
1
+ <%= l post.created_at, format: "%d/%m/%Y" %>
@@ -0,0 +1,20 @@
1
+ <div class="row small-12">
2
+ <% paginate_posts.each do |post| %>
3
+ <article class="card card--post">
4
+ <div class="card__content">
5
+ <div class="card__header">
6
+ <%= link_to post, class: "card__link" do %>
7
+ <h5 class="card__title card__title--strong">
8
+ <%= translated_attribute post.title %>
9
+ </h5>
10
+ <% end %>
11
+ <div class="card__author">
12
+ <%= render partial: "author_data", locals: { post: post } %>
13
+ </div>
14
+ </div>
15
+ <%= sanitize post_description(post) %>
16
+ </div>
17
+ </article>
18
+ <% end %>
19
+ </div>
20
+ <%= decidim_paginate paginate_posts %>
@@ -0,0 +1,21 @@
1
+ <% if posts.any? %>
2
+ <div class="section">
3
+ <div class="section-heading">
4
+ <%= t(".most_commented_posts") %>
5
+ </div>
6
+ <% posts.each do |post| %>
7
+ <div class="m-bottom">
8
+ <strong><%= link_to translated_attribute(post.title), post %></strong>
9
+ <div class="author-data author-data--nopadding">
10
+ <%= render partial: "datetime", locals: { post: post } %>&nbsp;&nbsp;·&nbsp;&nbsp;
11
+ <%= link_to "#{post_path(post)}#comments", title: t(".comments") do %>
12
+ <%= icon "comment-square", class: "icon--small", aria_label: "#{t(".comments")}", role: "img" %>
13
+ <%= post.comments.count %>
14
+ <%= t(".comments") %>
15
+ <% end %>
16
+ <a href="#comments" title="<%= t(".comments") %>"></a>
17
+ </div>
18
+ </div>
19
+ <% end %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <%= render partial: "decidim/shared/component_announcement" %>
2
+
3
+ <div class="row column">
4
+ <div id="blogs" class="columns medium-7 mediumlarge-8">
5
+ <%= render partial: "posts" %>
6
+ </div>
7
+ <div id="most-commented" class="columns medium-5 mediumlarge-4 large-4">
8
+ <%= render partial: "sidebar_blog", locals: {posts: posts_most_commented} %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,23 @@
1
+ <% provide(:title, translated_attribute(post.title)) %>
2
+
3
+ <% add_decidim_meta_tags({
4
+ title: translated_attribute(post.title),
5
+ description: translated_attribute(post.body),
6
+ url: post_url(post.id)
7
+ }) %>
8
+ <div class="row">
9
+ <div class="columns medium-7 mediumlarge-8">
10
+ <div class="row column view-header">
11
+ <h2 class="heading2"><%= translated_attribute post.title %></h2>
12
+ <%= render partial: "author_data", locals: { post: post } %>
13
+ </div>
14
+ <div class="section">
15
+ <p><%= sanitize translated_attribute post.body %></p>
16
+ </div>
17
+ </div>
18
+ <div id="most-commented" class="columns medium-5 mediumlarge-4 large-4">
19
+ <%= render partial: "sidebar_blog", locals: {posts: posts_most_commented} %>
20
+ </div>
21
+ </div>
22
+
23
+ <%= comments_for post %>
@@ -0,0 +1,69 @@
1
+ ca:
2
+ decidim:
3
+ blogs:
4
+ actions:
5
+ confirm_destroy: Estàs segur que vols eliminar aquesta publicació?
6
+ destroy: Suprimeix
7
+ edit: Edita
8
+ new: Nou
9
+ title: Accions
10
+ admin:
11
+ models:
12
+ components:
13
+ body: Cos
14
+ post:
15
+ name: Publicació
16
+ posts:
17
+ create:
18
+ invalid: S'ha produït un problema en crear aquesta publicació
19
+ success: S'ha creat correctament la publicació
20
+ destroy:
21
+ success: La publicació s'ha eliminat correctament
22
+ edit:
23
+ save: Actualitza
24
+ index:
25
+ title: Publicacions
26
+ new:
27
+ create: Crear
28
+ title: Crea una publicació
29
+ update:
30
+ invalid: Hi ha hagut errors en desar la publicació.
31
+ success: La publicació s'ha desat correctament
32
+ models:
33
+ post:
34
+ fields:
35
+ author: Autor
36
+ body: Cos
37
+ created_at: Creat el
38
+ title: títol
39
+ posts:
40
+ author_data:
41
+ comments: comentaris
42
+ sidebar_blog:
43
+ comments: comentaris
44
+ most_commented_posts: Publicacions més comentades
45
+ read_more: Llegeix més
46
+ components:
47
+ blogs:
48
+ name: Blog
49
+ settings:
50
+ global:
51
+ announcement: Anunci
52
+ comments_enabled: Comentaris habilitats
53
+ step:
54
+ announcement: Anunci
55
+ comments_blocked: Comentaris bloquejats
56
+ events:
57
+ blogs:
58
+ post_created:
59
+ email_intro: La publicació "%{resource_title}" s'ha publicat al "%{participatory_space_title}", que segueixes.
60
+ email_outro: Has rebut aquesta notificació perquè estàs seguint "%{participatory_space_title}". Pots deixar de seguir-lo des de l'enllaç anterior.
61
+ email_subject: Nova publicació publicada a %{participatory_space_title}
62
+ notification_title: La publicació <a href="%{resource_path}">%{resource_title}</a> ha estat publicada a %{participatory_space_title}
63
+ participatory_processes:
64
+ statistics:
65
+ posts_count: Publicacions
66
+ pages:
67
+ home:
68
+ statistics:
69
+ posts_count: Publicacions
@@ -0,0 +1,70 @@
1
+ ---
2
+ en:
3
+ decidim:
4
+ blogs:
5
+ actions:
6
+ confirm_destroy: Are you sure you want to delete this post?
7
+ destroy: Delete
8
+ edit: Edit
9
+ new: New
10
+ title: Actions
11
+ admin:
12
+ models:
13
+ components:
14
+ body: Body
15
+ post:
16
+ name: Post
17
+ posts:
18
+ create:
19
+ invalid: There's been a problem creating this post
20
+ success: Post successfully created
21
+ destroy:
22
+ success: Post successfully deleted
23
+ edit:
24
+ save: Update
25
+ index:
26
+ title: Posts
27
+ new:
28
+ create: Create
29
+ title: Create post
30
+ update:
31
+ invalid: There's been errors when saving the post.
32
+ success: Post saved successfully
33
+ models:
34
+ post:
35
+ fields:
36
+ author: Author
37
+ body: Body
38
+ created_at: Created at
39
+ title: title
40
+ posts:
41
+ author_data:
42
+ comments: comments
43
+ sidebar_blog:
44
+ comments: comments
45
+ most_commented_posts: Most commented posts
46
+ read_more: Read more
47
+ components:
48
+ blogs:
49
+ name: Blog
50
+ settings:
51
+ global:
52
+ announcement: Announcement
53
+ comments_enabled: Comments Enabled
54
+ step:
55
+ announcement: Announcement
56
+ comments_blocked: Comments Blocked
57
+ events:
58
+ blogs:
59
+ post_created:
60
+ email_intro: The post "%{resource_title}" has been published in "%{participatory_space_title}" that you are following.
61
+ email_outro: You have received this notification because you are following "%{participatory_space_title}". You can unfollow it from the previous link.
62
+ email_subject: New post published in %{participatory_space_title}
63
+ notification_title: The post <a href="%{resource_path}">%{resource_title}</a> has been published in %{participatory_space_title}
64
+ participatory_processes:
65
+ statistics:
66
+ posts_count: Posts
67
+ pages:
68
+ home:
69
+ statistics:
70
+ posts_count: Posts
@@ -0,0 +1,69 @@
1
+ es:
2
+ decidim:
3
+ blogs:
4
+ actions:
5
+ confirm_destroy: '¿Seguro que quieres eliminar esta publicación?'
6
+ destroy: Borrar
7
+ edit: Editar
8
+ new: Nuevo
9
+ title: Comportamiento
10
+ admin:
11
+ models:
12
+ components:
13
+ body: Cuerpo
14
+ post:
15
+ name: Enviar
16
+ posts:
17
+ create:
18
+ invalid: Ha habido un problema al crear esta publicación
19
+ success: Publicación creada con éxito
20
+ destroy:
21
+ success: Publicación eliminada con éxito
22
+ edit:
23
+ save: Actualizar
24
+ index:
25
+ title: Publicaciones
26
+ new:
27
+ create: Crear
28
+ title: Crear publicación
29
+ update:
30
+ invalid: Ha habido errores al guardar la publicación.
31
+ success: Publicación guardada con éxito
32
+ models:
33
+ post:
34
+ fields:
35
+ author: Autoría
36
+ body: Cuerpo
37
+ created_at: Creado en
38
+ title: título
39
+ posts:
40
+ author_data:
41
+ comments: comentarios
42
+ sidebar_blog:
43
+ comments: comentarios
44
+ most_commented_posts: Publicaciones más comentadas
45
+ read_more: Leer más
46
+ components:
47
+ blogs:
48
+ name: Blog
49
+ settings:
50
+ global:
51
+ announcement: Anuncio
52
+ comments_enabled: Comentarios habilitados
53
+ step:
54
+ announcement: Anuncio
55
+ comments_blocked: Comentarios bloqueados
56
+ events:
57
+ blogs:
58
+ post_created:
59
+ email_intro: La publicación "%{resource_title}" se publicó en "%{participatory_space_title}" que estás siguiendo.
60
+ email_outro: Recibió esta notificación porque está siguiendo "%{participatory_space_title}". Puedes dejar de seguirlo desde el enlace anterior.
61
+ email_subject: Nueva publicación publicada en %{participatory_space_title}
62
+ notification_title: La publicación <a href="%{resource_path}">%{resource_title}</a> se publicó en %{participatory_space_title}.
63
+ participatory_processes:
64
+ statistics:
65
+ posts_count: Publicaciones
66
+ pages:
67
+ home:
68
+ statistics:
69
+ posts_count: Publicaciones
@@ -0,0 +1,69 @@
1
+ eu:
2
+ decidim:
3
+ blogs:
4
+ actions:
5
+ confirm_destroy: Ziur mezua ezabatu nahi duzula?
6
+ destroy: ezabatu
7
+ edit: Editatu
8
+ new: New
9
+ title: Ekintzak
10
+ admin:
11
+ models:
12
+ components:
13
+ body: Gorputzeko
14
+ post:
15
+ name: Post
16
+ posts:
17
+ create:
18
+ invalid: Arazo bat izan da post hau sortzeko
19
+ success: Mezua ondo sortu da
20
+ destroy:
21
+ success: Mezua ondo ezabatu da
22
+ edit:
23
+ save: eguneratzearen
24
+ index:
25
+ title: Mezuak
26
+ new:
27
+ create: Sortu
28
+ title: Sortu mezua
29
+ update:
30
+ invalid: Erroreak gertatu dira mezua gordetzean.
31
+ success: Mezua ondo gorde da
32
+ models:
33
+ post:
34
+ fields:
35
+ author: Egilea
36
+ body: Gorputzeko
37
+ created_at: Sortutako at
38
+ title: Izenburua
39
+ posts:
40
+ author_data:
41
+ comments: iruzkinak
42
+ sidebar_blog:
43
+ comments: iruzkinak
44
+ most_commented_posts: Gehien iruzkinatutako mezu
45
+ read_more: Irakurri gehiago
46
+ components:
47
+ blogs:
48
+ name: Bloga
49
+ settings:
50
+ global:
51
+ announcement: Anuntzio
52
+ comments_enabled: Iruzkinak gaituta
53
+ step:
54
+ announcement: Anuntzio
55
+ comments_blocked: Iruzkinak blokeatuta
56
+ events:
57
+ blogs:
58
+ post_created:
59
+ email_intro: '"%{resource_title}" mezua "%{participatory_space_title}" argitaratzen ari zarela jarraitzen ari zara.'
60
+ email_outro: Jakinarazpena jaso duzu "%{participatory_space_title}" jarraitzen ari zarenagatik. Aurreko esteka estekan jarrai dezakezu.
61
+ email_subject: '%{participatory_space_title} urtean argitaratutako mezu berria'
62
+ notification_title: <a href="%{resource_path}">%{resource_title}</a> post %{participatory_space_title} argitaratu da
63
+ participatory_processes:
64
+ statistics:
65
+ posts_count: Mezuak
66
+ pages:
67
+ home:
68
+ statistics:
69
+ posts_count: Mezuak