#| Copyright 2012,2013 Andrei Mikhailov This file is part of bystroTeX. bystroTeX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. bystroTeX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with bystroTeX. If not, see . |# (module common racket (require scribble/core scribble/base scribble/html-properties scribble/decode scriblib/render-cond) (require setup/dirs) (require mzlib/etc) (require racket/list) (require racket/vector) (require racket/path) ;; --------------------------------------------------------------------------------------------------- (define filename-of-scribble-file "") (provide (contract-out ; Set the path to the folder containing the .css files [register-path-to-scribble-file (-> path? void?)])) (define (register-path-to-scribble-file s) (set! filename-of-scribble-file (path->string (file-name-from-path s)))) ;; --------------------------------------------------------------------------------------------------- (define css-dir (build-path 'same)) (provide (contract-out ; Set the path to the folder containing the .css files [bystro-set-css-dir (-> path? void?)])) (define (bystro-set-css-dir x) (set! css-dir x)) ;; --------------------------------------------------------------------------------------------------- (provide (contract-out [bystro-inject-style (->* () #:rest (listof string?) element?)])) (define (bystro-inject-style . css-file-names) (let ((style (make-style #f (map (lambda (fn) (make-css-addition (build-path css-dir (string->path fn)))) css-file-names)))) (make-element style '()))) ;; --------------------------------------------------------------------------------------------------- (provide (contract-out ; Provides relative path for e.g.: ; @(hyperlink (bystro-path-to-link "../document.pdf") "here") [bystro-path-to-link (-> path-string? string?)])) (define bystro-path-to-link (lambda (relpath) (string-append "file://" (path->string (path->complete-path (expand-user-path relpath)))))) ;; --------------------------------------------------------------------------------------------------- (provide (contract-out ; javascript injection [bystro-js (->* () () #:rest (listof string?) element?)])) (define (bystro-js . body) (make-element (make-style #f (list (make-script-property "text/javascript" body))) '() )) ;; --------------------------------------------------------------------------------------------------- (provide (contract-out ; javascript from URL [bystro-js-url (-> string? element?)])) (define (bystro-js-url url) (bystro-js "document.write(\"