def collectionListItem(iter, divClassName = u"thumbDiv", imgClass=u"thumbImage", tagName=u"li"):
    thumbViewScript = u"http://localhost:8803/thumb?path="
    #print iter
    res = ""
    for i in iter:
        res +=u'<%s class="%s">'%(tagName, divClassName+ " ui-widget-content")
        t = tagSys.getTagSysObj()
        tList = t.getTags(i)
        tagStr = u""
        '''
        for k in tList:
            tagStr += k.decode('utf8')
        '''
        tagStr = u','.join(tList)
        '''
        res += '<div class="elementTag" path=%s>'%urllib.quote(i)
        res += ','.join(tList)
        res += 'default'
        res += '</div>'
        '''
        if tagStr == u"":
            tagStr = u"input tag"
        #quote can not support unicode, see http://bugs.python.org/issue1712522
        encoded = urllib.quote(encodingTools.translateToPageEncoding(i))
        res += u'<img class="%s" src="%s%s" path="%s"/><p class="tagEditor">%s</p>'%(imgClass, 
            thumbViewScript, encoded, i, tagStr)#first encode the str, so the browser can decode the string to local encoding
        res +=u'<div class="placeholder"></div>'
        res += u'</%s>\n'%tagName
    return res
示例#2
0
def collectionListItem(iter, req):
    resList = []
    for i in iter:
        t = tagSys.getTagSysObj(req.getDbSys())
        tList = t.getTags(i)
        #encoded = urllib.quote(encodingTools.translateToPageEncoding(i))
        resList.append({"path":i, "tags":tList})
    return resList
示例#3
0
文件: tagObj.py 项目: weijia/ufs
def tagObj(req):
    fields = libs.http.queryParam.queryInfo().getAllFieldStorageUnicode()
    h = libs.html.response.html()
    h.genTxtHead()
    #fullPath = urllib.unquote(fields[u"path"][0])
    fullPath = fields[u"path"][0]
    fullPath = transform.transformDirToInternal(fullPath)
    #print fullPath
    #tags = urllib.unquote(fields[u"tags"][0])
    tags = fields[u"tags"][0]
    tl = stringTools.splitWithChars(tags, configurationTools.getTagSeparator())
    t = tagSys.getTagSysObj(req.getDbSys())
    t.tag(fullPath, tl)
    #h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(tl))))
    
    h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(t.getTags(fullPath)))))
    h.end()
示例#4
0
def containerListJson(treeItemToPopulate, start, cnt, isTree = False, req = None, checkedItems = []):
    #print 'list in dirlist:',treeItemToPopulate.listNamedChildren(start, cnt, isTree)
    #en = libs.platform.services.getEncodingService()
    r=[]
    dbSys = req.getDbSys()
    t = tagSys.getTagSysObj(dbSys)
    try:
        d = treeItemToPopulate.listNamedChildren(start, cnt, isTree)
        ncl("list children: ", start, cnt)
        for f in d:
            #print f, r
            itemId = f
            #not needed if jstree support ":"
            itemId = stringTools.jsIdEncoding(f)
            #print 'before get is container'
            encoded = urllib.quote(encodingTools.translateToPageEncoding(f))
            item = {}
            if itemId in checkedItems:
                item["class"] = "jstree-checked"
            else:
                item = {}
            item["attr"] = {"id":itemId}
            item["data"] = d[f]
            item["fullPath"] = f
            item["utf8FullPath"] = encoded
            if treeItemToPopulate.isChildContainer(f):
                #r.append(u'<li id="%s" class="%s">%s</li>' % (itemId,itemClassWithCheckState,i))
                item["children"] = []
                item["state"] = "closed"
            if not isTree:
                #print f
                #print 'getting tree --------------------------', f
                try:
                    tList = t.getTags(f)
                except:
                    tList = []
                item["tags"] = tList
            r.append(item)
            #break
    except IOError, e:#Exception,e:
        item = {}
        item["data"] = str(e)
        r.append(item)
