diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 71ee8d34db..9b07fbdea8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -79,6 +79,7 @@ def locale_name_pairs end def insert_extras(body) + body = NodeShared.notes_inline_grid(body) body = NodeShared.notes_grid(body) body = NodeShared.questions_grid(body) body = NodeShared.activities_grid(body) diff --git a/app/models/concerns/node_shared.rb b/app/models/concerns/node_shared.rb index dec87714d1..242b7849b9 100644 --- a/app/models/concerns/node_shared.rb +++ b/app/models/concerns/node_shared.rb @@ -186,6 +186,42 @@ def self.notes_map(body) end end + def self.notes_inline_grid(body) + body.gsub(/[^\>`](\
)?\[notes\:grid\:(\S+)\]/) do |_tagname| + tagname = Regexp.last_match(2) + exclude = nil + if tagname.include?('!') + exclude = tagname.split('!') - [tagname.split('!').first] + tagname = tagname.split('!').first + end + + nodes = Node.where(status: 1, type: 'note') + .includes(:revision, :tag) + .references(:term_data, :node_revisions) + .where('term_data.name = ?', tagname) + .order('node_revisions.timestamp DESC') + + if exclude.present? + exclude = Node.where(status: 1, type: 'note') + .includes(:revision, :tag) + .references(:node_revisions, :term_data) + .where('term_data.name IN (?)', exclude) + nodes -= exclude + end + output = '' + output += '
' if Regexp.last_match(1) == '
' + a = ActionController::Base.new + output += a.render_to_string(template: "notes/_note_thumbnails_grid", + layout: false, + locals: { + tagname: tagname, + nodes: nodes, + type: "notes" + }) + output + end + end + def self.notes_map_by_tag(body) body.gsub(/[^\>`](\
)?\[map\:tag\:(\S+)\:(\S+)\:(\S+)\]/) do |_tagname| tagname = Regexp.last_match(2) diff --git a/app/views/dashboard/_node_default.html.erb b/app/views/dashboard/_node_default.html.erb index ffb5ce981a..281f4e38c9 100644 --- a/app/views/dashboard/_node_default.html.erb +++ b/app/views/dashboard/_node_default.html.erb @@ -1,4 +1,5 @@ -