コード例 #1
0
ファイル: update-blog.py プロジェクト: racheltwu/herbalcell
    def handle(self, *args, **options):

        Article.objects.all().delete()

        articles = glob(
            path.join(settings.TEMPLATE_DIRS[0], 'articles', '*.html'))
        for article in articles:
            path_prefix, filename = path.split(article)
            filename = re.sub('.html', '', filename)
            file_contents = open(article, 'r').read()
            date = re.search('{% block date %}(.*?){% endblock %}',
                             file_contents)
            date = datetime.datetime.strptime(date.group(1),
                                              '%Y-%m-%d') if date else None
            Article(filename=filename,
                    created_on=date if date else datetime.datetime(1990, 1, 1),
                    title=re.search('{% block title %}(.*?){% endblock %}',
                                    file_contents).group(1),
                    views=get_view_count_from_google_analytics(filename),
                    is_static=True if not date else False).save()

        create_thumbnails('singles', 200, 900)
        for gallery in get_dirs(
                path.join(settings.STATIC_ROOT, 'images', 'galleries')):
            create_thumbnails(path.join('galleries', path.basename(gallery)),
                              900, 250)
コード例 #2
0
    def handle(self, *args, **options):

        WallpaperGroup.objects.all().delete()

        group_paths = glob(
            path.join(settings.STATIC_ROOT, 'images', 'wallpapers', '*'))
        for group_path in group_paths:
            group = WallpaperGroup(filename=path.basename(group_path),
                                   title=open(
                                       path.join(group_path, 'title.txt'),
                                       'r').read())
            group.save()
            wallpapers = glob(path.join(group_path, '*.jpg'))
            for wallpaper in wallpapers:
                Wallpaper(filename=path.basename(wallpaper),
                          group=group).save()
            create_thumbnails(path.join('wallpapers', group.filename), 150,
                              100)
            zip(path.join(group_path, 'all.zip'), wallpapers)
コード例 #3
0
    def handle(self, *args, **options):

        WallpaperGroup.objects.all().delete()

        group_paths = glob(path.join(settings.STATIC_ROOT, 'images', 'wallpapers', '*'))
        for group_path in group_paths:
            group = WallpaperGroup(
                filename = path.basename(group_path),
                title = open(path.join(group_path, 'title.txt'), 'r').read()
            )
            group.save()
            wallpapers = glob(path.join(group_path, '*.jpg'))
            for wallpaper in wallpapers:
                Wallpaper(
                    filename = path.basename(wallpaper),
                    group = group
                ).save()
            create_thumbnails(path.join('wallpapers', group.filename), 150, 100)
            zip(path.join(group_path, 'all.zip'), wallpapers)
コード例 #4
0
ファイル: update-blog.py プロジェクト: racheltwu/herbalcell
    def handle(self, *args, **options):

        Article.objects.all().delete()

        articles = glob(path.join(settings.TEMPLATE_DIRS[0], 'articles', '*.html'))
        for article in articles:
            path_prefix, filename = path.split(article)
            filename = re.sub('.html', '', filename)
            file_contents = open(article, 'r').read()
            date = re.search('{% block date %}(.*?){% endblock %}', file_contents)
            date = datetime.datetime.strptime(date.group(1), '%Y-%m-%d') if date else None
            Article(
                filename = filename,
                created_on = date if date else datetime.datetime(1990,1,1),
                title = re.search('{% block title %}(.*?){% endblock %}', file_contents).group(1),
                views = get_view_count_from_google_analytics(filename),
                is_static = True if not date else False
            ).save()

        create_thumbnails('singles', 200, 900)
        for gallery in get_dirs(path.join(settings.STATIC_ROOT, 'images', 'galleries')):
            create_thumbnails(path.join('galleries', path.basename(gallery)), 900, 250)