示例#5
0
文件: executeV2.py 项目: weijia/ufs
def executeAppOrOpenFile(req):
    fields = libs.http.queryParam.queryInfo().getAllFieldStorageUnicode()
    h = libs.html.response.html()
    h.genTxtHead()
    #fullPath = urllib.unquote(fields[u"path"][0])
    fullPath = fields[u"path"][0]
    if objTools.isUfsFs(fullPath):
        fullPath = objTools.getFullPathFromUfsUrl(fullPath)
    fullPath = transform.transformDirToInternal(fullPath)
    #print fullPath
    #tags = urllib.unquote(fields[u"tags"][0])
    tags = "sys.executable"
    tl = stringTools.splitWithChars(tags, configurationTools.getTagSeparator())
    t = tagSys.getTagSysObj(req.getDbSys())
    #t.tag(fullPath, tl)
    #h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(tl))))
    res = startAppOrOpenFile(fullPath)
    if res == "app":
        t.tag(fullPath, tl)

    h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(t.getTags(fullPath)))))
    h.end()
示例#6
0
def containerListJson(treeItemToPopulate, start, cnt, isTree = False, req = None, checkedItems = []):
    #print 'list in dirlist:',treeItemToPopulate.listNamedChildren()
    #en = libs.platform.services.getEncodingService()
    r=[]
    try:
        d = treeItemToPopulate.listNamedChildren(start, cnt, isTree)
        for f in d:
            #print f, r
            itemId = f
            #not needed if jstree support ":"
            itemId = stringTools.jsIdEncoding(f)
            ff=treeItemToPopulate.getChildAbsPath(f)
            #print 'before get is container'
            encoded = urllib.quote(encodingTools.translateToPageEncoding(f))
            if itemId in checkedItems:
                item["class"] = "jstree-checked"
            else:
                item = {}
            item["attr"] = {"id":itemId}
            item["data"] = d[f]
            item["fullPath"] = f
            item["utf8FullPath"] = encoded
            if treeItemToPopulate.isContainer(ff):
                #r.append(u'<li id="%s" class="%s">%s</li>' % (itemId,itemClassWithCheckState,i))
                item["children"] = []
                item["state"] = "closed"
            if not isTree:
                t = tagSys.getTagSysObj(req.getDbSys())
                tList = t.getTags(f)
                item["tags"] = tList
            r.append(item)
            #break
    except IOError:#Exception,e:
        r.append(u'<li id="%s" class="jstree-closed">Could not load directory: %s</a></li>' % str(e))
    #print json.dumps(r, indent = 4)
    return json.dumps(r, indent = 4)
示例#7
0
文件: tag.py 项目: weijia/ufs
 def __init__(self, itemId, req):
     super(tagCollectionItem, self).__init__()
     self.tagS = tagSys.getTagSysObj(req.getDbSys())
     print '--------------------------------tagCollectionItem'
     self.itemId = itemId
示例#8
0
import libSys
import libs.http.queryParam
import libs.html.response
import libs.tag.tagSystemInterface as tagSys
import lib.utils.transform as transform
import urllib
import libs.utils.configurationTools as configurationTools
import libs.utils.stringTools as stringTools

if __name__=='__main__':
    fields = libs.http.queryParam.queryInfo().getAllFieldStorageUnicode()
    h = libs.html.response.html()
    h.genTxtHead()
    fullPath = urllib.unquote(fields[u"path"][0])
    fullPath = transform.transformDirToInternal(fullPath)
    #print fullPath
    tags = urllib.unquote(fields[u"tags"][0])
    tl = stringTools.splitWithChars(tags, configurationTools.getTagSeparator())
    t = tagSys.getTagSysObj()
    t.removeTag(fullPath, tl)
    #h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(tl))))
    
    h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(t.getTags(fullPath)))))
    h.end()
示例#9
0
import libSys
import libs.http.queryParam
import libs.html.response
import libs.tag.tagSystemInterface as tagSystem
#from desktopApp.lib.transform import *
import urllib
import libs.utils.configurationTools as configurationTools
import libs.utils.stringTools as stringTools
import libs.utils.transform as transform
import libs.services.servicesV2 as service

if __name__=='__main__':
    r = service.req()
    fields = r.queryInfo.getAllFieldStorageUnicode()
    h = r.resp
    h.genTxtHead()
    #fullPath = urllib.unquote(fields[u"path"][0])
    fullPath = fields[u"path"][0]
    fullPath = transform.transformDirToInternal(fullPath)
    #print fullPath
    #tags = urllib.unquote(fields[u"tags"][0])
    tags = fields[u"tags"][0]
    tl = stringTools.splitWithChars(tags, configurationTools.getTagSeparator())
    t = tagSystem.getTagSysObj(r.getDbSys())
    t.appendTag(fullPath, tl)
    #h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(tl))))
    
    h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(t.getTags(fullPath)))))
    h.end()