decidim-proposals 0.16.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +3 -1
  3. data/app/cells/decidim/proposals/proposal_activity_cell.rb +9 -1
  4. data/app/commands/decidim/proposals/admin/discard_participatory_text.rb +40 -0
  5. data/app/commands/decidim/proposals/admin/import_participatory_text.rb +5 -1
  6. data/app/commands/decidim/proposals/admin/publish_participatory_text.rb +6 -18
  7. data/app/commands/decidim/proposals/admin/update_participatory_text.rb +56 -0
  8. data/app/commands/decidim/proposals/create_proposal.rb +21 -22
  9. data/app/commands/decidim/proposals/publish_collaborative_draft.rb +1 -0
  10. data/app/commands/decidim/proposals/publish_proposal.rb +25 -3
  11. data/app/commands/decidim/proposals/update_proposal.rb +19 -23
  12. data/app/controllers/concerns/decidim/proposals/orderable.rb +1 -1
  13. data/app/controllers/decidim/proposals/admin/participatory_texts_controller.rb +46 -14
  14. data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +1 -2
  15. data/app/forms/decidim/proposals/admin/proposal_form.rb +1 -1
  16. data/app/helpers/decidim/proposals/application_helper.rb +0 -4
  17. data/app/permissions/decidim/proposals/admin/permissions.rb +2 -4
  18. data/app/views/decidim/proposals/admin/participatory_texts/_article-preview.html.erb +1 -1
  19. data/app/views/decidim/proposals/admin/participatory_texts/_bulk-actions.html.erb +1 -0
  20. data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +8 -5
  21. data/app/views/decidim/proposals/proposals/show.html.erb +9 -0
  22. data/config/locales/ar-SA.yml +667 -0
  23. data/config/locales/ca.yml +28 -21
  24. data/config/locales/cs-CZ.yml +775 -0
  25. data/config/locales/de.yml +7 -0
  26. data/config/locales/en.yml +7 -0
  27. data/config/locales/es-MX.yml +751 -0
  28. data/config/locales/es-PY.yml +7 -0
  29. data/config/locales/es.yml +21 -14
  30. data/config/locales/eu.yml +10 -3
  31. data/config/locales/fi-pl.yml +8 -1
  32. data/config/locales/fi.yml +11 -4
  33. data/config/locales/fr.yml +7 -0
  34. data/config/locales/gl.yml +7 -0
  35. data/config/locales/hu.yml +21 -14
  36. data/config/locales/id-ID.yml +7 -0
  37. data/config/locales/it.yml +8 -1
  38. data/config/locales/nl.yml +10 -3
  39. data/config/locales/pl.yml +8 -1
  40. data/config/locales/pt-BR.yml +7 -0
  41. data/config/locales/pt.yml +7 -0
  42. data/config/locales/ru.yml +6 -0
  43. data/config/locales/sv.yml +7 -0
  44. data/config/locales/tr-TR.yml +8 -0
  45. data/config/locales/uk.yml +6 -0
  46. data/db/migrate/20190215113158_use_md5_indexes.rb +17 -0
  47. data/lib/decidim/content_parsers/proposal_parser.rb +2 -2
  48. data/lib/decidim/proposals/admin_engine.rb +4 -2
  49. data/lib/decidim/proposals/markdown_to_proposals.rb +49 -4
  50. data/lib/decidim/proposals/proposal_serializer.rb +3 -2
  51. data/lib/decidim/proposals/version.rb +1 -1
  52. metadata +26 -20
@@ -284,13 +284,16 @@ id:
284
284
  name: Usul
285
285
  participatory_texts:
286
286
  bulk-actions:
287
+ are_you_sure: Apakah Anda yakin akan membuang seluruh konsep teks partisipatif?
287
288
  import_doc: Impor dokumen
289
+ discard_all: Buang semua
288
290
  import:
289
291
  invalid: Formulirnya tidak valid!
290
292
  success: Selamat, bagian berikut telah diuraikan dari dokumen yang diimpor, mereka telah dikonversi menjadi proposal. Sekarang Anda dapat meninjau dan menyesuaikan apa pun yang Anda perlukan sebelum memublikasikan.
291
293
  index:
292
294
  info_1: Bagian berikut telah diurai dari dokumen yang diimpor, mereka telah dikonversi menjadi proposal. Sekarang Anda dapat meninjau dan menyesuaikan apa pun yang Anda perlukan sebelum memublikasikan.
293
295
  publish_document: Publikasikan dokumen
296
+ save_draft: Menyimpan konsep
294
297
  title: TEKNIK PREVIEW TEKNIKAL
295
298
  new_import:
296
299
  bottom_hint: "(Anda akan dapat melihat dan menyortir bagian dokumen)"
@@ -300,10 +303,14 @@ id:
300
303
  publish:
301
304
  invalid: Tidak dapat memublikasikan proposal
302
305
  success: Semua proposal telah dipublikasikan
306
+ discard:
307
+ success: Semua konsep teks Partisipatif telah dibuang.
303
308
  sections:
304
309
  article: "<em>Pasal</em>"
305
310
  section: "<em>Bagian:</em> <strong>%{title}</strong>"
306
311
  sub-section: "<em>Sub-bagian:</em> %{title}"
312
+ update:
313
+ success: Teks partisipatif berhasil diperbarui.
307
314
  proposal_answers:
308
315
  edit:
309
316
  accepted: Diterima
@@ -261,7 +261,7 @@ it:
261
261
  votes:
262
262
  description: Numero di voti generati nelle proposte degli utenti
263
263
  object: voti
264
- title: voti
264
+ title: Voti
265
265
  participatory_processes:
266
266
  participatory_process_groups:
267
267
  highlighted_proposals:
@@ -289,13 +289,16 @@ it:
289
289
  name: Proposta
290
290
  participatory_texts:
291
291
  bulk-actions:
292
+ are_you_sure: Sei sicuro di scartare l'intera bozza del testo partecipativo?
292
293
  import_doc: Importa il documento
294
+ discard_all: Scarta tutto
293
295
  import:
294
296
  invalid: Il modulo non è valido!
295
297
  success: Complimenti, le seguenti sezioni sono state analizzate dal documento importato, sono state convertite in proposte. Ora puoi rivedere e regolare qualsiasi cosa tu abbia bisogno prima di pubblicare.
296
298
  index:
297
299
  info_1: Le seguenti sezioni sono state analizzate dal documento importato, sono state convertite in proposte. Ora puoi rivedere e regolare qualsiasi cosa tu abbia bisogno prima di pubblicare.
298
300
  publish_document: Pubblica un documento
301
+ save_draft: Salva la bozza
299
302
  title: ANTEPRIMA DEL TESTO PARTECIPATIVO
300
303
  new_import:
301
304
  bottom_hint: "(Sarai in grado di visualizzare in anteprima e ordinare le sezioni del documento)"
@@ -305,10 +308,14 @@ it:
305
308
  publish:
306
309
  invalid: Impossibile pubblicare proposte
307
310
  success: Tutte le proposte sono state pubblicate
311
+ discard:
312
+ success: Tutte le bozze di testo partecipativo sono state scartate.
308
313
  sections:
309
314
  article: "<em>Articolo</em>"
310
315
  section: "<em>Sezione:</em> <strong>%{title}</strong>"
311
316
  sub-section: "<em>Sottosezione:</em> %{title}"
317
+ update:
318
+ success: Testo partecipativo aggiornato correttamente.
312
319
  proposal_answers:
313
320
  edit:
314
321
  accepted: Accettata
@@ -261,7 +261,7 @@ nl:
261
261
  votes:
262
262
  description: Aantal stemmen dat is gegenereerd in voorstellen van gebruikers
263
263
  object: stemmen
264
- title: stemmen
264
+ title: Stemmen
265
265
  participatory_processes:
266
266
  participatory_process_groups:
267
267
  highlighted_proposals:
@@ -289,13 +289,16 @@ nl:
289
289
  name: Voorstel
290
290
  participatory_texts:
291
291
  bulk-actions:
292
+ are_you_sure: Weet je zeker dat je de hele deelnemende tekstopmaak wilt verwijderen?
292
293
  import_doc: Document importeren
294
+ discard_all: Gooi alles weg
293
295
  import:
294
296
  invalid: Het formulier is ongeldig!
295
297
  success: Gefeliciteerd, de volgende secties zijn geparseerd uit het geïmporteerde document, ze zijn geconverteerd naar voorstellen. Nu kunt u alles bekijken en aanpassen wat u nodig heeft voordat u publiceert.
296
298
  index:
297
299
  info_1: De volgende secties zijn geparseerd uit het geïmporteerde document, ze zijn geconverteerd naar voorstellen. Nu kunt u alles bekijken en aanpassen wat u nodig heeft voordat u publiceert.
298
300
  publish_document: Publiceer document
301
+ save_draft: Concept opslaan
299
302
  title: VOORBEELD PARTICIPATIEVE TEKST BEKIJKEN
300
303
  new_import:
301
304
  bottom_hint: "(U kunt documentsecties vooraf bekijken en sorteren)"
@@ -305,10 +308,14 @@ nl:
305
308
  publish:
306
309
  invalid: Kan voorstellen niet publiceren
307
310
  success: Alle voorstellen zijn gepubliceerd
311
+ discard:
312
+ success: Alle participatieve tekstconcepten zijn genegeerd.
308
313
  sections:
309
314
  article: "<em>Artikel</em>"
310
315
  section: "<em>Sectie:</em> <strong>%{title}</strong>"
311
316
  sub-section: "<em>Onderafdeling:</em> %{title}"
317
+ update:
318
+ success: Participatieve tekst succesvol bijgewerkt.
312
319
  proposal_answers:
313
320
  edit:
314
321
  accepted: Aanvaard
@@ -461,7 +468,7 @@ nl:
461
468
  published: Gepubliceerd
462
469
  related_to: Gerelateerd aan
463
470
  search: Zoeken
464
- state: Staat
471
+ state: Status
465
472
  withdrawn: teruggetrokken
466
473
  filters_small_view:
467
474
  close_modal: Modal sluiten
@@ -551,7 +558,7 @@ nl:
551
558
  official_proposal: Officieel voorstel
552
559
  published_at: Gepubliceerd op
553
560
  scope: Scope
554
- state: Staat
561
+ state: Status
555
562
  title: Titel
556
563
  votes: Stemmen
557
564
  new:
@@ -271,7 +271,7 @@ pl:
271
271
  votes:
272
272
  description: Liczba głosów uzyskanych w propozycjach przez użytkowników
273
273
  object: głosów
274
- title: Głosy
274
+ title: Głosowania
275
275
  participatory_processes:
276
276
  participatory_process_groups:
277
277
  highlighted_proposals:
@@ -299,13 +299,16 @@ pl:
299
299
  name: Wniosek
300
300
  participatory_texts:
301
301
  bulk-actions:
302
+ are_you_sure: Czy na pewno chcesz odrzucić cały szkic tekstu dla uczestników?
302
303
  import_doc: Zaimportuj dokument
304
+ discard_all: Odrzuć wszystko
303
305
  import:
304
306
  invalid: Formularz jest nieprawidłowy!
305
307
  success: Gratulacje, z importowanego dokumentu zostały przeanalizowane następujące sekcje, które zostały przekształcone w propozycje. Teraz możesz przejrzeć i dostosować, co potrzebujesz przed publikacją.
306
308
  index:
307
309
  info_1: Z importowanego dokumentu przeanalizowano następujące sekcje, które zostały przekształcone w propozycje. Teraz możesz przejrzeć i dostosować, co potrzebujesz przed publikacją.
308
310
  publish_document: Opublikuj dokument
311
+ save_draft: Zapisz Projekt
309
312
  title: PREVIEW TEKST UCZESTNIKA
310
313
  new_import:
311
314
  bottom_hint: "(Będziesz mógł przeglądać i sortować sekcje dokumentów)"
@@ -315,10 +318,14 @@ pl:
315
318
  publish:
316
319
  invalid: Nie można publikować propozycji
317
320
  success: Wszystkie wnioski zostały opublikowane
321
+ discard:
322
+ success: Wszystkie projekty tekstowe z uczestnictwem zostały odrzucone.
318
323
  sections:
319
324
  article: "<em>Artykuł</em>"
320
325
  section: "<em>Sekcja:</em> <strong>%{title}</strong>"
321
326
  sub-section: "<em>Podsekcja:</em> %{title}"
327
+ update:
328
+ success: Tekst uczestnictwa został zaktualizowany pomyślnie.
322
329
  proposal_answers:
323
330
  edit:
324
331
  accepted: Przyjęty
@@ -289,13 +289,16 @@ pt-BR:
289
289
  name: Proposta
290
290
  participatory_texts:
291
291
  bulk-actions:
292
+ are_you_sure: Tem certeza de descartar todo o rascunho do texto participativo?
292
293
  import_doc: Importar documento
294
+ discard_all: Descartar tudo
293
295
  import:
294
296
  invalid: O formato é inválido!
295
297
  success: Parabéns, as seções a seguir foram analisadas do documento importado, elas foram convertidas em propostas. Agora você pode revisar e ajustar o que precisar antes de publicar.
296
298
  index:
297
299
  info_1: As seções a seguir foram analisadas a partir do documento importado, elas foram convertidas em propostas. Agora você pode revisar e ajustar o que precisar antes de publicar.
298
300
  publish_document: Publicar documento
301
+ save_draft: Salvar rascunho
299
302
  title: Visualizar texto participativo
300
303
  new_import:
301
304
  bottom_hint: "(Você será capaz de visualizar e classificar as seções do documento)"
@@ -305,10 +308,14 @@ pt-BR:
305
308
  publish:
306
309
  invalid: Não foi possível publicar propostas
307
310
  success: Todas as propostas foram publicadas
311
+ discard:
312
+ success: Todos os rascunhos de texto participativos foram descartados.
308
313
  sections:
309
314
  article: "<em>Artigo</em>"
310
315
  section: "<em>Seção:</em> <strong>%{title}</strong>"
311
316
  sub-section: "<em>Subsecção:</em> %{title}"
317
+ update:
318
+ success: Texto participativo atualizado com sucesso.
312
319
  proposal_answers:
313
320
  edit:
314
321
  accepted: Aceitaram
@@ -289,13 +289,16 @@ pt:
289
289
  name: Proposta
290
290
  participatory_texts:
291
291
  bulk-actions:
292
+ are_you_sure: Tem certeza de descartar todo o rascunho do texto participativo?
292
293
  import_doc: Documento de importação
294
+ discard_all: Descartar tudo
293
295
  import:
294
296
  invalid: O formulário é inválido!
295
297
  success: Parabéns, as seções a seguir foram analisadas do documento importado, elas foram convertidas em propostas. Agora você pode revisar e ajustar o que precisar antes de publicar.
296
298
  index:
297
299
  info_1: As seções a seguir foram analisadas a partir do documento importado, elas foram convertidas em propostas. Agora você pode revisar e ajustar o que precisar antes de publicar.
298
300
  publish_document: Publicar documento
301
+ save_draft: Salvar rascunho
299
302
  title: PREVIEW TEXTO PARTICIPATIVO
300
303
  new_import:
301
304
  bottom_hint: "(Você será capaz de visualizar e classificar as seções do documento)"
@@ -305,10 +308,14 @@ pt:
305
308
  publish:
306
309
  invalid: Não foi possível publicar propostas
307
310
  success: Todas as propostas foram publicadas
311
+ discard:
312
+ success: Todos os rascunhos de texto participativos foram descartados.
308
313
  sections:
309
314
  article: "<em>Artigo</em>"
310
315
  section: "<em>Seção:</em> <strong>%{title}</strong>"
311
316
  sub-section: "<em>Subsecção:</em> %{title}"
317
+ update:
318
+ success: Texto participativo atualizado com sucesso.
312
319
  proposal_answers:
313
320
  edit:
314
321
  accepted: Aceitaram
