예제 #1
0
파일: news.py 프로젝트: nkhine/ztm-ikaaro
    def update_relative_links(self, source):
        WebPage.update_relative_links(self, source)

        site_root = self.get_site_root()
        available_languages = site_root.get_property('website_languages')

        target = self.get_canonical_path()
        resources_old2new = get_context().database.resources_old2new

        for lang in available_languages:
            path = self.get_property('thumbnail', language=lang)
            if not path:
                continue
            ref = get_reference(path)
            if ref.scheme:
                continue
            path, view = get_path_and_view(ref.path)
            # Calcul the old absolute path
            old_abs_path = source.resolve2(path)
            # Check if the target path has not been moved
            new_abs_path = resources_old2new.get(old_abs_path, old_abs_path)
            # Build the new reference with the right path
            # Absolute path allow to call get_pathto with the target
            new_ref = deepcopy(ref)
            new_ref.path = str(target.get_pathto(new_abs_path)) + view
            self.set_property('thumbnail', str(new_ref), language=lang)
예제 #2
0
파일: news.py 프로젝트: nkhine/ztm-ikaaro
    def update_links(self, source, target):
        WebPage.update_links(self, source, target)

        site_root = self.get_site_root()
        available_languages = site_root.get_property('website_languages')

        base = self.get_canonical_path()
        resources_new2old = get_context().database.resources_new2old
        base = str(base)
        old_base = resources_new2old.get(base, base)
        old_base = Path(old_base)
        new_base = Path(base)

        for lang in available_languages:
            path = self.get_property('thumbnail', language=lang)
            if not path:
                continue
            ref = get_reference(path)
            if ref.scheme:
                continue
            path, view = get_path_and_view(ref.path)
            path = str(old_base.resolve2(path))
            if path == source:
                # Hit the old name
                # Build the new reference with the right path
                new_ref = deepcopy(ref)
                new_ref.path = str(new_base.get_pathto(target)) + view
                self.set_property('thumbnail', str(new_ref), language=lang)

        get_context().database.change_resource(self)
예제 #3
0
파일: html.py 프로젝트: nkhine/ztm-ikaaro
 def get_links(self):
     links = WebPage.get_links(self)
     base = self.get_canonical_path()
     path = self.get_property('title_link')
     if path:
         ref = get_reference(path)
         if not ref.scheme:
             path, view = get_path_and_view(ref.path)
             links.add(str(base.resolve2(path)))
     return links
예제 #4
0
파일: news.py 프로젝트: nkhine/ztm-ikaaro
    def get_links(self):
        links = WebPage.get_links(self)

        base = self.get_canonical_path()
        site_root = self.get_site_root()
        available_languages = site_root.get_property('website_languages')

        for language in available_languages:
            path = self.get_property('thumbnail')
            if not path:
                continue
            ref = get_reference(path)
            if not ref.scheme:
                path, view = get_path_and_view(ref.path)
                links.add(str(base.resolve2(path)))

        return links
예제 #5
0
파일: diaporama.py 프로젝트: hforge/itws
    def get_links(self):
        base = self.get_canonical_path()
        site_root = self.get_site_root()
        available_languages = site_root.get_property('website_languages')
        handler = self.handler
        links = super(DiaporamaTable, self).get_links()

        get_value = handler.get_record_value
        for record in handler.get_records():
            for lang in available_languages:
                for key in ('img_path', 'img_link'):
                    path = get_value(record, key, lang)
                    if not path:
                        continue
                    ref = get_reference(path)
                    if not ref.scheme:
                        path, view = get_path_and_view(ref.path)
                        links.add(str(base.resolve2(path)))

        return links
예제 #6
0
파일: html.py 프로젝트: nkhine/ztm-ikaaro
    def update_relative_links(self, source):
        WebPage.update_relative_links(self, source)

        target = self.get_canonical_path()
        resources_old2new = get_context().database.resources_old2new
        path = self.get_property('title_link')
        if path:
            ref = get_reference(str(path))
            if not ref.scheme:
                path, view = get_path_and_view(ref.path)
                # Calcul the old absolute path
                old_abs_path = source.resolve2(path)
                # Check if the target path has not been moved
                new_abs_path = resources_old2new.get(old_abs_path,
                                                     old_abs_path)
                # Build the new reference with the right path
                # Absolute path allow to call get_pathto with the target
                new_ref = deepcopy(ref)
                new_ref.path = str(target.get_pathto(new_abs_path)) + view
                # Update the title link
                self.set_property('title_link', str(new_ref))
