Sha256: 95a2898b0b601d519e78e3fb4e6c0829963c06e7569b5e258537d7313a41a856
Contents?: true
Size: 785 Bytes
Versions: 55
Compression:
Stored size: 785 Bytes
Contents
#!/usr/bin/env ruby # encoding: utf-8 require 'soywiki' def contains_links_to?(file, page_title) return false unless File.file?(file) return false if (file =~ /(\.swo|\.swp)$/ || file =~ /^\./) body = File.read(file) # '.' must be escaped in the regular expression to match literal body =~ /[\A\s\n\b]#{page_title.gsub(".", "\.")}\b/ end target_page = ARGV.first.dup # make sure this is a title, not a path target_page.gsub!("/", ".") # find all files in this namespace xs = Dir.glob("#{target_page.namespace}/*").select do |file| contains_links_to?(file, target_page) || contains_links_to?(file, target_page.short_page_title) end ys = Dir.glob('*/*').select do |file| contains_links_to?(file, target_page) end (xs + ys).uniq.sort.each {|x| puts x.to_page_title}
Version data entries
55 entries across 55 versions & 1 rubygems