@@ -149,6 +149,9 @@ ru:
149
149
  email_outro: Вы получили это уведомление, потому что вы следите за «%{participatory_space_title}». Вы можете отписаться от уведомлений, перейдя по приведенной выше ссылке.
150
150
  email_subject: В %{participatory_space_title} началось голосование по предложениям
151
151
  notification_title: Теперь в <a href="%{participatory_space_url}">%{participatory_space_title}</a> появилась возможность <a href="%{resource_path}">голосовать по предложениям</a>
152
+ metrics:
153
+ votes:
154
+ title: Голоса
152
155
  participatory_processes:
153
156
  participatory_process_groups:
154
157
  highlighted_proposals:
@@ -243,6 +246,9 @@ ru:
243
246
  official: Служебные
244
247
  filter_state_values:
245
248
  except_rejected: Все, кроме отклоненных
249
+ collaborative_drafts:
250
+ filters:
251
+ state: Cостояние
246
252
  create:
247
253
  error: При попытке сохранить это предложение произошли ошибки.
248
254
  success: Предложение успешно создано. Сохранено как черновик.
@@ -289,13 +289,16 @@ sv:
289
289
  name: Förslag
290
290
  participatory_texts:
291
291
  bulk-actions:
292
+ are_you_sure: Är du säker på att kassera hela deltagande textförslaget?
292
293
  import_doc: Importera dokument
294
+ discard_all: Kassera allt
293
295
  import:
294
296
  invalid: Blanketten är ogiltig!
295
297
  success: Grattis, följande avsnitt har analyserats från det importerade dokumentet, de har konverterats till förslag. Nu kan du granska och justera vad du behöver innan du publicerar.
296
298
  index:
297
299
  info_1: Följande avsnitt har analyserats från det importerade dokumentet, de har konverterats till förslag. Nu kan du granska och justera vad du behöver innan du publicerar.
298
300
  publish_document: Publicera dokument
301
+ save_draft: Spara utkast
299
302
  title: PREVIEW PARTICIPERY TEXT
300
303
  new_import:
301
304
  bottom_hint: "(Du kommer att kunna förhandsgranska och sortera dokumentavsnitt)"
@@ -305,10 +308,14 @@ sv:
305
308
  publish:
306
309
  invalid: Kunde inte publicera förslag
307
310
  success: Alla förslag har publicerats
311
+ discard:
312
+ success: Alla deltagande textförslag har kasseras.
308
313
  sections:
309
314
  article: "<em>Artikel</em>"
310
315
  section: "<em>Avsnitt:</em> <strong>%{title}</strong>"
311
316
  sub-section: "<em>Underavsnitt:</em> %{title}"
317
+ update:
318
+ success: Deltagande text uppdaterad framgångsrikt.
312
319
  proposal_answers:
313
320
  edit:
314
321
  accepted: Accepterad
@@ -141,6 +141,7 @@ tr:
141
141
  email_intro: 'Şimdi %{participatory_space_title}yeni teklifler oluşturabilirsiniz! Bu sayfaya katılmaya başlayın:'
142
142
  email_outro: Bu bildirimi, %{participatory_space_title}izlediğiniz için aldınız. Önceki bağlantıyı takip ederek bildirimleri almayı durdurabilirsiniz.
143
143
  email_subject: Şu anda %{participatory_space_title}teklif mevcut
144
+ notification_title: Artık ileri koyabilirsiniz <a href="%{resource_path}">yeni teklifler</a> içinde <a href="%{participatory_space_url}">%{participatory_space_title}</a>
144
145
  endorsing_enabled:
145
146
  email_intro: 'Teklifleri %{participatory_space_title}onaylayabilirsiniz! Bu sayfaya katılmaya başlayın:'
146
147
  email_outro: Bu bildirimi, %{participatory_space_title}izlediğiniz için aldınız. Önceki bağlantıyı takip ederek bildirimleri almayı durdurabilirsiniz.
@@ -288,13 +289,16 @@ tr:
288
289
  name: öneri
289
290
  participatory_texts:
290
291
  bulk-actions:
