Beispiel #1
0
def submit_note(inbox):

    # Fetch the current inbox.
    inbox = storage.Inbox(inbox)

    # Replace newlines with <br> tags.
    body = request.form['body']
    body = '---NEWLINE---'.join(body.split('\n'))

    # Strip any HTML away.
    body = Markup(body).striptags()
    byline = Markup(request.form['byline']).striptags()

    # Crazy hack to get br tags preserved.
    body = '<br>'.join(body.split('---NEWLINE---'))

    # Assert that the body has length.
    if not body:
        # Pretend that it was successful.
        return redirect(url_for('thanks'))

    # Store the incoming note to the database.
    note = inbox.submit_note(body=body, byline=byline)

    # Email the user the new note.
    if storage.Inbox.is_email_enabled(inbox.slug):
        note.notify(inbox.email)

    return redirect(url_for('thanks'))
 def load_asset(self, file, extension):
     content = Markup(read(join(self.assets_dir, file)))
     if extension == 'html':
         return content
     elif extension == 'svg':
         svgs = content.split('\n')
         if len(svgs) == 1:
             return process_svg(svgs[0])
         else:
             return tuple(map(process_svg, svgs))
Beispiel #3
0
    def _get_list_value(self, context, model, name, column_formatters,
                        column_type_formatters):
        """
            Returns the value to be displayed.

            :param context:
                :py:class:`jinja2.runtime.Context` if available
            :param model:
                Model instance
            :param name:
                Field name
            :param column_formatters:
                column_formatters to be used.
            :param column_type_formatters:
                column_type_formatters to be used.
        """
        column_fmt = column_formatters.get(name)
        if column_fmt is not None:
            value = column_fmt(self, context, model, name)
        else:
            value = self._get_field_value(model, name)

        choices_map = self._column_choices_map.get(name, {})
        if choices_map:
            return choices_map.get(value) or value

        type_fmt = None
        for typeobj, formatter in column_type_formatters.items():
            if isinstance(value, typeobj):
                type_fmt = formatter
                break
        if type_fmt is not None:
            value = type_fmt(self, value)
        ### overwritten here
        if name == 'socials':

            html_string = '<ul>'
            for item in value.split(','):
                html_string += '<li> {} </li>'.format(item)
            html_string += '</ul>'

            value = Markup(html_string)

        elif name == 'posts':

            html_string = '<table>'
            for item in value.split(','):
                html_string += '<tr><td> {} </td></tr>'.format(item)
            html_string += '</table>'

            value = Markup(html_string)

        return value
Beispiel #4
0
def get_tutorial_data():
    data = json.loads(request.data)

    # TODO: validate that tut_id is not a path
    tut_id = data['tutorial']
    tut_file = '/opt/webapp/webrob/tutorials/'+tut_id+'.md'

    # read tutorial md data
    page_data = ""
    with open(tut_file, 'r') as f:
        page_data = f.read()
    # convert to HTML
    page_data = Markup(markdown(page_data, fenced_code=True))
    # split into pages at <h2> tags
    pages = page_data.split('<h2>')[1:]
    pages = map(lambda p: p.split('</h2>'), pages)

    return jsonify({'pages': pages})
Beispiel #5
0
 def t1():
     value = text
     multiline = "\n" in value
     if multiline:
         value = value.replace("|"," ||").replace("\n"," |n")
     if "&" in value or "<" in value:
         value = Markup(Markup(value).unescape()).striptags()
     # soporte multilinea
     if multiline:
         values = value.split(" |n")
         # strip de la lista
         start = 0
         end = len(values)-1
         while values and start<end and not values[start].strip(): start+=1
         while values and end>start and not values[end].strip(): end-=1
         if values and start<end:
             value = "\n".join(value.replace(" ||", "|") for value in values[start:end+1])
         else:
             value = ""
     return value
