The markdown digest seemed broken, no line breaks, we now use kramdown which is able to generate markdown from html
This commit is contained in:
parent
4ce608dd5c
commit
45b18e0c34
2
Gemfile
2
Gemfile
@ -50,7 +50,7 @@ gem 'differ'
|
|||||||
gem 'activeadmin', github: 'activeadmin'
|
gem 'activeadmin', github: 'activeadmin'
|
||||||
|
|
||||||
# Markdown display
|
# Markdown display
|
||||||
gem 'redcarpet'
|
gem 'kramdown'
|
||||||
|
|
||||||
gem 'flag-icons-rails'
|
gem 'flag-icons-rails'
|
||||||
gem 'geocoder'
|
gem 'geocoder'
|
||||||
|
10
Gemfile.lock
10
Gemfile.lock
@ -1,6 +1,6 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: git://github.com/activeadmin/activeadmin.git
|
remote: git://github.com/activeadmin/activeadmin.git
|
||||||
revision: 54dcfeaf76b92e42b46cb573cdfa2093e6356a31
|
revision: e558e8c08e8c5d625a2d01369bfe2704cecdc296
|
||||||
specs:
|
specs:
|
||||||
activeadmin (1.0.0)
|
activeadmin (1.0.0)
|
||||||
arbre (>= 1.1.1)
|
arbre (>= 1.1.1)
|
||||||
@ -179,11 +179,11 @@ GEM
|
|||||||
haml (>= 4.0.6, < 6.0)
|
haml (>= 4.0.6, < 6.0)
|
||||||
html2haml (>= 1.0.1)
|
html2haml (>= 1.0.1)
|
||||||
railties (>= 4.0.1)
|
railties (>= 4.0.1)
|
||||||
haml_lint (0.25.1)
|
haml_lint (0.26.0)
|
||||||
haml (>= 4.0, < 5.1)
|
haml (>= 4.0, < 5.1)
|
||||||
rainbow
|
rainbow
|
||||||
rake (>= 10, < 13)
|
rake (>= 10, < 13)
|
||||||
rubocop (>= 0.47.0)
|
rubocop (>= 0.49.0)
|
||||||
sysexits (~> 1.1)
|
sysexits (~> 1.1)
|
||||||
has_scope (0.6.0)
|
has_scope (0.6.0)
|
||||||
actionpack (>= 3.2, < 5)
|
actionpack (>= 3.2, < 5)
|
||||||
@ -233,6 +233,7 @@ GEM
|
|||||||
activerecord
|
activerecord
|
||||||
kaminari-core (= 1.0.1)
|
kaminari-core (= 1.0.1)
|
||||||
kaminari-core (1.0.1)
|
kaminari-core (1.0.1)
|
||||||
|
kramdown (1.13.2)
|
||||||
leaflet-rails (1.0.3)
|
leaflet-rails (1.0.3)
|
||||||
rails (>= 4.2.0)
|
rails (>= 4.2.0)
|
||||||
libv8 (3.16.14.19)
|
libv8 (3.16.14.19)
|
||||||
@ -335,7 +336,6 @@ GEM
|
|||||||
rb-inotify (0.9.8)
|
rb-inotify (0.9.8)
|
||||||
ffi (>= 0.5.0)
|
ffi (>= 0.5.0)
|
||||||
rdoc (4.3.0)
|
rdoc (4.3.0)
|
||||||
redcarpet (3.4.0)
|
|
||||||
ref (2.0.0)
|
ref (2.0.0)
|
||||||
request_store (1.3.2)
|
request_store (1.3.2)
|
||||||
responders (2.4.0)
|
responders (2.4.0)
|
||||||
@ -461,6 +461,7 @@ DEPENDENCIES
|
|||||||
jbuilder
|
jbuilder
|
||||||
jquery-rails
|
jquery-rails
|
||||||
jquery-sparkline-rails!
|
jquery-sparkline-rails!
|
||||||
|
kramdown
|
||||||
leaflet-rails
|
leaflet-rails
|
||||||
meta-tags
|
meta-tags
|
||||||
modernizr-rails
|
modernizr-rails
|
||||||
@ -472,7 +473,6 @@ DEPENDENCIES
|
|||||||
rails
|
rails
|
||||||
rails-assets-leaflet.markercluster!
|
rails-assets-leaflet.markercluster!
|
||||||
rails-i18n
|
rails-i18n
|
||||||
redcarpet
|
|
||||||
sass-rails
|
sass-rails
|
||||||
sdoc
|
sdoc
|
||||||
simple_calendar
|
simple_calendar
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
$(document).on 'turbolinks:load', ->
|
$(document).on 'turbolinks:load', ->
|
||||||
# Setup the graphical editor for event's description
|
# Setup the graphical editor for event's description
|
||||||
tinyMCE.init
|
tinyMCE.init
|
||||||
schema: 'html5',
|
schema: 'html5'
|
||||||
height: '40em',
|
height: '40em'
|
||||||
menubar: '',
|
menubar: false
|
||||||
branding: false,
|
branding: false
|
||||||
language: 'fr_FR',
|
language: 'fr_FR'
|
||||||
selector: 'input.description',
|
selector: 'input.description'
|
||||||
content_css: '<%= asset_path 'application.css' %>',
|
content_css: '<%= asset_path 'application.css' %>'
|
||||||
entity_encoding : 'raw',
|
entity_encoding: 'raw'
|
||||||
add_unload_trigger: true,
|
add_unload_trigger: true
|
||||||
browser_spellcheck: true,
|
browser_spellcheck: true
|
||||||
toolbar: [
|
toolbar: [
|
||||||
' cut copy paste
|
' cut copy paste
|
||||||
| undo redo
|
| undo redo
|
||||||
@ -23,7 +23,7 @@ $(document).on 'turbolinks:load', ->
|
|||||||
| bullist numlist
|
| bullist numlist
|
||||||
| alignleft aligncenter alignright alignjustify alignnone
|
| alignleft aligncenter alignright alignjustify alignnone
|
||||||
| outdent indent'
|
| outdent indent'
|
||||||
],
|
]
|
||||||
plugins: 'lists, advlist, autolink, link, image, charmap, paste, print,
|
plugins: 'lists, advlist, autolink, link, image, charmap, paste, print,
|
||||||
preview, table, fullscreen, searchreplace, media, insertdatetime,
|
preview, table, fullscreen, searchreplace, media, insertdatetime,
|
||||||
visualblocks, wordcount, contextmenu, code'
|
visualblocks, wordcount, contextmenu, code'
|
||||||
|
@ -49,6 +49,11 @@ module EventsHelper
|
|||||||
s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n")
|
s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def display_attr(label, value = @event[label])
|
||||||
|
return unless value
|
||||||
|
Event.human_attribute_name(label).rjust(12) + " #{value}"
|
||||||
|
end
|
||||||
|
|
||||||
# Select the events to display in a month, sorted
|
# Select the events to display in a month, sorted
|
||||||
def month_events(events, date)
|
def month_events(events, date)
|
||||||
events.select { |e| (e.start_time.to_date..e.end_time.to_date).cover? date }
|
events.select { |e| (e.start_time.to_date..e.end_time.to_date).cover? date }
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
[#{event.region.region.try(:code) || event.region.try(:code)} #{event.city}] [#{event.title}](#{event_url event}) - #{display_date event}
|
[#{event.region.region.try(:code) || event.region.try(:code)} #{event.city}] [#{event.title}](#{event_url event}) - #{display_date event}
|
||||||
\-----
|
\-----
|
||||||
|
|
||||||
- lines = strip_tags(event.description).split(/\r\n/).reject(&:blank?)
|
- Kramdown::Document.new(event.description, input: 'html').to_kramdown.split(/\n/)[0..2].each do |p|
|
||||||
- lines[0..2].each do |p|
|
|
||||||
= p
|
= p
|
||||||
\
|
\
|
||||||
|
\
|
||||||
* #{[event.place_name, event.full_address].compact.join ', '}
|
* #{[event.place_name, event.full_address].compact.join ', '}
|
||||||
- if event.url.present?
|
- if event.url.present?
|
||||||
* #{Event.human_attribute_name :url}: #{event.url}
|
* #{Event.human_attribute_name :url}: #{event.url}
|
||||||
@ -31,13 +31,12 @@
|
|||||||
:markdown
|
:markdown
|
||||||
* [April](http://april.org)
|
* [April](http://april.org)
|
||||||
* [Agenda du Libre](http://www.agendadulibre.org)
|
* [Agenda du Libre](http://www.agendadulibre.org)
|
||||||
* [Carte des événements]
|
* [Carte des événements](#{maps_url future: false, period:
|
||||||
(#{maps_url future: false, period: { year: @week.year, week: @week.cweek }})
|
{ year: @week.year, week: @week.cweek }})
|
||||||
* [Proposer un événement](http://www.agendadulibre.org/events/new)
|
* [Proposer un événement](http://www.agendadulibre.org/events/new)
|
||||||
* [Annuaire des organisations](http://www.agendadulibre.org/orgas)
|
* [Annuaire des organisations](http://www.agendadulibre.org/orgas)
|
||||||
* [Agenda pour la semaine précédante]
|
* [Agenda pour la semaine précédante](#{digest_url :markdown,
|
||||||
(#{digest_url :markdown, future: false, period: {
|
future: false, period: { year: @week.year, week: (@week - 1.week).cweek }})
|
||||||
year: @week.year, week: (@week - 1.week).cweek }})
|
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
=====================================================
|
================================================================================
|
||||||
#{Event.human_attribute_name(:title).concat(':').ljust 12 } #{@event.title}
|
= display_attr :title
|
||||||
#{Event.human_attribute_name(:start_time).concat(':').ljust 12 } #{l @event.start_time, format: :at}
|
= display_attr :start_time, l(@event.start_time, format: :at)
|
||||||
#{Event.human_attribute_name(:end_time).concat(':').ljust 12 } #{l @event.end_time, format: :at}
|
= display_attr :end_time, l(@event.end_time, format: :at)
|
||||||
-if @event.repeat > 0
|
= display_attr :place_name
|
||||||
#{Event.human_attribute_name(:repeat).concat(':').ljust 12 } #{@event.repeat}
|
= display_attr :address
|
||||||
#{Event.human_attribute_name(:rule).concat(':').ljust 12 } #{t @event.rule, scope: 'activerecord.attributes.event.rule_values'}
|
= display_attr :city
|
||||||
#{Event.human_attribute_name(:place_name).concat(':').ljust 12 } #{@event.place_name}
|
= display_attr :region, @event.region
|
||||||
#{Event.human_attribute_name(:address).concat(':').ljust 12 } #{@event.address}
|
= display_attr :locality, t("attributes.locality_#{@event.locality}")
|
||||||
#{Event.human_attribute_name(:city).concat(':').ljust 12 } #{@event.city}
|
= display_attr :url
|
||||||
#{Event.human_attribute_name(:region).concat(':').ljust 12 } #{@event.region}
|
= display_attr :contact
|
||||||
#{Event.human_attribute_name(:locality).concat(':').ljust 12 } #{t "attributes.locality_#{@event.locality}"}
|
= display_attr :submitter
|
||||||
- if @event.url.present?
|
= display_attr :tags, @event.tag_list
|
||||||
#{Event.human_attribute_name(:url).concat(':').ljust 12 } #{@event.url}
|
- if @event.repeat > 0
|
||||||
#{Event.human_attribute_name(:contact).concat(':').ljust 12 } #{@event.contact}
|
= display_attr :repeat
|
||||||
#{Event.human_attribute_name(:submitter).concat(':').ljust 12 } #{@event.submitter}
|
= display_attr :rule, t(@event.rule, scope: 'activerecord.attributes.event.rule_values')
|
||||||
#{Event.human_attribute_name(:tags).concat(':').ljust 12 } #{@event.tag_list}
|
\
|
||||||
#{Event.human_attribute_name(:description).concat(':').ljust 12}
|
= Kramdown::Document.new(@event.description, input: 'html').to_kramdown
|
||||||
= wrap(strip_tags(@event.description).gsub(/ /, '')).gsub /^/, ' '
|
================================================================================
|
||||||
=====================================================
|
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -0,0 +1,23 @@
|
|||||||
|
(function() {
|
||||||
|
$(document).on('turbolinks:load', function() {
|
||||||
|
return tinyMCE.init({
|
||||||
|
schema: 'html5',
|
||||||
|
height: '40em',
|
||||||
|
menubar: false,
|
||||||
|
branding: false,
|
||||||
|
language: 'fr_FR',
|
||||||
|
selector: 'input.description',
|
||||||
|
content_css: '/assets/application-453868b5e8524811b06953b99485725a8bb6787b4936274042f7695531abcda3.css',
|
||||||
|
entity_encoding: 'raw',
|
||||||
|
add_unload_trigger: true,
|
||||||
|
browser_spellcheck: true,
|
||||||
|
toolbar: [' cut copy paste | undo redo | searchreplace | link image media charmap table | code visualblocks preview fullscreen', ' removeformat | bold italic strikethrough | superscript subscript | bullist numlist | alignleft aligncenter alignright alignjustify alignnone | outdent indent'],
|
||||||
|
plugins: 'lists, advlist, autolink, link, image, charmap, paste, print, preview, table, fullscreen, searchreplace, media, insertdatetime, visualblocks, wordcount, contextmenu, code'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('turbolinks:before-cache', function() {
|
||||||
|
return tinymce.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
}).call(this);
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user