Class: Banzai::Filter::WikiLinkFilter::Rewriter
- Inherits:
-
Object
- Object
- Banzai::Filter::WikiLinkFilter::Rewriter
- Defined in:
- lib/banzai/filter/wiki_link_filter/rewriter.rb
Instance Method Summary collapse
- #apply_rules ⇒ Object
-
#initialize(link_string, wiki:, slug:) ⇒ Rewriter
constructor
A new instance of Rewriter.
Constructor Details
#initialize(link_string, wiki:, slug:) ⇒ Rewriter
Returns a new instance of Rewriter.
7 8 9 10 11 |
# File 'lib/banzai/filter/wiki_link_filter/rewriter.rb', line 7 def initialize(link_string, wiki:, slug:) @uri = Addressable::URI.parse(link_string) @wiki_base_path = wiki&.wiki_base_path @slug = slug end |
Instance Method Details
#apply_rules ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/banzai/filter/wiki_link_filter/rewriter.rb', line 13 def apply_rules # Special case: relative URLs beginning with `/uploads/` refer to # user-uploaded files will be handled elsewhere. return @uri.to_s if public_upload? # Special case: relative URLs beginning with Wikis::CreateAttachmentService::ATTACHMENT_PATH # refer to user-uploaded files to the wiki repository. unless repository_upload? apply_file_link_rules! apply_hierarchical_link_rules! end apply_relative_link_rules! @uri.to_s end |