зеркало из https://github.com/mozilla/FlightDeck.git
Merge branch 'master' of git@github.com:zalun/FlightDeck
This commit is contained in:
Коммит
81be944b54
|
@ -2,10 +2,10 @@
|
|||
{# Base HTML every page will use #}
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="author" content="Mozilla Corporation" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="author" content="Mozilla Corporation">
|
||||
|
||||
<link rel="stylesheet" href="/media/jetpack/css/UI.Base.css" type="text/css" media="screen" />
|
||||
<link rel="stylesheet" href="/media/jetpack/css/UI.Base.css" type="text/css" media="screen">
|
||||
<script src="/media/js/lib/mootools-1.2.4-core-nc.js"></script>
|
||||
<script src="/media/js/lib/mootools-1.2.4.4-more.js"></script>
|
||||
<script src="/media/roar/Roar.js"></script>
|
||||
|
@ -41,4 +41,4 @@
|
|||
</div> <!-- /wrapper -->
|
||||
|
||||
</body><!-- /{{ body_id }} -->
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -1,24 +1,3 @@
|
|||
/*
|
||||
* Inspired from http://github.com/jeresig/sizzle/commit/7631f9c3f85e5fa72ac51532399cb593c2cdc71f
|
||||
* and this http://github.com/jeresig/sizzle/commit/5716360040a440041da19823964f96d025ca734b
|
||||
* and then http://dev.jquery.com/ticket/4512
|
||||
*/
|
||||
|
||||
Element.implement({
|
||||
|
||||
isHidden: function(){
|
||||
var w = this.offsetWidth, h = this.offsetHeight,
|
||||
force = (this.tagName.toLowerCase() === 'tr');
|
||||
return (w===0 && h===0 && !force) ? true : (w!==0 && h!==0 && !force) ? false : this.getStyle('display') === 'none';
|
||||
},
|
||||
|
||||
isVisible: function(){
|
||||
return !this.isHidden();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* Bespin wrapper
|
||||
*/
|
||||
|
@ -72,5 +51,17 @@ Class.refactor(Editor, {
|
|||
getContent: function() {
|
||||
this.textarea.set('text', this.bespin.value);
|
||||
return this.bespin.value;
|
||||
},
|
||||
hide: function() {
|
||||
this.element.hide();
|
||||
return this;
|
||||
},
|
||||
show: function() {
|
||||
this.element.show();
|
||||
this.element.getChildren().each(function(content) {
|
||||
console.log('show', content);
|
||||
content.show();
|
||||
});
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,7 +16,10 @@ var Capability = new Class({
|
|||
//developers: [],
|
||||
//public_permission: 2,
|
||||
//group_permission: 2,
|
||||
description_el: {element: 'capability_description'},
|
||||
description_el: {
|
||||
element: 'capability_description',
|
||||
type: 'text'
|
||||
},
|
||||
//switch_description_id: '',
|
||||
update_el: 'update',
|
||||
version_create_el: 'version_create',
|
||||
|
@ -251,8 +254,14 @@ var CapVersion = new Class({
|
|||
//is_base: null,
|
||||
name_el: 'version_name',
|
||||
// TODO: move to new Editor
|
||||
description_el: {element: 'version_description'},
|
||||
content_el: {element: 'version_content'},
|
||||
description_el: {
|
||||
element: 'version_description',
|
||||
type: 'text'
|
||||
},
|
||||
content_el: {
|
||||
element: 'version_content',
|
||||
type: 'js'
|
||||
},
|
||||
update_el: 'update',
|
||||
set_as_base_el: 'set_as_base',
|
||||
edit_url: '',
|
||||
|
@ -276,6 +285,12 @@ var CapVersion = new Class({
|
|||
version_name: this.options.name,
|
||||
version_description: this.options.description,
|
||||
});
|
||||
// set as base functionality
|
||||
this.set_as_base_el = $(this.options.set_as_base_el);
|
||||
this.set_as_base_el.addEvent('click', function(e) {
|
||||
e.stop();
|
||||
this.setAsBase();
|
||||
}.bind(this));
|
||||
},
|
||||
/*
|
||||
* Method: instantiateEditors
|
||||
|
@ -335,11 +350,6 @@ var CapVersion = new Class({
|
|||
}.bind(this));
|
||||
this.content_el.removeEvent('change', this.boundAfterDataChanged);
|
||||
this.description_el.removeEvent('change', this.boundAfterDataChanged);
|
||||
this.set_as_base_el = $(this.options.set_as_base_el);
|
||||
this.set_as_base_el.addEvent('click', function(e) {
|
||||
e.stop();
|
||||
this.setAsBase();
|
||||
}.bind(this));
|
||||
this.fireEvent('change');
|
||||
},
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* File: jetpack/CodeMirror.js
|
||||
*/
|
||||
|
||||
/*
|
||||
* Class: CodeMirror.js
|
||||
* Extension for Editor to use CodeMirror
|
||||
*/
|
||||
|
||||
Class.refactor(Editor, {
|
||||
options: {
|
||||
type: null,
|
||||
codeMirror: {
|
||||
lineNumbers: false,
|
||||
autoMatchParens: true,
|
||||
indentUnit: 4,
|
||||
tabMode: 'shift',
|
||||
height: '',
|
||||
path: '/media/codemirror/js/',
|
||||
stylesheet: []
|
||||
}
|
||||
},
|
||||
initialize: function(options) {
|
||||
this.previous(options);
|
||||
},
|
||||
initEditor: function() {
|
||||
if (this.options.type == 'js' || this.options.type == 'json') {
|
||||
this.options.codeMirror.parserfile = [
|
||||
"tokenizejavascript.js",
|
||||
"parsejavascript.js"
|
||||
];
|
||||
this.options.codeMirror.stylesheet = '/media/codemirror/css/jscolors.css';
|
||||
} else if (this.options.type == 'css') {
|
||||
this.options.codeMirror.parserfile = ["parsecss.js"];
|
||||
this.options.codeMirror.stylesheet = '/media/codemirror/css/csscolors.css';
|
||||
} else { // text
|
||||
this.options.codeMirror.parserfile = ["parsedummy.js"];
|
||||
}
|
||||
this.element = $(this.options.element);
|
||||
if (this.element.isHidden()) {
|
||||
this.hidden = true;
|
||||
}
|
||||
// hook to the onChange event
|
||||
// this has some delay
|
||||
if (!this.options.codeMirror.onChange) {
|
||||
this.options.codeMirror.onChange = this.onCodeMirrorChange.bind(this);
|
||||
}
|
||||
// instantiate editor
|
||||
this.editor = CodeMirror.fromTextArea(this.element, this.options.codeMirror);
|
||||
// fix codemirror focus
|
||||
if (! this.editor.editor) this.editor.editor = {};
|
||||
// hide if textarea was hidden
|
||||
if (this.hidden) {
|
||||
this.hide();
|
||||
} else {
|
||||
this.editor.focus();
|
||||
}
|
||||
},
|
||||
onCodeMirrorChange: function() {
|
||||
this.changed = true;
|
||||
this.fireEvent('change');
|
||||
},
|
||||
getContent: function() {
|
||||
return this.editor.getCode();
|
||||
},
|
||||
hide: function() {
|
||||
this.editor.wrapping.hide();
|
||||
return this;
|
||||
},
|
||||
show: function() {
|
||||
this.editor.wrapping.show();
|
||||
return this;
|
||||
},
|
||||
getWindow: function() {
|
||||
// return CodeMirror window
|
||||
if (!this._window) {
|
||||
this._window = this.element.getParent('.window');
|
||||
}
|
||||
return this._window || this.element;
|
||||
}
|
||||
});
|
|
@ -46,7 +46,10 @@ var JetVersion = new Class({
|
|||
options: {
|
||||
//manifest: null,
|
||||
//published: null,
|
||||
manifest_el: {element: 'version_manifest'}
|
||||
manifest_el: {
|
||||
element: 'version_manifest',
|
||||
type: 'json'
|
||||
}
|
||||
//switch_manifest_id: ''
|
||||
},
|
||||
/*
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
{% extends "base.html" %}
|
||||
{% load jetpack_extras %}
|
||||
{% block head %}
|
||||
<link rel="stylesheet" href="/media/jetpack/css/UI.Editor.css" type="text/css" media="screen" />
|
||||
<link rel="stylesheet" href="/media/bespin/BespinEmbedded.css" type="text/css" media="screen" />
|
||||
<script src="/media/bespin/BespinEmbedded.js"></script>
|
||||
<link rel="stylesheet" href="/media/jetpack/css/UI.Editor.css" type="text/css" media="screen">
|
||||
<script src="/media/jetpack/js/Create.js"></script>
|
||||
<script src="/media/jetpack/js/Editor.js"></script>
|
||||
<script src="/media/jetpack/js/Capability.js"></script>
|
||||
<script src="/media/jetpack/js/CapDependency.js"></script>
|
||||
<script src="/media/jetpack/js/Bespin.js"></script>
|
||||
{#<link rel="stylesheet" href="/media/bespin/BespinEmbedded.css" type="text/css" media="screen" />#}
|
||||
{#<script src="/media/bespin/BespinEmbedded.js"></script>#}
|
||||
{#<script src="/media/jetpack/js/Bespin.js"></script>#}
|
||||
<script src="/media/codemirror/js/codemirror.js"></script>
|
||||
<script src="/media/codemirror/js/mirrorframe.js"></script>
|
||||
<script src="/media/jetpack/js/CodeMirror.js"></script>
|
||||
<script type="text/javascript">
|
||||
var settings = {
|
||||
user: "{{ request.user }}",
|
||||
jp_jetpack_create_url: "{% url jp_jetpack_create %}",
|
||||
jp_capability_create_url: "{% url jp_capability_create %}",
|
||||
user: '{{ request.user }}',
|
||||
jp_jetpack_create_url: '{% url jp_jetpack_create %}',
|
||||
jp_capability_create_url: '{% url jp_capability_create %}',
|
||||
create_modal_template: '{% escape_template "_create.html" %}'
|
||||
};
|
||||
var item;
|
||||
|
|
|
@ -123,7 +123,7 @@ def jetpack_version_update(r, slug, version, counter):
|
|||
"""
|
||||
version = get_object_or_404(JetVersion, jetpack__slug=slug, name=version, counter=counter)
|
||||
# permission check
|
||||
if not version.jetpack.can_be_updated_by(r.user):
|
||||
if not version.author == r.user:
|
||||
return HttpResponseNotAllowed(HttpResponse(""))
|
||||
|
||||
version.author = r.user
|
||||
|
@ -243,7 +243,7 @@ def capability_version_update(r, slug, version, counter):
|
|||
"""
|
||||
version = get_object_or_404(CapVersion, capability__slug=slug, name=version, counter=counter)
|
||||
# permission check
|
||||
if not version.capability.can_be_updated_by(r.user):
|
||||
if not version.author == r.user:
|
||||
return HttpResponseNotAllowed(HttpResponse(""))
|
||||
|
||||
version.author = r.user
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* Inspired by
|
||||
* http://github.com/jeresig/sizzle/commit/7631f9c3f85e5fa72ac51532399cb593c2cdc71f
|
||||
* and this http://github.com/jeresig/sizzle/commit/5716360040a440041da19823964f96d025ca734b
|
||||
* and then http://dev.jquery.com/ticket/4512
|
||||
*/
|
||||
|
||||
Element.implement({
|
||||
|
||||
isHidden: function(){
|
||||
var w = this.offsetWidth, h = this.offsetHeight,
|
||||
force = (this.tagName.toLowerCase() === 'tr');
|
||||
return (w===0 && h===0 && !force)
|
||||
? true
|
||||
: (w!==0 && h!==0 && !force) ? false : this.getStyle('display') === 'none';
|
||||
},
|
||||
|
||||
isVisible: function(){
|
||||
return !this.isHidden();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* File: media/js/FlightDeck.js
|
||||
*/
|
||||
|
|
|
@ -52,7 +52,7 @@ fi
|
|||
|
||||
### Bespin installation
|
||||
cd $V_ENV/lib/
|
||||
if [ ! -e $V_ENV/lib/BespinEmbedded-0.6.1 ]
|
||||
if [ ! -e $V_ENV/lib/BespinEmbedded-DropIn-0.6.1 ]
|
||||
then
|
||||
wget http://ftp.mozilla.org/pub/mozilla.org/labs/bespin/Embedded/BespinEmbedded-DropIn-0.6.1.tar.gz --no-check-certificate
|
||||
tar xfvz BespinEmbedded-DropIn-0.6.1.tar.gz
|
||||
|
@ -66,6 +66,25 @@ then
|
|||
ln -fs $V_ENV/lib/BespinEmbedded/ $PROJECT_DIR/$PROJECT_NAME/media/bespin
|
||||
fi
|
||||
|
||||
### CodeMirror installation
|
||||
if [ ! -e $V_ENV/src/CodeMirror-0.65 ]
|
||||
then
|
||||
cd $V_ENV/src/
|
||||
wget http://marijn.haverbeke.nl/codemirror/codemirror.zip
|
||||
unzip -x codemirror.zip
|
||||
rm codemirror.zip
|
||||
rm $V_ENV/lib/codemirror
|
||||
fi
|
||||
if [ ! -e $V_ENV/lib/codemirror ]
|
||||
then
|
||||
ln -fs $V_ENV/src/CodeMirror-0.65/ $V_ENV/lib/codemirror
|
||||
fi
|
||||
|
||||
if [ ! -e $PROJECT_DIR/$PROJECT_NAME/media/codemirror ]
|
||||
then
|
||||
ln -fs $V_ENV/lib/codemirror $PROJECT_DIR/$PROJECT_NAME/media/codemirror
|
||||
fi
|
||||
|
||||
### Grappelli section
|
||||
# checkout the repository
|
||||
# TODO: wait with grappelli for the newer Django
|
||||
|
|
|
@ -11,6 +11,7 @@ pip-log.txt
|
|||
flightdeckenv
|
||||
flightdeck/media/jetpack
|
||||
flightdeck/media/bespin
|
||||
flightdeck/media/codemirror
|
||||
flightdeck/media/roar
|
||||
flightdeck/jetpack/media/media
|
||||
*local.py
|
||||
|
|
Загрузка…
Ссылка в новой задаче