292
+ are_you_sure: Katılımcı metin taslağının tamamını atadığınızdan emin misiniz?
291
293
  import_doc: Dokümanı içe aktar
294
+ discard_all: Hepsini at
292
295
  import:
293
296
  invalid: Form geçersiz!
294
297
  success: Tebrikler, aşağıdaki bölümler içe aktarılan belgeden ayrıştırılmış, tekliflere dönüştürülmüştür. Artık yayınlamadan önce ihtiyacınız olan şeyleri inceleyip ayarlayabilirsin.
295
298
  index:
296
299
  info_1: Aşağıdaki bölümler içe aktarılan belgeden ayrıştırılmış, tekliflere dönüştürülmüştür. Artık yayınlamadan önce ihtiyacınız olan şeyleri inceleyip ayarlayabilirsin.
297
300
  publish_document: Belge yayınla
301
+ save_draft: Taslağı kaydet
298
302
  title: ÖNEMLİ KATILIMCI METİN
299
303
  new_import:
300
304
  bottom_hint: "(Belge bölümlerini önizleyebilir ve sıralayabilirsiniz)"
@@ -304,10 +308,14 @@ tr:
304
308
  publish:
305
309
  invalid: Teklifler yayınlanamadı
306
310
  success: Tüm teklifler yayınlandı
311
+ discard:
312
+ success: Tüm Katılımcı metin taslakları atıldı.
307
313
  sections:
308
314
  article: "<em>Madde</em>"
309
315
  section: "<em>Bölüm:</em> <strong>%{title}</strong>"
310
316
  sub-section: "<em>Alt Bölüm:</em> %{title}"
317
+ update:
318
+ success: Katılımcı metin başarıyla güncellendi.
311
319
  proposal_answers:
312
320
  edit:
313
321
  accepted: Kabul edilmiş
@@ -149,6 +149,9 @@ uk:
149
149
  email_outro: Ви отримали це сповіщення, тому що ви стежите за %{participatory_space_title}. Ви можете відписатися від цих сповіщень, перейшовши за наведеним вище посиланням.
150
150
  email_subject: У %{participatory_space_title} почалось голосування щодо пропозицій
151
151
  notification_title: Тепер в <a href="%{participatory_space_url}">%{participatory_space_title}</a> відкрилась можливість <a href="%{resource_path}">голосувати щодо пропозицій</a>
152
+ metrics:
153
+ votes:
154
+ title: Голоси
152
155
  participatory_processes:
153
156
  participatory_process_groups:
154
157
  highlighted_proposals:
@@ -243,6 +246,9 @@ uk:
243
246
  official: Службове
244
247
  filter_state_values:
245
248
  except_rejected: Усі, окрім відхилених
249
+ collaborative_drafts:
250
+ filters:
251
+ state: Стан
246
252
  create:
247
253
  error: При спробі збереження цієї пропозиції сталися помилки.
248
254
  success: Пропозицію успішно створено. Збережено як чернетку.
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UseMd5Indexes < ActiveRecord::Migration[5.2]
4
+ def up
5
+ remove_index :decidim_proposals_proposals, name: "decidim_proposals_proposal_title_search"
6
+ remove_index :decidim_proposals_proposals, name: "decidim_proposals_proposal_body_search"
7
+ execute "CREATE INDEX decidim_proposals_proposal_title_search ON decidim_proposals_proposals(md5(title::text))"
8
+ execute "CREATE INDEX decidim_proposals_proposal_body_search ON decidim_proposals_proposals(md5(body::text))"
9
+ end
10
+
11
+ def down
12
+ remove_index :decidim_proposals_proposals, name: "decidim_proposals_proposal_title_search"
13
+ remove_index :decidim_proposals_proposals, name: "decidim_proposals_proposal_body_search"
14
+ add_index :decidim_proposals_proposals, :title, name: "decidim_proposals_proposal_title_search"
15
+ add_index :decidim_proposals_proposals, :body, name: "decidim_proposals_proposal_body_search"
16
+ end
17
+ end
@@ -22,8 +22,8 @@ module Decidim
22
22
  # Matches a URL
