Libraryless. Click here for Pure Java version (10959L/76K/234K).
!7 static S text, title; concept Text { S conceptID; S title; S text; S by; } p { db(); indexConceptField(Text, 'conceptID); indexConceptField(Text, 'by); load("text"); load("title"); if (isMainProgram()) serveHttpAndOpenBrowser(); } synchronized html { uri = dropPrefix("/", uri); if (possibleGlobalID(uri)) { S id = uri; Text t = findConcept(Text, conceptID := id); ret t == null ? "Text with ID " + id + " not found" : p(ahref(botLink(), "<< back")) + h3(t.conceptID + " - " + dynamize(or2(t.title, "Untitled"))) + textFormat(t.text) + p("by " + t.by); } S newTitle = params.get("title"); if (newTitle != null) { title = newTitle; save("title"); } S newText = params.get("text"); if (newText != null) { text = newText; save("text"); } S user = cookieConcept(); S msg = ""; if (nempty(params.get("publish"))) { Text t = uniq_sync(Text, +title, +text, by := user); if (empty(t.conceptID)) cset(t, conceptID := aGlobalID()); msg = "Published as: " + t.conceptID; } S list = p("Published texts: " + join(", ", map(func(Text t) { ahref(selfLink(t.conceptID), t.conceptID) }, list(Text)))); ret (empty(msg) ? "" : p(msg)) + list + p("You are: " + or2(user, "?")) + hpostform([[ <style type="text/css" media="screen"> #editor { width: 600px; height: 350px; } </style> <table><tr><td> </td></tr> Title: <input type="text" name="title" value="#TITLE#<>"> <tr><td> <div id="editor">#TEXT#<></div> <script src="http://tinybrain.de:8080/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script> <script src="http://tinybrain.de:8080/ace-builds/src-noconflict/ext-language_tools.js" type="text/javascript" charset="utf-8"></script> <script> ace.require("ace/ext/language_tools"); var editor = ace.edit("editor"); editor.setTheme("ace/theme/ambience"); //editor.getSession().setMode("ace/mode/lua"); editor.getSession().setTabSize(2); editor.getSession().setUseSoftTabs(true); editor.getSession().setUseWrapMode(true); document.getElementById('editor').style.fontSize='15px'; editor.setOptions({ enableBasicAutocompletion: true }); editor.focus(); </script> <input type="hidden" name="text" value=""> </td></tr> <tr><td> <input type="submit" value="Save"> <br><br> <input type="submit" name="publish" value="Publish this text"> </td></tr></table> ]].replace("#TITLE#<>", htmlencode(title)) .replace("#TEXT#<>", htmlencode(text)), onSubmit := "if (editor) text.value = editor.getValue(); return true;"); } sS textFormat(S text) { ret div(pre(dynamize(text)), style := "padding-left: 1em; padding-top: 0.5em; padding-bottom: 0.5em; background-color: #EEEEEE; border-style: solid; border-color: #666666; border-width: 1px 0px 1px 0px;"); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009208 |
Snippet name: | Ace Editor Test [syntax-enhanced editor for web pages, WORKS] |
Eternal ID of this version: | #1009208/24 |
Text MD5: | 69bb6aa539d78fb43a38f00046d0cba7 |
Transpilation MD5: | 820d9124544357107a727c7c29983642 |
Author: | stefan |
Category: | javax / html |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-07-17 00:34:12 |
Source code size: | 3091 bytes / 105 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 600 / 867 |
Version history: | 23 change(s) |
Referenced in: | -