using Dates include("WBInclusions") dt = string(Dates.now()) dtx = findfirst('T', dt) global noww = dt[1: dtx - 1] * " " * dt[dtx + 1: 19] global DATEPROBLEMS = [] global Validated = -1 global SZ = 0 global EXTERNAL_LINKS = 0 global IMAGE_LINKS = 0 APFS = "151" # WBTree:APFS version = APFS global szDict = Dict{String,Array{String}}() global IDS = Dict{String,Array{String}}() global LWIDS = Dict() global IDct = 0 global ID2ct = 0 global MAPS = 0 global L2C1FirstPadding = true global noTOCs = [] global FootnoteBlocks = 0 global HighRevisions = [-1, -2, -3, -4, -5, -6, -7, -8] global SumRevisions = 0 global NYTComments = 0 global Bingers = 0 global Qsum = 0 global Q = "" global AllRegisteredFiles = [] function qwrite(txt) global Qsum += length(txt) global Q *= txt end function ErrorQuit(txt) println(HI_RED * "\n--------\n " * txt * "\n--------" * HI_END * "\n") exit(16) end HSYMS = [] global fdict = Dict{String, String}() global ildict = Dict{String, Int64}() global linkCt = 0 global ilinkCt = 0 global pageCt = 0 global incoming = Dict{String, Array{String}}() global externalLinks = Dict{String, Array{String}}() global excludeds = ["IndexOfSubjects.html"] global ignoreds = [ "JUNK.html", "JUNK2.html" ] pre = "\n\n\n\nLink inventory\n\n\n\n\n
\n" * "

WBTree v" * version * ".        Index   Images   Dashboard\"Next2a.gif\"        " * APtS_ET * "
\n" pres = Dict( "Tree" => "Go: RTree\"Next2a.gif\"\"Next2a.gif\"", "RTree" => "Go: XTree\"Next2a.gif\"\"Next2a.gif\"", "XTree" => "Go: Tree\"Next2a.gif\"\"Next2a.gif\"" ) pre2 = "

\n" post = "\n

[ Ω W3C HTML validator  --S,Z-- ]

\n" println("\nWBTree v", version, " (./V1). ", noww, " " * APtS_ET * "\n") rm("XXXTree.html", force=true) rm("XXXRTree.html", force=true) rm("XXXXTree.html", force=true) function saveTable(fn, fv) global Q = "" global Qsum = 0 qwrite(pre) qwrite(pres[fn]) qwrite(pre2) qwrite(fv) qwrite(post) # sQsum = string(Qsum) sQsum = formatNumber(Qsum) # sQsum[1:3] * "," * sQsum[4:6] ilc = "" if fn == "Tree" ilc = "  " * formatNumber(length(findall(" href=\"#",Q))) end global Q = replace(Q, "--S,Z--" => sQsum * ilc, count = 1) global q = open("XXX" * fn * ".html", "w") write(q, Q) close(q) end function makeTable(DICT, ptr) global L2C1FirstPadding = true if ptr == "=>" istr = string(ilinkCt) if ilinkCt > 999 listr = length(istr) istr = istr[1: listr - 3] * "," * istr[listr - 2: listr] end global out = "\n" global ILINKS = istr global RLINKS = lc elseif ptr == "<=" global out = "
T Pages: " * string(pageCt) * ". Interpage links > " * lc * ". Imaps: " * string(MAPS) * ". NYTs: " * string(NYTComments) * ". Bingers: " * string(Bingers) * "
" * noww * ". Intrapage ('#') links > " * istr * ". Img links: " * formatNumber(IMAGE_LINKS) * ". Footnotes: " * string(FootnoteBlocks) * ".
\n" else global out = "
R Reverse table of incoming internal interpage links:
" * noww * "
\n" end global shit = [] for x in keys(DICT) push!(shit, x) end global shoot = copy(shit) ghosts = [] crt = 0 shitx = sort(shit, by=lowercase) for s in shitx s2 = s[1:(length(s) - 5)] if length(DICT[s]) == 0 push!(ghosts, (s2 == "IntoTheLight" ? "IntoTheLight" : "" * s2 * "")) end ilss = "" ils = get(ildict, s, 0) if ils > 0 ilss = "(DDD" * string(ils) * ")" end if ptr != "<<=" if s2 == "welcome" s2a = "" else s2a = "|" * s2 end ohmygod = "" * s2 * "" if s2 == "IntoTheLight" ohmygod = "IntotheLight" end global out *= "" else if s2 == "https://validator.w3" global Validated = length(findall(",", DICT[s])) + 1 DICT[s] = "[ TMTC ]" end crt += 1 crtx = string(crt) crtx = (" " ^ (4 - length(crtx))) * crtx global out *= "" end if s2 in ["OnCitation", "Date", "BRADFORD", "EndOfEarth"] && ptr == "<=" global out *= "" if s2 == "Date" #ds = replace(DICT[s], r"\1" => s"\1.html") ds = replace(DICT[s], r"([^\"]+)" => s"\1.html") global DS = split(ds, ", ") global DICK = Dict() for shooter in shoot DICK[shooter] = 0 end for ddss in DS DICK[ddss] = 1 end k = keys(DICK) for kk in k if DICK[kk] == 0 push!(DATEPROBLEMS, kk[1:length(kk) - 5]) end end global DATEPROBLEMS = sort(DATEPROBLEMS) end elseif s2 != "welcome" || ptr != "<=" global out *= "\n" else losers = "" snoTOCs = sort(noTOCs) for item in snoTOCs loser = item[1:length(item) - 5] if loser == "welcome" continue end losers *= "" * loser * ", " end global out *= "\n" end global L2C1FirstPadding = false end gh = replace(replace(replace(string(ghosts), "\\\"" => "SHIT"), "\"" => "\""), "SHIT" => "\"") out *= (length(ghosts) == 0 ? "" : "") out = replace(out, "!QWERTY!" => string(crt), count=1) return(out) end # Shrink code by translating all internal links into 2 character codenames, so "#BRADFORD" might become "#bO" # This will break at 2705 files Alphas = [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] global Translates = Dict{String,String}() global trix = 0 function setID(fn) if length(fn) == 1 Translates[fn] = fn return end ch1 = div(trix,52) ch2 = trix - ch1 * 52 Translates[fn] = Alphas[ch1 + 1] * Alphas[ch2 + 1] global trix += 1 end try global errId = 1 a = readdir() for itm in a if findfirst(".html", itm) == nothing || itm in ignoreds continue end incoming[itm] = [] itmX = itm[1 : length(itm) - 5] setID(itmX) push!(AllRegisteredFiles, itmX) end z = open("IndexOfSubjects.html", "r") zz = String(read(z)) close(z) z = findall(r"
  • ", zz) FilesInIndexOfSubjects = [] for itm in z shitstain = replace(zz[itm], r"
  • " => s"\1,\2") shitstain = replace(shitstain, " " => "_") shitcomma = findfirst(",", shitstain).start firstshit = shitstain[1:shitcomma - 1] lastshit = shitstain[shitcomma + 1 : length(shitstain)] if firstshit != lastshit println("SHITSTAIN: \"", shitstain, "\"") exit(16) end if firstshit in FilesInIndexOfSubjects println("Duplicate in IndexOfSubjects: \"", shitstain, "\"") exit(16) end push!(FilesInIndexOfSubjects,firstshit) end for itm in AllRegisteredFiles if !(itm in FilesInIndexOfSubjects) println("** In AllRegisteredFiles but not in FilesInIndexOfSubjects: " , itm) end end for itm in FilesInIndexOfSubjects if !(itm in AllRegisteredFiles) println("** In FilesInIndexOfSubjects but not in In AllRegisteredFiles: " , itm) end end global errId = 2 vTable = [] for itm in keys(incoming) global pageCt += 1 item = itm f = open(item, "r") global errId = 4 res = read(f) sres = String(res) global errId = 5 close(f) global SZ += length(sres) x = findfirst("href=\"welcome.html#TOC\"", sres) if x == nothing push!(noTOCs,item) end global EXTERNAL_LINKS += length(findall(r"", sres)) if fns > 0 global FootnoteBlocks += 1 end global NYTComments += length(findall("Your comment has been approved!", sres)) global Bingers += length(findall("This page indexed on Bing", sres)) # " +2022.04.30 v002 " yyyyyy = findall(r">\+[0-9][0-9][0-9][0-9]\.[0-9][0-9]\.[0-9][0-9] v[0-9][0-9][0-9]", sres) yLen = length(yyyyyy) if yLen != 1 && !(item == "Experiment.html" && yLen == 3) # KLUDGE ErrorQuit("Versioning wrong in file: " * item) end # Police department if length(findall(r"({{|}})", sres)) != 0 ErrorQuit("Loose bracket(s): " * item) end if length(findall("size:larger;\"> = HighRevisions[i] #if rv == HighRevisions[i] # break #end if i == HRlen HighRevisions[HRlen] = rv break end nh = [] if i > 1 nh = HighRevisions[1:i - 1] end global HighRevisions = append!(nh, rv, HighRevisions[i:HRlen - 1]) break end end x = findall(r"href=\"[a-zA-Z0-9-_!]+\.html#[^\"]+", sres) y = [] for z in x w = sres[z] v = findfirst("#", w) push!(y, [w[7 : v.start - 6], w[v.start + 1 : length(w)]]) global IDct += 1 end #x = findall(r"href=\"#[^\"]+", sres) #for z in x # w = sres[z] # push!(y, ["", w[8 : length(w)]]) # global IDct += 1 #end ittm = itm[1 : length(itm) - 5] LWIDS[ittm] = y x = findall(r" id=\"[^\"]+", sres) y = [] for z in x push!(y, sres[z.start + 5 : z.stop]) global ID2ct += 1 end IDS[ittm] = y x = findall(r"&#[^;]+;", sres) for y in x z = sres[y] if z in HSYMS continue end push!(HSYMS, z) end if itm in excludeds global fdict[itm] = "[ Everything ]" continue end if findfirst(r"aplacetostudy"i, sres) != nothing println((item in ["Dashboard.html", "JSource.html"] ? "" : "** ") * "Aplacetostudy: " * item) end global MAPS += length(findall(" \"" * ss * "\".") end if !(itm in incoming[ss * ".html"]) push!(incoming[ss * ".html"], itm) end global linkCt += 1 end str = "" for x in sort(srefs, by=lowercase) str *= (str != "" ? ", " : "") * "" * x * "" end global fdict[itm] = str global ildict[itm] = iq = length(findall(r" "", count=1) t = t[1:length(t) - 1] if get(externalLinks, t, "!") == "!" externalLinks[t] = [itm] else if !(itm in externalLinks[t]) push!(externalLinks[t], itm) end end end end vTable = sort(vTable) global vDict = "global V = [\"" * replace(string(Dates.now()), r"T(.{8}).*" => s" \1") *"\", Dict{String,String}(\n" for item in vTable a = findfirst(" ", item) #vText *= item[a.start + 1:length(item)] * " " * item[1 : a.start - 1] * "\n" dictName = item[1 : a.start - 1] dictValue = item[a.start + 1:length(item)] global vDict *= " \"" * dictName * "\" => \"" * dictValue * "\",\n" dv = get!(szDict, dictValue, ["NOTHING"]) if dv == ["NOTHING"] szDict[dictValue] = [dictName] else szDict[dictValue] = append!(szDict[dictValue], [dictName]) end end shitshit = [] for k in keys(szDict) push!(shitshit, string(k)) end shitshit = sort(shitshit, rev=true) hiVersions = "" for i = 1 : 12 s = shitshit[i] hiVersions *= " " * s * " " * replace(string(szDict[s]), r"([\[\]\"]|\.html)" => "") * "\n" end szFile = open("SZ1", "w") write(szFile, hiVersions) close(szFile) catch ex s = string(ex) if length(s) > 200 s = s[1:200] * "..." end ErrorQuit("\n Failure[" * string(errId) * "]: " * string(typeof(ex)) * ".\n" * s); end lc = string(linkCt) if linkCt > 999 lenlc = length(lc) lc = lc[1:lenlc - 3] * "," * lc[lenlc - 2:lenlc] end global incoming2 = Dict{String, String}() for k in keys(incoming) ary = incoming[k] str = "" for x in sort(ary, by=lowercase) stp = x[1:length(x)-5] str *= (str != "" ? ", " : "") * "" * stp * "" end global incoming2[k] = str end T = makeTable(fdict, "=>") RT = makeTable(incoming2, "<=") global incoming2 = Dict{String, String}() for k in keys(externalLinks) if findfirst("https://faculty.washington.edu/walter/Killing%20Cats3.html#_edn", k) != nothing continue end ary = externalLinks[k] str = "" for x in sort(ary, by=lowercase) stp = x[1:length(x)-5] stp2 = "" if stp != "welcome" stp2 = "|" * stp end str *= (str != "" ? ", " : "") * "" * stp * "" # ZZZZZ end global incoming2[k] = str end XT = makeTable(incoming2, "<<=") XT = replace(XT, "!VICTORY!" => string(Validated), count=1) saveTable("Tree", T) saveTable("RTree", RT) saveTable("XTree", XT) println("\n--------\n") global ct = 0 global chksL = 0 global chksR = 0 shit = [] for x in keys(LWIDS) push!(shit, string(x)) end shitx = sort(shit) for k in shitx for kk in LWIDS[k] if kk[1]== "" # local links in same file global chksL += 1 if kk[2] in IDS[k] continue end spacer = "" if length(k) < 12 spacer = " " ^ (12 - length(k)) end println(k, spacer, " ? \"#" * kk[2] * "\"") global ct += 1 continue end global chksR += 1 if kk[2] in IDS[kk[1]] continue end spacer = "" if length(k) < 12 spacer = " " ^ (12 - length(k)) end println(k, spacer, " ? \"" * kk[1] * "#" * kk[2] * "\"") global ct += 1 end end #println("\n RLINKS: ", RLINKS, ", ILINKS: " , ILINKS, " (R: " , chksR, ". L: ", chksL, ") Errs: ", ct, ". (IDct: " , IDct, ")") println("\n RLINKS: ", RLINKS, ", ILINKS: " , ILINKS, " ", formatNumber(SZ), " Errs: ", ct, ". (IDct: " , IDct, ":", ID2ct, ")") #println("\n", join(HSYMS, ", ")) hrs = string(HighRevisions) println("\n NYTs: ", NYTComments, ". Bingers: ", Bingers, ". Rev/max: " * HI_GREEN * replace(hrs[5:length(hrs) - 1], "," => "") * HI_END * " (" * HI_GREEN * string(SumRevisions) * HI_END * ") " * HI_AQUA * "Good to go!" * HI_END) println("\n",length(DICK), "-", length(DS), "= ", length(DATEPROBLEMS), ". ",length(shoot), " ", DATEPROBLEMS) vFile = open("V1", "w") write(vFile, "# " * string(pageCt - 1) * " " * # Don't count IndexOfSubjects string(linkCt + EXTERNAL_LINKS + IMAGE_LINKS) * " sum(map((x) -> tryparse(Int32,string(x)), values(V[2])))\n" * vDict * ")]\n") close(vFile)
  • X !QWERTY! outgoing external links (several uninteresting items excluded):
    " * noww * "  (Validator: !VICTORY!)
    " * ohmygod * " " * ptr * "
    " * crtx * ". " * s * "" * ilss * " " * ptr * "
    [ TMTC: " * string(1 + length(findall(",", DICT[s]))) * " ]
    " * (ptr == "<=" && s2 == "IntoTheLight" ? "[ All incoming links remote ==> ]" : DICT[s]) * "
    !TOC[" * losers[1 : length(losers) - 2] * "]
    Ghosts: " * gh * "