Sha256: 8b7c892fd1f5b7d20df45524dfd275d4765975e4949862d54ca239fef2ab720c
Contents?: true
Size: 810 Bytes
Versions: 26
Compression:
Stored size: 810 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|\.txt|Notes\ &\ Settings)$/ || 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
26 entries across 26 versions & 1 rubygems