]> gitweb.factorcode.org Git - factor.git/commitdiff
help.html: I give up with the article name escaping. Just compute a SHA1 hash and...
authorSlava Pestov <slava@factorcode.org>
Sat, 29 Oct 2011 22:26:52 +0000 (15:26 -0700)
committerSlava Pestov <slava@factorcode.org>
Sat, 29 Oct 2011 22:27:27 +0000 (15:27 -0700)
basis/help/html/html-tests.factor
basis/help/html/html.factor

index b4e6103868b92ce6be55acc90ce44602980095a4..1fe7ed5611c4f9cd0902f1f8956dff34bef03fbf 100644 (file)
@@ -1,9 +1,26 @@
-USING: help.html tools.test help.topics kernel sequences vocabs ;
+USING: help.html help.vocabs tools.test help.topics kernel sequences vocabs
+math ;
 IN: help.html.tests
 
 [ ] [ "xml" >link help>html drop ] unit-test
 
-[ "article-foobar.html" ] [ "foobar" >link topic>filename ] unit-test
+[ ] [ "foobar" >link topic>filename drop ] unit-test
+
+[ ] [ { "foo" "bar" } >link topic>filename drop ] unit-test
+
+[ ] [ \ + topic>filename drop ] unit-test
+
+[ ] [ \ + >link topic>filename drop ] unit-test
+
+[ ] [ "doesnotexist" >vocab-link topic>filename drop ] unit-test
+
+[ ] [ "kernel" lookup-vocab topic>filename drop ] unit-test
+
+[ ] [ "io" <vocab-tag> topic>filename drop ] unit-test
+
+[ ] [ "Steve Jobs" <vocab-author> topic>filename drop ] unit-test
+
+[ ] [ f topic>filename drop ] unit-test
 
 [ t ] [ all-vocabs-really [ vocab-spec? ] all? ] unit-test
 
index f19cd705e590cedb60bdafad12425470c9ace9a2..535fdd43b6e08bdff16d168be47bb356f663f8f5 100644 (file)
@@ -1,38 +1,16 @@
 ! Copyright (C) 2008, 2011 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io.encodings.utf8 io.encodings.binary io.files
-io.files.temp io.directories html.streams help help.home kernel
-assocs sequences make words accessors arrays help.topics vocabs
-vocabs.hierarchy help.vocabs namespaces prettyprint io
-vocabs.loader serialize fry memoize unicode.case math.order
-sorting debugger html xml.syntax xml.writer math.parser
-sets hashtables ;
+USING: checksums checksums.sha io.encodings.utf8
+io.encodings.binary io.encodings.string io.files io.files.temp
+io.directories html.streams help help.home kernel assocs
+sequences make words accessors arrays help.topics vocabs
+vocabs.hierarchy help.vocabs namespaces io vocabs.loader
+serialize fry memoize unicode.case math.order sorting debugger
+html xml.syntax xml.writer math.parser sets hashtables ;
 FROM: io.encodings.ascii => ascii ;
 FROM: ascii => ascii? ;
 IN: help.html
 
-: escape-char ( ch -- )
-    dup ascii? [
-        dup H{
-            { CHAR: " "__quo__" }
-            { CHAR: * "__star__" }
-            { CHAR: : "__colon__" }
-            { CHAR: < "__lt__" }
-            { CHAR: > "__gt__" }
-            { CHAR: ? "__que__" }
-            { CHAR: \\ "__back__" }
-            { CHAR: | "__pipe__" }
-            { CHAR: / "__slash__" }
-            { CHAR: , "__comma__" }
-            { CHAR: @ "__at__" }
-            { CHAR: # "__hash__" }
-            { CHAR: % "__percent__" }
-        } at [ % ] [ , ] ?if
-    ] [ number>string "__" "__" surround % ] if ;
-
-: escape-filename ( string -- filename )
-    [ [ escape-char ] each ] "" make ;
-
 GENERIC: topic>filename* ( topic -- name prefix )
 
 M: word topic>filename*
@@ -51,10 +29,9 @@ M: f topic>filename* drop \ f topic>filename* ;
     topic>filename* dup [
         [
             % "-" %
-            dup array?
-            [ [ escape-filename ] map "," join ]
-            [ escape-filename ]
-            if % ".html" %
+            dup array? [ "," join ] when
+            utf8 encode sha1 checksum-bytes hex-string
+            % ".html" %
         ] "" make
     ] [ 2drop f ] if ;