# -*- coding: utf8 -*-
from flask import Flask, render_template, Blueprint
from helpers import jinja_template_loader, _read_file
from filters import FILTERS
from globals import GLOBALS

app = Flask(__name__, static_folder='../static', template_folder='..')
app.jinja_env.filters.update(FILTERS)
app.jinja_env.globals.update(GLOBALS)
app.jinja_loader = jinja_template_loader

article = Blueprint('article', __name__, template_folder='templates')
@article.route('/article/<slug>/')
@article.route('/article/<slug>')
def article_by_slug(slug):
    return slug
app.register_blueprint(article)

demo_css = _read_file('demo.css')
demo_js = _read_file('demo.js')

example_article = {
  "created_at": "2016-01-12 22:24:16+0000",
  "display_date": "2013-12-18 15:29:52+0000",
  "gallery": {
    'images': [{
      "created_at": "2016-01-12 22:24:16+0000",
      "crops": [],
      "description": "",
      "meta": [],
      "original": {
        "aspect_ratio": "1:1",
        "content_type": "image/jpeg",
        "crop_type": "original",
        "filesize_bytes": 255565,
        "height": 1920,
        "orientation": "square",
        "public_url": "http://gq-images.s3.amazonaws.com/73/91/7f0a839d.jpg",
        "uid": "0JrRNXyoXdA",
        "width": 1920
      },
      "tags": [],
      "title": "",
      "uid": "yWOL1vbrol3"
    },{
      "created_at": "2016-01-12 22:24:16+0000",
      "crops": [],
      "description": "",
      "meta": [],
      "original": {
        "aspect_ratio": "1:1",
        "content_type": "image/jpeg",
        "crop_type": "original",
        "filesize_bytes": 255565,
        "height": 1920,
        "orientation": "square",
        "public_url": "http://gq-images.s3.amazonaws.com/73/91/7f0a839d.jpg",
        "uid": "0JrRNXyoXdA",
        "width": 1920
      },
      "tags": [],
      "title": "",
      "uid": "yWOL1vbrol3"
    },{
      "created_at": "2016-01-12 22:24:16+0000",
      "crops": [],
      "description": "",
      "meta": [],
      "original": {
        "aspect_ratio": "1:1",
        "content_type": "image/jpeg",
        "crop_type": "original",
        "filesize_bytes": 255565,
        "height": 1920,
        "orientation": "square",
        "public_url": "http://gq-images.s3.amazonaws.com/73/91/7f0a839d.jpg",
        "uid": "0JrRNXyoXdA",
        "width": 1920
      },
      "tags": [],
      "title": "",
      "uid": "yWOL1vbrol3"
    }]
  },
  "genre": {
    "ad_path": "/lifestyle",
    "ad_tag": "",
    "ad_zone": "",
    "body": "",
    "created_at": "2016-01-12 19:24:43+0000",
    "images": {},
    "is_sponsored": False,
    "meta": [],
    "meta_description": "",
    "meta_title": "",
    "priority": 99999,
    "slug": "lifestyle",
    "title": "Lifestyle",
    "type": "topic",
    "uid": "88jD1d2Wwex",
    "updated_at": "2016-01-14 14:08:55+0000"
  },
  "images": {
    "default": {
      "created_at": "2016-01-12 22:24:16+0000",
      "crops": [],
      "description": "",
      "meta": [
        {
          "key": "source",
          "value": "URL"
        },
        {
          "key": "source_url",
          "value": "http://cdni.condenast.co.uk/1920x1920/w_z/Watch-GQ_11Dec13_pr_bt.jpg"
        }
      ],
      "original": {
        "aspect_ratio": "1:1",
        "content_type": "image/jpeg",
        "crop_type": "original",
        "filesize_bytes": 255565,
        "height": 1920,
        "orientation": "square",
        "public_url": "http://gq-images.s3.amazonaws.com/73/91/7f0a839d.jpg",
        "uid": "0JrRNXyoXdA",
        "width": 1920
      },
      "tags": [],
      "title": "",
      "uid": "yWOL1vbrol3"
    }
  },
  "is_active": True,
  "is_legacy": True,
  "is_premium": False,
  "is_sponsored": True,
  "magazine": {},
  "meta": [],
  "profiles": [
    {
      "bio": "",
      "created_at": "2016-01-12 21:00:00+0000",
      "full_name": "Ken Kessler",
      "images": {},
      "job_title": "",
      "slug": "ken-kessler",
      "social_media": [],
      "teaser": "",
      "uid": "prL8BaP8zdB",
      "updated_at": "2016-01-12 21:00:00+0000"
    }
  ],
  "published_at": "2013-12-18 15:29:52+0000",
  "series": {
    "ad_path": "",
    "ad_tag": "",
    "ad_zone": "",
    "body": "",
    "created_at": "2016-02-19 11:17:50+0000",
    "images": {},
    "is_sponsored": False,
    "meta": [],
    "meta_description": "",
    "meta_title": "",
    "priority": 99999,
    "slug": "original-shorts",
    "title": "Original Shorts",
    "type": "series",
    "uid": "7qKO2Y12J2B",
    "updated_at": "2016-02-19 11:17:50+0000"
  },
  "show_date": True,
  "show_profiles": True,
  "slug": "rolex-air-king-watch-for-men-review",
  "status": "published",
  "tags": [{
          "ad_path": "",
          "ad_tag": "",
          "ad_zone": "",
          "article_priority": 0,
          "body": "",
          "created_at": "2016-03-23 14:20:07+0000",
          "images": {
            "logo": {
                "created_at": "2016-01-21 11:09:38+0000",
                "crops": [],
                "description": "",
                "meta": [],
                "original": {
                  "aspect_ratio": "1:0.66",
                  "content_type": "image/jpeg",
                  "crop_type": "original",
                  "filesize_bytes": 289525,
                  "height": 1280,
                  "orientation": "landscape",
                  "public_url": "http://gq-images.s3.amazonaws.com/77/54/17d5add7.jpg",
                  "uid": "w8k6vN6a0aP",
                  "width": 1920
                },
                "tags": [],
                "title": "",
                "uid": "JXmg7rgvk2x"
              }
          },
          "is_sponsored": False,
          "meta": [],
          "meta_description": "",
          "meta_title": "",
          "priority": 99999,
          "slug": "converse",
          "title": "Converse",
          "type": "brand",
          "uid": "Ylvp7MBB2lj",
          "updated_at": "2016-03-23 16:45:17+0000"
        },{
      "ad_path": "/watches",
      "ad_tag": "",
      "ad_zone": "",
      "article_priority": 0,
      "body": "",
      "created_at": "2016-01-12 19:29:17+0000",
      "images": {},
      "is_sponsored": False,
      "meta": [],
      "meta_description": "",
      "meta_title": "",
      "priority": 99999,
      "slug": "watches",
      "title": "Watches",
      "type": "topic",
      "uid": "eZ36l3NEV55",
      "updated_at": "2016-01-14 14:07:10+0000"
    }],
  "teaser_long": "The only watch a man needs to own? Ken Kessler makes his case for the Rolex Air-King...",
  "teaser_short": "The only watch a man needs to own? Ken Kessler makes his case for the Rolex Air-King: Rolex Oyster Air-King watch for men in pictures",
  "title": "A king indeed. A king indeed. A king indeed. Wat",
  "type": "article",
  "uid": "WZ1vNEPVbOW",
  "updated_at": "2016-01-17 12:21:16+0000"
}


@app.route('/')
def index():
    ctx = {
        'article': example_article,
        'css': demo_css,
        'js': demo_js
    }
    return render_template('/demo/demo.html', **ctx)

if __name__ == '__main__':
    app.run(debug=True)