Beispiel #6
0
def countUniqueBoardCountries(board):
    threads = getBoardThreads(board)
    uniquePersonalities = []  #IDs
    uniqueCountries = {}

    shitposts = {}  # {"Country":['ops a f*g', 'lyl']}
    fullShitpostList = []
    for thread in threads:
        url = 'http://a.4cdn.org/%s/thread/%s.json' % (board, str(thread))
        req = urllib2.Request(url, headers=hdr)
        u = urllib2.urlopen(req)

        mainJSON = eval(u.read())
        #Returns a dictionary with key 'posts'. Inside, a list with dictionaries of posts
        #Inside each post, post stats.
        for post in mainJSON['posts']:
            try:
                shitp = Markup(post['com']).striptags()
                shitp = "".join(shitp.split("\'"))
                fullShitpostList.append(shitp)
                if post['country_name'] in shitposts:
                    shitposts[post['country_name']].append(shitp)
                else:
                    shitposts[post['country_name']] = [shitp]
            except KeyError:  #Empty post
                pass
            try:
                if not post['id'] in uniquePersonalities:
                    uniquePersonalities.append(post['id'])
                    if post['country_name'] in uniqueCountries:
                        uniqueCountries[post['country_name']] += 1
                    else:
                        uniqueCountries[post['country_name']] = 1
            except KeyError:
                pass
        time.sleep(0.1)
    return [uniqueCountries, shitposts, fullShitpostList]
Beispiel #7
0
def deck(id):
    flask_login.login_user(current_user)
    db = get_db()
    cur = db.execute('SELECT * FROM decks WHERE id="' + id + '"')
    deck = cur.fetchone()
    if not deck:
        abort(404)
    cur = db.execute(
        'SELECT name, count(name), type, convertedManaCost, uuid, foil, featured, commander, layout, number, scryfallId, mainboard, sideboard, maybeboard, acquireboard FROM decksToCards INNER JOIN cards ON cardId=cards.scryfallId WHERE deckId="'
        + id + '" AND mainboard=1 GROUP BY name;')
    mainboard = cur.fetchall()
    cur = db.execute(
        'SELECT name, count(name), type, convertedManaCost, uuid, foil, featured, commander, layout, number, scryfallId, mainboard, sideboard, maybeboard, acquireboard FROM decksToCards INNER JOIN cards ON cardId=cards.scryfallId WHERE deckId="'
        + id + '" AND sideboard=1 GROUP BY name;')
    sideboard = cur.fetchall()
    cur = db.execute(
        'SELECT name, count(name), type, convertedManaCost, uuid, foil, featured, commander, layout, number, scryfallId, mainboard, sideboard, maybeboard, acquireboard FROM decksToCards INNER JOIN cards ON cardId=cards.scryfallId WHERE deckId="'
        + id + '" AND maybeboard=1 GROUP BY name;')
    maybeboard = cur.fetchall()
    cur = db.execute(
        'SELECT name, count(name), type, convertedManaCost, uuid, foil, featured, commander, layout, number, scryfallId, mainboard, sideboard, maybeboard, acquireboard FROM decksToCards INNER JOIN cards ON cardId=cards.scryfallId WHERE deckId="'
        + id + '" AND acquireboard=1 GROUP BY name;')
    acquireboard = cur.fetchall()
    convertedManaCost = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    mainboard_count = {}
    sideboard_count = {}
    maybeboard_count = {}
    acquireboard_count = {}
    foil = {}
    commander = {}
    lands = {}
    planeswalkers = {}
    creatures = {}
    sorceries = {}
    instants = {}
    enchantments = {}
    artifacts = {}
    makeup = deck["makeup"].split(", ")
    for card in mainboard:
        if card['convertedManaCost'] == '':
            convertedManaCost[0] == convertedManaCost[0] + 1
        else:
            convertedManaCost[int(card['convertedManaCost'])] = convertedManaCost[int(card['convertedManaCost'])] + 1
        card_count = card[1]
        mainboard_count[card["uuid"]] = card_count
        card_foil = card['foil']
        foil[card["uuid"]] = card_foil
        card_commander = card['commander']
        if card_commander == 1:
            commander = card

        # Sort the cards by type
        if "Land" in card["type"]:
            lands[card['uuid']] = card
        if "Planeswalker" in card["type"]:
            planeswalkers[card['uuid']] = card
        if "Creature" in card["type"] and "Land" not in card["type"]:
            creatures[card['uuid']] = card
        if "Sorcery" in card["type"]:
            sorceries[card['uuid']] = card
        if "Instant" in card["type"]:
            instants[card['uuid']] = card
        if "Enchantment" in card["type"] and "Artifact" not in card[
                "type"] and "Creature" not in card["type"]:
            enchantments[card['uuid']] = card
        if "Artifact" in card["type"] and "Creature" not in card["type"]:
            artifacts[card['uuid']] = card


    for card in sideboard:
        card_count = card[1]
        sideboard_count[card["uuid"]] = card_count
    for card in maybeboard:
        card_count = card[1]
        maybeboard_count[card["uuid"]] = card_count
    for card in acquireboard:
        card_count = card[1]
        acquireboard_count[card["uuid"]] = card_count

    deck_image = deck["image"]
    deck_tags = deck["tags"]
    deck_tags = deck_tags.split(', ')
    deck_legality = deck["legality"]
    deck_legality = deck_legality.split(', ')

    def is_today(date):
        if (date == datetime.now().strftime("%B %d, %Y")):
            date = "today"
            return date
        else:
            return date

    def format_date(date):
        date = datetime.strptime(date, "%Y-%m-%d")
        date = date.strftime("%B %d, %Y")
        date = is_today(date)
        return date

    deck_created = format_date(deck["created"])
    deck_updated = format_date(deck["updated"])
    deck_description = deck["description"]
    # Convert new lines to html line breaks
    deck_description = Markup('</p><p>'.join(deck_description.split('\n')))
    print commander
    return render_template(
        'deck.html',
        lands=lands,
        planeswalkers=planeswalkers,
        creatures=creatures,
        sorceries=sorceries,
        instants=instants,
        enchantments=enchantments,
        artifacts=artifacts,
        deck=deck,
        mainboard=mainboard,
        mainboard_count=mainboard_count,
        sideboard=sideboard,
        sideboard_count=sideboard_count,
        maybeboard=maybeboard,
        maybeboard_count=maybeboard_count,
        acquireboard=acquireboard,
        acquireboard_count=acquireboard_count,
        foil=foil,
        makeup=makeup,
        deck_image=deck_image,
        deck_tags=deck_tags,
        deck_legality=deck_legality,
        deck_created=deck_created,
        deck_updated=deck_updated,
        commander=commander,
        deck_description=deck_description,
        convertedManaCost=convertedManaCost)
Beispiel #8
0
def card(uuid):
    flask_login.login_user(current_user)
    db = get_db()
    cur = db.execute('SELECT * FROM cards WHERE uuid="' + uuid
                     + '"')
    card = cur.fetchone()
    if not card:
        abort(404)
    card_name = card['name']
    cur_cards = db.execute(
        'SELECT uuid, scryfallId, setCode, number FROM cards WHERE name=(?) AND uuid != "" ORDER BY releaseDate DESC',
        (card_name, ))
    other_cards = cur_cards.fetchall()
    likes = {}
    images = {}
    names = {}
    legality = {}
    tags = {}
    decks = {}
    authors = {}
    makeup = {}
    for other_card in other_cards:
        cur_decks = db.execute(
            'SELECT DISTINCT decks.id, name, tags, legality, image, likes, author, makeup FROM decksToCards INNER JOIN decks ON deckId=decks.id WHERE cardId=(?) ORDER BY likes DESC',
            (other_card['scryfallId'], ))

        cur_decks = cur_decks.fetchall()
        for deck in cur_decks:
            names[deck["id"]] = deck["name"]
            authors[deck["id"]] = deck["author"]
            likes[deck["id"]] = deck["likes"]
            decks[deck["id"]] = deck["id"]
            images[deck["id"]] = deck["image"]
            deck_tags = deck["tags"]
            deck_tags = deck_tags.split(', ')
            tags[deck["id"]] = deck_tags
            deck_legality = deck["legality"]
            deck_legality = deck_legality.split(', ')
            legality[deck["id"]] = deck_legality
            makeup[deck["id"]] = deck["makeup"].split(", ")
            print deck
    card_number = card['number']
    # Use card['layout'] instead of this jank
    flip_card_a = False
    flip_card_b = False
    if re.search('[a]', unicode(card_number)):
        flip_card_a = True
    if re.search('[b]', unicode(card_number)):
        flip_card_b = True
    card_mana = card['manaCost']
    card_mana = card_mana.replace('}{', ' ')
    card_mana = card_mana.replace('{', '')
    card_mana = card_mana.replace('}', '')
    card_mana = card_mana.replace('/', '')
    card_text = card["text"]
    # Italicize ability words
    card_text = re.compile(r'(((' + '|'.join(ABILITY_WORDS) + ')\s*?)+)',
                           re.I).sub(r'<em>\1</em>', card_text)
    # Making keyword abilities links so they can be used for tooltips and to
    # link to the glossary eventually
    card_text = re.compile(
        r'(((' + '|'.join(KEYWORD_ABILITIES) + ')\s*?)+)', re.I).sub(
            r'<a href="tooltip" title="Keyword Ability: \1">\1</a>', card_text)
    # Convert mana symbols to styled span elements
    card_text = card_text.replace('{', '<span class="mana medium shadow s')
    card_text = card_text.replace('}', '">&nbsp;</span>')
    # Text on cards in parentheses is always italicized
    card_text = card_text.replace('(', '<em class="card-explanation">(')
    card_text = card_text.replace(')', ')</em>')
    card_text = card_text.replace('sW/U', 'swu')
    card_text = card_text.replace('sW/B', 'swb')
    card_text = card_text.replace('sU/B', 'sub')
    card_text = card_text.replace('sU/R', 'sur')
    card_text = card_text.replace('sB/R', 'sbr')
    card_text = card_text.replace('sB/G', 'sbg')
    card_text = card_text.replace('sR/W', 'srw')
    card_text = card_text.replace('sR/G', 'srg')
    card_text = card_text.replace('sG/W', 'sgw')
    card_text = card_text.replace('sG/U', 'sgu')
    card_text = card_text.replace('sW/P', 'swp')
    card_text = card_text.replace('sU/P', 'sup')
    card_text = card_text.replace('sB/P', 'sbp')
    card_text = card_text.replace('sR/P', 'srp')
    card_text = card_text.replace('sG/P', 'sgp')
    # Convert new lines to html line breaks
    card_text = Markup('</p><p>'.join(card_text.split('\n')))
    card_flavor = card['flavorText']
    card_flavor = Markup('</p><p>'.join(card_flavor.split('\n')))
    return render_template(
        'card.html',
        card=card,
        card_text=card_text,
        card_mana=card_mana,
        card_flavor=card_flavor,
        flip_card_a=flip_card_a,
        flip_card_b=flip_card_b,
        decks=decks,
        other_cards=other_cards,
        legality=legality,
        tags=tags,
        names=names,
        likes=likes,
        images=images,
        authors=authors,
        makeup=makeup)
Beispiel #9
0
def cards(page):
    flask_login.login_user(current_user)
    filter_name = request.args.get('name')
    filter_set = request.args.get('set')
    filter_subtype = request.args.get('subtype')
    filter_type = request.args.get('type')
    sql_query = 'FROM cards WHERE uuid != "" AND supertypes != "Basic" AND multiverseId != ""'
    if filter_name:
        sql_query = sql_query + ' AND name LIKE "%' + filter_name + '%"'
    if filter_set:
        sql_query = sql_query + ' AND setCode = "' + filter_set.upper() + '"'
    if filter_type:
        sql_query = sql_query + ' AND type LIKE "%' + filter_type + '%"'
    if filter_subtype:
        sql_query = sql_query + ' AND subtypes LIKE "%' + filter_subtype + '%"'
    db = get_db()
    if filter_name or filter_set or filter_subtype or filter_type:
        cur_count = db.execute('SELECT COUNT(*) ' + sql_query)
        count = cur_count.fetchone()[0]
        cur_cards = db.execute(
            'SELECT * ' + sql_query + ' ORDER BY uuid DESC LIMIT ' +
            str(PER_PAGE) + ' offset ' + str(PER_PAGE * page - PER_PAGE))
        cards = cur_cards.fetchall()
        cur_sets = db.execute('SELECT * FROM sets')
    else:
        cur_count = db.execute(
            'SELECT COUNT(*) FROM cards WHERE supertypes != "Basic" AND hasNonFoil="1"'
        )
        count = cur_count.fetchone()[0]
        cur_cards = db.execute(
            'SELECT * FROM cards WHERE supertypes != "Basic" AND hasNonFoil = "1" ORDER BY "releaseDate" DESC, "number" ASC LIMIT '
            + str(PER_PAGE) + ' offset ' + str(PER_PAGE * page - PER_PAGE))
        cur_sets = db.execute(
            'SELECT * FROM sets WHERE tcgplayerGroupId != "" ORDER BY releaseDate DESC LIMIT 5')
        cards = cur_cards.fetchall()
    pagination = Pagination(page, PER_PAGE, count)
    card_mana = {}
    for card in cards:
        mana = card["manaCost"]
        mana = mana.replace('}{', ' ')
        mana = mana.replace('{', '')
        mana = mana.replace('}', '')
        mana = mana.replace('/', '')
        card_mana[card["id"]] = mana
    card_text = {}
    for card in cards:
        text = card["text"]
        # Italicize ability words
        text = re.compile(r'(((' + '|'.join(ABILITY_WORDS) + ')\s*?)+)',
                          re.I).sub(r'<em>\1</em>', text)
        # Making keyword abilities links so they can be used for tooltips and to
        # link to the glossary eventually
        text = re.compile(
            r'(((' + '|'.join(KEYWORD_ABILITIES) + ')\s*?)+)', re.I
        ).sub(
            r'<span class="tooltip" href="tooltip" title="Keyword Ability: \1">\1</span>',
            text)
        # Convert mana symbols to styled span elements
        text = text.replace('{', '<span class="mana small shadow s')
        text = text.replace('}', '">&nbsp;</span>')
        # Text on cards in parentheses is always italicized
        text = text.replace('(', '<em class="card-explanation">(')
        text = text.replace(')', ')</em>')
        text = text.replace('sW/U', 'swu')
        text = text.replace('sW/B', 'swb')
        text = text.replace('sU/B', 'sub')
        text = text.replace('sU/R', 'sur')
        text = text.replace('sB/R', 'sbr')
        text = text.replace('sB/G', 'sbg')
        text = text.replace('sR/W', 'srw')
        text = text.replace('sR/G', 'srg')
        text = text.replace('sG/W', 'sgw')
        text = text.replace('sG/U', 'sgu')
        text = text.replace('sW/P', 'swp')
        text = text.replace('sU/P', 'sup')
        text = text.replace('sB/P', 'sbp')
        text = text.replace('sR/P', 'srp')
        text = text.replace('sG/P', 'sgp')
        # Convert new lines to html line breaks
        text = Markup('</p><p>'.join(text.split('\n')))
        card_text[card["id"]] = text
    sets = cur_sets.fetchall()
    query_string = request.query_string
    return render_template(
        'cards.html',
        cards=cards,
        sets=sets,
        card_mana=card_mana,
        card_text=card_text,
        pagination=pagination,
        query_string=query_string,
        filter_set=filter_set,
        filter_type=filter_type,
        filter_subtype=filter_subtype,
        filter_name=filter_name,
        card_types=CARD_TYPES)
Beispiel #10
0
def grimoire():
    flask_login.login_user(current_user)
    db = get_db()
    cur_count = db.execute('select count(*) from decks')
    count = cur_count.fetchone()[0]
    cur_decks = db.execute('select * from decks order by likes desc LIMIT 10')
    cur_sets = db.execute(
        'select * from sets limit 5')
    decks = cur_decks.fetchall()
    sets = cur_sets.fetchall()
    legality = {}
    tags = {}
    makeup = {}
    for deck in decks:
        deck_tags = deck["tags"]
        deck_tags = deck_tags.split(', ')
        tags[deck["id"]] = deck_tags
        deck_legality = deck["legality"]
        deck_legality = deck_legality.split(', ')
        legality[deck["id"]] = deck_legality
        makeup[deck["id"]] = deck["makeup"].split(', ')

    sql_query = 'FROM cards WHERE uuid != ""'
    cur_count = db.execute(
        'SELECT COUNT(*) FROM cards WHERE uuid != "" LIMIT 15'
    )
    count = cur_count.fetchone()[0]
    cur_cards = db.execute(
        'SELECT * FROM cards WHERE uuid != "" AND type LIKE "%Creature%" AND subtypes LIKE "%Frog%" ORDER BY uuid DESC'
    )
    cards = cur_cards.fetchall()
    card_mana = {}
    for card in cards:
        mana = card["manaCost"]
        mana = mana.replace('}{', ' ')
        mana = mana.replace('{', '')
        mana = mana.replace('}', '')
        mana = mana.replace('/', '')
        card_mana[card["id"]] = mana
    card_text = {}
    for card in cards:
        text = card["text"]
        # Italicize ability words
        text = re.compile(r'(((' + '|'.join(ABILITY_WORDS) + ')\s*?)+)',
                          re.I).sub(r'<em>\1</em>', text)
        # Making keyword abilities links so they can be used for tooltips and to
        # link to the glossary eventually
        text = re.compile(
            r'(((' + '|'.join(KEYWORD_ABILITIES) + ')\s*?)+)', re.I
        ).sub(
            r'<span class="tooltip" href="tooltip" title="Keyword Ability: \1">\1</span>',
            text)
        # Convert mana symbols to styled span elements
        text = text.replace('{', '<span class="mana small shadow s')
        text = text.replace('}', '">&nbsp;</span>')
        # Text on cards in parentheses is always italicized
        text = text.replace('(', '<em class="card-explanation">(')
        text = text.replace(')', ')</em>')
        text = text.replace('sW/U', 'swu')
        text = text.replace('sW/B', 'swb')
        text = text.replace('sU/B', 'sub')
        text = text.replace('sU/R', 'sur')
        text = text.replace('sB/R', 'sbr')
        text = text.replace('sB/G', 'sbg')
        text = text.replace('sR/W', 'srw')
        text = text.replace('sR/G', 'srg')
        text = text.replace('sG/W', 'sgw')
        text = text.replace('sG/U', 'sgu')
        text = text.replace('sW/P', 'swp')
        text = text.replace('sU/P', 'sup')
        text = text.replace('sB/P', 'sbp')
        text = text.replace('sR/P', 'srp')
        text = text.replace('sG/P', 'sgp')
        # Convert new lines to html line breaks
        text = Markup('</p><p>'.join(text.split('\n')))
        card_text[card["id"]] = text
    return render_template(
        'grimoire.html',
        decks=decks,
        sets=sets,
        tags=tags,
        legality=legality,
        makeup=makeup,
        cards=cards,
        card_mana=card_mana,
        card_text=card_text,
        card_types=CARD_TYPES)
