collaboration editor update fix, use closure for compression
This commit is contained in:
parent
88fdf6b2ca
commit
ccbf8336ea
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,7 +2,6 @@
|
||||||
.idea
|
.idea
|
||||||
.webassets-cache
|
.webassets-cache
|
||||||
*.pyc
|
*.pyc
|
||||||
packed-*.js
|
|
||||||
config.py
|
config.py
|
||||||
config.sls
|
config.sls
|
||||||
realms/static/vendor
|
realms/static/vendor
|
|
@ -132,16 +132,25 @@ def create_app(subdomain=None):
|
||||||
return CurrentUser(user_id)
|
return CurrentUser(user_id)
|
||||||
|
|
||||||
assets.init_app(app)
|
assets.init_app(app)
|
||||||
|
if config.ENV is 'PROD':
|
||||||
if 'js_common' not in assets._named_bundles:
|
if 'js_common' not in assets._named_bundles:
|
||||||
js = Bundle('vendor/jquery/jquery.js',
|
assets.register('js_common', Bundle('packed-common.js'))
|
||||||
|
if 'js_editor' not in assets._named_bundles:
|
||||||
|
assets.register('js_editor', Bundle('packed-editor.js'))
|
||||||
|
else:
|
||||||
|
if 'js_common' not in assets._named_bundles:
|
||||||
|
js = Bundle(
|
||||||
|
Bundle('vendor/jquery/jquery.js',
|
||||||
'vendor/components-underscore/underscore.js',
|
'vendor/components-underscore/underscore.js',
|
||||||
'vendor/components-bootstrap/js/bootstrap.js',
|
'vendor/components-bootstrap/js/bootstrap.js',
|
||||||
'vendor/handlebars/handlebars.js',
|
'vendor/handlebars/handlebars.js',
|
||||||
'vendor/showdown/src/showdown.js',
|
'vendor/showdown/src/showdown.js',
|
||||||
'js/html-sanitizer-minified.js',
|
|
||||||
'js/wmd.js',
|
'js/wmd.js',
|
||||||
|
filters='closure_js'),
|
||||||
|
'js/html-sanitizer-minified.js',
|
||||||
'vendor/highlightjs/highlight.pack.js',
|
'vendor/highlightjs/highlight.pack.js',
|
||||||
filters='uglifyjs', output='packed-common.js')
|
Bundle('js/main.js', filters='closure_js'),
|
||||||
|
output='packed-common.js')
|
||||||
assets.register('js_common', js)
|
assets.register('js_common', js)
|
||||||
|
|
||||||
if 'js_editor' not in assets._named_bundles:
|
if 'js_editor' not in assets._named_bundles:
|
||||||
|
@ -149,7 +158,7 @@ def create_app(subdomain=None):
|
||||||
'js/ace/mode-markdown.js',
|
'js/ace/mode-markdown.js',
|
||||||
'vendor/keymaster/keymaster.js',
|
'vendor/keymaster/keymaster.js',
|
||||||
'js/dillinger.js',
|
'js/dillinger.js',
|
||||||
filters='uglifyjs', output='packed-editor.js')
|
filters='closure_js', output='packed-editor.js')
|
||||||
assets.register('js_editor', js)
|
assets.register('js_editor', js)
|
||||||
|
|
||||||
repo_dir = config.repos['dir']
|
repo_dir = config.repos['dir']
|
||||||
|
@ -184,7 +193,10 @@ def create_app(subdomain=None):
|
||||||
@ratelimiter(limit=50, per=60)
|
@ratelimiter(limit=50, per=60)
|
||||||
def root():
|
def root():
|
||||||
return render('home')
|
return render('home')
|
||||||
#return redirect('/home')
|
|
||||||
|
@app.route("/home")
|
||||||
|
def home():
|
||||||
|
return redirect(url_for('root'))
|
||||||
|
|
||||||
@app.route("/account/")
|
@app.route("/account/")
|
||||||
@login_required
|
@login_required
|
||||||
|
|
|
@ -10,6 +10,7 @@ $(function(){
|
||||||
|
|
||||||
var editor
|
var editor
|
||||||
, autoInterval
|
, autoInterval
|
||||||
|
, keyCheck // used to detect changes not made via keyup
|
||||||
, profile =
|
, profile =
|
||||||
{
|
{
|
||||||
theme: 'ace/theme/idle_fingers'
|
theme: 'ace/theme/idle_fingers'
|
||||||
|
@ -291,7 +292,6 @@ $(function(){
|
||||||
|
|
||||||
// Immediately populate the preview <div>
|
// Immediately populate the preview <div>
|
||||||
previewMd();
|
previewMd();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -331,8 +331,12 @@ $(function(){
|
||||||
* @return {Void}
|
* @return {Void}
|
||||||
*/
|
*/
|
||||||
function saveFile(isManual){
|
function saveFile(isManual){
|
||||||
|
if (!keyCheck && profile.currentMd != editor.getSession().getValue()) {
|
||||||
updateUserProfile({currentMd: editor.getSession().getValue()})
|
previewMd();
|
||||||
|
console.log(keyCheck);
|
||||||
|
}
|
||||||
|
keyCheck = false;
|
||||||
|
updateUserProfile({currentMd: editor.getSession().getValue()});
|
||||||
|
|
||||||
if (isManual) {
|
if (isManual) {
|
||||||
updateUserProfile({ currentMd: "" });
|
updateUserProfile({ currentMd: "" });
|
||||||
|
@ -362,8 +366,7 @@ $(function(){
|
||||||
saveFile();
|
saveFile();
|
||||||
}, profile.autosave.interval);
|
}, profile.autosave.interval);
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
clearInterval( autoInterval )
|
clearInterval( autoInterval )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,19 +425,14 @@ $(function(){
|
||||||
*/
|
*/
|
||||||
function fetchTheme(th, cb){
|
function fetchTheme(th, cb){
|
||||||
var name = th.split('/').pop();
|
var name = th.split('/').pop();
|
||||||
|
|
||||||
asyncLoad("/static/js/ace/theme-"+ name +".js", function() {
|
asyncLoad("/static/js/ace/theme-"+ name +".js", function() {
|
||||||
editor.setTheme(th);
|
editor.setTheme(th);
|
||||||
|
|
||||||
cb && cb();
|
cb && cb();
|
||||||
|
|
||||||
updateBg(name);
|
updateBg(name);
|
||||||
|
|
||||||
updateUserProfile({theme: th});
|
updateUserProfile({theme: th});
|
||||||
|
});
|
||||||
|
|
||||||
}); // end asyncLoad
|
}
|
||||||
|
|
||||||
} // end fetchTheme(t)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the body background color based on theme.
|
* Change the body background color based on theme.
|
||||||
|
@ -481,14 +479,13 @@ $(function(){
|
||||||
*/
|
*/
|
||||||
function updateFilename(str){
|
function updateFilename(str){
|
||||||
// Check for string because it may be keyup event object
|
// Check for string because it may be keyup event object
|
||||||
var f
|
var f;
|
||||||
if(typeof str === 'string'){
|
if(typeof str === 'string'){
|
||||||
f = str
|
f = str;
|
||||||
}else
|
} else {
|
||||||
{
|
f = getCurrentFilenameFromField();
|
||||||
f = getCurrentFilenameFromField()
|
|
||||||
}
|
}
|
||||||
updateUserProfile( {current_filename: f })
|
updateUserProfile( { current_filename: f });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -532,31 +529,27 @@ $(function(){
|
||||||
alert('Sad Panda - No localStorage for you!')
|
alert('Sad Panda - No localStorage for you!')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles the autosave feature.
|
* Toggles the autosave feature.
|
||||||
*
|
*
|
||||||
* @return {Void}
|
* @return {Void}
|
||||||
*/
|
*/
|
||||||
function toggleAutoSave(){
|
function toggleAutoSave(){
|
||||||
|
|
||||||
$autosave.html( profile.autosave.enabled ? '<i class="icon-remove"></i> Disable Autosave' : '<i class="icon-ok"></i> Enable Autosave' );
|
$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 }});
|
updateUserProfile({autosave: {enabled: !profile.autosave.enabled }});
|
||||||
|
|
||||||
autoSave();
|
autoSave();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind keyup handler to the editor.
|
* Bind keyup handler to the editor.
|
||||||
*
|
*
|
||||||
* @return {Void}
|
* @return {Void}
|
||||||
*/
|
*/
|
||||||
function bindPreview(){
|
function bindPreview(){
|
||||||
$('#editor').bind('keyup', previewMd);
|
$('#editor').bind('keyup', function() {
|
||||||
|
keyCheck = true;
|
||||||
|
previewMd();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
33
realms/static/js/main.js
Normal file
33
realms/static/js/main.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// Init highlight JS
|
||||||
|
hljs.initHighlightingOnLoad();
|
||||||
|
|
||||||
|
// Markdown Renderer
|
||||||
|
MDR = {
|
||||||
|
doc: null,
|
||||||
|
callback: WMD.convert,
|
||||||
|
sanitize: null, // Override
|
||||||
|
convert: function(md, sanitize){
|
||||||
|
if (this.sanitize !== null) {
|
||||||
|
sanitize = this.sanitize;
|
||||||
|
}
|
||||||
|
this.doc = this.callback(md);
|
||||||
|
var html = this.doc.html;
|
||||||
|
if (sanitize) {
|
||||||
|
// Causes some problems with inline styles
|
||||||
|
html = html_sanitize(html);
|
||||||
|
}
|
||||||
|
html = this.hook(html);
|
||||||
|
return html;
|
||||||
|
},
|
||||||
|
hook: function(html) {
|
||||||
|
if (!this.doc.metadata) {
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var template = Handlebars.compile(html);
|
||||||
|
return template(this.doc.metadata);
|
||||||
|
} catch(e) {
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
563
realms/static/packed-common.js
Normal file
563
realms/static/packed-common.js
Normal file
File diff suppressed because one or more lines are too long
653
realms/static/packed-editor.js
Normal file
653
realms/static/packed-editor.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -103,37 +103,6 @@
|
||||||
{% assets "js_common" %}
|
{% assets "js_common" %}
|
||||||
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
||||||
{% endassets %}
|
{% endassets %}
|
||||||
<script>
|
|
||||||
hljs.initHighlightingOnLoad();
|
|
||||||
|
|
||||||
// Markdown Renderer
|
|
||||||
MDR = {
|
|
||||||
doc: null,
|
|
||||||
callback: WMD.convert,
|
|
||||||
convert: function(md, sanitize){
|
|
||||||
this.doc = this.callback(md);
|
|
||||||
var html = this.doc.html;
|
|
||||||
if (sanitize) {
|
|
||||||
// Causes some problems with inline styles
|
|
||||||
html = html_sanitize(html);
|
|
||||||
}
|
|
||||||
html = this.hook(html);
|
|
||||||
return html;
|
|
||||||
},
|
|
||||||
hook: function(html) {
|
|
||||||
if (!this.doc.metadata) {
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
var template = Handlebars.compile(html);
|
|
||||||
return template(this.doc.metadata);
|
|
||||||
} catch(e) {
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
</script>
|
|
||||||
{% block js %}{% endblock %}
|
{% block js %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
||||||
{% endassets %}
|
{% endassets %}
|
||||||
<script>
|
<script>
|
||||||
|
$(function(){
|
||||||
|
$("#start-togetherjs").click(function(){
|
||||||
|
$(this).prop('disabled', true).html("Loading");
|
||||||
|
});
|
||||||
|
});
|
||||||
TogetherJSConfig_toolName = "Collaboration";
|
TogetherJSConfig_toolName = "Collaboration";
|
||||||
TogetherJSConfig_suppressJoinConfirmation = true;
|
TogetherJSConfig_suppressJoinConfirmation = true;
|
||||||
TogetherJSConfig_getUserName = function () {
|
TogetherJSConfig_getUserName = function () {
|
||||||
|
@ -15,12 +20,12 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
TogetherJSConfig_on_ready = function () {
|
TogetherJSConfig_on_ready = function () {
|
||||||
//$("#start-togetherjs").addClass('btn-danger').html($(this).data('end-togetherjs-html'));
|
MDR.sanitize = true;
|
||||||
$("#start-togetherjs").addClass('btn-danger').html('End Collaboration');
|
$("#start-togetherjs").addClass('btn-danger').html('End Collaboration').prop('disabled', false);
|
||||||
|
|
||||||
};
|
};
|
||||||
TogetherJSConfig_on_close = function () {
|
TogetherJSConfig_on_close = function () {
|
||||||
$("#start-togetherjs").removeClass('btn-danger').html('Collaborate')
|
MDR.sanitize = null;
|
||||||
|
$("#start-togetherjs").removeClass('btn-danger').html('Collaborate').prop('disabled', false);
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -6,7 +6,7 @@ python-pkgs:
|
||||||
- build-essential
|
- build-essential
|
||||||
|
|
||||||
|
|
||||||
{% for pkg in ['BeautifulSoup', 'html5lib', 'ghdiff', 'tornado', 'pyzmq', 'itsdangerous', 'boto', 'redis', 'simplejson', 'sockjs-tornado', 'flask', 'flask-bcrypt', 'flask-login', 'flask-assets', 'gittle', 'gevent', 'lxml', 'markdown2', 'recaptcha-client', 'RethinkORM' ] %}
|
{% for pkg in ['closure', 'ghdiff', 'tornado', 'pyzmq', 'itsdangerous', 'boto', 'redis', 'simplejson', 'sockjs-tornado', 'flask', 'flask-bcrypt', 'flask-login', 'flask-assets', 'gittle', 'gevent', 'lxml', 'markdown2', 'recaptcha-client', 'RethinkORM' ] %}
|
||||||
{{ pkg }}-pip:
|
{{ pkg }}-pip:
|
||||||
pip:
|
pip:
|
||||||
- name: {{ pkg }}
|
- name: {{ pkg }}
|
||||||
|
|
Loading…
Reference in a new issue