Class: Jekyll::WikiLinks::LinkIndex
- Inherits:
-
Object
- Object
- Jekyll::WikiLinks::LinkIndex
- Defined in:
- lib/jekyll-wikilinks/util/link_index.rb
Defined Under Namespace
Classes: DocLinks
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #assign_metadata(doc) ⇒ Object
-
#initialize(site) ⇒ LinkIndex
constructor
A new instance of LinkIndex.
- #populate(doc, wikilink_blocks, wikilink_inlines) ⇒ Object
Constructor Details
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
7 8 9 |
# File 'lib/jekyll-wikilinks/util/link_index.rb', line 7 def index @index end |
Instance Method Details
#assign_metadata(doc) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/jekyll-wikilinks/util/link_index.rb', line 17 def (doc) doc.data['attributed'] = @index[doc.url].attributed.uniq doc.data['attributes'] = @index[doc.url].attributes.uniq doc.data['backlinks'] = @index[doc.url].backlinks.uniq doc.data['forelinks'] = @index[doc.url].forelinks.uniq doc.data['missing'] = @index[doc.url].missing.uniq end |
#populate(doc, wikilink_blocks, wikilink_inlines) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/jekyll-wikilinks/util/link_index.rb', line 25 def populate(doc, wikilink_blocks, wikilink_inlines) # # # blocks # # # wikilink_blocks.each do |wlbl| if wlbl.is_valid? # # attributes # target_attr = @index[doc.url].attributes.detect { |atr| atr['type'] == wlbl.link_type } # create if target_attr.nil? @index[doc.url].attributes << wlbl.linked_fm_data # append else target_attr['urls'] += wlbl.urls end ## append missing docs @index[doc.url].missing += wlbl.missing_doc_filenames # # attributed # wlbl.linked_docs.each do |linked_doc| target_attr = @index[linked_doc.url].attributed.detect { |atr| atr['type'] == wlbl.link_type } # create if target_attr.nil? @index[linked_doc.url].attributed << wlbl.context_fm_data # append else target_attr['urls'] << doc.url end end else # # invalid || empty # @index[doc.url].missing += wlbl.missing_doc_filenames end end # # # inlines # # # wikilink_inlines.each do |wlil| return if wlil.is_img? if wlil.is_valid? # forelink @index[doc.url].forelinks << wlil.linked_fm_data # backlink @index[wlil.linked_doc.url].backlinks << wlil.context_fm_data else @index[doc.url].missing << wlil.filename end end end |