Added the fileBrowser hook stuff.
This commit is contained in:
parent
030166f356
commit
5830655100
@ -38,6 +38,10 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class MediaController(BaseController):
|
class MediaController(BaseController):
|
||||||
|
|
||||||
|
def __before__(self):
|
||||||
|
BaseController.__before__(self)
|
||||||
|
self._add_javascript('ScribeEngine.Media.js')
|
||||||
|
|
||||||
def _get_directories(self, parent=None, tree=[]):
|
def _get_directories(self, parent=None, tree=[]):
|
||||||
old_root = parent
|
old_root = parent
|
||||||
dirname = os.path.split(parent)[1]
|
dirname = os.path.split(parent)[1]
|
||||||
@ -53,7 +57,10 @@ class MediaController(BaseController):
|
|||||||
def index(self):
|
def index(self):
|
||||||
self._add_javascript(u'jtree/jquery.tree.js')
|
self._add_javascript(u'jtree/jquery.tree.js')
|
||||||
directories = []
|
directories = []
|
||||||
self._get_directories(config[u'paths.media'], directories)
|
path = os.path.join(config[u'paths.media'], u'user%s' % c.current_user.id)
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.makedirs(path)
|
||||||
|
self._get_directories(path, directories)
|
||||||
c.directories = json.dumps(directories)
|
c.directories = json.dumps(directories)
|
||||||
#return pformat(c.directories, indent=2)
|
#return pformat(c.directories, indent=2)
|
||||||
return render(u'/media/index.mako')
|
return render(u'/media/index.mako')
|
||||||
|
35
scribeengine/public/scripts/ScribeEngine.Media.js
Normal file
35
scribeengine/public/scripts/ScribeEngine.Media.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* ScribeEngine - Open Source Blog Software *
|
||||||
|
* ------------------------------------------------------------------------- *
|
||||||
|
* Copyright (c) 2010 Raoul Snyman *
|
||||||
|
* ------------------------------------------------------------------------- *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms of the GNU General Public License as published by the *
|
||||||
|
* Free Software Foundation; version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, but *
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
|
||||||
|
* Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
ScribeEngine.Namespace.create("ScribeEngine.Media", {
|
||||||
|
new_directory: function ()
|
||||||
|
{
|
||||||
|
var dirname = prompt("New Directory:", "directory");
|
||||||
|
},
|
||||||
|
get_files: function (node, tree)
|
||||||
|
{
|
||||||
|
node = $(node);
|
||||||
|
alert(node.children("a").text());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ScribeEngine.Events.load(function () {
|
||||||
|
ScribeEngine.Events.click("#new-directory", ScribeEngine.Media.new_directory);
|
||||||
|
ScribeEngine.Events.click("#file-select", window.close);
|
||||||
|
});
|
@ -23,15 +23,5 @@ ScribeEngine.Namespace.create("ScribeEngine.Post", {
|
|||||||
|
|
||||||
ScribeEngine.Events.load(function () {
|
ScribeEngine.Events.load(function () {
|
||||||
ScribeEngine.Widgets.tagEditor("#post-tags");
|
ScribeEngine.Widgets.tagEditor("#post-tags");
|
||||||
$('textarea').tinymce({
|
ScribeEngine.Widgets.tinymce("textarea");
|
||||||
script_url: "/scripts/tinymce/tiny_mce.js",
|
|
||||||
theme: "advanced",
|
|
||||||
dialog_type: "modal",
|
|
||||||
theme_advanced_toolbar_location: "top",
|
|
||||||
theme_advanced_toolbar_align: "left",
|
|
||||||
theme_advanced_statusbar_location: "bottom",
|
|
||||||
theme_advanced_resizing: true,
|
|
||||||
theme_advanced_resize_horizontal: false
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -130,6 +130,69 @@ ScribeEngine.Namespace.create("ScribeEngine.Widgets", {
|
|||||||
elastic: function (selector)
|
elastic: function (selector)
|
||||||
{
|
{
|
||||||
$(selector).elastic();
|
$(selector).elastic();
|
||||||
|
},
|
||||||
|
fileBrowser: function (field_name, url, type, win)
|
||||||
|
{
|
||||||
|
alert("Field_Name: " + field_name + "\nURL: " + url + "\nType: " + type + "\nWin: " + win); // debug/testing
|
||||||
|
var cmsURL = window.location.toString(); // script URL - use an absolute path!
|
||||||
|
if (cmsURL.indexOf("?") < 0)
|
||||||
|
{
|
||||||
|
//add the type as the only query parameter
|
||||||
|
cmsURL = cmsURL + "?type=" + type;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//add the type as an additional query parameter
|
||||||
|
// (PHP session ID is now included if there is one at all)
|
||||||
|
cmsURL = cmsURL + "&type=" + type;
|
||||||
|
}
|
||||||
|
tinyMCE.activeEditor.windowManager.open(
|
||||||
|
{
|
||||||
|
file: "/media",
|
||||||
|
title: "Media Library",
|
||||||
|
width: 600, // Your dimensions may differ - toy around with them!
|
||||||
|
height: 400,
|
||||||
|
resizable: "yes",
|
||||||
|
inline: "yes", // This parameter only has an effect if you use the inlinepopups plugin!
|
||||||
|
close_previous: "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
window: win,
|
||||||
|
input: field_name
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
tinymce: function (selector)
|
||||||
|
{
|
||||||
|
$(selector).tinymce({
|
||||||
|
script_url: "/scripts/tinymce/tiny_mce.js",
|
||||||
|
theme: "advanced",
|
||||||
|
dialog_type: "modal",
|
||||||
|
theme_advanced_toolbar_location: "top",
|
||||||
|
theme_advanced_toolbar_align: "left",
|
||||||
|
theme_advanced_statusbar_location: "bottom",
|
||||||
|
theme_advanced_resizing: true,
|
||||||
|
theme_advanced_resize_horizontal: false,
|
||||||
|
file_browser_callback: "ScribeEngine.Widgets.fileBrowser"
|
||||||
|
});
|
||||||
|
},
|
||||||
|
tree: function (selector, data, onselect)
|
||||||
|
{
|
||||||
|
$(selector).tree({
|
||||||
|
data:
|
||||||
|
{
|
||||||
|
type: "json",
|
||||||
|
opts:
|
||||||
|
{
|
||||||
|
static: data
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback:
|
||||||
|
{
|
||||||
|
onselect: onselect
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,22 +10,22 @@
|
|||||||
% if c.jsinit:
|
% if c.jsinit:
|
||||||
<script src="/scripts/${c.jsinit}" type="text/javascript"></script>
|
<script src="/scripts/${c.jsinit}" type="text/javascript"></script>
|
||||||
% endif
|
% endif
|
||||||
|
<style type="text/css">
|
||||||
|
body { margin: 0; padding: 0; }
|
||||||
|
#directory-tree { border-right: 1px solid #999; border-bottom: 1px solid #999; height: 370px; float: left; padding-right: 4px; width: 195px; }
|
||||||
|
#file-list { border-bottom: 1px solid #999; height: 370px; padding-left: 4px; float: left; width: 396px; }
|
||||||
|
#button-bar { clear: both; height: 30px; line-height: 30px; }
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="directory-tree" style="border: 1px solid #999; height: 400px; width: 200px;"></div>
|
<div id="directory-tree"></div>
|
||||||
|
<div id="file-list"></div>
|
||||||
|
<div id="button-bar">
|
||||||
|
<input type="button" id="new-directory" value="New Directory"/>
|
||||||
|
<input type="button" id="file-select" value="Select"/>
|
||||||
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$("#directory-tree").tree(
|
ScribeEngine.Widgets.tree("#directory-tree", ${c.directories | n}, ScribeEngine.Media.get_files);
|
||||||
{
|
|
||||||
data:
|
|
||||||
{
|
|
||||||
type: "json",
|
|
||||||
opts:
|
|
||||||
{
|
|
||||||
static : ${c.directories | n}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Reference in New Issue
Block a user