Coverage report: /development/source/library/org/datagraph/spocq-shard/src/core/encoding/sparql-query-olog.lisp

KindCoveredAll%
expression048 0.0
branch02 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; -*- Mode: lisp; Syntax: ansi-common-lisp; Base: 10; Package: org.datagraph.spocq.implementation; -*-
2
 
3
 (in-package :org.datagraph.spocq.implementation)
4
 
5
 
6
 (def-mime-type-key "SPARQL-QUERY+OLOG")
7
 (def-mime-type-key "SPARQL-QUERY+OLOG+TEX")
8
 (def-mime-type-key "SPARQL-QUERY+OLOG+SVG+XML")
9
 
10
 
11
 (def-mime-type ("APPLICATION" "SPARQL-QUERY+OLOG") ()
12
   ((de.setf.utility.implementation::charset
13
     :initform :utf-8)
14
    (de.setf.utility.implementation::file-type
15
     :initform "olog"))
16
   (:documentation "SPARQL query encoded as an OLOG"))
17
 
18
 
19
 (def-mime-type ("APPLICATION" "SPARQL-QUERY+OLOG+TEX") (mime::application/SPARQL-QUERY+OLOG)
20
   ()
21
   (:documentation "SPARQL query encoded as an OLOG as a tex tikz document"))
22
 
23
 (def-mime-type ("APPLICATION" "SPARQL-QUERY+OLOG+SVG+XML") (mime::application/SPARQL-QUERY+OLOG)
24
   ()
25
   (:documentation "SPARQL query encoded as an OLOG as a tex tikz document rendered to svg"))
26
 
27
 (defparameter *executable-pathname.tikztosvg* "/usr/local/texlive/2020/bin/x86_64-linux/tikztosvg")
28
 
29
 (defmethod send-response-message ((operation t) (tex-expression string) (response-stream stream) (content-type mime:application/sparql-query+olog+svg+xml))
30
   "Given a QUERY, and a STREAM with the application/sparql-query+olog+svg CONTENT-TYPE, render the query as olog+svg"
31
   (when *encoding-trace-output*
32
     (setf response-stream (make-broadcast-stream *encoding-trace-output* response-stream)))
33
   ;; the generation process did not behave well reading from standard input
34
   (let* ((tex-pathname (tmp-export-pathname (task-id *task*) "olog")))
35
     (unwind-protect
36
         (progn
37
           (with-open-file (tex-stream tex-pathname :direction :output :if-exists :error :if-does-not-exist :create)
38
             (write-string tex-expression tex-stream))
39
           (let ((process (run-program *executable-pathname.tikztosvg*
40
                                       `("-q" "-p" "tikz-cd" "-p" "xfrac" "-o" "/dev/stdout"
41
                                         ,(namestring tex-pathname))
42
                                       :output response-stream
43
                                       :wait t)))
44
             (unless (and process (zerop (run-program-exit-code process)))
45
               (http:internal-error "tikz-cd image generation failed."))
46
             (run-program-close process)
47
             (finish-output response-stream)
48
             (run-program-exit-code process)))
49
       (conditional-delete-file tex-pathname))))
50
 
51
 
52
 
53
 #|
54
 (send-response-message
55
 :query
56
 "\\begin{tikzcd}
57
 G \\arrow[r, \"\\varphi\"] \\arrow[d, \"\\psi\"', two heads] & H \\\\
58
 \\sfrac{G}{\\ker \\varphi} \\arrow[ru, dotted]           &  
59
 \\end{tikzcd}
60
 "
61
 *standard-output*
62
 mime:application/sparql-query+olog+svg+xml)
63
 
64
 curl -k -v -H "Accept: application/sparql-query+olog+svg+xml" \
65
   "https://nl4.dydra.com/james/test/olog.olog?query=%5Cbegin%7Btikzcd%7D%0AG%20%5Carrow%5Br%2C%20%22%5Cvarphi%22%5D%20%5Carrow%5Bd%2C%20%22%5Cpsi%22%27%2C%20two%20heads%5D%20%26%20H%20%5C%5C%0A%5Csfrac%7BG%7D%7B%5Cker%20%5Cvarphi%7D%20%5Carrow%5Bru%2C%20dotted%5D%20%20%20%20%20%20%20%20%20%20%20%26%20%20%0A%5Cend%7Btikzcd%7D%0A"
66
 |#