ó
ÛàÞSc           @   s  d  Z  d Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z m Z d d l	 m
 Z
 d d l m Z d d l m Z e j e j j e j ƒ  d ƒ e j j e j e ƒ d	 ƒ ƒ Z d
 „  Z d e
 j f d „  ƒ  YZ d e
 j f d „  ƒ  YZ d S(   s   
S5/HTML Slideshow Writer.
t   reStructuredTextiÿÿÿÿN(   t   frontendt   nodest   utils(   t	   html4css1(   t
   directives(   t   bt   dummyt   themesc         C   sG   t  j j t |  ƒ } t  j j | ƒ sC t j d |  | f ƒ ‚ n  | S(   Ns(   Theme directory not found: %r (path: %r)(   t   ost   patht   joint   themes_dir_patht   isdirt   docutilst   ApplicationError(   t   nameR
   (    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyt
   find_theme   s
    t   Writerc           B   sl  e  Z e j j d  d d d g i d d 6d d 6d d 6f d	 d
 g i d d 6d d 6f d d g i d d 6e j d 6f d d g i d d 6d d 6f d d g i d d g d 6d d 6d d 6f d d g i d d 6e d 6e j d 6f d d  g i d! d 6d d 6f d" d# g i d d 6e j d 6f d$ d% g i d& d 6d d 6f f	 f Z i d' d( 6Z d) Z	 d- Z
 d, „  Z RS(.   s   S5 Slideshow Specific OptionssŒ   For the S5/HTML writer, the --no-toc-backlinks option (defined in General Docutils Options above) is the default, and should not be changed.sB  Specify an installed S5 theme by name.  Overrides --theme-url.  The default theme name is "default".  The theme files will be copied into a "ui/<theme>" directory, in the same directory as the destination file (output HTML).  Note that existing theme files will not be overwritten (unless --overwrite-theme-files is used).s   --themet   defaults   <name>t   metavart	   theme_urlt	   overridess   Specify an S5 theme URL.  The destination file (output HTML) will link to this theme; nothing will be copied.  Overrides --theme.s   --theme-urls   <URL>t   themes{   Allow existing theme files in the ``ui/<theme>`` directory to be overwritten.  The default is not to overwrite theme files.s   --overwrite-theme-filest
   store_truet   actiont	   validatorsf   Keep existing theme files in the ``ui/<theme>`` directory; do not overwrite any.  This is the default.s   --keep-theme-filest   overwrite_theme_filest   destt   store_falses@   Set the initial view mode to "slideshow" [default] or "outline".s   --view-modet	   slideshowt   outlinet   choicess   <mode>sO   Normally hide the presentation controls in slideshow mode. This is the default.s   --hidden-controlss^   Always show the presentation controls in slideshow mode.  The default is to hide the controls.s   --visible-controlst   hidden_controlssM   Enable the current slide indicator ("1 / 15").  The default is to disable it.s   --current-slides:   Disable the current slide indicator.  This is the default.s   --no-current-slidet   current_slidei    t   toc_backlinkss   s5_html writert   writerss   html4css1 writerc         C   s   t  j j |  ƒ t |  _ d  S(   N(   R   R   t   __init__t   S5HTMLTranslatort   translator_class(   t   self(    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyR%   Y   s    (   R$   s   html4css1 writer(   t   __name__t
   __module__R   R   t   settings_specR   t   validate_booleant   Truet   settings_default_overridest   config_sectiont   config_section_dependenciesR%   (    (    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyR   $   sJ   	

R&   c           B   s¥   e  Z d  Z d Z d Z d Z d Z d Z d Z e e Z	 d „  Z
 d „  Z d „  Z e j d ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sœ  <!-- configuration parameters -->
<meta name="defaultView" content="%(view_mode)s" />
<meta name="controlVis" content="%(control_visibility)s" />
<!-- style sheet links -->
<script src="%(path)s/slides.js" type="text/javascript"></script>
<link rel="stylesheet" href="%(path)s/slides.css"
      type="text/css" media="projection" id="slideProj" />
<link rel="stylesheet" href="%(path)s/outline.css"
      type="text/css" media="screen" id="outlineStyle" />
<link rel="stylesheet" href="%(path)s/print.css"
      type="text/css" media="print" id="slidePrint" />
<link rel="stylesheet" href="%(path)s/opera.css"
      type="text/css" media="projection" id="operaFix" />
sA   
<style type="text/css">
#currentSlide {display: none;}
</style>
s¥   <div class="layout">
<div id="controls"></div>
<div id="currentSlide"></div>
<div id="header">
%(header)s
</div>
<div id="footer">
%(title)s%(footer)s
</div>
</div>
R   t   __base__s
   slides.csss   outline.csss	   print.csss	   opera.csss	   slides.jss   s5-core.csss   framing.csss
   pretty.csss	   blank.gifs   iepngfix.htcc         G   sÑ   t  j j |  | Œ d  |  _ |  j ƒ  |  j j j } d |  j j j	 } |  j
 j |  j i |  j d 6| d 6| d 6ƒ |  j j j sœ |  j
 j |  j ƒ n  |  j d ƒ g  |  _ g  |  _ d |  _ d  |  _ d  S(	   Nt   visiblet   hiddenR
   t	   view_modet   control_visibilitys)   <meta name="version" content="S5 1.1" />
i    (   R2   R3   (   R   t   HTMLTranslatorR%   t   Nonet   theme_file_patht   setup_themet   documentt   settingsR4   R!   t
   stylesheett   appendt   s5_stylesheet_templateR"   t   disable_current_slidet   add_metat	   s5_footert	   s5_headert   section_countt   theme_files_copied(   R(   t   argsR4   R5   (    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyR%   ™   s     	
			c         C   sS   |  j  j j r |  j ƒ  n3 |  j  j j r@ |  j  j j |  _ n t j d ƒ ‚ d  S(   Ns&   No theme specified for S5/HTML writer.(   R:   R;   R   t
   copy_themeR   R8   R   R   (   R(   (    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyR9   ­   s    c         C   s…  |  j  j } t | j ƒ } | g } i  |  _ i  } d d | j f |  _ | j r¡ t j j	 t j j
 | j ƒ d | j ƒ } t j j | ƒ s¥ t j | ƒ q¥ n d St } xO| rüx] t j | ƒ D]L } | |  j k rß qÄ n  |  j | | | ƒ rÄ | |  j k rÄ d | | <qÄ qÄ W| rPn  t j j	 | |  j ƒ } t j j | ƒ rÈt | ƒ j ƒ  }	 xq |	 D]Z }
 |
 j ƒ  }
 |
 ra|
 j d ƒ rat |
 ƒ } | | k rªd } n | j | ƒ PqaqaWd } n d } | s® t |  j ƒ } | j | ƒ t } q® q® Wt | ƒ t |  j ƒ k rt |  j ƒ } x! | j ƒ  D] } | j | ƒ q4Wt j  d d j	 g  | D] } d | ^ qaƒ ƒ ‚ n  d S(	   s  
        Locate & copy theme files.

        A theme may be explicitly based on another theme via a '__base__'
        file.  The default base theme is 'default'.  Files are accumulated
        from the specified theme, any base themes, and 'default'.
        s   %s/%st   uiNi   t   #s   Theme files not found: %ss   , s   %r(!   R:   R;   R   R   RD   R8   t   _destinationR	   R
   R   t   dirnameR   t   makedirst   Falset   listdirt   base_theme_filet	   copy_filet   required_theme_filest   isfilet   opent	   readlinest   stript
   startswithR7   R=   t   default_themeR-   t   lent   listt   keyst   removeR   R   (   R(   R;   R
   t   theme_pathst   required_files_copiedR   R   t   fRN   t   linest   linet   required(    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyRF   ¶   s\    				!			s   ~$|\.bak$|#$|\.cvsignore$c   
      C   si  t  j j | | ƒ } t  j j | | ƒ } | |  j k r= d Sd |  j | <t  j j | ƒ rO|  j j | ƒ rr d S|  j j	 } t  j j
 | ƒ r­ | j r­ | j j | ƒ nž t | d ƒ } | j ƒ  } | j ƒ  t | d ƒ }	 | j t  j d ƒ } |	 j | j t d ƒ | | j d ƒ j t j ƒ  ƒ ƒ ƒ |	 j ƒ  | j j | ƒ d St  j j | ƒ red Sd S(   s   
        Copy file `name` from `source_dir` to `dest_dir`.
        Return 1 if the file exists in either `source_dir` or `dest_dir`.
        i   t   rbt   wbt   /s
   ui/defaults   ui/N(   R	   R
   R   RD   RQ   t   files_to_skip_patternt   searchR7   R:   R;   t   existsR   t   record_dependenciest   addRR   t   readt   closet   replacet   sept   writeR   t   rfindt   encodet   syst   getfilesystemencoding(
   R(   R   t
   source_dirt   dest_dirt   sourceR   R;   t   src_filet   src_datat	   dest_file(    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyRO   ø   s2    
	
c         C   s  |  j  j |  j |  j i |  j j d 6g ƒ |  j j |  j ƒ |  j j	 d |  j
 |  j j ƒ |  j j	 d |  j
 |  j j ƒ |  j rÄ |  j d k r® |  j j |  j ƒ qÄ |  j j |  j ƒ n  |  j j |  j d ƒ |  j j |  j ƒ d j |  j ƒ } d j |  j ƒ } d j |  j ƒ j d d ƒ } |  j i | d 6| d	 6| d
 6} |  j j | ƒ |  j j d ƒ |  j j |  j i d g d 6d g d 6d ƒ ƒ |  j s¾|  j j d ƒ n  |  j j	 d d ƒ |  j j |  j d |  j |  j |  j |  j d  ƒ d  S(   Nt   langi    t   mathjaxi   t    s   <h1 class="title">s   <h1>t   headert   titlet   footers   <div class="presentation">
t   slidet   classest   slide0t   idst   divs   </div>
iÿÿÿÿ(    t   head_prefixt   extendt   doctypet   head_prefix_templateR;   t   language_codet   html_prologR=   t   metat   insertt   content_typet   output_encodingt   headt   math_headert   math_outputR<   t	   html_headt   fragmentt   bodyR   RB   RA   t
   html_titleRk   t   layout_templatet   body_prefixt   starttagRC   t   body_suffixt	   html_bodyt   body_pre_docinfot   docinfo(   R(   t   nodeR{   R}   R|   t   layout(    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyt   depart_document  s6      		'		c         C   sT   |  j  j ƒ  } |  j j d ƒ |  j j |  j | ƒ |  j j d ƒ |  j | 3d  S(   Ns   <h2>s   </h2>(   t   contextt   popRA   R=   R„   R’   (   R(   R›   t   start(    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyt   depart_footer;  s
    c         C   sW   |  j  j ƒ  } d g } | j |  j | ƒ | j d ƒ |  j | 3|  j j | ƒ d  S(   Ns   <div id="header">
s   
</div>
(   Rž   RŸ   R„   R’   R=   RB   (   R(   R›   R    R{   (    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyt   depart_headerB  s    	
c         C   s”   |  j  s |  j j d ƒ n  |  j  d 7_  |  j d 7_ |  j d k rn |  j j |  j | d d d ƒƒ n" |  j j |  j | d d d ƒƒ d  S(   Ns   
</div>
i   R‚   t   CLASSt   sectionR~   (   RC   R’   R=   t   section_levelR–   (   R(   R›   (    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyt   visit_sectionJ  s    	%c         C   s•   t  | j t j ƒ r~ |  j |  j d } | d k r> d } n  d | } |  j j |  j | | d ƒ ƒ |  j	 j d | ƒ n t
 j j |  | ƒ d  S(   Ni   i   s   h%sRz   s   </%s>
(   t
   isinstancet   parentR   R¤   R¥   t   initial_header_levelR’   R=   R–   Rž   R   R6   t   visit_subtitle(   R(   R›   t   levelt   tag(    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyRª   U  s    	
c         C   s   t  j j |  | ƒ d  S(   N(   R   R6   t   visit_title(   R(   R›   (    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyR­   `  s    (   s
   slides.csss   outline.csss	   print.csss	   opera.csss	   slides.js(   s   s5-core.csss   framing.csss
   pretty.csss	   blank.gifs   iepngfix.htc(   R)   R*   R>   R?   R”   RV   RN   t   direct_theme_filest   indirect_theme_filesRP   R%   R9   RF   t   ret   compileRd   RO   R   R¡   R¢   R¦   Rª   R­   (    (    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyR&   ^   s&   
				@	!	"				(   t   __doc__t   __docformat__Rp   R	   R°   R   R   R   R   t   docutils.writersR   t   docutils.parsers.rstR   t   docutils._compatR   t   relative_pathR
   R   t   getcwdt   _datadirt   __file__R   R   R   R6   R&   (    (    (    sE   /usr/lib/python2.7/dist-packages/docutils/writers/s5_html/__init__.pyt   <module>   s   !	
: