<commit_before># Copyright (c) 2007-2008 gocept gmbh & co. kg
# See also LICENSE.txt
# $Id$

import transaction

import zope.component
import zope.cachedescriptors.property
import zope.viewlet.viewlet
import zope.traversing.interfaces
import zope.traversing.api

import zeit.cms.browser.interfaces
import zeit.cms.browser.tree
import zeit.cms.repository.interfaces
import zeit.cms.browser.listing

import zeit.cms.clipboard.interfaces


class Sidebar(zope.viewlet.viewlet.ViewletBase):

    @zope.cachedescriptors.property.Lazy
    def clipboard(self):
        return zeit.cms.clipboard.interfaces.IClipboard(self.request.principal)


class Tree(zeit.cms.browser.tree.Tree):
    """Clipbaord tree"""

    root_name = 'Clipboard'
    key = __module__ + '.Tree'

    @zope.cachedescriptors.property.Lazy
    def root(self):
        """repository representing the root of the tree"""
        return zeit.cms.clipboard.interfaces.IClipboard(self.request.principal)

    def isRoot(self, container):
        return zeit.cms.clipboard.interfaces.IClipboard.providedBy(container)

    def getUniqueId(self, object):
        if self.isRoot(object):
            return ''
        root_path = zope.traversing.api.getPath(self.root)
        full_path = zope.traversing.api.getPath(object)
        relative = full_path[len(root_path) + 1:]
        return relative

    def addContent(self, add_to, unique_id):
        container = self.getAddContext(add_to)
        add_object = self.repository.getContent(unique_id)
        self.context.addContent(container, add_object, add_object.__name__)<commit_msg>- expand the clip if its collapsed and new content is dragged into it<commit_after># Copyright (c) 2007-2008 gocept gmbh & co. kg
# See also LICENSE.txt
# $Id$

import transaction

import zope.component
import zope.cachedescriptors.property
import zope.viewlet.viewlet
import zope.traversing.interfaces
import zope.traversing.api

import zeit.cms.browser.interfaces
import zeit.cms.browser.tree
import zeit.cms.repository.interfaces
import zeit.cms.browser.listing

import zeit.cms.clipboard.interfaces


class Sidebar(zope.viewlet.viewlet.ViewletBase):

    @zope.cachedescriptors.property.Lazy
    def clipboard(self):
        return zeit.cms.clipboard.interfaces.IClipboard(self.request.principal)


class Tree(zeit.cms.browser.tree.Tree):
    """Clipbaord tree"""

    root_name = 'Clipboard'
    key = __module__ + '.Tree'

    @zope.cachedescriptors.property.Lazy
    def root(self):
        """repository representing the root of the tree"""
        return zeit.cms.clipboard.interfaces.IClipboard(self.request.principal)

    def isRoot(self, container):
        return zeit.cms.clipboard.interfaces.IClipboard.providedBy(container)

    def getUniqueId(self, object):
        if self.isRoot(object):
            return ''
        root_path = zope.traversing.api.getPath(self.root)
        full_path = zope.traversing.api.getPath(object)
        relative = full_path[len(root_path) + 1:]
        return relative

    def addContent(self, add_to, unique_id):
        container = self.getAddContext(add_to)
        add_object = self.repository.getContent(unique_id)
        self.context.addContent(container, add_object, add_object.__name__)
        if self.expandable(container) and not self.expanded(container):
            self.expandNode(container.__name__)
{'fraction_non_alphanumeric': 0.10065515187611673, 'fraction_numerical': 0.005360333531864205, 'mean_word_length': 3.6459197786998616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7649306', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1050, 'n_words': 204}