Mercurial Hosting > lang
view src/edit_course.html.luan @ 52:27758f3b2d69
add hide_ruby
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 16 Aug 2025 09:56:10 +0900 |
parents | a119fc092f42 |
children | 285029931499 |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Html = require "luan:Html.luan" local html_encode = Html.encode or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Shared = require "site:/lib/Shared.luan" local head = Shared.head or error() local header = Shared.header or error() local User = require "site:/lib/User.luan" local current_user = User.current_required or error() local Course = require "site:/lib/Course.luan" local get_course_by_id = Course.get_by_id or error() return function() local user = current_user() if user == nil then return end local course_id = Http.request.parameters.course local course if course_id ~= nil then course = get_course_by_id(course_id) or error() course.user_id == user.id or error() else course = Course.new{ language = Http.request.parameters.language or error() name = "" ai_system_prompt = "" ai_first_message = "" tts_instructions = "" has_ruby = false } end Io.stdout = Http.response.text_writer() %> <!doctype html> <html lang="en"> <head> <% head() %> <style> input[type=text], textarea { display: block; width: 100%; } h4 { margin-top: 22px; margin-bottom: 4px; } input[type=submit] { margin-top: 22px; margin-bottom: 22px; } </style> </head> <body> <% header() %> <form content onsubmit="ajaxForm('/save_course.js',this)" action="javascript:"> <input type=hidden name=language value="<%=course.language%>"> <% if course_id ~= nil then %> <input type=hidden name=course value="<%=course_id%>"> <% end %> <h1>Edit Course</h1> <h3><%= course.language_name() %></h3> <h4>Course name</h4> <input type=text required name=name value="<%=html_encode(course.name)%>"> <p><label clickable><input type=checkbox name=has_ruby <%= course.has_ruby and "checked" or "" %> > Has pronunciation like {japanese|romaji}</label></p> <h4>AI system prompt</h4> <textarea required name=ai_system_prompt oninput="fixTextarea(event.target)"><%=html_encode(course.ai_system_prompt)%></textarea> <h4>AI first message (optional)</h4> <textarea name=ai_first_message oninput="fixTextarea(event.target)"><%=html_encode(course.ai_first_message)%></textarea> <h4>Text to speech instructions</h4> <textarea name=tts_instructions oninput="fixTextarea(event.target)"><%=html_encode(course.tts_instructions)%></textarea> <input type=submit> <hr> <p>Text areas take <a href="/tools/markdown.html">Markdown</a>. AI generally recognizes Markdown.</p> </form> <script> 'use strict'; let textareas = document.querySelectorAll('textarea'); for( let textarea of textareas ) { fixTextarea(textarea); } scrollToTop(); </script> </body> </html> <% end