many things have occured
This commit is contained in:
parent
db70df22a2
commit
a9158f3d30
|
@ -148,7 +148,7 @@ manager = Manager(app)
|
|||
# Flask extension objects
|
||||
login_manager = LoginManager()
|
||||
login_manager.init_app(app)
|
||||
login_manager.login_view = 'login'
|
||||
login_manager.login_view = 'auth.login'
|
||||
|
||||
|
||||
@login_manager.user_loader
|
||||
|
|
|
@ -98,7 +98,7 @@ class User(Base):
|
|||
|
||||
@classmethod
|
||||
def login(cls, id):
|
||||
login_user(CurrentUser(id), True)
|
||||
login_user(CurrentUser(id), remember=True)
|
||||
|
||||
@classmethod
|
||||
def logout(cls):
|
||||
|
|
|
@ -8,9 +8,9 @@ from realms.models import Site
|
|||
blueprint = Blueprint('wiki', __name__)
|
||||
|
||||
|
||||
@blueprint.route("/wiki/_new/", methods=['GET', 'POST'])
|
||||
@blueprint.route("/wiki/new/", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def new_wiki():
|
||||
def new():
|
||||
if request.method == 'POST':
|
||||
wiki_name = to_canonical(request.form['name'])
|
||||
|
||||
|
@ -26,7 +26,7 @@ def new_wiki():
|
|||
|
||||
|
||||
@blueprint.route("/wiki/_commit/<sha>/<name>")
|
||||
def commit_sha(name, sha):
|
||||
def commit(name, sha):
|
||||
cname = to_canonical(name)
|
||||
|
||||
data = g.current_wiki.get_page(cname, sha=sha)
|
||||
|
@ -55,7 +55,7 @@ def revert():
|
|||
@blueprint.route("/wiki/_history/<name>")
|
||||
def history(name):
|
||||
history = g.current_wiki.get_history(name)
|
||||
return render_template('wiki/history.html', name=name, history=history)
|
||||
return render_template('wiki/history.html', name=name, history=history, wiki_home=url_for('wiki.page'))
|
||||
|
||||
|
||||
@blueprint.route("/wiki/_edit/<name>", methods=['GET', 'POST'])
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
$(function(){
|
||||
|
||||
// Cache some shit
|
||||
var url_prefix = "/wiki";
|
||||
|
||||
var $theme = $('#theme-list')
|
||||
, $preview = $('#preview')
|
||||
, $autosave = $('#autosave')
|
||||
|
@ -261,22 +262,11 @@ $(function(){
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize theme and other options of Ace editor.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function initAce(){
|
||||
|
||||
editor = ace.edit("editor");
|
||||
|
||||
editor.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize various UI elements based on userprofile data.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function initUi(){
|
||||
// Set proper theme value in theme dropdown
|
||||
fetchTheme(profile.theme, function(){
|
||||
|
@ -288,8 +278,6 @@ $(function(){
|
|||
editor.getSession().setMode('ace/mode/markdown');
|
||||
|
||||
editor.getSession().setValue( profile.currentMd || editor.getSession().getValue());
|
||||
|
||||
// Immediately populate the preview <div>
|
||||
previewMd();
|
||||
});
|
||||
|
||||
|
@ -309,26 +297,11 @@ $(function(){
|
|||
}
|
||||
|
||||
|
||||
/// HANDLERS =================
|
||||
|
||||
|
||||
/**
|
||||
* Clear the markdown and text and the subsequent HTML preview.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function clearSelection(){
|
||||
editor.getSession().setValue("");
|
||||
previewMd();
|
||||
}
|
||||
|
||||
// TODO: WEBSOCKET MESSAGE?
|
||||
/**
|
||||
* Save the markdown via localStorage - isManual is from a click or key event.
|
||||
*
|
||||
* @param {Boolean}
|
||||
* @return {Void}
|
||||
*/
|
||||
function saveFile(isManual){
|
||||
updateUserProfile({currentMd: editor.getSession().getValue()});
|
||||
|
||||
|
@ -341,17 +314,12 @@ $(function(){
|
|||
content: editor.getSession().getValue()
|
||||
};
|
||||
$.post(window.location, data, function(){
|
||||
location.href = "/" + data['name'];
|
||||
location.href = url_prefix + '/' + data['name'];
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable autosave for a specific interval.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function autoSave(){
|
||||
|
||||
if(profile.autosave.enabled) {
|
||||
|
@ -371,11 +339,6 @@ $(function(){
|
|||
});
|
||||
|
||||
|
||||
/**
|
||||
* Clear out user profile data in localStorage.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function resetProfile(){
|
||||
// For some reason, clear() is not working in Chrome.
|
||||
localStorage.clear();
|
||||
|
@ -387,11 +350,6 @@ $(function(){
|
|||
window.location.reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dropbown nav handler to update the current theme.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function changeTheme(e){
|
||||
// check for same theme
|
||||
var $target = $(e.target);
|
||||
|
@ -409,14 +367,6 @@ $(function(){
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Maybe we just load them all once and stash in appcache?
|
||||
/**
|
||||
* Dynamically appends a script tag with the proper theme and then applies that theme.
|
||||
*
|
||||
* @param {String} The theme name
|
||||
* @param {Function} Optional callback
|
||||
* @return {Void}
|
||||
*/
|
||||
function fetchTheme(th, cb){
|
||||
var name = th.split('/').pop();
|
||||
asyncLoad("/static/js/ace/theme-"+ name +".js", function() {
|
||||
|
@ -428,21 +378,10 @@ $(function(){
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the body background color based on theme.
|
||||
*
|
||||
* @param {String} The theme name
|
||||
* @return {Void}
|
||||
*/
|
||||
function updateBg(name){
|
||||
// document.body.style.backgroundColor = bgColors[name]
|
||||
}
|
||||
|
||||
/**
|
||||
* Clientside update showing rendered HTML of Markdown.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function previewMd(){
|
||||
|
||||
var unmd = editor.getSession().getValue()
|
||||
|
@ -455,12 +394,6 @@ $(function(){
|
|||
//refreshWordCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stash current file name in the user's profile.
|
||||
*
|
||||
* @param {String} Optional string to force the value
|
||||
* @return {Void}
|
||||
*/
|
||||
function updateFilename(str){
|
||||
// Check for string because it may be keyup event object
|
||||
var f;
|
||||
|
@ -503,43 +436,23 @@ $(function(){
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a sad panda because they are using a shitty browser.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function sadPanda(){
|
||||
// TODO: ACTUALLY SHOW A SAD PANDA.
|
||||
alert('Sad Panda - No localStorage for you!')
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the autosave feature.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function toggleAutoSave(){
|
||||
$autosave.html( profile.autosave.enabled ? '<i class="icon-remove"></i> Disable Autosave' : '<i class="icon-ok"></i> Enable Autosave' );
|
||||
updateUserProfile({autosave: {enabled: !profile.autosave.enabled }});
|
||||
autoSave();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind keyup handler to the editor.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function bindPreview(){
|
||||
editor.getSession().on('change', function(e) {
|
||||
previewMd();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind navigation elements.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
function bindNav(){
|
||||
|
||||
$theme
|
||||
|
@ -575,11 +488,7 @@ $(function(){
|
|||
|
||||
} // end bindNav()
|
||||
|
||||
/**
|
||||
* Bind special keyboard handlers.
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
|
||||
function bindKeyboard(){
|
||||
// CMD+s TO SAVE DOC
|
||||
key('command+s, ctrl+s', function(e){
|
||||
|
@ -605,14 +514,6 @@ $(function(){
|
|||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get scrollHeight of preview div
|
||||
* (code adapted from https://github.com/anru/rsted/blob/master/static/scripts/editor.js)
|
||||
*
|
||||
* @param {Object} The jQuery object for the preview div
|
||||
* @return {Int} The scrollHeight of the preview area (in pixels)
|
||||
*/
|
||||
function getScrollHeight($prevFrame) {
|
||||
// Different browsers attach the scrollHeight of a document to different
|
||||
// elements, so handle that here.
|
||||
|
@ -626,12 +527,6 @@ function getScrollHeight($prevFrame) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll preview to match cursor position in editor session
|
||||
* (code adapted from https://github.com/anru/rsted/blob/master/static/scripts/editor.js)
|
||||
*
|
||||
* @return {Void}
|
||||
*/
|
||||
|
||||
function syncPreview() {
|
||||
var $ed = window.ace.edit('editor');
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
<title>Realms</title>
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.ico') }}">
|
||||
<link href="/static/css/bootstrap/spacelab.css" rel="stylesheet">
|
||||
<link href="/static/css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="/static/vendor/highlightjs/styles/github.css" rel="stylesheet">
|
||||
<link href="/static/css/style.css" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/bootstrap/spacelab.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='vendor/highlightjs/styles/github.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
|
||||
{% block css %}{% endblock %}
|
||||
|
||||
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
|
@ -43,14 +43,14 @@
|
|||
<i class="icon-caret-down"></i></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="dropdown-header">Page Options</li>
|
||||
<li><a href="/_create/">Create Page</a></li>
|
||||
<li><a href="{{ url_for('wiki.create') }}">Create Page</a></li>
|
||||
{% if name %}
|
||||
<li><a href="/_edit/{{ name }}">Edit Page</a></li>
|
||||
<li><a href="/_history/{{ name }}">History</a></li>
|
||||
<li><a href="{{ url_for('wiki.edit', name=name) }}">Edit Page</a></li>
|
||||
<li><a href="{{ url_for('wiki.history', name=name) }}">History</a></li>
|
||||
{% endif %}
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-header">Site Options</li>
|
||||
<li><a href="/_new/">Create New Wiki</a></li>
|
||||
<li><a href="{{ url_for('wiki.new') }}">Create New Site</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
@ -63,13 +63,13 @@
|
|||
</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/account">Account</a></li>
|
||||
<li><a href="/logout">Logout</a></li>
|
||||
<li><a href="{{ url_for('account') }}">Account</a></li>
|
||||
<li><a href="{{ url_for('auth.logout') }}">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li><a href="/login"><i class="icon-user"></i> Login</a></li>
|
||||
<li><a href="/register"><i class="icon-pencil"></i> Register</a></li>
|
||||
<li><a href="{{ url_for('auth.login') }}"><i class="icon-user"></i> Login</a></li>
|
||||
<li><a href="{{ url_for('auth.register') }}"><i class="icon-pencil"></i> Register</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% macro recaptcha(config) -%}
|
||||
<script>
|
||||
var RecaptchaOptions = {
|
||||
theme : '{{ config.RECAPTCHA_OPTIONS['theme'] }}'
|
||||
theme : "{{ config.RECAPTCHA_OPTIONS['theme'] }}"
|
||||
};
|
||||
</script>
|
||||
<script src="http://www.google.com/recaptcha/api/challenge?k={{ config.RECAPTCHA_PUBLIC_KEY }}">
|
||||
|
|
|
@ -3,18 +3,17 @@
|
|||
|
||||
<h2>History for <strong>{{ name }}</strong></h2>
|
||||
<div class="pull-right">
|
||||
<a href="/_commit/{{ old }}/{{ name }}" class="btn btn-default btn-sm">View Old</a>
|
||||
<a href="/_commit/{{ new }}/{{ name }}" class="btn btn-info btn-sm">View New</a>
|
||||
<a href="{{ url_for('wiki.commit', name=name, sha=old) }}" class="btn btn-default btn-sm">View Old</a>
|
||||
<a href="{{ url_for('wiki.commit', name=name, sha=new) }}" class="btn btn-info btn-sm">View New</a>
|
||||
</div>
|
||||
<p>
|
||||
<a class="btn btn-default btn-sm" href="/_history/{{ name }}">Back to History</a>
|
||||
<a class="btn btn-default btn-sm" href="{{ url_for('wiki.history', name=name) }}">Back to History</a>
|
||||
</p>
|
||||
|
||||
|
||||
{{ diff|safe }}
|
||||
<p></p>
|
||||
|
||||
<p>
|
||||
<a class="btn btn-default btn-sm" href="/_history/{{ name }}">Back to History</a>
|
||||
<a class="btn btn-default btn-sm" href="{{ url_for('wiki.history', name=name) }}">Back to History</a>
|
||||
</p>
|
||||
{% endblock %}
|
|
@ -4,7 +4,7 @@
|
|||
<form role="form" method="post">
|
||||
<div class="form-group">
|
||||
<label for="name"></label>
|
||||
<input type="text" class="form-control" id="page" name="name" placeholder="Name" value="{{- name -}}" />
|
||||
<input id="name" type="text" class="form-control" id="page" name="name" placeholder="Name" value="{{- name -}}" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<div id="app-controls" class="row">
|
||||
<div class="col-xs-3">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon btn-info input-sm">realms.io/</span>
|
||||
<span class="input-group-addon btn-info input-sm">realms.io/wiki/</span>
|
||||
<input id="page-name" type="text" class="form-control input-sm" name="name" placeholder="Name" value="{{- name -}}" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<input type="checkbox" name="versions[]" value="{{ h.sha }}" />
|
||||
</td>
|
||||
<td>{{ h.author }}</td>
|
||||
<td><a href="/_commit/{{ h.sha }}/{{ name }}" class='label label-primary'>View</a> {{ h.message }} </td>
|
||||
<td><a href="{{ url_for('wiki.commit', name=name, sha=h.sha) }}" class='label label-primary'>View</a> {{ h.message }} </td>
|
||||
<td>{{ h.time|datetime }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -52,7 +52,7 @@ $(function(){
|
|||
});
|
||||
revs.reverse();
|
||||
revs = revs.join("..");
|
||||
location.href = "/_compare/{{ name }}/" + revs;
|
||||
location.href = "{{ url_for('wiki.page') }}_compare/{{ name }}/" + revs;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% block page_menu %}
|
||||
<div class="controls pull-right">
|
||||
<a class="btn btn-default btn-sm" href="/_edit/{{ name }}">Edit</a>
|
||||
<a class="btn btn-default btn-sm" href="/_history/{{ name }}">History</a>
|
||||
<a class="btn btn-default btn-sm" href="{{ url_for('wiki.edit', name=name) }}">Edit</a>
|
||||
<a class="btn btn-default btn-sm" href="{{ url_for('wiki.history', name=name) }}">History</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
{% if commit %}
|
||||
<div id="page-action-bar">
|
||||
<form method="POST" action="/_revert">
|
||||
<form method="POST" action="{{ url_for('wiki.revert') }}">
|
||||
<input type="hidden" value="{{ name }}" name="name" />
|
||||
<input type="hidden" value="{{ commit }}" name="commit" />
|
||||
<input type="submit" class="btn btn-danger btn-sm" title="Revert back to this revision" value="Revert" />
|
||||
|
|
Loading…
Reference in a new issue