1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 module RedClothArvadosLinkExtension
7 class RedClothViewBase < ActionView::Base
8 include ApplicationHelper
9 include ActionView::Helpers::UrlHelper
10 include Rails.application.routes.url_helpers
12 def helper_link_to_if_arvados_object(link, opts)
13 link_to_if_arvados_object(link, opts)
17 def refs_arvados(text)
18 text.gsub!(/"(?!\s)([^"]*\S)":(\S+)/) do
20 arvados_link = RedClothViewBase.new.helper_link_to_if_arvados_object(link, { :link_text => text })
21 # if it's not an arvados_link the helper will return the link unprocessed and so we will reconstruct the textile link string so it can be processed normally
22 (arvados_link == link) ? "\"#{text}\":#{link}" : arvados_link
27 RedCloth.send(:include, RedClothArvadosLinkExtension)