diff --git a/scribeengine/controllers/media.py b/scribeengine/controllers/media.py index f3d0436..43b7cff 100644 --- a/scribeengine/controllers/media.py +++ b/scribeengine/controllers/media.py @@ -72,7 +72,7 @@ class MediaController(BaseController): self._get_directories(path, directories) c.directories = json.dumps(directories) c.files = self._get_files(path) - #return pformat(c.directories, indent=2) + c.page_title = u'Media Browser' return render(u'/media/index.mako') @jsonify @@ -80,7 +80,7 @@ class MediaController(BaseController): path = request.GET.get(u'path', u'').split(u',') dirpath = os.path.join(config[u'paths.media'], *path) #log.debug(dirpath) - return self._get_files(dirpath) + return {u'results': self._get_files(dirpath)} @jsonify def create_directory(self): diff --git a/scribeengine/public/images/file-image.png b/scribeengine/public/images/file-image.png new file mode 100644 index 0000000..a56f9af Binary files /dev/null and b/scribeengine/public/images/file-image.png differ diff --git a/scribeengine/public/images/file-unknown.png b/scribeengine/public/images/file-unknown.png new file mode 100644 index 0000000..dc28b5a Binary files /dev/null and b/scribeengine/public/images/file-unknown.png differ diff --git a/scribeengine/public/scripts/ScribeEngine.Media.js b/scribeengine/public/scripts/ScribeEngine.Media.js index 323e718..2ee0875 100644 --- a/scribeengine/public/scripts/ScribeEngine.Media.js +++ b/scribeengine/public/scripts/ScribeEngine.Media.js @@ -18,6 +18,10 @@ *****************************************************************************/ ScribeEngine.Namespace.create("ScribeEngine.Media", { + closeWindow: function () + { + window.close(); + }, newDirectory: function () { var dirname = prompt("New Directory:", "directory"); @@ -31,24 +35,44 @@ ScribeEngine.Namespace.create("ScribeEngine.Media", { {"path": path.toString()}, function (data, textStatus) { $("#file-list > ul").html(""); - $.each(data, function () { + $.each(data.results, function () { var filename = this; + var extension = filename.substr(filename.length - 4); + if (extension == ".png" || extension == ".jpg") + { + var filetype = "file-image"; + } + else + { + var filetype = "file-unknown"; + } if (filename.length > 15) { filename = filename.substr(0, 12) + "..."; } $("#file-list > ul").append( $("
  • ") - .append($("
    ").attr("class", "file").html(" ")) - .append($("
    ").attr("class", "caption").attr("title", filename).text(filename)) + .append($("").attr("href", "#").attr("class", "file") + .html("").click(ScribeEngine.Media.selectFile)) + .append($("").attr("href", "#").attr("class", "caption").attr("title", filename).text(filename).click(ScribeEngine.Media.selectFile)) ); }); } ); + }, + selectFile: function (e) + { + var li = ScribeEngine.Events.getElement(e).parent(); + if (!li.is("li")) + { + li = li.parent(); + } + li.parent().children("li").children(".selected").removeClass("selected"); + li.children("a").addClass("selected").blur(); } }); ScribeEngine.Events.load(function () { ScribeEngine.Events.click("#new-directory", ScribeEngine.Media.newDirectory); - ScribeEngine.Events.click("#file-select", window.close); + ScribeEngine.Events.click("#file-select", ScribeEngine.Media.closeWindow); }); diff --git a/scribeengine/public/styles/style.css b/scribeengine/public/styles/style.css index a78b713..d8f9712 100644 --- a/scribeengine/public/styles/style.css +++ b/scribeengine/public/styles/style.css @@ -512,6 +512,9 @@ fieldset.form-details .form-text { color: #000; } +/* Media Browser */ + + /* Pagination */ .pagination { diff --git a/scribeengine/templates/media/index.mako b/scribeengine/templates/media/index.mako index 1ea90c7..d33464b 100644 --- a/scribeengine/templates/media/index.mako +++ b/scribeengine/templates/media/index.mako @@ -11,15 +11,18 @@ % endif