# Path: src/merveilles/constants.py
# PERSON_COLORS = ["#FFD923", "#AA2BEF", "#366EEF", "#A68B0B", "#18BECD",
#     "#4BFD03", "#32D7B7", "#E13611"
# ]
# 
# THUMBNAIL_SIZE = 256, 256
# 
# THUMBNAIL_DIR = "src/static/thumbnails/"


from .constants import PERSON_COLORS, THUMBNAIL_SIZE, THUMBNAIL_DIR
from flask import Markup, current_app
from merveilles.filters import get_domain_filter
from PIL import Image
    from merveilles.database import get_page_count
import re, requests, os, markdown, random, string

        im = Image.open("/tmp/tmp_img")
        im.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS)
        print("Thumbnail writing to {}".format(full_filepath))
        if ext.lower() == 'jpg':
            im.save(full_filepath, 'JPEG')
        else:
            im.save(full_filepath, ext)

        return "thumbnails/{}.{}".format(filename, ext.lower())
    return None

def slugify_post(post):
    cleaned = post.split('.')[0] # Remove file extension
    cleaned = cleaned.replace('_', '-')
    return cleaned

def build_posts(location):
    posts = []
    blog_posts = os.listdir(location)
    blog_posts = [x for x in blog_posts if x.endswith(".markdown")]
    for post in blog_posts:
        post_file = open("{0}/{1}".format(location, post))
        md = markdown.Markdown(extensions = ['meta'])

        post_html = md.convert(post_file.read())
        post_content = Markup(post_html)

        author = md.Meta['author'][0]
        author_color = [ord(x) for x in author]

# Path: src/merveilles/constants.py
# PERSON_COLORS = ["#FFD923", "#AA2BEF", "#366EEF", "#A68B0B", "#18BECD",
#     "#4BFD03", "#32D7B7", "#E13611"
# ]
# 
# THUMBNAIL_SIZE = 256, 256
# 
# THUMBNAIL_DIR = "src/static/thumbnails/"


# Path: src/merveilles/utils.py
from .constants import PERSON_COLORS, THUMBNAIL_SIZE, THUMBNAIL_DIR
from flask import Markup, current_app
from merveilles.filters import get_domain_filter
from PIL import Image
    from merveilles.database import get_page_count
import re, requests, os, markdown, random, string


        im = Image.open("/tmp/tmp_img")
        im.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS)
        print("Thumbnail writing to {}".format(full_filepath))
        if ext.lower() == 'jpg':
            im.save(full_filepath, 'JPEG')
        else:
            im.save(full_filepath, ext)

        return "thumbnails/{}.{}".format(filename, ext.lower())
    return None

def slugify_post(post):
    cleaned = post.split('.')[0] # Remove file extension
    cleaned = cleaned.replace('_', '-')
    return cleaned

def build_posts(location):
    posts = []
    blog_posts = os.listdir(location)
    blog_posts = [x for x in blog_posts if x.endswith(".markdown")]
    for post in blog_posts:
        post_file = open("{0}/{1}".format(location, post))
        md = markdown.Markdown(extensions = ['meta'])

        post_html = md.convert(post_file.read())
        post_content = Markup(post_html)

        author = md.Meta['author'][0]
        author_color = [ord(x) for x in author]

        author_color = PERSON_COLORS[len(PERSON_COLORS) - 1 % sum(author_color)]