23
23
  URL_REGEX_SCHEME = '(?:http(s)?:\/\/)'
24
24
  URL_REGEX_CONTENT = '[\w.-]+[\w\-\._~:\/?#\[\]@!\$&\'\(\)\*\+,;=.]+'
25
- URL_REGEX_END_CHAR = '[\w]'
26
- URL_REGEX = /#{URL_REGEX_SCHEME}#{URL_REGEX_CONTENT}#{URL_REGEX_END_CHAR}/i
25
+ URL_REGEX_END_CHAR = '[\d]'
26
+ URL_REGEX = %r{#{URL_REGEX_SCHEME}#{URL_REGEX_CONTENT}/proposals/#{URL_REGEX_END_CHAR}+}i
27
27
  # Matches a mentioned Proposal ID (~(d)+ expression)
28
28
  ID_REGEX = /~(\d+)/
29
29
 
@@ -21,11 +21,13 @@ module Decidim
21
21
  resources :proposal_notes, only: [:index, :create]
22
22
  end
23
23
  scope "/proposal_components/:component_id" do
24
- resources :participatory_texts, only: :index do
24
+ resources :participatory_texts, only: [:index] do
25
25
  collection do
26
26
  get :new_import
27
27
  post :import
28
- post :publish
28
+ patch :import
29
+ post :update
30
+ post :discard
29
31
  end
30
32
  end
31
33
  end
@@ -19,11 +19,17 @@ module Decidim
19
19
  @current_user = current_user
20
20
  @last_position = 0
21
21
  @num_sections = 0
22
+ @list_items = []
22
23
  end
23
24
 
24
25
  def parse(document)
25
26
  renderer = self
26
- parser = ::Redcarpet::Markdown.new(renderer)
27
+ extensions = {
28
+ # no lax_spacing so that it is easier to group paragraphs in articles.
29
+ lax_spacing: false,
30
+ fenced_code_blocks: true
31
+ }
32
+ parser = ::Redcarpet::Markdown.new(renderer, extensions)
27
33
  parser.render(document)
28
34
  end
29
35
 
@@ -31,6 +37,8 @@ module Decidim
31
37
  # Redcarpet callbacks
32
38
  ##########################################
33
39
 
40
+ # Block-level calls ######################
41
+
34
42
  # Recarpet callback to process headers.
35
43
  # Creates Paricipatory Text Proposals at Section and Subsection levels.
36
44
  def header(title, level)
@@ -60,9 +68,46 @@ module Decidim
60
68
  text
61
69
  end
62
70
 
63
- # ignore images
64
- def image(_link, _title, _alt_text)
65
- ""
71
+ # Render the list as a whole
72
+ def list(_contents, list_type)
73
+ return if @list_items.empty?
74
+
75
+ body = case list_type
76
+ when :ordered
77
+ @list_items.collect.with_index { |item, idx| "#{idx + 1}. #{item}\n" }.join
78
+ else
79
+ @list_items.collect { |item| "- #{item}\n" }.join
80
+ end
81
+ # reset items for the next list
82
+ @list_items = []
83
+ create_proposal(
84
+ (@last_position + 1 - @num_sections).to_s,
85
+ body,
86
+ Decidim::Proposals::ParticipatoryTextSection::LEVELS[:article]
87
+ )
88
+
89
+ body
90
+ end
91
+
92
+ # do not render list items, save them for rendering with the whole list
93
+ def list_item(text, _list_type)
94
+ @list_items << text.strip
95
+ nil
96
+ end
97
+
98
+ # Span-level calls #######################
99
+
100
+ def link(link, title, content)
101
+ attrs = %(href="#{link}")
102
+ attrs += %( title="#{title}") if title.present?
103
+ "<a #{attrs}>#{content}</a>"
104
+ end
105
+
106
+ def image(link, title, alt_text)
107
+ attrs = %(src="#{link}")
108
+ attrs += %( alt="#{alt_text}") if alt_text.present?
109
+ attrs += %( title="#{title}") if title.present?
110
+ "<img #{attrs}/>"
66
111
  end
67
112
 
68
113
  private