One Hat Cyber Team
Your IP :
216.73.216.115
Server IP :
194.44.31.54
Server :
Linux zen.imath.kiev.ua 4.18.0-553.77.1.el8_10.x86_64 #1 SMP Fri Oct 3 14:30:23 UTC 2025 x86_64
Server Software :
Apache/2.4.37 (Rocky Linux) OpenSSL/1.1.1k
PHP Version :
5.6.40
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
Macaulay2
/
Core
/
View File Name :
webapp.m2
-- Paul Zinn-Justin 2018-2022 needs "expressions.m2" needs "matrix1.m2" needs "monideal.m2" -- topLevelMode=WebApp definitions -- tags are required to help the browser app distinguish html from text webAppTags := apply((17,18,19,20,28,29,30,14,21,(17,36),(36,18)),ascii); ( webAppHtmlTag, -- indicates what follows is HTML ~ <span class='M2Html'> webAppEndTag, -- closing tag ~ </span> webAppCellTag, -- start of cell (bundled input + output) ~ <p> webAppCellEndTag, -- closing tag for cell ~ </p> webAppInputTag, -- it's text but it's input ~ <span class='M2Input'> webAppInputContdTag, -- text, continuation of input webAppUrlTag, -- used internally to follow URLs webAppPromptTag, -- input/output prompt webAppPositionTag, -- code position (row:col) webAppTexTag, -- effectively deprecated, ~ <span class='M2Html'> $ webAppTexEndTag -- effectively deprecated, ~ $ </span> )=webAppTags; webAppTagsRegex := concatenate("[",drop(webAppTags,-2),"]") -- output routines for WebApp mode recordPosition = () -> if currentFileName == "stdio" then ( -- for now only stdio recorded webAppPositionTag, -- toString currentFileName, -- ":", toString currentRowNumber(), -- not to be confused with lineNumber!!! ":", toString currentColumnNumber(), webAppEndTag ) ZZ#{WebApp,InputPrompt} = lineno -> concatenate( webAppCellEndTag, -- close previous cell webAppCellTag, webAppPromptTag, interpreterDepth:"i", toString lineno, webAppEndTag, " : ", webAppInputTag, recordPosition() ) ZZ#{WebApp,InputContinuationPrompt} = lineno -> concatenate( webAppInputContdTag, recordPosition() ) Thing#{WebApp,BeforePrint} = identity Nothing#{WebApp,Print} = identity printFunc := Thing#{WebApp,print} = x -> ( y := html x; -- we compute the html now (in case it produces an error) if class y =!= String then error "invalid html output"; << webAppHtmlTag | y | webAppEndTag << endl; ) on := () -> concatenate(webAppPromptTag,interpreterDepth:"o", toString lineNumber,webAppEndTag) Thing#{WebApp,Print} = x -> ( << endl << on() | " = "; printFunc x; ) InexactNumber#{WebApp,Print} = x -> withFullPrecision ( () -> Thing#{WebApp,Print} x ) -- afterprint htmlAfterPrint := x -> ( << endl << on() | " : "; if class x === Sequence then x = SPAN deepSplice { x }; printFunc x; ) Thing#{WebApp,AfterPrint} = x -> ( l:=lookup(AfterPrint,class x); if l === null then return; s:=l x; if s =!= null then htmlAfterPrint s ) Thing#{WebApp,AfterNoPrint} = x -> ( l:=lookup(AfterNoPrint,class x); if l === null then return; s:=l x; if s =!= null then htmlAfterPrint s ) removeWebAppTags = s -> if s === null then null else replace(webAppTagsRegex,"😀",s); if topLevelMode === WebApp then ( extractStr := x -> concatenate apply(x,y -> if instance(y,Hypertext) then extractStr y else if instance(y,String) then y); -- the help hack: if started in WebApp mode, help is compiled in it as well processExamplesLoop ExampleItem := (x->new LITERAL from extractStr x) @@ (lookup(processExamplesLoop,ExampleItem)); -- the help hack 2 (incidentally, this regex is safer than in standard mode) M2outputRE = "(?="|webAppCellTag|")"; -- the show/edit hack show URL := url -> (<< webAppUrlTag | url#0 | webAppEndTag;); editURL := f -> "#editor:"|toString f; editMethod String := editMethod FilePosition := f -> show editURL f; hypertext FilePosition := f -> SAMP HREF {editURL f,toString f}; -- redefine htmlLiteral to exclude codes htmlLiteral = removeWebAppTags @@ htmlLiteral; )