-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added auto save (as draft) feature to the editor. Closes #66.
When a user starts editing a page, up to every five seconds the content will we send as draft to the server. The server stores the draft (for anonymous users only in the session). Is the page saved in the process, the draft is discarded. If the page is not saved, the user will be prompted if the editing of the drat should be continued or the draft should be discarded.
- Loading branch information
Showing
6 changed files
with
235 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python | ||
|
||
from otterwiki.server import db | ||
|
||
__all__ = ['Preferences'] | ||
|
||
class Preferences(db.Model): | ||
name = db.Column(db.String(256), primary_key=True) | ||
value = db.Column(db.String(256)) | ||
|
||
def __str__(self): | ||
return '{}: {}'.format(self.name, self.value) | ||
|
||
class Drafts(db.Model): | ||
id = db.Column(db.Integer, primary_key=True) | ||
pagepath = db.Column(db.String(2048), index=True) | ||
revision = db.Column(db.String(64)) | ||
author_email = db.Column(db.String(256)) | ||
content = db.Column(db.Text) | ||
cursor_line = db.Column(db.Integer) | ||
cursor_ch = db.Column(db.Integer) | ||
datetime = db.Column(db.DateTime()) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{#- vim: set et ts=8 sts=4 sw=4 ai: -#} | ||
{% extends "page.html" %} | ||
|
||
{% block content %} | ||
<div class="card"> | ||
<h2 class="card-title">Continue editing draft?</h2> | ||
|
||
<div class="mt-5 mb-15"> | ||
For <strong>{{pagepath}}</strong> exists a draft version saved <span title="{{draft_datetime|format_datetime}}">{{draft_datetime|format_datetime("deltanow")}} ago</span>. | ||
</div> | ||
|
||
<div class="d-flex"> | ||
<form action="{{ url_for("edit", path=pagepath) }}" method="POST" class="mr-15"> | ||
<input type="hidden" name="draft" value="edit" /> | ||
<input class="btn btn-primary" type="submit" name="submit" value="Continue editing draft" /> | ||
</form> | ||
<form action="{{ url_for("edit", path=pagepath) }}" method="POST"> | ||
<input type="hidden" name="draft" value="discard" /> | ||
<input class="btn" type="submit" name="submit" value="Discard draft" /> | ||
</form> | ||
</div> | ||
</div> | ||
<table class="table table-inner-bordered"> | ||
<thead> | ||
<tr> | ||
<td><em>Draft</em></td> | ||
{% if content %} | ||
<td>Stored Version</td> | ||
{% endif %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr class="align-top"> | ||
<td>{{draft_content|safe}}</td> | ||
{% if content %} | ||
<td>{{content|safe}}</td> | ||
{% endif %} | ||
</tr> | ||
</tbody> | ||
</table> | ||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters