File: //lib64/python2.7/Demo/cgi/wiki.pyo
ó
¿œ^c @ sk d Z d d l Z d d l Z d d l Z d d l Z d d l Z e j Z d „ Z d d d „ ƒ YZ d S( s0 Wiki main program. Imported and run by cgi3.py.iÿÿÿÿNc C so t j ƒ } d GHH| j d d ƒ } | j d d ƒ } t | ƒ } t | d | d ƒ p^ | j } | | ƒ d S( Ns Content-type: text/htmlt cmdt viewt paget FrontPaget cmd_( t cgit FieldStoraget getvaluet WikiPaget getattrt Nonet cmd_view( t formR R t wikit method( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt main s R c B sŸ e Z e j ƒ Z e j j e j d ƒ Z
d „ Z d „ Z d „ Z
d d „ Z d „ Z d „ Z d „ Z d „ Z d d
„ Z d „ Z d „ Z d
„ Z RS( i c C s2 | j | ƒ s t d ‚ n | | _ | j ƒ d S( Ns page name is not a wiki word( t
iswikiwordt
ValueErrort namet load( t selfR ( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt __init__ s c C s¦ d Gt | j | j ƒ ƒ Gd GHd GHx? | j j ƒ D]. } | j ƒ } | sT d GHq4 | j | ƒ GHq4 Wd GHd G| j d | j d ƒ d GH| j d d d
ƒ d GHd S( Ns <h1>s </h1>s <p>s <hr>t edits Edit this paget ;R R s go to front paget .( t escapet
splitwikiwordR t datat
splitlinest rstript
formatlinet mklink( R R t line( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyR s c C s§ g } x‘ t j d | ƒ D]} } | j | ƒ r} t j j | j | ƒ ƒ ra | j d | | ƒ } q‰ | j d | | d ƒ } n t | ƒ } | j | ƒ q Wd j
| ƒ S( Ns (\W+)R t newt *t ( t ret splitR t ost patht isfilet mkfileR R t appendt join( R R t wordst word( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyR ( s t Changec C sZ d G| G| j Gd GHd | j GHd } | | j GHd GHd | j GHd GHd | GHd GHd S(
Ns <h1>s </h1>s <form method="POST" action="%s">s7 <textarea cols="70" rows="20" name="text">%s</textarea>s/ <input type="hidden" name="cmd" value="create">s, <input type="hidden" name="page" value="%s">s <br>s% <input type="submit" value="%s Page">s </form>( R t scripturlR ( R R t labelt s( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt cmd_edit5 s c C s— | j d d ƒ j ƒ | _ | j ƒ } | rI d GHd GHd Gt | ƒ GHnJ d GHd } | | j d | j GHd GHd GHd
G| j d | j | j ƒ GHd S( Nt textR# s% <h1>I'm sorry. That didn't work</h1>s8 <p>An error occurred while attempting to write the file:s <p>s <head>s/ <meta http-equiv="refresh" content="1; URL=%s">s ?cmd=view&page=s <h1>OK</h1>s) <p>If nothing happens, please click here:R ( R t stripR t storeR R/ R R ( R R t errorR1 ( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt
cmd_create@ s c C s | j | d d ƒd S( NR0 t Create( R2 ( R R ( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyt cmd_newQ s c C s t j d | ƒ S( Ns [A-Z][a-z]+([A-Z][a-z]*)+( R$ t match( R R- ( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyR T s c C sS g } x= | D]5 } | r5 | j ƒ r5 | j d ƒ n | j | ƒ q
Wd j | ƒ S( Nt R# ( t isupperR* R+ ( R R- t charst c( ( s% /usr/lib64/python2.7/Demo/cgi/wiki.pyR W s
c C s2 | d k r | j } n t j j | j | d ƒ S( Ns .txt( R
R R&