User:Lidia.Pereira/PNMII/WB/CE: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 23: Line 23:
     <body>
     <body>
     <img src='/cadavrebanner.png' class = 'banner'/>
     <img src='/cadavrebanner.png' class = 'banner'/>
     <p class = 'frontpage'>Welcome! Whether you want to participate in the Cadavre Exquis or just read the Tales of Nonsense, you've come to the right place. Plase, proceed! </p>
     <p class = 'frontpage'>Welcome! Whether you want to participate in the Cadavre Exquis\
or just read the Tales of Nonsense, you've come to the right place. Plase, proceed! </p>
     <a href = 'cadavrexquisresults.cgi'> <img src ='/nonsenselink.png'class ='frontpagelink2'/> </a>
     <a href = 'cadavrexquisresults.cgi'> <img src ='/nonsenselink.png'class ='frontpagelink2'/> </a>
     <a href = 'cadavrexquis.cgi'> <img src ='/cadavrelink.png' class ='frontpagelink1'/> </a> <br>
     <a href = 'cadavrexquis.cgi'> <img src ='/cadavrelink.png' class ='frontpagelink1'/> </a> <br>
Line 37: Line 38:
     database = open("database.txt","a")
     database = open("database.txt","a")
     database.write("Begin!"+"\n")
     database.write("Begin!"+"\n")
</syntax>
</syntaxhighlight>


[[File:Exquis.png|755px]]
[[File:Exquis.png|755px]]
Line 80: Line 81:
     <a href='exquisfrontpage.cgi'><img src='/cadavrebanner.png' class = 'banner2'/></a> <br>
     <a href='exquisfrontpage.cgi'><img src='/cadavrebanner.png' class = 'banner2'/></a> <br>
     <a href='cadavrexquisresults.cgi'><img src='/nonsenselink.png' class='nonsenselink'></a>
     <a href='cadavrexquisresults.cgi'><img src='/nonsenselink.png' class='nonsenselink'></a>
     <p class='exquisrule'> The only rule is that you have to start your contribution with the word you see on the form! </p>
     <p class='exquisrule'> The only rule is that you have to start your contribution with \
    the word you see on the form! </p>
     <form method='post'>
     <form method='post'>
     <input type='text' name ='textcontent' id='reply' size='121' class ='exquis' placeholder='"""+lastWord+"""'/>  
     <input type='text' name ='textcontent' id='reply' size='121' class ='exquis' placeholder='"""+lastWord+"""'/>  
Line 87: Line 89:
     </body>
     </body>
     </html> """
     </html> """
</syntax>
</syntaxhighlight>


[[File:Talesofnonsense.png|755px]]
[[File:Talesofnonsense.png|755px]]
Line 145: Line 147:
         </body>
         </body>
         </html>"""
         </html>"""
</syntax>
</syntaxhighlight>

Latest revision as of 20:32, 30 March 2014

This is a simple prototype of a cgi-based Cadavre Exquis which I hope to use in the future, applied to my Self-Directed Research. It also still lacks a way to handle multiple users editing the same part of the narrative.

Exquisfrontpage.png

#!/usr/bin/env python
#-*- coding:utf-8 -*-
import cgi, urllib
import cgitb; cgitb.enable()


print "Content-Type: text/html"
print 
print """
    <!DOCTYPE html>
    <html>
    <head>
    <link href='http://fonts.googleapis.com/css?family=Share+Tech+Mono' rel='stylesheet' type='text/css'>
    <link rel='stylesheet' type='text/css' href='/cadavreexquiscss.css'
    <title>Cadavre Exquis</title>
    </head>
    <body>
    <img src='/cadavrebanner.png' class = 'banner'/>
    <p class = 'frontpage'>Welcome! Whether you want to participate in the Cadavre Exquis\
 or just read the Tales of Nonsense, you've come to the right place. Plase, proceed! </p>
    <a href = 'cadavrexquisresults.cgi'> <img src ='/nonsenselink.png'class ='frontpagelink2'/> </a>
    <a href = 'cadavrexquis.cgi'> <img src ='/cadavrelink.png' class ='frontpagelink1'/> </a> <br>
    </body>
    </html>
"""
 
database = open("database.txt", "a")
database = open("database.txt")
lines = database.readlines()

if not lines:
    database = open("database.txt","a")
    database.write("Begin!"+"\n")

Exquis.png

#!/usr/bin/env python
#-*- coding:utf-8 -*-
import cgi, urllib
import cgitb; cgitb.enable()
import urlparse

form = cgi.FieldStorage()
text_content = str(form.getvalue('textcontent'))

database = open("database.txt","a")
if text_content != "None":
    database.write(text_content + "\n")
database = open("database.txt")
lines = database.readlines()

def last_Word():
    for line in lines:
        a = line.split()
        for word in a:
            lastword = word
    return lastword

lastWord = last_Word()
x = 0

print "Content-Type: text/html"
print 
print """
    <!DOCTYPE html>
    <html>
    <head>
    <link href='http://fonts.googleapis.com/css?family=Share+Tech+Mono' rel='stylesheet' type='text/css'>
    <link rel='stylesheet' type='text/css' href='/cadavreexquiscss.css'>
    <title>Cadavre Exquis</title>
    </head>
    <body>
    <a href='exquisfrontpage.cgi'><img src='/cadavrebanner.png' class = 'banner2'/></a> <br>
    <a href='cadavrexquisresults.cgi'><img src='/nonsenselink.png' class='nonsenselink'></a>
    <p class='exquisrule'> The only rule is that you have to start your contribution with \
    the word you see on the form! </p>
    <form method='post'>
    <input type='text' name ='textcontent' id='reply' size='121' class ='exquis' placeholder='"""+lastWord+"""'/> 
    <input type='submit' value='Contribute!' class ='button'/>
    </form>
    </body>
    </html> """

Talesofnonsense.png

#!/usr/bin/env python
#-*- coding:utf-8 -*-
import cgi, urllib
import cgitb; cgitb.enable()
import time


print "Content-Type: text/html"
print 
print """
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset = utf-8 >
    <link href='http://fonts.googleapis.com/css?family=Share+Tech+Mono' rel='stylesheet' type='text/css'>
    <link rel='stylesheet' type='text/css' href='/cadavreexquiscss.css'>
    <style>
    body {
        background-color: #FFF;
    }
    </style>
    <title>Tales of Nonsense</title>
    </head>
    <body> 
    <a href='exquisfrontpage.cgi'><img src='/talesofnonsensebanner.png' class = 'nonsensebanner'/></a> <br>
    <a href='cadavrexquis.cgi'><img src='/exquislink.png' class = 'nonsenselink2'></a>
    <div class='nonsensediva'>"""
x = 0
database = open("database.txt")
lines = database.readlines()
numberlines = len(lines)

def getBlob():
    blob = ""
    for line in lines[1:numberlines]:
        data = line.strip("\n")
        blob = blob + data + " "
    return blob

blob = getBlob()
blobies = blob.split(".")
lenbloblies = len(blobies)
n = 0
for x in range (lenbloblies-3):
    paragraph = " "
    for blobi in blobies[n:n+3]:
        paragraph = paragraph + blobi + "."
    n = n + 3
    print """<p class = 'nonsense'>"""+paragraph+"""</p>"""

print """</div>
        </body>
        </html>"""