diff --git a/scribeengine/controllers/media.py b/scribeengine/controllers/media.py index 43b7cff..134d373 100644 --- a/scribeengine/controllers/media.py +++ b/scribeengine/controllers/media.py @@ -60,7 +60,13 @@ class MediaController(BaseController): def _get_files(self, dirpath): for root, dirs, files in os.walk(os.path.abspath(dirpath)): - return files + filelist = [] + for filename in files: + if os.path.splitext(filename)[1] in [u'.png', u'.jpg', u'.gif']: + filelist.append({u'name': filename, u'type': u'/images/file-image.png'}) + else: + filelist.append({u'name': filename, u'type': u'/images/file-unknown.png'}) + return filelist break def index(self): @@ -79,7 +85,6 @@ class MediaController(BaseController): def get_files(self): path = request.GET.get(u'path', u'').split(u',') dirpath = os.path.join(config[u'paths.media'], *path) - #log.debug(dirpath) return {u'results': self._get_files(dirpath)} @jsonify diff --git a/scribeengine/public/scripts/ScribeEngine.Media.js b/scribeengine/public/scripts/ScribeEngine.Media.js index 2ee0875..fb6f60c 100644 --- a/scribeengine/public/scripts/ScribeEngine.Media.js +++ b/scribeengine/public/scripts/ScribeEngine.Media.js @@ -36,25 +36,23 @@ ScribeEngine.Namespace.create("ScribeEngine.Media", { function (data, textStatus) { $("#file-list > ul").html(""); $.each(data.results, function () { - var filename = this; - var extension = filename.substr(filename.length - 4); - if (extension == ".png" || extension == ".jpg") + var file = this; + if (file.name.length > 15) { - var filetype = "file-image"; - } - else - { - var filetype = "file-unknown"; - } - if (filename.length > 15) - { - filename = filename.substr(0, 12) + "..."; + file.name = file.name.substr(0, 12) + "..."; } $("#file-list > ul").append( $("