Skip to content

Commit

Permalink
Update theme and include plain_ex
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshtr committed Sep 24, 2023
1 parent 23f5b58 commit a97cfb2
Show file tree
Hide file tree
Showing 6 changed files with 2,169 additions and 7 deletions.
9 changes: 9 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import uuid
import shlex
import shutil
import tempfile

app = FastAPI()
Expand Down Expand Up @@ -38,6 +39,14 @@ async def compile(request: Request) -> Response:
temp_dir: str = tempfile.gettempdir()
id: str = get_unique_file_name()
mp_code: str = request_obj["code"]

if not mp_code.strip().endswith("end"):
mp_code += "\nend\n"

if "plain_ex" in mp_code:
shutil.copyfile(os.path.join('static', 'plain_ex.mp'),
os.path.join(temp_dir, 'plain_ex.mp'))

with open(os.path.join(temp_dir, id + ".mp"), "w") as file_object:
file_object.write(mp_code)
file_object.close()
Expand Down
4 changes: 2 additions & 2 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ z2 = (x1+250, y1+250);
z3 = (x2+250, y1);
z4 = (x2, y0);
pickup calligraphicpen;
draw z0..z1..z2..z3..z4 withcolor blue;
draw z0..z1..z2..z3..z4 withcolor white;
endfig;
end
`
Expand Down Expand Up @@ -44,7 +44,7 @@ document.addEventListener("DOMContentLoaded", (event) => {
{
lineNumbers: true,
mode: "metapost",
theme: "default",
theme: "nord",
value: placeholdercode
});
editor.on("change", (editor) => {
Expand Down
42 changes: 42 additions & 0 deletions static/nord.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Based on arcticicestudio's Nord theme */
/* https://github.com/arcticicestudio/nord */

.cm-s-nord.CodeMirror { background: #2e3440; color: #d8dee9; }
.cm-s-nord div.CodeMirror-selected { background: #434c5e; }
.cm-s-nord .CodeMirror-line::selection, .cm-s-nord .CodeMirror-line > span::selection, .cm-s-nord .CodeMirror-line > span > span::selection { background: #3b4252; }
.cm-s-nord .CodeMirror-line::-moz-selection, .cm-s-nord .CodeMirror-line > span::-moz-selection, .cm-s-nord .CodeMirror-line > span > span::-moz-selection { background: #3b4252; }
.cm-s-nord .CodeMirror-gutters { background: #2e3440; border-right: 0px; }
.cm-s-nord .CodeMirror-guttermarker { color: #4c566a; }
.cm-s-nord .CodeMirror-guttermarker-subtle { color: #4c566a; }
.cm-s-nord .CodeMirror-linenumber { color: #4c566a; }
.cm-s-nord .CodeMirror-cursor { border-left: 1px solid #f8f8f0; }

.cm-s-nord span.cm-comment { color: #4c566a; }
.cm-s-nord span.cm-atom { color: #b48ead; }
.cm-s-nord span.cm-number { color: #b48ead; }

.cm-s-nord span.cm-comment.cm-attribute { color: #97b757; }
.cm-s-nord span.cm-comment.cm-def { color: #bc9262; }
.cm-s-nord span.cm-comment.cm-tag { color: #bc6283; }
.cm-s-nord span.cm-comment.cm-type { color: #5998a6; }

.cm-s-nord span.cm-property, .cm-s-nord span.cm-attribute { color: #8FBCBB; }
.cm-s-nord span.cm-keyword { color: #81A1C1; }
.cm-s-nord span.cm-builtin { color: #81A1C1; }
.cm-s-nord span.cm-string { color: #A3BE8C; }

.cm-s-nord span.cm-variable { color: #d8dee9; }
.cm-s-nord span.cm-variable-2 { color: #d8dee9; }
.cm-s-nord span.cm-variable-3, .cm-s-nord span.cm-type { color: #d8dee9; }
.cm-s-nord span.cm-def { color: #8FBCBB; }
.cm-s-nord span.cm-bracket { color: #81A1C1; }
.cm-s-nord span.cm-tag { color: #bf616a; }
.cm-s-nord span.cm-header { color: #b48ead; }
.cm-s-nord span.cm-link { color: #b48ead; }
.cm-s-nord span.cm-error { background: #bf616a; color: #f8f8f0; }

.cm-s-nord .CodeMirror-activeline-background { background: #3b4252; }
.cm-s-nord .CodeMirror-matchingbracket {
text-decoration: underline;
color: white !important;
}
Loading

0 comments on commit a97cfb2

Please sign in to comment.