Code-Input was updated to 1.2.2 and currently works! I have the upload functionality working and have begun working on an undo button. It currently saves all the files to a dir everytime you access /templates but I haven't implemented a full undo yet.

This commit is contained in:
Norm Rasmussen
2023-03-15 17:07:34 -04:00
parent 8afdec139b
commit dae2eb440e
20 changed files with 817 additions and 96 deletions

13
app/templates/cmtest.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
{% include 'head.html' %}
{% include 'header.html' %}
{% include 'logo.html' %}
<p>&nbsp;</p>
{% if error %}
<h3>{{ error }}</h4>
{% endif %}
<form method="POST" action="/">
{{ form.name.label }} {{ form.name(size=20) }}
<input type="submit" value="Go">
</form>

View File

@ -17,8 +17,8 @@
<link rel="stylesheet" href="{{ url_for('static', filename="css/styles.css") }}" />
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.2/code-input.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.2/code-input.min.css">
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.2.2/code-input.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.2.2/code-input.min.css">
<link href="{{ url_for('static', filename='css/prism.css')}}" rel="stylesheet" />
</head>
<body>

View File

@ -11,7 +11,7 @@
<p>
</p>
<form action="{{ url_for("ask_key")}}" method="post">
<input id="fields" type="text" name="apikey">
<input id="fields" type="password" name="apikey">
<input id="fields" type="submit" value="Submit">
</form>
</div>

View File

@ -6,6 +6,17 @@
{% if error %}
<h3>{{ error }}</h4>
{% endif %}
{% if button %}
<br>
<form
id="undo_template"
method="post"
action="{{ url_for('undo_template')}}">
<input type="submit" name="undo_template" value="Undo Last Upload"></input>
</form>
{% endif %}
{% if templates %}
<h2> Here are the liquid templates for </h2>
<h2 style="color:#F05323"><strong> {{ session.school }} </strong></h2>
@ -18,10 +29,9 @@
id="templates"
action="{{ url_for('templates')}}"
method="post">
<h2>
{{ templates[0] }}
</h2>
<code-input
<h2> {{ templates[0] }}</h2>
<h3> Last Updated: {{ templates [2] }}</h3>
<code-input
lang="HTML"
value="{{ templates[1] }}"
id="editor"
@ -29,10 +39,6 @@
template="code-input">
{{ templates[1] }}
</code-input>
<textarea
name="loaded-content"
id="loaded-content"
style="width:100%;"></textarea>
<label for="template_name">
Create New Template Name (optional):
</label>
@ -42,12 +48,6 @@
value="{{ templates[0] }}">
</input>
<p>&nbsp;</p>
<div
name="load-template"
value="Load Changes"
onclick="copyToTextArea()"
style="cursor:pointer"
>Click here to load changes</div>
<input
type="submit"
name="submit-template"
@ -58,7 +58,7 @@
</div>
<p>&nbsp;</p>
{% endfor %}
<!--
{% if templates %}
<h3> Advanced users only: create new template </h3>
<p>&nbsp;</p>
<div class="html_code">
@ -69,12 +69,12 @@
<h2>
Enter the code below
</h2>
<textarea
id="body"
name="body"
rows="35"
cols="100">
</textarea>
<code-input
lang="HTML"
id="editor"
name="body"
template="code-input">
</code-input>
<p>&nbsp;</p>
<label for="template_name">
Template Name:
@ -86,7 +86,8 @@
<p>&nbsp;</p>
<input type="submit" name="submit_template" value="Submit Template"</input>
</form>
</div> -->
</div>
{% endif %}
<script>
codeInput.registerTemplate("code-input", codeInput.templates.hljs(hljs,
@ -96,13 +97,3 @@
<script>
codeInput.registerTemplate("code-input", codeInput.templates.prism(Prism, []));
</script>
<script>
function copyToTextArea() {
var code = document.getElementById("editor").value;
let textarea = document.getElementById("loaded-content");
textarea.textContent = code;
console.log(code);
}
</script>