Download Jar. Libraryless. Click here for Pure Java version (5448L/41K).
!7 static new ThreadLocal<Bool> youtubeOff; static int perPage = 20; sS rawSelfLink(S uri) { ret "/blog" + addSlashPrefix(uri); } html { S vis = registerVisitor(); S domain = domain(); print("domain: " + domain); if (swic(domain, "javax.")) { pcall { O result = callHtmlMethod2(getBot(#1020398), uri, params); print("Result: " + className(result)); ret result; } } /*if (startsWith(uri, "/.well-known/pki-validation/")) ret subBot_serveText(loadTextFile(userDir("validation.txt")));*/ tempSetThreadLocal(youtubeOff, eq("1", params.get('youtubeOff)) || eqOneOf(params.get('youtube), "0", "off", "no")); O[] linkStyle = litobjectarray("style", "color: inherit; text-decoration: underline"); uri = dropPrefix("/", uri); int page = startsWithDigit(uri) ? parseFirstInt(uri) : 1; LS allPosts = ll( imagePost("2019/04/04", "Whenever my language bores me", #1101627, "40%", p("...I shorten it. Let's say I want to make a big input field with full persistence and switchable font size (like you see on the right). Then I write " + ahref("http://tinybrain.de/1022742", "this") + ":") + [[<pre style="clear: both"><span title="compact module (sharing common code)" style="border-bottom: dotted 1px">cmodule</span> BigInput { <span title="short for: String" style="border-bottom: dotted 1px">S</span> text; // auto-persisted string field <span title="A field that can be changed through the module's popup menu" style="border-bottom: dotted 1px">switchable</span> int fontSize = 40; <span title="short definition of the visualize() function" style="border-bottom: dotted 1px">visual</span> <a title="setFontSize" style="text-decoration: none; color: black; border-bottom: dotted 1px" href="http://tinybrain.de:8080/tb/show-snippet.php?id=1007197">setFontSize</a>(fontSize, <a title="dm_textArea - synonym of dm_fieldTextArea" style="text-decoration: none; color: black; border-bottom: dotted 1px" href="http://tinybrain.de:8080/tb/show-snippet.php?id=1021496">dm_textArea</a>(<span title="string constant, "text"" style="border-bottom: dotted 1px">'text</span>)); }</pre>]] + p("(I just created the 2 new JavaX syntax constructs " + ahref("http://tinybrain.de/1022743", "'switchable'") + " and " + ahref("http://tinybrain.de/1022746", "'visual'") + " in like 10 minutes. Hover over the source code for more info.) —" + ahref("http://botcompany.de/1004590/raw/1101628", "Automatic popup menu.")) ), imagePost("2018/06/16", "New Look&Feel", #1016391, "30%", p([[Pretty, isn't it. Look&Feel is called ]] + ahref("http://jtattoo.net", "JTattoo") + [[.]]) + p([[Image was made with the automatic screenshot module on a very old Windows 7 machine where my OS runs flawlessly.]]), left := true) , textPost("2018/06/15", "Fixing the last memory leaks in Java 10", [[ <p>I submitted this <a href="https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8204963">bug report</a> to Oracle, and I'm making super-fancy functions like <a href="http://tinybrain.de/1016334">cleanDefunctACCsInAllThreads</a> that automatically fix memory leaks other Java programmers have never heard of.</p> <p>We will sail memory leak-free! :)</p> ]]) + [[ <!-- A single blog post --> <section class="post"> <header class="post-header"> <img width="48" height="48" title="Stefan Reich's avatar" class="post-avatar" src="]] + snippetImgLink(#1101324) + [["> <h2 class="post-title">New Module: YouTube Downloader</h2> <p class="post-meta"> By <a href="mailto:info@botcompany.de" class="post-author">Stefan Reich</a> @ 2018/06/14 </p> </header> <div class="post-description" style="clear: both"> <div style="float: right; width: 50%"> <a href="https://botcompany.de/1004590/raw/1101311"> <img title="" class="pure-img-responsive" src="https://botcompany.de/1004590/raw/1101311" style="width: 100%"> </a> </div> <p> Today we launched <b>bla bla bla</b>. </p> <p> </p> <p>(No, seriously—we actually did. There is an awesome YouTube downloader in my <a href="http://exe.tinybrain.de/">operating system</a>. I'm just too lazy to write.)</p> <p>Now I need an awesome screenshot module and an awesome auto-upload-to-blog module.</p> </div> </section> ]]); // end of posts LS posts = subList(allPosts, (page-1)*perPage, page*perPage); bool hasPrev = page > 1, hasNext = l(allPosts) > page*perPage; S nav = !hasNext && !hasPrev ? "" : hsection(joinNempties(" | ", hasPrev ? ahref(rawSelfLink(str(page-1)), "Last page") : "", ahref("http://javax.botcompany.de/1020398/raw/contact", "Imprint"), hasNext ? ahref(rawSelfLink(str(page+1)), "Next page") : ""), class := "post", style := "text-align: right"); S html = [[ <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>BotCompany.de</title> <link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" crossorigin="anonymous"> <link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/grids-responsive-min.css"> <link rel="stylesheet" href="css/layouts/blog.css"> </head> ]] + hcss(loadSnippet_cached(#1008309)) + [[<body>]] + [[<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/cookie-bar/cookiebar-latest.min.js?tracking=1&always=1"></script>]] + [[ <div id="layout" class="pure-g"> <div class="sidebar pure-u-1 pure-u-md-1-4"> <div class="header"> <h1 class="brand-title"><a href="https://www.BotCompany.de">Bot]] + html_invisibleSpace() + [[Company</a></h1> <h2 class="brand-tagline">English & German Chat Bots</h2> <nav class="nav"> ]] + tag('ul, li(a("JAVAX", class := "pure-button", href := "http://javax.botcompany.de"), class := "nav-item") + " " + li(a("GERMAN DEMO BOT", class := "pure-button", href := "http://www.web-woody-lab.de/", target := "_blank"), class := "nav-item") + " " + li(a("DISCORD GROUP", class := "pure-button", href := "https://discordapp.com/invite/SEAjPqk", target := "_blank"), class := "nav-item") + " " + li(a("Download Windows", class := "pure-button", href := "https://www.botcompany.de/files/1400170/Stefans%20OS%20Installer.exe"), class := "nav-item") + " " + + li(a("Download Mac/Linux", title := "Install Java first (from java.com)", class := "pure-button", href := "https://www.botcompany.de/files/1400169/Stefans%20OS.jar"), class := "nav-item") + " " + li(a("Videos", class := "pure-button", href := "http://youtube.tinybrain.de/"), class := "nav-item") //, class := "nav-list") + " " + //tag('ul, li(a("Meetings", class := "pure-button", target := "_blank", href := "http://aimeetup.tinybrain.de/"), class := "nav-item") //, class := "nav-list") + " " + //tag('ul, li(a("Slides", class := "pure-button", target := "_blank", href := "https://slides.com/stefanreich"), class := "nav-item") , class := "nav-list") + [[ </nav> <p> </p> <p><a style="text-decoration: none; color: white" href="https://www.botcompany.de:8443/1013826/raw"><b>Stefan's OS</b></a><br> is an inspiring Java program you can <a style="text-decoration: underline; color: white" href="https://www.botcompany.de:8443/1013826/raw">try out</a> in Windows, Mac OS or Linux.</p> ]] + p(" ") + youtubi("jt8j8llwBa8", 150) + "<br>" + small("(good music)") + [[ </div> </div> <div class="content pure-u-1 pure-u-md-3-4"> <div> <div class="posts"> <!--<h1 class="content-subhead">Recent News</h1>--> ]] + hcss([[ pre { margin-left: 20px; font-weight: bold; } ]]) + nav + lines(posts) + nav + [[ </div> <div class="footer"> <div class="pure-menu pure-menu-horizontal"> <ul> <li class="pure-menu-item" id="visitors"></li> <li class="pure-menu-item"><a href="https://www.botcompany.de:8443/1013826/raw" class="pure-menu-link">More</a></li> <li class="pure-menu-item"><a href="http://youtube.tinybrain.de/" class="pure-menu-link">YouTube</a></li> <li class="pure-menu-item"><a href="http://javax.botcompany.de/1020398/raw/contact" class="pure-menu-link">Impressum</a></li> </ul> </div> </div> </div> </div> </div> </body> </html> ]]; ret html.replace("\"css/layouts/blog.css\"", htmlQuote(rawSnippetURL(#1016322, "text/css"))) .replaceFirst(regexpQuote("<body>"), "<body>" + hSilentComputatorWithFlag("homepage")); } sS textPost(S date, S title, S text) { ret invtag('section, class := "post", style := "clear: both", invtag('header, class := "post-header", invtag('img, width := 48, height := 48, title := "Stefan Reich's avatar", class := "post-avatar", src := snippetImgLink(#1101324)) + [[ <h2 class="post-title">]] + title + [[</h2> <p class="post-meta"> By <a href="mailto:info@botcompany.de" class="post-author">Stefan Reich</a> @ ]] + date + [[ </p> ]]) + [[ <div class="post-description"> ]] + text + [[ </div>]]); } sS imagePost(S date, S title, S imageID, S width, S text, O... opt) { bool left = optParam(opt, 'left, false); S picLink = stringParam(opt, 'picLink); ret textPost(date, title, invtag('div, style := "float: " + (left ? "left" : "right") + "; width: " + width + "; margin-bottom: 30px; margin-" + (left ? "right" : "left") + ": 30px;", ahref(or2(picLink, snippetImageLink(imageID)), invTag('img, title := "", class := "pure-img-responsive", src := snippetImageLink(imageID), style := "width: 100%"))) + text); } sS youtubi(S url) { ret isTrue(youtubeOff!) ? "" : youtubeEmbed_newer(url); } sS youtubi(S url, int width) { ret isTrue(youtubeOff!) ? "" : youtubeEmbed_newer(url, width); } sS youtubi(S url, int width, int height) { ret isTrue(youtubeOff!) ? "" : youtubeEmbed_newer(url, width, height); }
Began life as a copy of #1016323
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022824 |
Snippet name: | Blog Bot with chat bot [dev.] |
Eternal ID of this version: | #1022824/2 |
Text MD5: | d0c9ed5b3bf9771370bf1de8ce8ede47 |
Transpilation MD5: | 43dc7e4e66ab77bed8a31b5aa6308ec5 |
Author: | stefan |
Category: | javax / html |
Type: | JavaX module (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-09 20:30:20 |
Source code size: | 11859 bytes / 233 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 356 / 1374 |
Version history: | 1 change(s) |
Referenced in: | -