Added jsTree jQuery Plugin.

Started on a browser function (fetching the directories).
This commit is contained in:
Raoul Snyman 2010-04-15 07:47:15 +02:00
parent 74054e69a4
commit 63950167b1
10 changed files with 2259 additions and 12 deletions

View File

@ -34,8 +34,8 @@ beaker.session.timeout = 1209600
# SQLAlchemy database URL
sqlalchemy.url = sqlite:///%(here)s/scribeengine.sqlite
# Images directory
paths.images = %(here)s/images
# Media upload directory
paths.media = %(here)s/media
# Themes directory
paths.themes = %(here)s/themes

View File

@ -34,8 +34,8 @@ app_instance_uuid = ${app_instance_uuid}
# SQLAlchemy database URL
sqlalchemy.url = sqlite:///production.db
# Images directory
paths.images = %(here)s/images
# Media upload directory
paths.media = %(here)s/media
# Themes directory
paths.themes = %(here)s/themes

View File

@ -1,16 +1,46 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# 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 #
###############################################################################
import os
import logging
from pylons import request, response, session, tmpl_context as c
from pylons.controllers.util import abort, redirect_to
from scribeengine.lib.base import BaseController, render
from scribeengine.lib.base import *
from scribeengine.lib import utils
from scribeengine.model import MediaType, File
from scribeengine.model.meta import Session
log = logging.getLogger(__name__)
class MediaController(BaseController):
def _get_directories(self, parent=None, tree={}):
if not parent:
parent = config[u'paths.media']
for dirpath in os.listdir(parent):
if os.path.isdir(dirpath):
tree[os.path.abspath(dirpath)] = {u'path': dirpath, u'children': {}}
self._get_directories(os.path.abspath(dirpath),
tree[os.path.abspath(dirpath)][u'children'])
def index(self):
# Return a rendered template
#return render('/media.mako')
# or, return a response
return 'Hello World'
c.directories = self._get_directories()
return render(u'/media/index.html')

View File

@ -77,6 +77,7 @@ class BaseController(WSGIController):
c.month_posts[post.created.day] = []
c.month_posts[post.created.day].append(post)
self._add_javascript(u'jquery.js')
self._add_javascript(u'jquery.metadata.js')
if c.jsvalidation:
self._add_javascript(u'jquery.validate.js')
self._add_javascript(u'ScribeEngine.js')

View File

