ó
¹9—^c           @   s]  d  d l  Z  d  d l Z d  d l Z e j d k  rR d  d l Z e j d e ƒ n  d  d l m Z d  d l	 m
 Z
 d  d l m Z d  d l m Z d  d l m Z y d  d	 l m Z Wn! e k
 rÙ d  d	 l m Z n Xd  d
 l m Z y d  d l Z Wn e k
 rd Z n Xe d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d S(   iÿÿÿÿNi   s\   Support for Django < 2.0 will be removed soon,please upgrade your projects to use Django 2.0(   t   HttpResponse(   t   render(   t
   force_text(   t   ugettext(   t   csrf_exempt(   t   reverse(   t   gzip_compressorc         C   s~  y7t  s t d ƒ ‚ n  t |  j ƒ } t j | ƒ } | d } | d } | d } | d } | d } t  j t | ƒ ƒ s• t d j | ƒ ƒ ‚ n  t  j	 t | ƒ ƒ } | d k rè g  | D]" }	 |	 r½ | j
 |	 ƒ r½ |	 ^ q½ }
 n3 | d	 k r| j | ƒ }
 n t d
 j | ƒ ƒ ‚ i | d 6|
 d 6d d 6} Wn+ t k
 rdt j d ƒ t t d ƒ ƒ SXt t j | ƒ d d ƒS(   sS   
    Returns a HttpResponse that implements the TinyMCE spellchecker protocol.
    s0   install pyenchant for spellchecker functionalityt   idt   methodt   paramsi    i   s&   dictionary not found for language {!r}t
   checkWordst   getSuggestionss   Unknown spellcheck method: {!r}t   resultt   errors   Error running spellcheckert   content_types   application/jsonN(   t   enchantt   RuntimeErrorR   t   bodyt   jsont   loadst   dict_existst   strt   formatt   Dictt   checkt   suggestt   Nonet	   Exceptiont   loggingt	   exceptionR    t   _t   dumps(   t   requestt   rawt   inputR   R   R	   t   langt   argt   checkert   wordR   t   output(    (    s/   /tmp/pip-unpacked-wheel-51oq52/tinymce/views.pyt   spell_check    s6    




2c         C   sH   d d l  m } g  | j j ƒ  D] } | j | j f ^ q  } t | ƒ S(   sr   
    Returns a HttpResponse whose content is a Javascript file representing a
    list of links to flatpages.
    iÿÿÿÿ(   t   FlatPage(   t   django.contrib.flatpages.modelsR)   t   objectst   allt   titlet   urlt   render_to_link_list(   R    R)   t   paget	   link_list(    (    s/   /tmp/pip-unpacked-wheel-51oq52/tinymce/views.pyt   flatpages_link_listH   s    .c         C   s
   t  |  ƒ S(   s-   
    Returns a GZip-compressed response.
    (   R   (   R    (    (    s/   /tmp/pip-unpacked-wheel-51oq52/tinymce/views.pyt
   compressorR   s    c         C   s   t  d |  ƒ S(   sê   
    Returns a HttpResponse whose content is a Javascript file representing a
    list of links suitable for use wit the TinyMCE external_link_list_url
    configuration option. The link_list parameter must be a list of 2-tuples.
    t   tinyMCELinkList(   t   render_to_js_vardef(   R1   (    (    s/   /tmp/pip-unpacked-wheel-51oq52/tinymce/views.pyR/   Y   s    c         C   s   t  d |  ƒ S(   sí   
    Returns a HttpResponse whose content is a Javascript file representing a
    list of images suitable for use wit the TinyMCE external_image_list_url
    configuration option. The image_list parameter must be a list of 2-tuples.
    t   tinyMCEImageList(   R5   (   t
   image_list(    (    s/   /tmp/pip-unpacked-wheel-51oq52/tinymce/views.pyt   render_to_image_listb   s    c         C   s+   d j  |  t j | ƒ ƒ } t | d d ƒS(   Ns   var {!s} = {!s};R   s   application/x-javascript(   R   R   R   R    (   t   var_namet	   var_valueR'   (    (    s/   /tmp/pip-unpacked-wheel-51oq52/tinymce/views.pyR5   k   s    c         C   s_   y |  j  t d ƒ ƒ } Wn& t k
 rA |  j  t d ƒ ƒ } n Xt |  d i | d 6d d ƒS(   Nt	   fb_browses   filebrowser:fb_browses   tinymce/filebrowser.jst   fb_urlR   s   application/javascript(   t   build_absolute_uriR   R   R   (   R    R<   (    (    s/   /tmp/pip-unpacked-wheel-51oq52/tinymce/views.pyt   filebrowserp   s    (   i   (!   R   R   t   djangot   VERSIONt   warningst   warnt   DeprecationWarningt   django.httpR    t   django.shortcutsR   t   django.utils.encodingR   t   django.utils.translationR   R   t   django.views.decorators.csrfR   t   django.urlsR   t   ImportErrort   django.core.urlresolverst   tinymce.compressorR   R   R   R(   R2   R3   R/   R8   R5   R>   (    (    (    s/   /tmp/pip-unpacked-wheel-51oq52/tinymce/views.pyt   <module>   s6   	

(	
						