diff --git a/collects/help/bug-report.ss b/collects/help/bug-report.ss
deleted file mode 100644
index 984597fd62..0000000000
--- a/collects/help/bug-report.ss
+++ /dev/null
@@ -1,542 +0,0 @@
-
-(module bug-report mzscheme
- (require (lib "string-constant.ss" "string-constants")
- (lib "head.ss" "net")
- (lib "mred.ss" "mred")
- (lib "framework.ss" "framework")
- (lib "class.ss")
- (lib "etc.ss")
- (lib "list.ss")
- (lib "url.ss" "net")
- (lib "uri-codec.ss" "net")
- (lib "htmltext.ss" "browser")
- (lib "dirs.ss" "setup")
- "private/buginfo.ss"
- "private/manuals.ss")
-
- (provide help-desk:report-bug)
-
- (define bug-www-server "bugs.plt-scheme.org")
- (define bug-www-server-port 80)
-
- ;; this one should be defined by help desk.
- (define frame-mixin
- (namespace-variable-value 'help-desk:frame-mixin #f (lambda () (lambda (x) x))))
-
- (preferences:set-default 'drscheme:email "" string?)
- (preferences:set-default 'drscheme:full-name "" string?)
-
- (define bug-frame%
- (class (frame-mixin (frame:standard-menus-mixin frame:basic%))
- (init title)
-
- ;; a bunch of stuff we don't want
- (define/override (file-menu:between-print-and-close menu) (void))
- (define/override (edit-menu:between-find-and-preferences menu) (void))
- (define/override (file-menu:create-open?) #f)
- (define/override (file-menu:create-open-recent?) #f)
- (define/override (file-menu:create-new?) #f)
- (define/override (file-menu:create-save?) #f)
- (define/override (file-menu:create-revert?) #f)
-
- (field (ok-to-close? #f))
- (public set-ok-to-close)
- (define (set-ok-to-close ok?) (set! ok-to-close? #t))
- (define/augment (can-close?)
- (or ok-to-close?
- (ask-yes-or-no (string-constant cancel-bug-report?)
- (string-constant are-you-sure-cancel-bug-report?)
- this)))
-
- (super-make-object title)))
-
-
- (define (help-desk:report-bug)
- (define bug-frame (instantiate bug-frame% () (title (string-constant bug-report-form))))
- (define single (new panel:single% (parent (send bug-frame get-area-container))))
- (define outermost-panel (make-object vertical-panel% single))
-
- (define response-panel (new vertical-panel% (parent single)))
- (define response-text (new (html-text-mixin text%) (auto-wrap #t)))
- (define response-ec (new editor-canvas% (parent response-panel) (editor response-text)))
- (define response-button-panel (new horizontal-panel%
- (stretchable-height #f)
- (parent response-panel)
- (alignment '(right center))))
- (define cancel-kill-thread #f)
- (define response-reset (new button%
- (parent response-button-panel)
- (enabled #f)
- (label (string-constant dialog-back))
- (callback
- (lambda (x y)
- (switch-to-compose-view)))))
- (define response-abort (new button%
- (parent response-button-panel)
- (enabled #f)
- (callback
- (lambda (x y)
- (kill-thread cancel-kill-thread)
- (switch-to-compose-view)))
- (label (string-constant abort))))
- (define response-close (new button%
- (parent response-button-panel)
- (enabled #f)
- (callback (lambda (x y) (cleanup-frame)))
- (label (string-constant close))))
- (define stupid-internal-define-syntax1
- (new grow-box-spacer-pane% (parent response-button-panel)))
-
- (define top-panel (make-object vertical-panel% outermost-panel))
-
- (define (switch-to-response-view)
- (send response-text lock #f)
- (send response-text erase)
- (render-html-to-text ; hack to get nice text in
- (open-input-string
- "
" '(p)] - [(title . path) (mk-link path title)]) - (let loop ([breaks (sec-seps sec)] - [names+paths names+paths]) - (cond - [(null? breaks) names+paths] - [else - (let ([break (car breaks)]) - (loop (cdr breaks) - (break-between (car breaks) names+paths)))]))))))) - - ;; break-between : regexp - ;; (listof (union string (cons string string))) - ;; -> (listof (union string (cons string string))) - ;; adds the para-mark string into the list at the first place - ;; that the regexp fails to match (not counting other para-marks - ;; in the list) - (define (break-between re l) - (let ([para-mark "
"]) - (let loop ([l l]) - (cond - [(null? l) null] - [else - (let ([fst (car l)]) - (cond - [(pair? fst) - (let ([name (car fst)]) - (if (regexp-match re name) - (cons para-mark l) - (cons fst (loop (cdr l)))))] - [else (cons fst (loop (cdr l)))]))])))) - - - ;; mk-link : string string -> xexpr - (define (mk-link doc-path name) - (let* ([manual-name (basename doc-path)] - [index-file (get-index-file doc-path)]) - `(li (a ((href ,(get-help-url (build-path doc-path index-file)))) - ,name) - ,@(cond - [(and (repos-or-nightly-build?) - (file-exists? (build-path doc-path index-file))) - `((br) - 'nbsp - 'nbsp - (font ((size "-1")) - ,@(if (is-known-doc? doc-path) - (list - "[" - `(a ((mzscheme - ,(to-string/escape-quotes - `((dynamic-require '(lib "refresh-manuals.ss" "help") 'refresh-manuals) - (list (cons ((dynamic-require '(lib "refresh-manuals.ss" "help") 'bytes-to-path) - ,(path->bytes manual-name)) - ,name)))))) - ,(string-constant plt:hd:refresh)) - "]" 'nbsp) - (list))))] - [else - (list - (format (string-constant plt:hd:manual-installed-date) - (date->string - (seconds->date - (file-or-directory-modify-seconds - (build-path doc-path index-file))))))])))) - - (define (to-string/escape-quotes exp) - (regexp-replace* #rx"\"" (format "~s" exp) "|")) - - ;; get-doc-name : path -> string - (define cached-doc-names (make-hash-table 'equal)) - (define (get-doc-name doc-dir) - (hash-table-get cached-doc-names doc-dir - (lambda () - (let ([res (compute-doc-name doc-dir)]) - (hash-table-put! cached-doc-names doc-dir res) - res)))) - - ;; compute-doc-name : path -> string[title of manual] - ;; gets the title either from the known docs list, by parsing the - ;; html, or if both those fail, by using the name of the directory - ;; Special-cases the help collection. It's not a known doc directory - ;; per se, so it won't appear in known-docs, but its name is always - ;; the same. - (define (compute-doc-name doc-dir) - (let ([doc-short-dir-name (basename doc-dir)]) - (cond - [(equal? (string->path "help") doc-short-dir-name) "PLT Help Desk"] - [(get-known-doc-name doc-dir) => values] - [else (let* ([main-file (get-index-file doc-dir)] - [m (and main-file - (call-with-input-file (build-path doc-dir main-file) - (lambda (inp) (regexp-match re:title inp))))]) - (if m - (bytes->string/utf-8 (cadr m)) - (path->string doc-short-dir-name)))]))) - (define re:title - #rx"<[tT][iI][tT][lL][eE]>[ \t\r\n]*(.*?)[ \t\r\n]*[tT][iI][tT][lL][eE]>") - - ;; is-known-doc? : string[path] -> boolean - (define (is-known-doc? doc-path) - (and (assoc (basename doc-path) known-docs) #t)) - - ;; get-known-doc-name : string[full-path] -> (union string #f) - (define (get-known-doc-name doc-path) - (cond [(assoc (basename doc-path) known-docs) => cdr] [else #f])) - - ;; get-uninstalled : (listof path) -> (listof (cons path string[docs-name])) - (define (get-uninstalled docs) - (let ([ht (make-hash-table 'equal)]) - (for-each (lambda (known-doc) - (hash-table-put! ht - (car known-doc) - (cdr known-doc))) - known-docs) - (for-each (lambda (doc) (hash-table-remove! ht (basename doc))) docs) - (sort (hash-table-map ht cons) - (λ (a b) (compare-docs (car a) (car b)))))) - - (define (compare-docs a b) - (let ([ap (standard-html-doc-position (basename a))] - [bp (standard-html-doc-position (basename b))]) - (cond [(= ap bp) (string (path->string a) (path->string b))] - [else (< ap bp)]))) - - ;; get-manual-index : string -> html - (define (get-manual-index manual-dirname) (get-help-url (build-path (find-doc-dir) manual-dirname))) - - ;; get-index-file : path -> (union #f path) - ;; returns the name of the main file, if one can be found - (define (get-index-file doc-dir) - (cond - [(file-exists? (build-path doc-dir "index.htm")) - (build-path "index.htm")] - [(file-exists? (build-path doc-dir "index.html")) - (build-path "index.html")] - [(tex2page-detected doc-dir) - => - (lambda (x) x)] - [else #f])) - - ;; tex2page-detected : string -> (union #f string) - (define (tex2page-detected dir) - (let loop ([contents (directory-list dir)]) - (cond - [(null? contents) #f] - [else (let* ([file (car contents)] - [m (regexp-match #rx#"(.*)-Z-H-1.html" (path->bytes file))]) - (or (and m - (file-exists? (build-path dir file)) - (let ([index-file - (bytes->path - (bytes-append (cadr m) #".html"))]) - (if (file-exists? (build-path dir index-file)) - index-file - #f))) - (loop (cdr contents))))]))) - - - (provide find-manuals - main-manual-page - finddoc - finddoc-page-anchor) - - (provide/contract [manual-entry (string? string? xexpr? . -> . xexpr?)] - [finddoc-page (string? string? . -> . string?)] - [get-doc-name (path? . -> . string?)] - [find-doc-directories (-> (listof path?))] - [find-doc-directory (path? . -> . (or/c false/c path?))] - [find-doc-names (-> (listof (cons/c path? string?)))] - [get-manual-index (-> string? string?)] - [get-index-file (path? . -> . (or/c false/c path?))])) diff --git a/collects/help/private/options.ss b/collects/help/private/options.ss deleted file mode 100644 index d3e54d264a..0000000000 --- a/collects/help/private/options.ss +++ /dev/null @@ -1,22 +0,0 @@ -(module options mzscheme - - ;; This module provides configuration options that are shared - ;; between servlets and the web-server. (Mostly to allow - ;; configuration as an application or as a standalone server.) - - (provide helpdesk-platform internal-port) - - ;; internal browser or external browser? - ;; (used to produce simpler html for the internal browser) - (define helpdesk-platform - (make-parameter - 'internal-browser-simple ; main page only - ;; 'internal-browser ; menu + main page - ;; 'external-browser - )) - - ;; Port for the server to listen on - ;; (relevant only for a standalone server) - (define internal-port (make-parameter 8012)) - - ) diff --git a/collects/help/private/path.ss b/collects/help/private/path.ss deleted file mode 100644 index f842a3ae08..0000000000 --- a/collects/help/private/path.ss +++ /dev/null @@ -1,10 +0,0 @@ -(module path mzscheme - (require (lib "contract.ss")) - (define (servlet-path? path) - (if (regexp-match #rx#"^/servlets/" - (path->bytes path)) - #t - #f)) - (provide/contract - [servlet-path? (path? . -> . boolean?)])) - diff --git a/collects/help/private/search.ss b/collects/help/private/search.ss deleted file mode 100644 index 3c20106433..0000000000 --- a/collects/help/private/search.ss +++ /dev/null @@ -1,604 +0,0 @@ -(module search mzscheme - (require (lib "string-constant.ss" "string-constants") - "colldocs.ss" - "path.ss" - "manuals.ss" - (lib "port.ss") - (lib "getinfo.ss" "setup") - (lib "list.ss") - (lib "plt-match.ss") - (lib "contract.ss") - (lib "dirs.ss" "setup")) - - (provide doc-collections-changed - reset-doc-lists - extract-doc-txt - load-txt-keywords-into-hash-table) - (provide/contract - [do-search - (string? - number? - boolean? - boolean? - (listof path?) - boolean? - any/c - (-> any) - (string? any/c . -> . void?) - (string? any/c . -> . void?) - (string? string? string? path? (or/c string? number? false/c) any/c . -> . void?) - . -> . - (or/c string? false/c))] - - (build-string-finds/finds (string? - boolean? - boolean? - . -> . - (values (listof string?) - (listof (or/c regexp? string?))))) - - (non-regexp (string? . -> . string?))) - - (define doc-dirs (get-doc-search-dirs)) - - ; These are set by reset-doc-lists: - ; docs, doc-names and doc-kinds are parallel lists. doc-kinds - ; distinguishes between the two variants of docs. - ; docs : (list-of (union string (list path string))) - (define docs null) - ; doc-names : (list-of string) - (define doc-names null) - ; doc-kinds : (list-of symbol) - (define doc-kinds null) - ; doc-collection-date : (union #f number 'none) - (define doc-collection-dates (map (lambda (x) #f) doc-dirs)) - - (define (dir-date/none dir) - (with-handlers ([exn:fail:filesystem? (lambda (x) 'none)]) - (file-or-directory-modify-seconds dir))) - - (define (reset-doc-lists) - ; Locate standard HTML documentation - (define-values (std-docs std-doc-names) - (let* ([docs (find-doc-directories)] - [doc-names (map get-doc-name docs)]) - (values docs doc-names))) - - ; Check collections for doc.txt files: - (define-values (txt-docs txt-doc-names) (colldocs)) - - (set! docs (append std-docs txt-docs)) - - (set! doc-names (append - std-doc-names - (map (lambda (s) (format "the ~a" s)) - txt-doc-names))) - (set! doc-kinds (append (map (lambda (x) 'html) std-docs) (map (lambda (x) 'text) txt-docs))) - - (set! doc-collection-dates (map dir-date/none doc-dirs))) - - (define MAX-HIT-COUNT 300) - - (define (clean-html s) - (regexp-replace* - "&[^;]*;" - (regexp-replace* - "<[^>]*>" - (regexp-replace* - "&" - (regexp-replace* - ">" - (regexp-replace* - "<" - s - "<") - ">") - "\\&") - "") - "")) - - (define (with-hash-table ht key compute) - (hash-table-get - ht - key - (lambda () - (let ([v (compute)]) - (hash-table-put! ht key v) - v)))) - - (define html-keywords (make-hash-table 'equal)) - (define (load-html-keywords doc) - (with-hash-table - html-keywords - doc - (lambda () - (transform-keywords - (build-path doc "keywords"))))) - - (define html-indices (make-hash-table 'equal)) - (define (load-html-index doc) - (with-hash-table - html-indices - doc - (lambda () - (transform-hdindex - (build-path doc "hdindex"))))) - - ;; transform-hdindex : any -> (listof (list string path string string) - ;; makes sure the input from the file is well-formed and changes - ;; the bytes to paths. - (define (transform-hdindex filename) - (verify-file filename - (λ (l) - (match l - [`(,(? string? index) - ,(? string? file) - ,(? string? label) - ,(? string? title)) - #t] - [else - #f])))) - - ;; transform-keywords : any -> (listof (list string string path string string) - ;; as with transform-hdindex - (define (transform-keywords filename) - (verify-file filename - (λ (l) - (match l - [`(,(? string? keyword) - ,(? string? result) - ,(? path-string? file) - ,(? string? label) - ,(? string? title)) - #t] - [else - #f])))) - - (define (verify-file filename ele-ok?) - (let/ec k - (let ([fail (lambda (why) - (fprintf (current-error-port) - "loading docs from ~a failed: ~a\n" - (path->string filename) - why) - (k '()))]) - (with-handlers ([exn:fail:read? (lambda (x) - (fail - (format "read error when opening the file ~a" - (exn-message x))))] - [exn:fail:filesystem? - (lambda (x) - (fail (format - "filesystem error when opening the file ~a" - (exn-message x))))]) - (let ([l (if (file-exists? filename) - (call-with-input-file filename read) - '())]) - (unless (list? l) (fail "not a list")) - (for-each (lambda (l) - (unless (ele-ok? l) - (fail (format "line ~s is malformed" l)))) - l) - l))))) - - (define (parse-txt-file doc ht handle-parsing) - (with-hash-table - ht - doc - (lambda () - (with-handlers ([exn:fail:filesystem? (lambda (x) null)]) - (call-with-input-file doc - handle-parsing))))) - - (define re:keyword-line (regexp "\n>")) - (define text-keywords (make-hash-table 'equal)) - - (define (load-txt-keywords doc) - (load-txt-keywords-into-hash-table text-keywords doc)) - - (define (load-txt-keywords-into-hash-table ht doc) - (parse-txt-file - (apply build-path doc) - ht - (λ (p) - (port-count-lines! p) - (let loop () - (let ([m (regexp-match re:keyword-line p)]) - (cond - [m - (let/ec k - (let* ([peek-port (let-values ([(line col pos) (port-next-location p)]) - (let ([pp (peeking-input-port p)]) - (port-count-lines! pp) - (let ([rp (relocate-input-port pp line col pos)]) - (port-count-lines! rp) - rp)))] - [entry (parameterize ([read-accept-bar-quote #f]) - (with-handlers ([exn:fail:read? - (lambda (x) - (fprintf (current-error-port) - "found > on line ~a in ~s that did not parse properly\n first-line: ~a\n exn-msg: ~a\n" - (let-values ([(line col pos) (port-next-location p)]) - line) - (path->string (apply build-path doc)) - (read-line (peeking-input-port p)) - (exn-message x)) - (k null))]) - (read peek-port)))] - [key (let loop ([l-entry entry]) - (cond - [(symbol? l-entry) l-entry] - [(keyword? l-entry) l-entry] - [(pair? l-entry) (if (and (eq? (car l-entry) 'quote) - (pair? (cdr l-entry))) - (loop (cadr l-entry)) - (loop (car l-entry)))] - [else (fprintf (current-error-port) "load-txt-keyword: bad entry in ~s: ~s\n" doc entry) - #f]))] - [content (if (symbol? entry) - (with-handlers ([exn:fail:read? (lambda (x) #f)]) - (let ([s (read peek-port)]) - (if (eq? s '::) - (format "~s ~s ~s" entry s (read peek-port)) - #f))) - #f)] - [txt-to-display - (let ([p (open-output-string)]) - (if content - (display content p) - (if (and (pair? entry) - (pair? (cdr entry)) - (eq? (car entry) 'quote)) - (fprintf p "'~s" (cadr entry)) - (display entry p))) - (get-output-string p))] - [kwd-entry - (and key - ; Make the keyword entry: - (list (format "~s" key) ; the keyword name - txt-to-display ; the text to display - (cadr doc) ; file - (let-values ([(line col pos) (port-next-location p)]) - (- pos 2)) ; label (a position in this case) - "doc.txt"))]) - (if kwd-entry - (cons kwd-entry (loop)) - (loop))))] ; title - [else null])))))) - - (define re:index-line (regexp "_([^_]*)_(.*)")) - (define text-indices (make-hash-table 'equal)) - (define (load-txt-index doc) - (parse-txt-file - (apply build-path doc) - text-indices - (λ (p) - (let loop ([start 0]) - (let* ([r (read-line p 'any)] - [next (if (eof-object? r) - start - (+ start (string-length r) 1))]) - (cond - [(eof-object? r) null] - [(regexp-match re:index-line r) - => - (lambda (m) - (append (let loop ([m m]) - (let ([s (cadr m)]) - (cons - ; Make an index entry: - (cons s start) - (let ([m (regexp-match re:index-line (caddr m))]) - (if m - (loop m) - null))))) - (loop next)))] - [else (loop next)])))))) - - (define re:splitter (regexp "^ *([^ ]+)(.*)")) - (define (split-words s) - (let ([m (regexp-match re:splitter s)]) - (if m - (cons (cadr m) - (split-words (caddr m))) - null))) - - ;; non-regexp : string -> string - (define (non-regexp s) - (list->string - (apply - append - (map - (lambda (c) - (cond - [(memq c '(#\$ #\| #\\ #\[ #\] #\. #\* #\? #\+ #\( #\) #\^)) - (list #\\ c)] - [(char-alphabetic? c) - (list #\[ (char-upcase c) (char-downcase c) #\])] - [else (list c)])) - (string->list s))))) - - (define (doc-collections-changed) - (reset-relevant-directories-state!) - (reset-doc-lists) - (set! doc-collection-dates (map (lambda (x) #f) doc-dirs)) - (set! html-keywords (make-hash-table 'equal)) - (set! html-indices (make-hash-table 'equal)) - (set! text-keywords (make-hash-table 'equal)) - (set! text-indices (make-hash-table 'equal))) - - (define max-reached #f) - - (define (build-string-finds/finds given-find regexp? exact?) - (cond - [exact? (values (list given-find) - (list given-find))] - [regexp? (values (list given-find) - (list (regexp given-find)))] - [else (let ([wl (split-words given-find)]) - (values wl - (map regexp (map non-regexp wl))))])) - - ; do-search : (string ; the search text, unprocessed - ; num ; 0 = keyword, 1 = keyword+index, 2 = all text - ; boolean ; #t if string should be used as a regexp - ; boolean ; #t if the string should match exactly (not just "contains") - ; (listof path) ; the manuals to search - ; boolean ; #t if the doc.txt files should be searched - ; value ; arbitrary key supplied to the "add" functions - ; (-> A) ; called when more than enough are found; must escape - ; (string value -> void) ; called to output a document section header (e.g., a manual name) - ; (symbol value -> void) ; called to output a document-kind section header, 'text or 'html - ; (string string string path (union string #f) value -> void) - ; ^ ^ ^ ^ ^- label within page - ; ^ ^ ^ ^- path to doc page - ; ^ ^ ^- source doc title - ; ^ ^- display label - ; ^- found entry's key - ; -> - ; (union string #f)) - (define (do-search given-find search-level regexp? exact? manuals doc-txt? - ckey maxxed-out - add-doc-section add-kind-section add-choice) - ; When new docs are installed, the directory's modification date changes: - (set! max-reached #f) - - (when (ormap (lambda (date new-date) - (cond - [(not date) #t] - [(equal? date new-date) #f] - [(eq? date 'none) #t] - [(eq? new-date 'none) #t] - [else (new-date . > . date)])) - doc-collection-dates - (map dir-date/none doc-dirs)) - (reset-doc-lists)) - - (let ([hit-count 0]) - (let-values ([(string-finds finds) (build-string-finds/finds given-find regexp? exact?)] - [(filtered-docs filtered-doc-names filtered-doc-kinds) - (filter-docs manuals doc-txt?)]) - (for-each - (lambda (doc doc-name doc-kind) - (define found-one #f) - (define (found kind) - (unless found-one - (add-doc-section doc-name ckey)) - (unless (equal? found-one kind) - (set! found-one kind) - (add-kind-section kind ckey)) - (set! hit-count (add1 hit-count)) - (unless (< hit-count MAX-HIT-COUNT) - (maxxed-out))) - - ; Keyword search - (let ([keys (case doc-kind - [(html) (load-html-keywords doc)] - [(text) (load-txt-keywords doc)] - [else null])] - [add-key-choice (lambda (v) - (when (and (pair? v) - (pair? (cdr v)) - (pair? (cddr v)) - (pair? (cdddr v)) - (pair? (cddddr v))) - (found "keyword entries") - (add-choice - (car v) ; key - (cadr v) ; display - (list-ref v 4) ; title - (if (eq? 'text doc-kind) - (apply build-path doc) - (let ([file (bytes->path - (string->bytes/utf-8 - (list-ref v 2)))]) - (if (servlet-path? file) - file - (build-path doc file)))) - (list-ref v 3) ; label - ckey)))]) - - (unless regexp? - (for-each - (lambda (v) - (when (string=? given-find (car v)) - (add-key-choice v))) - keys)) - (unless (or exact? (null? finds)) - (for-each - (lambda (v) - (when (andmap (lambda (find) (regexp-match find (car v))) finds) - (unless (and (not regexp?) (string=? given-find (car v))) - (add-key-choice v)))) - keys))) - - ; Index search - (unless (< search-level 1) - (let ([index (case doc-kind - [(html) (load-html-index doc)] - [(text) (load-txt-index doc)] - [else null])] - [add-index-choice (lambda (name desc) - (case doc-kind - [(html) - (when (and (pair? desc) - (pair? (cdr desc)) - (pair? (cddr desc))) - (found "index entries") - (add-choice - "" name - (list-ref desc 2) - (let ([filename (bytes->path (string->bytes/utf-8 (list-ref desc 0)))]) - (if (servlet-path? filename) - filename - (build-path doc filename))) - (list-ref desc 1) - ckey))] - [(text) - (found "index entries") - (add-choice - "" name - "indexed content" - (apply build-path doc) - desc - ckey)]))]) - (when index - (unless regexp? - (for-each - (lambda (v) - (when (string=? given-find (car v)) - (add-index-choice (car v) (cdr v)))) - index)) - (unless (or exact? (null? finds)) - (for-each - (lambda (v) - (when (andmap (lambda (find) (regexp-match find (car v))) finds) - (unless (and (not regexp?) (string=? given-find (car v))) - (add-index-choice (car v) (cdr v))))) - index))))) - - ; Content Search - (unless (or (< search-level 2) exact? (null? finds)) - (let ([files (case doc-kind - [(html) (with-handlers ([exn:fail:filesystem? (lambda (x) null)]) - (map (lambda (x) (build-path doc x)) - (filter - (lambda (x) - (let ([str (path->string x)]) - (cond - [(or (regexp-match "--h\\.idx$" str) - (regexp-match "--h\\.ind$" str) - (regexp-match "Z-A\\.scm$" str) - (regexp-match "Z-L\\.scm$" str) - (regexp-match "gif$" str) - (regexp-match "png$" str) - (regexp-match "hdindex$" str) - (regexp-match "keywords$" str)) - #f] - [else - (file-exists? (build-path doc x))]))) - (directory-list doc))))] - [(text) (list (apply build-path doc))] - [else null])]) - (for-each - (lambda (f) - (with-handlers ([exn:fail:filesystem? (lambda (x) #f)]) - (with-input-from-file f - (lambda () - (let loop () - (let ([pos (file-position (current-input-port))] - [r (read-line)]) - (unless (eof-object? r) - (let ([m (andmap (lambda (find) (regexp-match find r)) finds)]) - (when m - (found "text") - (add-choice (car m) - ; Strip leading space and clean HTML - (regexp-replace - "^ [ ]*" - (if (eq? doc-kind 'html) - (clean-html r) - r) - "") - "content" - f - (if (eq? doc-kind 'text) pos "NO TAG") - ckey))) - (loop)))))))) - files)))) - filtered-docs filtered-doc-names filtered-doc-kinds) - - (if (= 0 hit-count) - (format (string-constant plt:hd:nothing-found-for) - (if (null? string-finds) - "" - (apply - string-append - (cons (format "\"~a\"" (car string-finds)) - (map (lambda (i) (format " ~a \"~a\"" (string-constant plt:hd:and) i)) - (cdr string-finds)))))) - #f)))) - - ;; filter-docs : (listof path) boolean -> (values docs[sublist] doc-names[sublist] doc-kinds[sublist]) - ;; given the list of manuals specified by `manuals', returns the sublists of the global - ;; variables docs, doc-names, and doc-kinds that make sense for this search. - (define (filter-docs manuals doc-txt?) - (let loop ([manuals manuals]) - (cond - [(null? manuals) (if doc-txt? - (extract-doc-txt) - (values null null null))] - [else (let ([man (car manuals)]) - (let-values ([(r-doc r-doc-names r-doc-kinds) (loop (cdr manuals))] - [(t-doc t-doc-names t-doc-kinds) (find-doc man)]) - (if t-doc - (values (cons t-doc r-doc) - (cons t-doc-names r-doc-names) - (cons t-doc-kinds r-doc-kinds)) - (values r-doc - r-doc-names - r-doc-kinds))))]))) - - ;; find-doc : - ;; path -> (values doc[element of docs] doc-name[element of doc-names] doc-kind[element of doc-kinds]) - (define (find-doc man) - (let loop ([x-docs docs] - [x-doc-names doc-names] - [x-doc-kinds doc-kinds]) - (cond - [(and (null? x-docs) (null? x-doc-names) (null? x-doc-kinds)) - (values #f #f #f)] - [(or (null? x-docs) (null? x-doc-names) (null? x-doc-kinds)) - (error 'find-doc "mismatched lists\n")] - [else - (let ([doc (car x-docs)]) - (cond - [(eq? 'html (car x-doc-kinds)) - (let-values ([(base name dir?) (split-path doc)]) - (cond - [(equal? man name) - (values doc (car x-doc-names) (car x-doc-kinds))] - [else (loop (cdr x-docs) (cdr x-doc-names) (cdr x-doc-kinds))]))] - [else (loop (cdr x-docs) (cdr x-doc-names) (cdr x-doc-kinds))]))]))) - - ;; extract-doc-txt : (listof string) boolean -> (values docs[sublist] doc-names[sublist] doc-kinds[sublist]) - ;; returns the manuals that are not 'html. - (define (extract-doc-txt) - (let loop ([x-docs docs] - [x-doc-names doc-names] - [x-doc-kinds doc-kinds]) - (cond - [(null? x-docs) (values null null null)] - [(or (null? x-doc-names) (null? x-doc-kinds)) - (error 'extract-doc-txt "mismatched lists\n")] - [else - (if (eq? (car x-doc-kinds) 'html) - (loop (cdr x-docs) (cdr x-doc-names) (cdr x-doc-kinds)) - (let-values ([(r-docs r-doc-names r-doc-kinds) (loop (cdr x-docs) - (cdr x-doc-names) - (cdr x-doc-kinds))]) - (values (cons (car x-docs) r-docs) - (cons (car x-doc-names) r-doc-names) - (cons (car x-doc-kinds) r-doc-kinds))))])))) - - diff --git a/collects/help/private/sig.ss b/collects/help/private/sig.ss deleted file mode 100644 index 4ab77349d5..0000000000 --- a/collects/help/private/sig.ss +++ /dev/null @@ -1,18 +0,0 @@ -(module sig mzscheme - (require (lib "unit.ss")) - (provide gui^ - main^) - - (define-signature main^ - (add-help-desk-font-prefs)) - - (define-signature gui^ - (help-desk-frame<%> - add-help-desk-mixin - new-help-desk - find-help-desk-frame - show-help-desk - goto-hd-location - goto-manual-link - search-for-docs - search-for-docs/in-frame))) diff --git a/collects/help/private/standard-urls.ss b/collects/help/private/standard-urls.ss deleted file mode 100644 index 33a4654597..0000000000 --- a/collects/help/private/standard-urls.ss +++ /dev/null @@ -1,134 +0,0 @@ -(module standard-urls mzscheme - (require (lib "uri-codec.ss" "net") - (lib "dirs.ss" "setup") - (lib "contract.ss") - (lib "config.ss" "planet") - (lib "help-desk-urls.ss" "help") - "../servlets/private/util.ss" - "internal-hp.ss" - "get-help-url.ss") - - (provide home-page-url host+dirs) - - (define (search-type? x) - (member x '("keyword" "keyword-index" "keyword-index-text"))) - - (define (search-how? x) - (member x '("exact-match" "containing-match" "regexp-match"))) - - (define (base-docs-url) - (if (repos-or-nightly-build?) - "http://pre.plt-scheme.org/docs" - (string-append "http://download.plt-scheme.org/doc/" (version)))) - - (define (make-docs-plt-url manual-name) - (format "~a/bundles/~a-doc.plt" (base-docs-url) manual-name)) - - (define (make-docs-html-url manual-name) - (format "~a/html/~a/index.htm" (base-docs-url) manual-name)) - - (define (prefix-with-server suffix) - (format "http://~a:~a~a" internal-host (internal-port) suffix)) - - (define results-url-prefix (format "http://~a:~a/servlets/results.ss?" internal-host (internal-port))) - (define flush-manuals-path "/servlets/results.ss?flush=yes") - (define flush-manuals-url (format "http://~a:~a~a" internal-host (internal-port) flush-manuals-path)) - - - (define relative-results-url-prefix "/servlets/results.ss?") - - (define home-page-url (format "http://~a:~a/servlets/home.ss" internal-host (internal-port))) - - (define (make-missing-manual-url coll name link) - (format "http://~a:~a/servlets/missing-manual.ss?manual=~a&name=~a&link=~a" - internal-host - (internal-port) - coll - (uri-encode name) - (uri-encode link))) - - (define (make-relative-results-url search-string search-type match-type lucky? manuals doc.txt? lang-name) - (string-append - relative-results-url-prefix - (make-results-url-args search-string search-type match-type lucky? manuals doc.txt? lang-name))) - - (define (make-results-url search-string search-type match-type lucky? manuals doc.txt? lang-name) - (string-append - results-url-prefix - (make-results-url-args search-string search-type match-type lucky? manuals doc.txt? lang-name))) - - (define (make-results-url-args search-string search-type match-type lucky? manuals doc.txt? language-name) - (let ([start - (format - (string-append "search-string=~a&" - "search-type=~a&" - "match-type=~a&" - "lucky=~a&" - "manuals=~a&" - "doctxt=~a") - (uri-encode search-string) - search-type - match-type - (if lucky? "true" "false") - (uri-encode (format "~s" (map path->bytes manuals))) - (if doc.txt? "true" "false"))]) - (if language-name - (string-append start (format "&langname=~a" (uri-encode language-name))) - start))) - - ; sym, string assoc list - (define hd-locations - `((hd-tour ,(format "~a/index.html" (get-help-url (build-path (find-doc-dir) "tour")))) - (release-notes ,url-helpdesk-release-notes) - (plt-license ,url-helpdesk-license) - (front-page ,url-helpdesk-home))) - - (define hd-location-syms (map car hd-locations)) - - (define (get-hd-location sym) - ; the assq is guarded by the contract - (cadr (assq sym hd-locations))) - - ; host+dirs : (list (cons host-string dir-path)) - ; association between internal (in normal Helpdesk also virtual) - ; hosts and their corresponding file root. - (define host+dirs - (map cons - (append collects-hosts doc-hosts) - (append collects-dirs doc-dirs))) - - (define (host+file->path host file-path) - (cond [(assoc host host+dirs) - => (lambda (internal-host+path) - (let ([path (cdr internal-host+path)]) - (build-path path file-path)))] - [(equal? host "planet") - (build-path (PLANET-DIR) file-path)] - [else #f])) - - (provide host+file->path) - (provide search-type? search-how?) - (provide/contract - (make-relative-results-url (string? - search-type? - search-how? - any/c - (listof path?) - any/c - (or/c false/c string?) . -> . string?)) - (make-results-url (string? - search-type? search-how? any/c - (listof path?) - any/c - (or/c false/c string?) - . -> . - string?)) - (flush-manuals-url string?) - (flush-manuals-path string?) - (make-missing-manual-url (string? string? string? . -> . string?)) - (get-hd-location ((lambda (sym) (memq sym hd-location-syms)) - . -> . - string?)) - [prefix-with-server (string? . -> . string?)] - [make-docs-plt-url (string? . -> . string?)] - [make-docs-html-url (string? . -> . string?)])) diff --git a/collects/help/private/tcp-intercept.ss b/collects/help/private/tcp-intercept.ss deleted file mode 100644 index 2630ec8e21..0000000000 --- a/collects/help/private/tcp-intercept.ss +++ /dev/null @@ -1,117 +0,0 @@ -(module tcp-intercept mzscheme - (provide tcp-intercept@ url-intercept@) - - (require (lib "unit.ss") - (lib "etc.ss") - (lib "web-server-sig.ss" "web-server") - (lib "tcp-sig.ss" "net") - (lib "url-sig.ss" "net") - "internal-hp.ss") - - (define-syntax (redefine stx) - (syntax-case stx () - [(_ names ...) - (with-syntax ([(defs ...) (map (lambda (x) - (with-syntax ([orig-name x] - [raw-name - (datum->syntax-object - x - (string->symbol - (string-append - "raw:" - (symbol->string (syntax-object->datum x)))))]) - (syntax (define orig-name raw-name)))) - (syntax->list (syntax (names ...))))]) - (syntax (begin defs ...)))])) - - (define-unit url-intercept@ (import (prefix raw: url^)) (export url^) - (init-depend url^) - (redefine url->string - get-pure-port - get-impure-port - post-pure-port - post-impure-port - head-pure-port - head-impure-port - put-pure-port - put-impure-port - delete-pure-port - delete-impure-port - display-pure-port - purify-port - netscape/string->url - string->url - call/input-url - combine-url/relative - url-exception? - current-proxy-servers)) - - (define raw:tcp-abandon-port tcp-abandon-port) - (define raw:tcp-accept tcp-accept) - (define raw:tcp-accept/enable-break tcp-accept/enable-break) - (define raw:tcp-accept-ready? tcp-accept-ready?) - (define raw:tcp-addresses tcp-addresses) - (define raw:tcp-close tcp-close) - (define raw:tcp-connect tcp-connect) - (define raw:tcp-connect/enable-break tcp-connect/enable-break) - (define raw:tcp-listen tcp-listen) - (define raw:tcp-listener? tcp-listener?) - - ; For tcp-listeners, we use an else branch in the conds since - ; (instead of a contract) I want the same error message as the raw - ; primitive for bad inputs. - - ; : (listof nat) -> (unit/sig () -> net:tcp^) - (define-unit tcp-intercept@ (import web-server^) (export tcp^) - - ; : port -> void - (define (tcp-abandon-port tcp-port) - (cond - [(tcp-port? tcp-port) - (raw:tcp-abandon-port tcp-port)] - [(input-port? tcp-port) - (close-input-port tcp-port)] - [(output-port? tcp-port) - (close-output-port tcp-port)] - [else (void)])) - - ; : listener -> iport oport - (define tcp-accept raw:tcp-accept) - ; : listener -> iport oport - (define tcp-accept/enable-break raw:tcp-accept/enable-break) - - ; : tcp-listener -> iport oport - (define tcp-accept-ready? raw:tcp-accept-ready?) - - ; : tcp-port -> str str - (define (tcp-addresses tcp-port) - (if (tcp-port? tcp-port) - (raw:tcp-addresses tcp-port) - (values "127.0.0.1" internal-host))) - - ; : port -> void - (define tcp-close raw:tcp-close) - - ; : (str nat -> iport oport) -> str nat -> iport oport - (define (gen-tcp-connect raw) - (lambda (hostname-string port) - (if (and (is-internal-host? hostname-string) - (equal? (internal-port) port)) - (let-values ([(req-in req-out) (make-pipe)] - [(resp-in resp-out) (make-pipe)]) - (parameterize ([current-custodian (make-custodian)]) - (serve-ports req-in resp-out)) - (values resp-in req-out)) - (raw hostname-string port)))) - - ; : str nat -> iport oport - (define tcp-connect (gen-tcp-connect raw:tcp-connect)) - - ; : str nat -> iport oport - (define tcp-connect/enable-break (gen-tcp-connect raw:tcp-connect/enable-break)) - - ; FIX - support the reuse? flag. - (define tcp-listen raw:tcp-listen) - - ; : tst -> bool - (define tcp-listener? raw:tcp-listener?))) diff --git a/collects/help/refresh-manuals.ss b/collects/help/refresh-manuals.ss deleted file mode 100644 index e4c31fb3a6..0000000000 --- a/collects/help/refresh-manuals.ss +++ /dev/null @@ -1,232 +0,0 @@ -(module refresh-manuals mzscheme - (require "private/docpos.ss" - "private/search.ss" - "private/manuals.ss" - "private/standard-urls.ss" - "private/link.ss" - (lib "plt-installer.ss" "setup") - (lib "url.ss" "net") - (lib "mred.ss" "mred") - (lib "string-constant.ss" "string-constants") - (lib "contract.ss") - (lib "port.ss") - (lib "thread.ss")) - - (provide refresh-manuals - bytes-to-path) - - - (define sc-refreshing-manuals (string-constant plt:hd:refreshing-manuals)) - (define sc-refresh-downloading... (string-constant plt:hd:refresh-downloading...)) - (define sc-refresh-deleting... (string-constant plt:hd:refresh-deleting...)) - (define sc-refresh-installing... (string-constant plt:hd:refresh-installing...)) - (define sc-finished-installation (string-constant plt:hd:refreshing-manuals-finished)) - (define sc-clearing-cached-indicies (string-constant plt:hd:refresh-clearing-indicies)) - - (define refresh-manuals - (case-lambda - [() (refresh-manuals known-docs)] - [(docs-to-install) - (unless (and (list? docs-to-install) - (andmap (lambda (x) (and (pair? x) - (path? (car x)) - (string? (cdr x)))) - docs-to-install)) - (error 'refresh-manuals "expected (listof (cons path string)) as argument, got ~e" docs-to-install)) - (let ([tmp-directory (find/create-temporary-docs-dir)] - [success? #f] - [thd #f]) - (with-installer-window - (lambda (parent) - (set! thd (current-thread)) - (unless tmp-directory - (error 'plt-installer "please clean out ~a" (find-system-path 'temp-dir))) - (let ([docs-error (download-docs docs-to-install tmp-directory)]) - (cond - [docs-error - (printf "~a\n" docs-error)] - [else - (delete-docs docs-to-install) - (install-docs docs-to-install tmp-directory parent) - (delete-local-plt-files tmp-directory) - (display sc-clearing-cached-indicies) - (newline) - - ;; tell the web-server to visit the url for flushing the cache - ;; this is necc. because the server creates a new namespace for - ;; each servlet, so we have to get the webserver to visit the servlet - ;; in order to flush the cache. We don't, however, want to actually - ;; visit the page, so we just do this for its effect. - (let-values ([(in1 out1) (make-pipe)] - [(in2 out2) (make-pipe)]) - (thread (lambda () - (fprintf out1 "GET ~a HTTP/1.0\r\n" flush-manuals-path) - (close-output-port out1))) - (serve-ports in1 out2) ;; spawns its own thread - (let loop () - (let ([b (with-handlers ([exn? (lambda (x) eof)]) - (read-byte in2))]) - (unless (eof-object? b) - (loop)))) - (close-input-port in2))]) - - (display sc-finished-installation) - (newline) - (set! success? #t))) - (lambda () - (unless success? - (delete-local-plt-files tmp-directory)) - (kill-thread thd))))])) - - ; needed in "../private/manuals.ss" due to links with > getting mangled - (define bytes-to-path bytes->path) - - (define (make-local-doc-filename tmp-dir stub) - (build-path tmp-dir (format "~a-doc.plt" stub))) - - ;; if cannot find a suitable directory, #f is returned - ;; if okay, returns the path to the directory. - (define find/create-temporary-docs-dir - ;(-> (union string? false?)) - (lambda () - (let ([temp-dir (find-system-path 'temp-dir)]) - (let loop ([n 0]) - (if (= n 30) - #f - (let ([candidate (build-path temp-dir (format "help-refresh-docs~a" n))]) - (if (directory-exists? candidate) - (loop (+ n 1)) - (begin - (make-directory candidate) - candidate)))))))) - - - - - - - ;; ;;; ;; - ; ; ; - ; ; ; - ;;;; ;;; ;;; ;;;; ;;; ; ;;; ;;;; ;;;; - ; ; ; ; ; ; ;; ; ; ; ; ; ; ; - ; ; ; ; ; ; ; ; ; ; ; ; ;;;; ; ; - ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; - ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; - ;;; ; ;;; ; ; ;;; ;; ;;;;;; ;;; ;;; ; ;;; ; - - - - - ;; download-docs : ... -> (union #f string) - ;; downloads the docs to the tmp-dir - (define download-docs - (lambda (docs-to-install tmp-dir) - (let loop ([known-docs docs-to-install]) - (cond - [(null? known-docs) #f] - [else (let* ([known-doc (car known-docs)] - [resp (download-doc tmp-dir (car known-doc) (cdr known-doc))]) - (if (string? resp) - resp - (loop (cdr known-docs))))])))) - - ;; download-doc : ... -> (union #f string) - ;; stub is the `drscheme' portion of `drscheme-doc.plt'. - (define download-doc - (lambda (tmp-dir stub full-name) - (let ([url (make-docs-plt-url (path->string stub))] - [doc-name (make-local-doc-filename tmp-dir stub)]) - (display (format sc-refresh-downloading... full-name)) - (newline) - (call-with-output-file doc-name - (lambda (out-port) - (call/input-url (string->url url) - get-impure-port - (lambda (in-port) - (let/ec k - (let* ([resp (purify-port in-port)] - [m (regexp-match #rx"HTTP/[^ ]* ([0-9]+)([^\r\n]*)" resp)]) - (unless m - (k "malformed response from server ~s" resp)) - (let ([code (string->number (cadr m))]) - (unless (equal? code 200) - (k (format "error response from server \"~a~a\"" code (caddr m))))) - (copy-port in-port out-port) - #f))))))))) - - - - ;; ;;; - ; ; ; - ; ; ; - ;;;; ;;; ; ;;; ;;;;; ;;; - ; ; ; ; ; ; ; ; ; ; - ; ; ;;;;; ; ;;;;; ; ;;;;; - ; ; ; ; ; ; ; - ; ; ; ; ; ; ; ; ; ; ; - ;;; ; ;;; ;;;;;; ;;; ;;; ;;; - - - - (define delete-docs - (lambda (docs) - (for-each (lambda (known-doc) (delete-known-doc (car known-doc) (cdr known-doc))) - docs))) - - (define delete-known-doc - (lambda (doc full-name) - (let ([doc-dir (find-doc-directory doc)]) - (when doc-dir - (display (format sc-refresh-deleting... full-name)) - (newline) - (with-handlers ([exn:fail:filesystem? - (lambda (exn) - (fprintf (current-error-port) - "Warning: delete failed: ~a\n" - (exn-message exn)))]) - (delete-directory/r doc-dir)))))) - - (define delete-local-plt-files - (lambda (tmp-dir) - (delete-directory/r tmp-dir))) - - ;; deletes the entire subtree underneath this directory - ;; (including the dir itself) - (define delete-directory/r - (lambda (dir) - (when (directory-exists? dir) - (let loop ([dir dir]) - (let ([children (directory-list dir)]) - (for-each (lambda (f) (when (file-exists? (build-path dir f)) - (delete-file (build-path dir f)))) - children) - (for-each (lambda (d) (when (directory-exists? (build-path dir d)) - (loop (build-path dir d)))) - children) - (delete-directory dir)))))) - - - - ; ;;; ;;; - ; ; ; - ; ; ; - ;;; ; ;;; ;;; ;;;;; ;;;; ; ; - ; ;; ; ; ; ; ; ; ; - ; ; ; ;;; ; ;;;; ; ; - ; ; ; ; ; ; ; ; ; - ; ; ; ; ; ; ; ; ; ; ; - ;;;;; ;;; ;; ;;; ;;; ;;; ; ;;;;;; ;;;;;; - - - - (define install-docs - (lambda (docs-to-install tmp-dir parent) - (for-each (lambda (pr) - (display (format sc-refresh-installing... (cdr pr))) - (newline) - (run-single-installer (make-local-doc-filename tmp-dir (car pr)) - (lambda () - (error 'install-docs - "expected PLT-relative archive")))) - docs-to-install))))