@ -0,0 +1,122 @@
/*
* Metadata - jQuery plugin for parsing metadata from elements
*
* Copyright (c) 2006 John Resig, Yehuda Katz, J<EFBFBD>örn Zaefferer, Paul McLanahan
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.metadata.js 4187 2007-12-16 17:15:27Z joern.zaefferer $
*
*/
/**
* Sets the type of metadata to use. Metadata is encoded in JSON, and each property
* in the JSON will become a property of the element itself.
*
* There are three supported types of metadata storage:
*
* attr: Inside an attribute. The name parameter indicates *which* attribute.
*
* class: Inside the class attribute, wrapped in curly braces: { }
*
* elem: Inside a child element (e.g. a script tag). The
* name parameter indicates *which* element.
*
* The metadata for an element is loaded the first time the element is accessed via jQuery.
*
* As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
* matched by expr, then redefine the metadata type and run another $(expr) for other elements.
*
* @name $.metadata.setType
*
* @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("class")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from the class attribute
*
* @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("attr", "data")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a "data" attribute
*
* @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
* @before $.metadata.setType("elem", "script")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a nested script element
*
* @param String type The encoding type
* @param String name The name of the attribute to be used to get metadata (optional)
* @cat Plugins/Metadata
* @descr Sets the type of encoding to be used when loading metadata for the first time
* @type undefined
* @see metadata()
*/
(function($) {
$.extend({
metadata : {
defaults : {
type: 'class',
name: 'metadata',
cre: /({.*})/,
single: 'metadata'
},
setType: function( type, name ){
this.defaults.type = type;
this.defaults.name = name;
},
get: function( elem, opts ){
var settings = $.extend({},this.defaults,opts);
// check for empty string in single property
if ( !settings.single.length ) settings.single = 'metadata';
var data = $.data(elem, settings.single);
// returned cached data if it already exists
if ( data ) return data;
data = "{}";
if ( settings.type == "class" ) {
var m = settings.cre.exec( elem.className );
if ( m )
data = m[1];
} else if ( settings.type == "elem" ) {
if( !elem.getElementsByTagName )
return undefined;
var e = elem.getElementsByTagName(settings.name);
if ( e.length )
data = $.trim(e[0].innerHTML);
} else if ( elem.getAttribute != undefined ) {
var attr = elem.getAttribute( settings.name );
if ( attr )
data = attr;
}
if ( data.indexOf( '{' ) <0 )
data = "{" + data + "}";
data = eval("(" + data + ")");
$.data( elem, settings.single, data );
return data;
}
}
});
/**
* Returns the metadata object for the first member of the jQuery object.
*
* @name metadata
* @descr Returns element's metadata object
* @param Object opts An object contianing settings to override the defaults
* @type jQuery
* @cat Plugins/Metadata
*/
$.fn.metadata = function( opts ){
return $.metadata.get( this[0], opts );
};
})(jQuery);

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -0,0 +1,30 @@
/* LOCKED */
.tree-default .locked li a { color:gray; }
/* DOTS */
.tree-default ul { background-position:6px 1px; background-repeat:repeat-y; background-image:url(data:image/gif;base64,R0lGODlhAgACAIAAAB4dGf///yH5BAEAAAEALAAAAAACAAIAAAICRF4AOw==); _background-image:url("dot_for_ie.gif"); *background-image:url("dot_for_ie.gif"); }
.tree-default li { background-position:-64px -16px; background-repeat:no-repeat; background-image:url("icons.png"); }
/* NO DOTS */
.tree-default .no_dots, .tree-default .no_dots ul { background:transparent; }
.tree-default .no_dots li.leaf { background-image:none; background-color:transparent; }
/* OPEN or CLOSED */
.tree-default li.open { background:url("icons.png") -32px -48px no-repeat; }
.tree-default li.closed, #jstree-dragged.tree-default li li.open { background:url("icons.png") -48px -32px no-repeat; }
#jstree-marker { background-image:url("icons.png"); }
/* DEFAULT, HOVER, CLICKED, LOADING STATES */
.tree-default li a, .tree-default li span { border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; }
.tree-default li a:hover, .tree-default li a.hover, .tree-default li span { background: #e7f4f9; border:1px solid #d8f0fa; padding:0px 3px 0px 3px; }
.tree-default li a.clicked, .tree-default li a.clicked:hover, .tree-default li span.clicked { background: #beebff; border:1px solid #99defd; padding:0px 3px 0px 3px; }
/* ICONS */
.tree-default ins { background-image:url("icons.png"); background-position:0 0; background-repeat:no-repeat; }
.tree-default ul li a.loading ins { background-image:url("throbber.gif") !important; background-position:0 0 !important; } /* UL is added to make selector stronger */
.tree-default li a ins.forbidden { background-position:-16px -16px; }
.tree-default .locked li a ins { background-position:0 -48px; }
.tree-default li span ins { background-position:-16px 0; }
#jstree-dragged.tree-default ins { background:url("icons.png") -16px -32px no-repeat; }
#jstree-dragged.tree-default ins.forbidden { background:url("icons.png") -16px -16px no-repeat; }
/* CONTEXT MENU */
.tree-default-context a ins { background-image:url("icons.png"); background-repeat:no-repeat; background-position:-64px -64px; }
.tree-default-context a ins.create { background-position:0 -16px; }
.tree-default-context a ins.rename { background-position:-16px 0px; }
.tree-default-context a ins.remove { background-position:0 -32px; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB