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

Version Path
soywiki-0.7.2 bin/soywiki-pages-linking-in
soywiki-0.7.1 bin/soywiki-pages-linking-in
soywiki-0.7.0 bin/soywiki-pages-linking-in
soywiki-0.6.7 bin/soywiki-pages-linking-in
soywiki-0.6.6 bin/soywiki-pages-linking-in
soywiki-0.6.5 bin/soywiki-pages-linking-in
soywiki-0.6.4 bin/soywiki-pages-linking-in
soywiki-0.6.3 bin/soywiki-pages-linking-in
soywiki-0.6.2 bin/soywiki-pages-linking-in
soywiki-0.6.1 bin/soywiki-pages-linking-in
soywiki-0.6.0 bin/soywiki-pages-linking-in
soywiki-0.5.9 bin/soywiki-pages-linking-in
soywiki-0.5.8 bin/soywiki-pages-linking-in
soywiki-0.5.7 bin/soywiki-pages-linking-in
soywiki-0.5.6 bin/soywiki-pages-linking-in
soywiki-0.5.5 bin/soywiki-pages-linking-in
soywiki-0.5.4 bin/soywiki-pages-linking-in
soywiki-0.5.3 bin/soywiki-pages-linking-in
soywiki-0.5.2 bin/soywiki-pages-linking-in
soywiki-0.5.1 bin/soywiki-pages-linking-in