예제 #7
0
파일: diaporama.py 프로젝트: hforge/itws
    def update_links(self, source, target):
        super(DiaporamaTable, self).update_links(source, target)

        # Caution multilingual property
        base = self.get_canonical_path()
        resources_new2old = get_context().database.resources_new2old
        base = str(base)
        old_base = resources_new2old.get(base, base)
        old_base = Path(old_base)
        new_base = Path(base)

        site_root = self.get_site_root()
        available_languages = site_root.get_property('website_languages')
        handler = self.handler
        record_properties = handler.record_properties

        # TODO To improve
        get_value = handler.get_record_value
        for record in handler.get_records():
            for lang in available_languages:
                for key in ('img_path', 'img_link'):
                    path = get_value(record, key, lang)
                    if not path:
                        continue
                    ref = get_reference(path)
                    if ref.scheme:
                        continue
                    path, view = get_path_and_view(ref.path)
                    path = str(old_base.resolve2(path))
                    if path == source:
                        # Hit the old name
                        # Build the new reference with the right path
                        new_ref = deepcopy(ref)
                        new_ref.path = str(new_base.get_pathto(target)) + view
                        datatype = record_properties.get(key, String)
                        new_path = Property(datatype.decode(str(new_ref)),
                                            language=lang)
                        handler.update_record(record.id, **{key: new_path})

        get_context().database.change_resource(self)
예제 #8
0
파일: diaporama.py 프로젝트: hforge/itws
 def get_item_value(self, resource, context, item, column):
     if column == 'img_path':
         img_path = resource.handler.get_record_value(item, column)
         image = resource.get_resource(str(img_path), soft=True)
         if not image:
             return None
         return get_resource_preview(image, 128, 64, 0, context)
     elif column == 'img_link':
         img_link = resource.handler.get_record_value(item, column)
         reference = get_reference(img_link)
         if isinstance(reference, EmptyReference):
             return None
         if reference.scheme:
             # Encode the reference '&' to avoid XMLError
             ref = XMLContent.encode(str(reference))
             return XMLParser('<a href="{ref}">{ref}</a>'.format(ref=ref))
         # Split path/view
         reference_path, view = get_path_and_view(reference.path)
         item_resource = resource.get_resource(reference_path, soft=True)
         if not item_resource:
             # Not found, just return the reference
             # Encode the reference '&' to avoid XMLError
             return XMLContent.encode(str(reference))
         # Build the new reference with the right path
         reference2 = deepcopy(reference)
         reference2.path = context.get_link(item_resource)
         if view:
             # Append the view
             reference2.path = '%s/;%s' % (reference2.path, view)
         # Encode the reference '&' to avoid XMLError
         # Reference : the reference used for the a content
         reference = XMLContent.encode(str(reference))
         # Reference2 : the reference used for href attribute
         reference2 = XMLContent.encode(str(reference2))
         return XMLParser('<a href="%s">%s</a>' % (reference2, reference))
     return OrderedTable_View.get_item_value(self, resource, context, item,
                                             column)
예제 #9
0
파일: diaporama.py 프로젝트: hforge/itws
    def update_relative_links(self, source):
        super(DiaporamaTable, self).update_relative_links(source)

        site_root = self.get_site_root()
        available_languages = site_root.get_property('website_languages')
        target = self.get_canonical_path()

        handler = self.handler
        record_properties = handler.record_properties
        resources_old2new = get_context().database.resources_old2new
        # TODO To improve
        get_value = handler.get_record_value
        for record in handler.get_records():
            for lang in available_languages:
                for key in ('img_path', 'img_link'):
                    path = get_value(record, key, lang)
                    if not path:
                        continue
                    ref = get_reference(str(path))
                    if ref.scheme:
                        continue
                    path, view = get_path_and_view(ref.path)
                    # Calcul the old absolute path
                    old_abs_path = source.resolve2(path)
                    # Check if the target path has not been moved
                    new_abs_path = resources_old2new.get(old_abs_path,
                                                         old_abs_path)
                    # Build the new reference with the right path
                    # Absolute path allow to call get_pathto with the target
                    new_ref = deepcopy(ref)
                    new_ref.path = str(target.get_pathto(new_abs_path)) + view
                    # Update the record
                    datatype = record_properties.get(key, String)
                    new_path = Property(datatype.decode(str(new_ref)),
                                        language=lang)
                    handler.update_record(record.id, **{key: new_path})
예제 #10
0
파일: html.py 프로젝트: nkhine/ztm-ikaaro
    def update_links(self, source, target):
        WebPage.update_links(self, source, target)

        base = self.get_canonical_path()
        resources_new2old = get_context().database.resources_new2old
        base = str(base)
        old_base = resources_new2old.get(base, base)
        old_base = Path(old_base)
        new_base = Path(base)

        path = self.get_property('title_link')
        if path:
            ref = get_reference(path)
            if not ref.scheme:
                path, view = get_path_and_view(ref.path)
                path = str(old_base.resolve2(path))
                if path == source:
                    # Hit the old name
                    # Build the new reference with the right path
                    new_ref = deepcopy(ref)
                    new_ref.path = str(new_base.get_pathto(target)) + view
                    self.set_property('title_link', str(new_ref))

        get_context().database.change_resource(self)