예제 #1
0
    def get(self, path, include_body=True):
        # preable taken from StaticFileHandler
        # Set up our path instance variables.
        self.path = self.parse_url_path(path)
        del path  # make sure we don't refer to path instead of self.path again
        absolute_path = self.get_absolute_path(self.root, self.path)
        self.absolute_path = self.validate_absolute_path(
            self.root, absolute_path)

        if self.absolute_path is None:
            return

        # typing is hard
        abs_path = self.absolute_path
        rel_path = self.path

        everything = [
            File(os.path.join(abs_path, f), self.root)
            for f in os.listdir(abs_path)
        ]

        files = []
        directories = []
        for f in everything:
            if f.basename[0] == '.':
                # hidden file
                # do not display
                continue

            if f.is_directory:
                directories.append(Dir(f.absolute, self.root))
                continue

            if is_image(f.absolute):
                img = Image(f.absolute, self.root)
                img.generate_thumb_in_background()
                files.append(img)
                continue

            files.append(f)

        files = self.order(files)
        directories = self.order(directories)
        columns = self.columns.values()

        #raise Exception('hi')

        self.render('index.html',
                    files=files,
                    dirs=directories,
                    path=rel_path,
                    columns=columns,
                    query_string=self.generate_query_string)
예제 #2
0
    def get(self, path, include_body=True):
        # preable taken from StaticFileHandler
        # Set up our path instance variables.
        self.path = self.parse_url_path(path)
        del path  # make sure we don't refer to path instead of self.path again
        absolute_path = self.get_absolute_path(self.root, self.path)
        self.absolute_path = self.validate_absolute_path(self.root,
                                                         absolute_path)

        if self.absolute_path is None:
            return

        # typing is hard
        abs_path = self.absolute_path
        rel_path = self.path

        everything = [File(os.path.join(abs_path, f), self.root) for f in
                      os.listdir(abs_path)]


        files = []
        directories = []
        for f in everything:
            if f.basename[0] == '.':
                # hidden file
                # do not display
                continue

            if f.is_directory:
                directories.append(Dir(f.absolute, self.root))
                continue

            if is_image(f.absolute):
                img = Image(f.absolute, self.root)
                img.generate_thumb_in_background()
                files.append(img)
                continue

            files.append(f)


        files = self.order(files)
        directories = self.order(directories)
        columns = self.columns.values()

        #raise Exception('hi')

        self.render('index.html', files=files, dirs=directories, path=rel_path,
                    columns=columns, query_string=self.generate_query_string)
예제 #3
0
    def get(self, path, include_body=True):
        self.path = self.parse_url_path(path)
        absolute_path = self.get_absolute_path(self.root, self.path)
        self.absolute_path = self.validate_absolute_path(
            self.root, absolute_path)
        if self.absolute_path is None:
            return

        should_count = self.get_argument('count', 'true')
        if should_count != 'false':
            # count access times with hit()
            meta = FileMeta.for_path(self.absolute_path)
            meta.hit()
            if is_image(self.absolute_path):
                img = WebImage(self.absolute_path, self.root)
                img.generate_thumb_in_background()

        return super(HitCountImageServer, self).get(path, include_body)
예제 #4
0
    def get(self, path, include_body=True):
        self.path = self.parse_url_path(path)
        absolute_path = self.get_absolute_path(self.root, self.path)
        self.absolute_path = self.validate_absolute_path(self.root,
                                                         absolute_path)
        if self.absolute_path is None:
            return

        should_count = self.get_argument('count', 'true')
        if should_count != 'false':
            # count access times with hit()
            meta = FileMeta.for_path(self.absolute_path)
            meta.hit()
            if is_image(self.absolute_path):
                img = WebImage(self.absolute_path, self.root)
                img.generate_thumb_in_background()

        return super(HitCountImageServer, self).get(path, include_body)