lots more stuff
This commit is contained in:
parent
46c9f0a447
commit
c4f250573a
19 changed files with 7619 additions and 149 deletions
31
thinks/templates/registration/login.html
Normal file
31
thinks/templates/registration/login.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
{% extends "thinks/base.html" %}
|
||||
|
||||
{% block body_class %}login {{block.super}}{% endblock %}
|
||||
|
||||
{% block header %}
|
||||
<h1>Login</h1>
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
{% if form.errors %}
|
||||
<p>Your username and password didn't match. Please try again.</p>
|
||||
{% endif %}
|
||||
|
||||
{% if next %}
|
||||
{% if user.is_authenticated %}
|
||||
<p>Your account doesn't have access to this page. To proceed,
|
||||
please login with an account that has access.</p>
|
||||
{% else %}
|
||||
<p>Please login to see this page.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="{% url 'login' %}">
|
||||
{% csrf_token %}
|
||||
{{form}}
|
||||
<button type="submit">Log in</button>
|
||||
<input type="hidden" name="next" value="{{ next }}">
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
|
@ -8,7 +8,7 @@
|
|||
<title>{% block title %}Thinks{% endblock %}</title>
|
||||
|
||||
{% block stylesheets %}
|
||||
<link rel="stylesheet" href="{% static "thinks/thinks.css" %}">
|
||||
<link rel="stylesheet" href="{% static "thinks/thinks.css" %}?{% now "U" %}">
|
||||
{% endblock stylesheets %}
|
||||
|
||||
{% block scripts %}
|
||||
|
|
|
@ -7,18 +7,45 @@
|
|||
{% endblock header %}
|
||||
|
||||
{% block main %}
|
||||
<ul id="thinks-list">
|
||||
{% for think in object_list %}
|
||||
<li class="think">
|
||||
<a href="{% url 'think' think.slug %}">{{think.slug}}</a>
|
||||
{% with readme=think.get_readme %}
|
||||
{% if readme %}
|
||||
<pre class="readme">{{readme}}
|
||||
</pre>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<a href="{% url 'new_think' %}">New think</a>
|
||||
<section id="templates">
|
||||
<h2>Templates</h2>
|
||||
<ul id="templates-list">
|
||||
{% for think in templates %}
|
||||
<li class="think">
|
||||
<a class="remix" href="{% url 'remix_think' think.slug %}">{{think.slug}}</a>
|
||||
<br>
|
||||
<small>(<a href="{% url 'think' think.slug %}">edit</a>)</small>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section id="thinks">
|
||||
<h2>Thinks</h2>
|
||||
<p><a href="{% url 'new_think' %}">New think</a></p>
|
||||
{% regroup thinks by category as categories %}
|
||||
<ul id="thinks-list">
|
||||
{% for category in categories %}
|
||||
<li>
|
||||
<details {% if not category.grouper %}open{% endif %}>
|
||||
<summary>{% if category.grouper %}{{category.grouper}}{% else %}Uncategorised{% endif %}</summary>
|
||||
<ul>
|
||||
{% for think in category.list %}
|
||||
<li class="think">
|
||||
<a href="{% url 'think' think.slug %}">{{think.slug}}</a>
|
||||
<time datetime="{{think.creation_time|date:"c"}}">{{think.creation_time}}</time>
|
||||
{% with readme=think.get_readme %}
|
||||
{% if readme %}
|
||||
<pre class="readme">{{readme|safe}}</pre>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</dl>
|
||||
</section>
|
||||
{% endblock main %}
|
||||
|
|
30
thinks/templates/thinks/new_think.html
Normal file
30
thinks/templates/thinks/new_think.html
Normal file
|
@ -0,0 +1,30 @@
|
|||
{% extends "thinks/base.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{{path}} - {{think.slug}} - {{block.super}}{% endblock title %}
|
||||
|
||||
{% block body_class %}thing-editor {{block.super}}{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{% static "thinks/think-editor.js" %}"></script>
|
||||
|
||||
{{think_editor_data|json_script:"think-editor-data"}}
|
||||
<script id="csrftoken" type="text/plain">{{csrf_token}}</script>
|
||||
|
||||
<script type="module"">
|
||||
import init_app from "{% static "thinks/load-think-editor.mjs" %}";
|
||||
init_app();
|
||||
</script>
|
||||
{% endblock scripts %}
|
||||
|
||||
{% block stylesheets %}
|
||||
<link rel="stylesheet" href="{% static "thinks/think-editor.css" %}?{% now "U" %}">
|
||||
{% endblock stylesheets %}
|
||||
|
||||
{% block header %}
|
||||
<a href="/">thinks</a>
|
||||
<h1>{{think.slug}}</h1>
|
||||
{% endblock header %}
|
||||
|
||||
{% block main %}
|
||||
{% endblock main %}
|
|
@ -8,6 +8,11 @@
|
|||
|
||||
<form method="post" >
|
||||
{{form}}
|
||||
<datalist id="categories">
|
||||
{% for category in categories %}
|
||||
<option value="{{category}}"></option>
|
||||
{% endfor %}
|
||||
</datalist>
|
||||
{% csrf_token %}
|
||||
<button type="submit">Rename</button>
|
||||
</form>
|
||||
|
|
|
@ -1,106 +1,30 @@
|
|||
{% extends "thinks/base.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{{path}} - {{think.slug}} - {{block.super}}{% endblock title %}
|
||||
|
||||
{% block body_class %}thing-editor {{block.super}}{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{% static "thinks/think-editor.js" %}"></script>
|
||||
|
||||
{{think_editor_data|json_script:"think-editor-data"}}
|
||||
<script id="csrftoken" type="text/plain">{{csrf_token}}</script>
|
||||
|
||||
<script type="module"">
|
||||
import init_app from "{% static "thinks/load-think-editor.mjs" %}";
|
||||
init_app();
|
||||
</script>
|
||||
{% endblock scripts %}
|
||||
|
||||
{% block stylesheets %}
|
||||
<link rel="stylesheet" href="{% static "thinks/think-editor.css" %}?{% now "U" %}">
|
||||
{% endblock stylesheets %}
|
||||
|
||||
{% block header %}
|
||||
<a href="/">thinks</a>
|
||||
<h1>{{think.slug}}</h1>
|
||||
<a href="{% url 'rename_think' slug=think.slug %}">Rename</a>
|
||||
<a href="{% url 'delete_think' slug=think.slug %}">Delete</a>
|
||||
<a href="{% url 'remix_think' slug=think.slug %}">Remix</a>
|
||||
<a href="/">thinks</a>
|
||||
<h1>{{think.slug}}</h1>
|
||||
{% endblock header %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<nav>
|
||||
<a target="preview" href="{{think.get_static_url}}">Preview</a>
|
||||
|
||||
<ul id="file-tree">
|
||||
{% for name, path in files %}
|
||||
<li><a href="?path={{path}}">{{name}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<form id="new-file-form" method="post" action="{% url 'save_file' slug=think.slug %}" enctype="multipart/form-data">
|
||||
<input aria-labelledby="new-file-button" id="new_file_path" type="text" name="path">
|
||||
<button id="new-file-button" type="submit">New file</button>
|
||||
{% csrf_token %}
|
||||
</form>
|
||||
|
||||
<form method="post" action="{% url 'run_command' slug=think.slug %}">
|
||||
<input aria-labelledby="run-command-button" name="command">
|
||||
{% csrf_token %}
|
||||
<button id="run-command-button" type="submit">Run</button>
|
||||
</form>
|
||||
</nav>
|
||||
|
||||
<section id="editor">
|
||||
{% if path is not None and not path.is_dir %}
|
||||
<nav id="editor-controls">
|
||||
{{path}}
|
||||
<details>
|
||||
<summary>actions</summary>
|
||||
<form method="post" action="{% url 'delete_file' slug=think.slug %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="path" value="{{path}}">
|
||||
<button type="submit">Delete</button>
|
||||
</form>
|
||||
<form method="post" action="{% url 'rename_file' slug=think.slug %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="path" value="{{path}}">
|
||||
<input type="text" name="newpath" value="{{path}}">
|
||||
<button type="submit">Rename</button>
|
||||
</form>
|
||||
</details>
|
||||
</nav>
|
||||
<form id="file-form" method="post" action="{% url 'save_file' slug=think.slug %}" enctype="multipart/form-data">
|
||||
{{file_form.path.as_hidden}}
|
||||
{{file_form.content.as_hidden}}
|
||||
<code-editor id="code-editor">{{content}}</code-editor>
|
||||
{% csrf_token %}
|
||||
</form>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section id="preview">
|
||||
<button type="button" id="reload-preview">Reload</button>
|
||||
<iframe id="preview-frame" src="{{think.get_static_url}}"></iframe>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
const file_form = document.getElementById('file-form');
|
||||
const preview_frame = document.getElementById('preview-frame');
|
||||
const content_input = document.getElementById('code-editor');
|
||||
|
||||
function debounce(fn) {
|
||||
let last = null;
|
||||
return function() {
|
||||
if(last) {
|
||||
clearTimeout(last);
|
||||
}
|
||||
last = setTimeout(fn, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
function reload_preview() {
|
||||
preview_frame.src = preview_frame.src;
|
||||
}
|
||||
|
||||
if(content_input) {
|
||||
const save_content = debounce(async() => {
|
||||
const value = content_input.value;
|
||||
console.log('save', value);
|
||||
file_form.querySelector('[name="content"]').value = value;
|
||||
await fetch(file_form.action, {method: 'POST', body: new FormData(file_form)});
|
||||
reload_preview();
|
||||
});
|
||||
content_input.addEventListener('change', save_content);
|
||||
}
|
||||
console.log('hey');
|
||||
|
||||
document.getElementById('reload-preview').addEventListener('click', () => {
|
||||
reload_preview();
|
||||
})
|
||||
</script>
|
||||
|
||||
{% endblock main %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue