예제 #1
0
    def build(self):
        page_rel_path = self.rel_path(self.dir.flattening_dir)
        logging.info(_("  XHTML %s") % page_rel_path)
        logging.debug("(%s)" % self.page_path)

        tpl_values = self.init_tpl_values()

        # Breadcrumbs
        tpl_values['webgal_path'] = tplvars.Webgal(self, self.dir).path()

        tpl_values['name'] = self.media.filename
        tpl_values['mediatype'] = self.media.type
        tpl_values['dir'] = self.dir.source_dir.strip_root()

        prev = self.webalbum_media.previous
        if prev:
            tpl_values['prev_link'] = tplvars.Media(self, prev).link()

        next = self.webalbum_media.next
        if next:
            tpl_values['next_link'] = tplvars.Media(self, next).link()

        tpl_values['index_link'] = self._add_size_qualifier('index.html',
                                                            self.size_name)
        if self.dir.should_be_flattened():
            index_rel_dir = self.dir.flattening_dir.source_dir.rel_path(self.dir.source_dir)
            tpl_values['index_link'] = index_rel_dir + tpl_values['index_link']

        tpl_values['osize_links'] = self._get_osize_links(self.media.name)
        tpl_values['rel_root'] = pathutils.url_path(self.dir.source_dir.rel_root()) + '/'

        if self.dir.feed is not None:
            tpl_values['feed_url'] = os.path.relpath(self.dir.feed.path,
                                                     self.dir.path)
            tpl_values['feed_url'] = pathutils.url_path(tpl_values['feed_url'])
            tpl_values['feed_url'] = self.url_quote(tpl_values['feed_url'])
        else:
            tpl_values['feed_url'] = None

        if self.dir.original:
            if self.dir.orig_base:
                tpl_values['original_link'] = posixpath.join(
                    pathutils.url_path(self.dir.source_dir.rel_root()),
                    self.dir.orig_base,
                    pathutils.url_path(self.dir.source_dir.strip_root()),
                    self.media.filename)
            else:
                tpl_values['original_link'] = self.media.filename
            tpl_values['original_link'] =\
                self.url_quote(tpl_values['original_link'])

        self.add_extra_vals(tpl_values)

        self.page_template.dump(tpl_values, self.page_path)
예제 #2
0
    def build(self):
        logging.info(_("  XHTML %s") % os.path.basename(self.page_path))
        logging.debug("(%s)" % self.page_path)

        values = self.init_tpl_values()

        # Breadcrumbs (current is static, see dirindex.thtml, that's why the
        # last item of the list is removed).
        values['webgal_path'] = tplvars.Webgal(self, self.dir).path()[:-1]

        if not self.dir.source_dir.is_album_root():
            # Parent index link not for album root
            values['parent_index_link'] = self._get_related_index_fn()

        values['osize_index_links'] = self._get_osize_links(self._get_paginated_name())
        values['onum_index_links'] = self._get_onum_links()

        if self.dir.flatten_below():
            values['subgal_links'] = []
        else:
            values['subgal_links'] = self._get_subgal_links()

        values['medias'] = []
        for subdir, medias in self.galleries:
            info = tplvars.Webgal(self, subdir).info()
            if self.size_name in subdir.browse_sizes:
                media_links = [tplvars.media_vars(self, media).full()
                               for media in medias]
            else:
                # This happens when this dir index size is not available in the
                # subdir.
                media_links = []
            values['medias'].append((info, media_links, ))

        values.update(tplvars.Webgal(self, self.dir).info())

        values['rel_root'] = pathutils.url_path(self.dir.source_dir.rel_root()) + '/'
        values['rel_path'] = pathutils.url_path(self.dir.source_dir.strip_root())

        if self.dir.feed is not None:
            values['feed_url'] = os.path.relpath(self.dir.feed.path,
                                                 self.dir.path)
            values['feed_url'] = pathutils.url_path(values['feed_url'])
            values['feed_url'] = self.url_quote(values['feed_url'])
        else:
            values['feed_url'] = None

        self.page_template.dump(values, self.page_path)
예제 #3
0
    def rel_path(self, dir, url=False):
        """
        Returns the path of the current object relative to the supplied dir
        object argument. Force forward slashes if url is True.
        """
        ret = None
        if dir is None or dir is self.dir:
            ret = os.path.basename(self.path)
        else:
            ret = dir.rel_path(self.path)

        if url:
            return pathutils.url_path(ret)
        else:
            return ret
예제 #4
0
    def link(self):
        link_target = self.page._add_size_qualifier('index.html')

        if self.should_be_flattened():
            # Add anchor target to get straight to gallery listing
            link_target = link_target + '#' + self.id()

        # Add relative path to link if needed
        index_path = None
        if self.should_be_flattened():
            index_path = self.page.dir.flattening_srcpath(self.srcpath)
        elif self.srcpath != self.page.dir.source_dir.path:
            index_path = self.srcpath
        if index_path is not None:
            index_path = self.page.dir.rel_path_to_src(index_path)
            index_path = pathutils.url_path(index_path)
            link_target = posixpath.join(index_path, link_target)

        return self.page.url_quote(link_target)