diff options
Diffstat (limited to 'app/helpers/content_helper.rb')
| -rw-r--r-- | app/helpers/content_helper.rb | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index 21cc579..5810966 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb | |||
| @@ -23,6 +23,26 @@ module ContentHelper | |||
| 23 | ) | 23 | ) |
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | def open_erfas_today | ||
| 27 | occurrences = Occurrence | ||
| 28 | .find_in_range(Time.now.beginning_of_day, Time.now.end_of_day) | ||
| 29 | .joins(event: :tags) | ||
| 30 | .where(tags: { name: 'open-day' }) | ||
| 31 | .reject { |o| o.node.nil? || o.node.head.nil? } | ||
| 32 | .sample(3) | ||
| 33 | |||
| 34 | return if occurrences.empty? | ||
| 35 | |||
| 36 | render( | ||
| 37 | :partial => 'content/open_erfas_today', | ||
| 38 | :locals => { :occurrences => occurrences } | ||
| 39 | ) | ||
| 40 | end | ||
| 41 | |||
| 42 | def weekday_abbr(time) | ||
| 43 | RruleHumanizer.wday_abbr(time, I18n.locale) | ||
| 44 | end | ||
| 45 | |||
| 26 | def tags | 46 | def tags |
| 27 | render :partial => 'content/tags' | 47 | render :partial => 'content/tags' |
| 28 | end | 48 | end |
| @@ -67,11 +87,14 @@ module ContentHelper | |||
| 67 | # Syntax of the [aggregate ] short code: | 87 | # Syntax of the [aggregate ] short code: |
| 68 | # | 88 | # |
| 69 | # [aggregate | 89 | # [aggregate |
| 70 | # flags="update, pressemitteilung" | 90 | # children="all" | children="direct" # optional, at least one of children |
| 91 | # tags="update, pressemitteilung" # or tags is required | ||
| 71 | # limit="20" | 92 | # limit="20" |
| 72 | # order_by="published_at" | 93 | # order_by="published_at" |
| 73 | # order_direction="DESC" | 94 | # order_direction="DESC" |
| 74 | # ] | 95 | # ] |
| 96 | |||
| 97 | |||
| 75 | def aggregate? content | 98 | def aggregate? content |
| 76 | options = {} | 99 | options = {} |
| 77 | 100 | ||
| @@ -80,7 +103,7 @@ module ContentHelper | |||
| 80 | begin | 103 | begin |
| 81 | if content =~ /\[aggregate([^\]]*)\]/ | 104 | if content =~ /\[aggregate([^\]]*)\]/ |
| 82 | tag = $~.to_s | 105 | tag = $~.to_s |
| 83 | matched_data = $1.scan(/\w+\="[a-zA-Z\s\/_\d,.=]*"/) | 106 | matched_data = $1.scan(/\w+\="[a-zA-Z\s\/_\d,.=-]*"/) |
| 84 | 107 | ||
| 85 | matched_data.each do |data| | 108 | matched_data.each do |data| |
| 86 | splitted_data = data.split("=", 2) | 109 | splitted_data = data.split("=", 2) |
| @@ -88,6 +111,7 @@ module ContentHelper | |||
| 88 | end | 111 | end |
| 89 | 112 | ||
| 90 | options[:partial] = select_partial(options[:partial]) | 113 | options[:partial] = select_partial(options[:partial]) |
| 114 | options[:node] = @page.node if options[:children].present? | ||
| 91 | 115 | ||
| 92 | sanitize(content.sub(tag, render_collection(options)), :attributes => cccms_attributes) | 116 | sanitize(content.sub(tag, render_collection(options)), :attributes => cccms_attributes) |
| 93 | else | 117 | else |
