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
|
||||
.webassets-cache
|
||||
*.pyc
|
||||
packed-*.js
|
||||
config.py
|
||||
config.sls
|
||||
realms/static/vendor
|
|
@ -132,16 +132,25 @@ def create_app(subdomain=None):
|
|||
return CurrentUser(user_id)
|
||||
|
||||
assets.init_app(app)
|
||||
if config.ENV is 'PROD':
|
||||
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-bootstrap/js/bootstrap.js',
|
||||
'vendor/handlebars/handlebars.js',
|
||||
'vendor/showdown/src/showdown.js',
|
||||
'js/html-sanitizer-minified.js',
|
||||
'js/wmd.js',
|
||||
filters='closure_js'),
|
||||
'js/html-sanitizer-minified.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)
|
||||
|
||||
if 'js_editor' not in assets._named_bundles:
|
||||
|
@ -149,7 +158,7 @@ def create_app(subdomain=None):
|
|||
'js/ace/mode-markdown.js',
|
||||
'vendor/keymaster/keymaster.js',
|
||||
'js/dillinger.js',
|
||||
filters='uglifyjs', output='packed-editor.js')
|
||||
filters='closure_js', output='packed-editor.js')
|
||||
assets.register('js_editor', js)
|
||||
|
||||
repo_dir = config.repos['dir']
|
||||
|
@ -184,7 +193,10 @@ def create_app(subdomain=None):
|
|||
@ratelimiter(limit=50, per=60)
|
||||
def root():
|
||||
return render('home')
|
||||
#return redirect('/home')
|
||||
|
||||
@app.route("/home")
|
||||
def home():
|
||||
return redirect(url_for('root'))
|
||||
|
||||
@app.route("/account/")
|
||||
@login_required
|
||||
|
|
|
@ -10,6 +10,7 @@ $(function(){
|
|||
|
||||
var editor
|
||||
, autoInterval
|
||||
, keyCheck // used to detect changes not made via keyup
|
||||
, profile =
|
||||
{
|
||||
theme: 'ace/theme/idle_fingers'
|
||||
|
@ -291,7 +292,6 @@ $(function(){
|
|||
|
||||
// Immediately populate the preview <div>
|
||||
previewMd();
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -331,8 +331,12 @@ $(function(){
|
|||
* @return {Void}
|
||||
*/
|
||||
function saveFile(isManual){
|
||||
|
||||
updateUserProfile({currentMd: editor.getSession().getValue()})
|
||||
if (!keyCheck && profile.currentMd != editor.getSession().getValue()) {
|
||||
previewMd();
|
||||
console.log(keyCheck);
|
||||
}
|
||||
keyCheck = false;
|
||||
updateUserProfile({currentMd: editor.getSession().getValue()});
|
||||
|
||||
if (isManual) {
|
||||
updateUserProfile({ currentMd: "" });
|
||||
|
@ -362,8 +366,7 @@ $(function(){
|
|||
saveFile();
|
||||
}, profile.autosave.interval);
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
clearInterval( autoInterval )
|
||||
}
|
||||
|
||||
|
@ -422,19 +425,14 @@ $(function(){
|
|||
*/
|
||||
function fetchTheme(th, cb){
|
||||
var name = th.split('/').pop();
|
||||
|
||||
asyncLoad("/static/js/ace/theme-"+ name +".js", function() {
|
||||
editor.setTheme(th);
|
||||
|
||||
cb && cb();
|
||||
|
||||
updateBg(name);
|
||||
|
||||
updateUserProfile({theme: th});
|
||||
});
|
||||
|
||||
}); // end asyncLoad
|
||||
|
||||
} // end fetchTheme(t)
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the body background color based on theme.
|
||||
|
@ -481,14 +479,13 @@ $(function(){
|
|||
*/
|
||||
function updateFilename(str){
|
||||
// Check for string because it may be keyup event object
|
||||
var f
|
||||
var f;
|
||||
if(typeof str === 'string'){
|
||||
f = str
|
||||
}else
|
||||
{
|
||||
f = getCurrentFilenameFromField()
|
||||
f = str;
|
||||
} else {
|
||||
f = getCurrentFilenameFromField();
|
||||
}
|
||||
updateUserProfile( {current_filename: f })
|
||||
updateUserProfile( { current_filename: f });
|
||||
}
|
||||
|
||||
|
||||
|
@ -532,31 +529,27 @@ $(function(){
|
|||
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').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" %}
|
||||
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
||||
{% 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 %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
||||
{% endassets %}
|
||||
<script>
|
||||
$(function(){
|
||||
$("#start-togetherjs").click(function(){
|
||||
$(this).prop('disabled', true).html("Loading");
|
||||
});
|
||||
});
|
||||
TogetherJSConfig_toolName = "Collaboration";
|
||||
TogetherJSConfig_suppressJoinConfirmation = true;
|
||||
TogetherJSConfig_getUserName = function () {
|
||||
|
@ -15,12 +20,12 @@
|
|||
};
|
||||
|
||||
TogetherJSConfig_on_ready = function () {
|
||||
//$("#start-togetherjs").addClass('btn-danger').html($(this).data('end-togetherjs-html'));
|
||||
$("#start-togetherjs").addClass('btn-danger').html('End Collaboration');
|
||||
|
||||
MDR.sanitize = true;
|
||||
$("#start-togetherjs").addClass('btn-danger').html('End Collaboration').prop('disabled', false);
|
||||
};
|
||||
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>
|
||||
|
|
|
@ -6,7 +6,7 @@ python-pkgs:
|
|||
- 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:
|
||||
pip:
|
||||
- name: {{ pkg }}
|
||||
|
|
Loading…
Reference in a new issue