assets
This commit is contained in:
parent
904d83ea3c
commit
d0777e2b85
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@
|
||||||
config.py
|
config.py
|
||||||
config.sls
|
config.sls
|
||||||
realms/static/vendor
|
realms/static/vendor
|
||||||
|
realms/static/assets/*
|
|
@ -11,6 +11,6 @@
|
||||||
"components-font-awesome": "~3.2.1",
|
"components-font-awesome": "~3.2.1",
|
||||||
"showdown": "~0.3.1",
|
"showdown": "~0.3.1",
|
||||||
"keymaster": "madrobby/keymaster",
|
"keymaster": "madrobby/keymaster",
|
||||||
"ace": "~1.0.0"
|
"ace": "~1.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -224,33 +224,25 @@ for status_code in httplib.responses:
|
||||||
if status_code >= 400:
|
if status_code >= 400:
|
||||||
app.register_error_handler(status_code, error_handler)
|
app.register_error_handler(status_code, error_handler)
|
||||||
|
|
||||||
assets = Environment()
|
from realms.lib.assets import assets, register
|
||||||
assets.init_app(app)
|
assets.init_app(app)
|
||||||
|
assets.app = app
|
||||||
|
|
||||||
|
app.jinja_env.globals['bundles'] = assets
|
||||||
|
|
||||||
js = Bundle(
|
register(
|
||||||
Bundle('vendor/jquery/jquery.js',
|
'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',
|
||||||
'vendor/showdown/src/extensions/table.js',
|
'vendor/marked/lib/marked.js',
|
||||||
'js/wmd.js',
|
'vendor/showdown/src/extensions/table.js',
|
||||||
filters='closure_js'),
|
'js/wmd.js',
|
||||||
'js/html-sanitizer-minified.js',
|
'js/html-sanitizer-minified.js', # don't minify
|
||||||
'vendor/highlightjs/highlight.pack.js',
|
'vendor/highlightjs/highlight.pack.js',
|
||||||
Bundle('js/main.js', filters='closure_js'),
|
'js/main.js'
|
||||||
output='packed-common.js')
|
)
|
||||||
assets.register('js_common', js)
|
|
||||||
|
|
||||||
js = Bundle('js/ace/ace.js',
|
|
||||||
'js/ace/mode-markdown.js',
|
|
||||||
'vendor/keymaster/keymaster.js',
|
|
||||||
'js/dillinger.js',
|
|
||||||
filters='closure_js', output='packed-editor.js')
|
|
||||||
|
|
||||||
assets.register('js_editor', js)
|
|
||||||
|
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def check_subdomain():
|
def check_subdomain():
|
||||||
|
|
10
realms/lib/assets.py
Normal file
10
realms/lib/assets.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from flask.ext.assets import Bundle, Environment
|
||||||
|
|
||||||
|
assets = Environment()
|
||||||
|
|
||||||
|
|
||||||
|
def register(*files):
|
||||||
|
assets.debug = True
|
||||||
|
filters = 'uglifyjs'
|
||||||
|
output = 'assets/%(version)s.js'
|
||||||
|
assets.add(Bundle(*files, filters=filters, output=output))
|
8
realms/modules/wiki/assets.py
Normal file
8
realms/modules/wiki/assets.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from realms.lib.assets import register
|
||||||
|
|
||||||
|
register(
|
||||||
|
'js/ace/ace.js',
|
||||||
|
'js/ace/mode-markdown.js',
|
||||||
|
'vendor/keymaster/keymaster.js',
|
||||||
|
'js/dillinger.js'
|
||||||
|
)
|
|
@ -1,4 +1,4 @@
|
||||||
$(function(){
|
$(function () {
|
||||||
|
|
||||||
var url_prefix = "/wiki";
|
var url_prefix = "/wiki";
|
||||||
|
|
||||||
|
@ -13,14 +13,9 @@ $(function(){
|
||||||
, autoInterval
|
, autoInterval
|
||||||
, profile =
|
, profile =
|
||||||
{
|
{
|
||||||
theme: 'ace/theme/idle_fingers'
|
theme: 'ace/theme/idle_fingers', currentMd: '', autosave: {
|
||||||
, currentMd: ''
|
enabled: true, interval: 3000 // might be too aggressive; don't want to block UI for large saves.
|
||||||
, autosave:
|
}, current_filename: $pagename.val()
|
||||||
{
|
|
||||||
enabled: true
|
|
||||||
, interval: 3000 // might be too aggressive; don't want to block UI for large saves.
|
|
||||||
}
|
|
||||||
, current_filename : $pagename.val()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Feature detect ish
|
// Feature detect ish
|
||||||
|
@ -39,21 +34,21 @@ $(function(){
|
||||||
* @param {Function} Optional callback to be executed after the script loads.
|
* @param {Function} Optional callback to be executed after the script loads.
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
function asyncLoad(filename,cb){
|
function asyncLoad(filename, cb) {
|
||||||
(function(d,t){
|
(function (d, t) {
|
||||||
|
|
||||||
var leScript = d.createElement(t)
|
var leScript = d.createElement(t)
|
||||||
, scripts = d.getElementsByTagName(t)[0];
|
, scripts = d.getElementsByTagName(t)[0];
|
||||||
|
|
||||||
leScript.async = 1;
|
leScript.async = 1;
|
||||||
leScript.src = filename;
|
leScript.src = filename;
|
||||||
scripts.parentNode.insertBefore(leScript,scripts);
|
scripts.parentNode.insertBefore(leScript, scripts);
|
||||||
|
|
||||||
leScript.onload = function(){
|
leScript.onload = function () {
|
||||||
cb && cb();
|
cb && cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
}(document,'script'));
|
}(document, 'script'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,10 +56,15 @@ $(function(){
|
||||||
*
|
*
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
function hasLocalStorage(){
|
function hasLocalStorage() {
|
||||||
// http://mathiasbynens.be/notes/localstorage-pattern
|
// http://mathiasbynens.be/notes/localstorage-pattern
|
||||||
var storage;
|
var storage;
|
||||||
try{ if(localStorage.getItem) {storage = localStorage} }catch(e){}
|
try {
|
||||||
|
if (localStorage.getItem) {
|
||||||
|
storage = localStorage
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,16 +73,16 @@ $(function(){
|
||||||
*
|
*
|
||||||
* @return {Void}
|
* @return {Void}
|
||||||
*/
|
*/
|
||||||
function getUserProfile(){
|
function getUserProfile() {
|
||||||
|
|
||||||
var p;
|
var p;
|
||||||
|
|
||||||
try{
|
try {
|
||||||
p = JSON.parse( localStorage.profile );
|
p = JSON.parse(localStorage.profile);
|
||||||
// Need to merge in any undefined/new properties from last release
|
// Need to merge in any undefined/new properties from last release
|
||||||
// Meaning, if we add new features they may not have them in profile
|
// Meaning, if we add new features they may not have them in profile
|
||||||
p = $.extend(true, profile, p);
|
p = $.extend(true, profile, p);
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
p = profile
|
p = profile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,9 +98,9 @@ $(function(){
|
||||||
* @param {Object} An object containg proper keys and values to be JSON.stringify'd
|
* @param {Object} An object containg proper keys and values to be JSON.stringify'd
|
||||||
* @return {Void}
|
* @return {Void}
|
||||||
*/
|
*/
|
||||||
function updateUserProfile(obj){
|
function updateUserProfile(obj) {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
localStorage.profile = JSON.stringify( $.extend(true, profile, obj) );
|
localStorage.profile = JSON.stringify($.extend(true, profile, obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +111,9 @@ $(function(){
|
||||||
* @param {String} The property to test
|
* @param {String} The property to test
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
function prefixed(prop){ return testPropsAll(prop, 'pfx') }
|
function prefixed(prop) {
|
||||||
|
return testPropsAll(prop, 'pfx')
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generic CSS / DOM property test; if a browser supports
|
* A generic CSS / DOM property test; if a browser supports
|
||||||
|
@ -122,11 +124,11 @@ $(function(){
|
||||||
* @param {String} A prefix
|
* @param {String} A prefix
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
function testProps( props, prefixed ) {
|
function testProps(props, prefixed) {
|
||||||
|
|
||||||
for ( var i in props ) {
|
for (var i in props) {
|
||||||
|
|
||||||
if( dillingerStyle[ props[i] ] !== undefined ) {
|
if (dillingerStyle[ props[i] ] !== undefined) {
|
||||||
return prefixed === 'pfx' ? props[i] : true;
|
return prefixed === 'pfx' ? props[i] : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,10 +146,10 @@ $(function(){
|
||||||
* @param {String} The prefix string
|
* @param {String} The prefix string
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
function testPropsAll( prop, prefixed ) {
|
function testPropsAll(prop, prefixed) {
|
||||||
|
|
||||||
var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1)
|
var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1)
|
||||||
, props = (prop + ' ' + domPrefixes.join(ucProp + ' ') + ucProp).split(' ');
|
, props = (prop + ' ' + domPrefixes.join(ucProp + ' ') + ucProp).split(' ');
|
||||||
|
|
||||||
return testProps(props, prefixed);
|
return testProps(props, prefixed);
|
||||||
}
|
}
|
||||||
|
@ -157,29 +159,24 @@ $(function(){
|
||||||
*
|
*
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
function normalizeTransitionEnd()
|
function normalizeTransitionEnd() {
|
||||||
{
|
|
||||||
|
|
||||||
var transEndEventNames =
|
var transEndEventNames =
|
||||||
{
|
{
|
||||||
'WebkitTransition' : 'webkitTransitionEnd'
|
'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd', 'msTransition': 'msTransitionEnd' // maybe?
|
||||||
, 'MozTransition' : 'transitionend'
|
, 'transition': 'transitionend'
|
||||||
, 'OTransition' : 'oTransitionEnd'
|
|
||||||
, 'msTransition' : 'msTransitionEnd' // maybe?
|
|
||||||
, 'transition' : 'transitionend'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return transEndEventNames[ prefixed('transition') ];
|
return transEndEventNames[ prefixed('transition') ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current filename from contenteditable field.
|
* Get current filename from contenteditable field.
|
||||||
*
|
*
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
function getCurrentFilenameFromField(){
|
function getCurrentFilenameFromField() {
|
||||||
return $('#filename > span[contenteditable="true"]').text()
|
return $('#filename > span[contenteditable="true"]').text()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,8 +187,8 @@ $(function(){
|
||||||
* @param {String} Optional string to force set the value.
|
* @param {String} Optional string to force set the value.
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
function setCurrentFilenameField(str){
|
function setCurrentFilenameField(str) {
|
||||||
$('#filename > span[contenteditable="true"]').text( str || profile.current_filename || "Untitled Document")
|
$('#filename > span[contenteditable="true"]').text(str || profile.current_filename || "Untitled Document")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,10 +233,12 @@ $(function(){
|
||||||
*
|
*
|
||||||
* @return {Void}
|
* @return {Void}
|
||||||
*/
|
*/
|
||||||
function init(){
|
function init() {
|
||||||
|
|
||||||
if( !hasLocalStorage() ) { sadPanda() }
|
if (!hasLocalStorage()) {
|
||||||
else{
|
sadPanda()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
// Attach to jQuery support object for later use.
|
// Attach to jQuery support object for later use.
|
||||||
$.support.transitionEnd = normalizeTransitionEnd();
|
$.support.transitionEnd = normalizeTransitionEnd();
|
||||||
|
@ -262,29 +261,29 @@ $(function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initAce(){
|
function initAce() {
|
||||||
editor = ace.edit("editor");
|
editor = ace.edit("editor");
|
||||||
editor.focus();
|
editor.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initUi(){
|
function initUi() {
|
||||||
// Set proper theme value in theme dropdown
|
// Set proper theme value in theme dropdown
|
||||||
fetchTheme(profile.theme, function(){
|
fetchTheme(profile.theme, function () {
|
||||||
$theme.find('li > a[data-value="'+profile.theme+'"]').addClass('selected');
|
$theme.find('li > a[data-value="' + profile.theme + '"]').addClass('selected');
|
||||||
|
|
||||||
editor.getSession().setUseWrapMode(true);
|
editor.getSession().setUseWrapMode(true);
|
||||||
editor.setShowPrintMargin(false);
|
editor.setShowPrintMargin(false);
|
||||||
|
|
||||||
editor.getSession().setMode('ace/mode/markdown');
|
editor.getSession().setMode('ace/mode/markdown');
|
||||||
|
|
||||||
editor.getSession().setValue( profile.currentMd || editor.getSession().getValue());
|
editor.getSession().setValue(profile.currentMd || editor.getSession().getValue());
|
||||||
previewMd();
|
previewMd();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Set text for dis/enable autosave / word counter
|
// Set text for dis/enable autosave / word counter
|
||||||
$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');
|
||||||
$wordcount.html( !profile.wordcount ? '<i class="icon-remove"></i> Disabled Word Count' : '<i class="icon-ok"></i> Enabled Word Count' );
|
$wordcount.html(!profile.wordcount ? '<i class="icon-remove"></i> Disabled Word Count' : '<i class="icon-ok"></i> Enabled Word Count');
|
||||||
|
|
||||||
setCurrentFilenameField();
|
setCurrentFilenameField();
|
||||||
|
|
||||||
|
@ -297,12 +296,12 @@ $(function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function clearSelection(){
|
function clearSelection() {
|
||||||
editor.getSession().setValue("");
|
editor.getSession().setValue("");
|
||||||
previewMd();
|
previewMd();
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveFile(isManual){
|
function saveFile(isManual) {
|
||||||
updateUserProfile({currentMd: editor.getSession().getValue()});
|
updateUserProfile({currentMd: editor.getSession().getValue()});
|
||||||
|
|
||||||
if (isManual) {
|
if (isManual) {
|
||||||
|
@ -313,47 +312,50 @@ $(function(){
|
||||||
message: $("#page-message").val(),
|
message: $("#page-message").val(),
|
||||||
content: editor.getSession().getValue()
|
content: editor.getSession().getValue()
|
||||||
};
|
};
|
||||||
$.post(window.location, data, function(){
|
$.post(window.location, data, function () {
|
||||||
location.href = url_prefix + '/' + data['name'];
|
location.href = url_prefix + '/' + data['name'];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function autoSave(){
|
function autoSave() {
|
||||||
|
|
||||||
if(profile.autosave.enabled) {
|
if (profile.autosave.enabled) {
|
||||||
autoInterval = setInterval( function(){
|
autoInterval = setInterval(function () {
|
||||||
// firefox barfs if I don't pass in anon func to setTimeout.
|
// firefox barfs if I don't pass in anon func to setTimeout.
|
||||||
saveFile();
|
saveFile();
|
||||||
}, profile.autosave.interval);
|
}, profile.autosave.interval);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
clearInterval( autoInterval )
|
clearInterval(autoInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#save-native").on('click', function() {
|
$("#save-native").on('click', function () {
|
||||||
saveFile(true);
|
saveFile(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function resetProfile(){
|
function resetProfile() {
|
||||||
// For some reason, clear() is not working in Chrome.
|
// For some reason, clear() is not working in Chrome.
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
// Let's turn off autosave
|
// Let's turn off autosave
|
||||||
profile.autosave.enabled = false
|
profile.autosave.enabled = false
|
||||||
// Delete the property altogether --> need ; for JSHint bug.
|
// Delete the property altogether --> need ; for JSHint bug.
|
||||||
; delete localStorage.profile;
|
;
|
||||||
|
delete localStorage.profile;
|
||||||
// Now reload the page to start fresh
|
// Now reload the page to start fresh
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeTheme(e){
|
function changeTheme(e) {
|
||||||
// check for same theme
|
// check for same theme
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
if( $target.attr('data-value') === profile.theme) { return; }
|
if ($target.attr('data-value') === profile.theme) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// add/remove class
|
// add/remove class
|
||||||
$theme.find('li > a.selected').removeClass('selected');
|
$theme.find('li > a.selected').removeClass('selected');
|
||||||
|
@ -361,15 +363,15 @@ $(function(){
|
||||||
// grabnew theme
|
// grabnew theme
|
||||||
var newTheme = $target.attr('data-value');
|
var newTheme = $target.attr('data-value');
|
||||||
$(e.target).blur();
|
$(e.target).blur();
|
||||||
fetchTheme(newTheme, function(){
|
fetchTheme(newTheme, 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);
|
||||||
|
@ -378,15 +380,14 @@ $(function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateBg(name){
|
function updateBg(name) {
|
||||||
// document.body.style.backgroundColor = bgColors[name]
|
// document.body.style.backgroundColor = bgColors[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
function previewMd(){
|
function previewMd() {
|
||||||
|
|
||||||
var unmd = editor.getSession().getValue()
|
var unmd = editor.getSession().getValue()
|
||||||
, md = MDR.convert(unmd, true);
|
, md = MDR.convert(unmd, true);
|
||||||
|
|
||||||
$preview
|
$preview
|
||||||
.html('') // unnecessary?
|
.html('') // unnecessary?
|
||||||
.html(md);
|
.html(md);
|
||||||
|
@ -394,32 +395,32 @@ $(function(){
|
||||||
//refreshWordCount();
|
//refreshWordCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function showHtml(){
|
function showHtml() {
|
||||||
|
|
||||||
// TODO: UPDATE TO SUPPORT FILENAME NOT JUST A RANDOM FILENAME
|
// TODO: UPDATE TO SUPPORT FILENAME NOT JUST A RANDOM FILENAME
|
||||||
|
|
||||||
var unmd = editor.getSession().getValue();
|
var unmd = editor.getSession().getValue();
|
||||||
|
|
||||||
function _doneHandler(jqXHR, data, response){
|
function _doneHandler(jqXHR, data, response) {
|
||||||
// console.dir(resp)
|
// console.dir(resp)
|
||||||
var resp = JSON.parse(response.responseText);
|
var resp = JSON.parse(response.responseText);
|
||||||
$('#myModalBody').text(resp.data);
|
$('#myModalBody').text(resp.data);
|
||||||
$('#myModal').modal();
|
$('#myModal').modal();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _failHandler(){
|
function _failHandler() {
|
||||||
alert("Roh-roh. Something went wrong. :(");
|
alert("Roh-roh. Something went wrong. :(");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,52 +437,52 @@ $(function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sadPanda(){
|
function sadPanda() {
|
||||||
// TODO: ACTUALLY SHOW A SAD PANDA.
|
// TODO: ACTUALLY SHOW A SAD PANDA.
|
||||||
alert('Sad Panda - No localStorage for you!')
|
alert('Sad Panda - No localStorage for you!')
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindPreview(){
|
function bindPreview() {
|
||||||
editor.getSession().on('change', function(e) {
|
editor.getSession().on('change', function (e) {
|
||||||
previewMd();
|
previewMd();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindNav(){
|
function bindNav() {
|
||||||
|
|
||||||
$theme
|
$theme
|
||||||
.find('li > a')
|
.find('li > a')
|
||||||
.bind('click', function(e){
|
.bind('click', function (e) {
|
||||||
changeTheme(e);
|
changeTheme(e);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#clear')
|
$('#clear')
|
||||||
.on('click', function(){
|
.on('click', function () {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#autosave")
|
$("#autosave")
|
||||||
.on('click', function(){
|
.on('click', function () {
|
||||||
toggleAutoSave();
|
toggleAutoSave();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#reset')
|
$('#reset')
|
||||||
.on('click', function(){
|
.on('click', function () {
|
||||||
resetProfile();
|
resetProfile();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cheat').
|
$('#cheat').
|
||||||
on('click', function(){
|
on('click', function () {
|
||||||
window.open("https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet", "_blank");
|
window.open("https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet", "_blank");
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -489,9 +490,9 @@ $(function(){
|
||||||
} // end bindNav()
|
} // end bindNav()
|
||||||
|
|
||||||
|
|
||||||
function bindKeyboard(){
|
function bindKeyboard() {
|
||||||
// CMD+s TO SAVE DOC
|
// CMD+s TO SAVE DOC
|
||||||
key('command+s, ctrl+s', function(e){
|
key('command+s, ctrl+s', function (e) {
|
||||||
saveFile(true);
|
saveFile(true);
|
||||||
e.preventDefault(); // so we don't save the web page - native browser functionality
|
e.preventDefault(); // so we don't save the web page - native browser functionality
|
||||||
});
|
});
|
||||||
|
@ -502,7 +503,7 @@ $(function(){
|
||||||
mac: "Command-S",
|
mac: "Command-S",
|
||||||
win: "Ctrl-S"
|
win: "Ctrl-S"
|
||||||
},
|
},
|
||||||
exec: function(){
|
exec: function () {
|
||||||
saveFile(true);
|
saveFile(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -545,12 +546,12 @@ function syncPreview() {
|
||||||
$prev.scrollTop(scrollFactor * previewScrollRange);
|
$prev.scrollTop(scrollFactor * previewScrollRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function(){
|
window.onload = function () {
|
||||||
var $loading = $('#loading');
|
var $loading = $('#loading');
|
||||||
|
|
||||||
if ($.support.transition){
|
if ($.support.transition) {
|
||||||
$loading
|
$loading
|
||||||
.bind( $.support.transitionEnd, function(){
|
.bind($.support.transitionEnd, function () {
|
||||||
$('#main').removeClass('bye');
|
$('#main').removeClass('bye');
|
||||||
$loading.remove();
|
$loading.remove();
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,7 +5,7 @@ hljs.initHighlightingOnLoad();
|
||||||
MDR = {
|
MDR = {
|
||||||
doc: null,
|
doc: null,
|
||||||
callback: WMD.convert,
|
callback: WMD.convert,
|
||||||
sanitize: null, // Override
|
sanitize: true, // Override
|
||||||
convert: function(md, sanitize){
|
convert: function(md, sanitize){
|
||||||
if (this.sanitize !== null) {
|
if (this.sanitize !== null) {
|
||||||
sanitize = this.sanitize;
|
sanitize = this.sanitize;
|
||||||
|
@ -14,7 +14,13 @@ MDR = {
|
||||||
var html = this.doc.html;
|
var html = this.doc.html;
|
||||||
if (sanitize) {
|
if (sanitize) {
|
||||||
// Causes some problems with inline styles
|
// Causes some problems with inline styles
|
||||||
html = html_sanitize(html);
|
html = html_sanitize(html, function(url) {
|
||||||
|
if(/^https?:\/\//.test(url)) {
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
}, function(id){
|
||||||
|
return id;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
html = this.hook(html);
|
html = this.hook(html);
|
||||||
return html;
|
return html;
|
||||||
|
|
|
@ -51,7 +51,8 @@ function gsub(str, re, fn, /*optional*/newstr) {
|
||||||
return gsub(remaining, re, fn, newstr);
|
return gsub(remaining, re, fn, newstr);
|
||||||
}
|
}
|
||||||
return newstr + str;
|
return newstr + str;
|
||||||
}
|
};
|
||||||
|
|
||||||
WMD.showdown = new Showdown.converter({extensions: ['table']});
|
WMD.showdown = new Showdown.converter({extensions: ['table']});
|
||||||
WMD.processor = WMD.showdown.makeHtml;
|
WMD.processor = WMD.showdown.makeHtml;
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -97,9 +97,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% assets "js_common" %}
|
{% for bundle in bundles %}
|
||||||
|
{% assets bundle %}
|
||||||
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
||||||
{% endassets %}
|
{% endassets %}
|
||||||
|
{% endfor %}
|
||||||
{% block js %}{% endblock %}
|
{% block js %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
{% extends 'layout.html' %}
|
{% extends 'layout.html' %}
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{% assets "js_editor" %}
|
|
||||||
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
|
||||||
{% endassets %}
|
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$("#start-togetherjs").click(function(){
|
$("#start-togetherjs").click(function(){
|
||||||
$(this).prop('disabled', true).html("Loading");
|
$(this).prop('disabled', true).html("Loading");
|
||||||
});
|
});
|
||||||
MDR.sanitize = false;
|
|
||||||
});
|
});
|
||||||
TogetherJSConfig_toolName = "Collaboration";
|
TogetherJSConfig_toolName = "Collaboration";
|
||||||
TogetherJSConfig_suppressJoinConfirmation = true;
|
TogetherJSConfig_suppressJoinConfirmation = true;
|
||||||
|
|
|
@ -18,18 +18,27 @@ bower:
|
||||||
- require:
|
- require:
|
||||||
- pkg.installed: common-pkgs
|
- pkg.installed: common-pkgs
|
||||||
|
|
||||||
realms-repo:
|
uglify-js:
|
||||||
git.latest:
|
npm.installed:
|
||||||
- unless: test -e /vagrant
|
- user: root
|
||||||
- name: git@github.com:scragg0x/realms.git
|
- require:
|
||||||
- target: /home/deploy
|
- pkg.installed: common-pkgs
|
||||||
- rev: master
|
|
||||||
- user: deploy
|
|
||||||
- identity: /home/deploy/.ssh/id_rsa
|
|
||||||
|
|
||||||
/home/deploy/virtualenvs/realms:
|
create_virtualenv:
|
||||||
virtualenv.managed:
|
virtualenv.managed:
|
||||||
|
- name: /home/deploy/virtualenvs/realms
|
||||||
- requirements: /home/deploy/realms/requirements.txt
|
- requirements: /home/deploy/realms/requirements.txt
|
||||||
- cwd: /home/deploy/realms
|
- cwd: /home/deploy/realms
|
||||||
- user: deploy
|
- user: root
|
||||||
|
|
||||||
|
vagrant_ownership:
|
||||||
|
cmd.run:
|
||||||
|
- name: chown -R vagrant.vagrant /home/deploy
|
||||||
|
- onlyif: test -d /vagrant
|
||||||
|
- user: root
|
||||||
|
|
||||||
|
deploy_ownership:
|
||||||
|
cmd.run:
|
||||||
|
- name: chown -R vagrant.vagrant /home/deploy
|
||||||
|
- unless: test -d /vagrant
|
||||||
|
- user: root
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
/etc/supervisor/conf.d/realms.conf:
|
/etc/supervisor/conf.d/realms.conf:
|
||||||
file.managed:
|
file.managed:
|
||||||
- source: salt://supervisor/supervisord.conf
|
- source: salt://supervisor/supervisord.conf
|
||||||
|
|
||||||
supervisor-run:
|
|
||||||
cmd.run:
|
|
||||||
- unless: test -e /tmp/supervisord.pid
|
|
||||||
- name: /usr/local/bin/supervisord
|
|
||||||
- require:
|
|
||||||
- file.managed: /etc/supervisor/conf.d/realms.conf
|
|
|
@ -1,2 +1,3 @@
|
||||||
[program:realms]
|
[program:realms]
|
||||||
command=/home/deploy/virtualenvs/realms/bin/python /home/deploy/realms/manage.py server
|
user=deploy
|
||||||
|
command=/home/deploy/realms/virtualenvs/realms/bin/python /home/deploy/realms/manage.py server
|
Loading…
Reference in a new issue