diff --git a/scribeengine/controllers/media.py b/scribeengine/controllers/media.py index ba12036..be902e4 100644 --- a/scribeengine/controllers/media.py +++ b/scribeengine/controllers/media.py @@ -38,6 +38,10 @@ log = logging.getLogger(__name__) class MediaController(BaseController): + def __before__(self): + BaseController.__before__(self) + self._add_javascript('ScribeEngine.Media.js') + def _get_directories(self, parent=None, tree=[]): old_root = parent dirname = os.path.split(parent)[1] @@ -53,7 +57,10 @@ class MediaController(BaseController): def index(self): self._add_javascript(u'jtree/jquery.tree.js') 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) #return pformat(c.directories, indent=2) return render(u'/media/index.mako') diff --git a/scribeengine/public/scripts/ScribeEngine.Media.js b/scribeengine/public/scripts/ScribeEngine.Media.js new file mode 100644 index 0000000..a3bb8e2 --- /dev/null +++ b/scribeengine/public/scripts/ScribeEngine.Media.js @@ -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); +}); diff --git a/scribeengine/public/scripts/ScribeEngine.Post.js b/scribeengine/public/scripts/ScribeEngine.Post.js index 9380b3a..45da5b6 100644 --- a/scribeengine/public/scripts/ScribeEngine.Post.js +++ b/scribeengine/public/scripts/ScribeEngine.Post.js @@ -23,15 +23,5 @@ ScribeEngine.Namespace.create("ScribeEngine.Post", { ScribeEngine.Events.load(function () { ScribeEngine.Widgets.tagEditor("#post-tags"); - $('textarea').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 - }); - + ScribeEngine.Widgets.tinymce("textarea"); }); diff --git a/scribeengine/public/scripts/ScribeEngine.js b/scribeengine/public/scripts/ScribeEngine.js index 4e1e3c9..c55f727 100644 --- a/scribeengine/public/scripts/ScribeEngine.js +++ b/scribeengine/public/scripts/ScribeEngine.js @@ -119,18 +119,81 @@ ScribeEngine.Namespace.create("ScribeEngine.Widgets", { /** * Adds a datepicker to an element. */ - datepicker: function (selector) - { - $(selector).datepicker({showButtonPanel: true, dateFormat: "dd/mm/yy"}); - }, - tagEditor: function (selector) - { - $(selector).tagEditor({completeOnBlur: true, initialParse: true}); - }, - elastic: function (selector) - { - $(selector).elastic(); - } + datepicker: function (selector) + { + $(selector).datepicker({showButtonPanel: true, dateFormat: "dd/mm/yy"}); + }, + tagEditor: function (selector) + { + $(selector).tagEditor({completeOnBlur: true, initialParse: true}); + }, + elastic: function (selector) + { + $(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 + } + }); + } }); ScribeEngine.Namespace.create("ScribeEngine.General", { diff --git a/scribeengine/templates/media/index.mako b/scribeengine/templates/media/index.mako index 63f7e70..71e8cb1 100644 --- a/scribeengine/templates/media/index.mako +++ b/scribeengine/templates/media/index.mako @@ -10,22 +10,22 @@ % if c.jsinit: % endif + -
+
+
+
+ + +
- \ No newline at end of file +