Beispiel #11
0
from flask import Flask
from flask import render_template
from flask import Markup

app = Flask(__name__)

test = ""


@app.route("/")
def hello():

    # return "Hello World!<br>" + test
    return render_template("index.html", inject=test)


if __name__ == "__main__":
    f = open("test.txt", "r")
    test = f.read()
    test = Markup("<br>".join(test.split()))
    app.run(host="0.0.0.0", port=8080, debug=False)
Beispiel #12
0
def deck(id):
    db = get_db()
    cur = db.execute('SELECT * FROM decks WHERE id="' + id + '"')
    deck = cur.fetchone()
    if not deck:
        abort(404)
    cur = db.execute(
        'SELECT name, count(name), type, cmc, multiverseid, foil, featured, commander, layout, number FROM decksToCards INNER JOIN cards ON cardId=cards.multiverseid WHERE deckId="'
        + id + '" GROUP BY name')
    cards = cur.fetchall()
    cmc = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    for card in cards:
        if card['cmc'] == '':
            cmc[0] == cmc[0] + 1
        else:
            cmc[int(card['cmc'])] = cmc[int(card['cmc'])] + 1
    count = {}
    foil = {}
    commander = {}
    lands = {}
    planeswalkers = {}
    creatures = {}
    sorceries = {}
    instants = {}
    enchantments = {}
    artifacts = {}
    makeup = deck["makeup"].split(", ")
    for card in cards:
        card_count = card[1]
        count[card["multiverseid"]] = card_count
        card_foil = card['foil']
        foil[card["multiverseid"]] = card_foil
        card_commander = card['commander']
        if card_commander == 1:
            commander = card

        # Sort the cards by type
        if "Land" in card["type"]:
            lands[card['multiverseid']] = card
        if "Planeswalker" in card["type"]:
            planeswalkers[card['multiverseid']] = card
        if "Creature" in card["type"] and "Land" not in card["type"]:
            creatures[card['multiverseid']] = card
        if "Sorcery" in card["type"]:
            sorceries[card['multiverseid']] = card
        if "Instant" in card["type"]:
            instants[card['multiverseid']] = card
        if "Enchantment" in card["type"] and "Artifact" not in card[
                "type"] and "Creature" not in card["type"]:
            enchantments[card['multiverseid']] = card
        if "Artifact" in card["type"] and "Creature" not in card["type"]:
            artifacts[card['multiverseid']] = card

    deck_image = deck["image"]
    deck_tags = deck["tags"]
    deck_tags = deck_tags.split(', ')
    deck_legality = deck["legality"]
    deck_legality = deck_legality.split(', ')

    def is_today(date):
        if (date == datetime.now().strftime("%B %d, %Y")):
            date = "today"
            return date
        else:
            return date

    def format_date(date):
        date = datetime.strptime(date, "%Y-%m-%d")
        date = date.strftime("%B %d, %Y")
        date = is_today(date)
        return date

    deck_created = format_date(deck["created"])
    deck_updated = format_date(deck["updated"])
    deck_description = deck["description"]
    # Convert new lines to html line breaks
    deck_description = Markup('</p><p>'.join(deck_description.split('\n')))
    return render_template(
        'deck.html',
        lands=lands,
        planeswalkers=planeswalkers,
        creatures=creatures,
        sorceries=sorceries,
        instants=instants,
        enchantments=enchantments,
        artifacts=artifacts,
        deck=deck,
        cards=cards,
        foil=foil,
        makeup=makeup,
        deck_image=deck_image,
        deck_tags=deck_tags,
        deck_legality=deck_legality,
        deck_created=deck_created,
        deck_updated=deck_updated,
        count=count,
        commander=commander,
        deck_description=deck_description,
        cmc=cmc)