parent
9567ea0c8f
commit
058a0636fa
2 changed files with 35 additions and 1 deletions
@ -1,3 +1,3 @@ |
||||
[submodule "wiki-data"] |
||||
path = wiki-data |
||||
url = https://github.com/CTHN/wiki-data |
||||
url = git@github.com:CTHN/wiki-data.git |
||||
|
@ -0,0 +1,34 @@ |
||||
#!/usr/bin/env ruby |
||||
|
||||
# Simple script to check broken links in the wiki. This is a weak and simple |
||||
# check to work with markdown, html and even php scripts. Keep in mind that |
||||
# the script does not find linked pages through "meta-pages" like a php script |
||||
# which links all files in the /user/ folder. |
||||
# |
||||
# Last change: 2014-06-27, Aaron Mueller <mail@aaron-mueller.de> |
||||
|
||||
|
||||
blacklist = [ |
||||
'mainpage', |
||||
'error_404' |
||||
] |
||||
|
||||
Dir.chdir(File.join(File.dirname(__FILE__), '..', 'wiki-data')) |
||||
|
||||
files = Dir.glob('pages/**/*') |
||||
.delete_if {|file| Dir.exists?(file) } |
||||
wiki_links = files |
||||
.map {|file| file[6..-1].split('.').first } |
||||
.delete_if {|file| blacklist.include?(file) } |
||||
|
||||
files.each do |file| |
||||
content = File.new(file).read |
||||
wiki_links.reject! do |link| |
||||
not content.scan(/#{link}/).empty? |
||||
end |
||||
end |
||||
|
||||
wiki_links.each do |broken_link| |
||||
puts "Check linkage for '#{broken_link}'." |
||||
end |
||||
puts "#{wiki_links.size} in total." |
Reference in new issue