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

From XPUB & Lens-Based wiki
(Created page with "Rough version: <source lang = "python" > #!/usr/bin/env python #-*- coding:utf-8 -*- import cgi, cgitb import urlparse, urllib form = cgi.FieldStorage() if form.getvalue('...")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
Rough version:
<div style="width: 70%;">
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.


<source lang = "python" >
[[File:Exquisfrontpage.png|755px]]
 
<syntaxhighlight lang="python">
#!/usr/bin/env python
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#-*- coding:utf-8 -*-
import cgi, cgitb
import cgi, urllib
import urlparse, urllib
import cgitb; cgitb.enable()
 
 


form = cgi.FieldStorage()
if form.getvalue('textcontent'):
  text_content = form.getvalue('textcontent')
else:
  text_content = "Not entered"
dict = {}
dict["entry"] = text_content
database = open("database.txt","a")
database.write(urllib.urlencode(dict) + "\n")
database.close()


print "Content-Type: text/html"
print "Content-Type: text/html"
Line 27: Line 17:
     <html>
     <html>
     <head>
     <head>
     <title>Technical Issues</title>
     <link href='http://fonts.googleapis.com/css?family=Share+Tech+Mono' rel='stylesheet' type='text/css'>
     <style>
    <link rel='stylesheet' type='text/css' href='/cadavreexquiscss.css'
    form {
     <title>Cadavre Exquis</title>
        border-style: none;
        outline-color: none;
    }
    </style>
     </head>
     </head>
     <body>
     <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")
</syntaxhighlight>
[[File:Exquis.png|755px]]
<syntaxhighlight lang="python">
#!/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")
database = open("database.txt")
lines = database.readlines()
lines = database.readlines()
Line 43: Line 60:
def last_Word():
def last_Word():
     for line in lines:
     for line in lines:
         neatly = urlparse.parse_qs(line.rstrip())
         a = line.split()
        parsed = neatly["entry"]
        parsed = str(parsed[len(parsed)-1])
        a = parsed.split()
         for word in a:
         for word in a:
             lastword = word
             lastword = word
     return lastword
     return lastword


lastWord = last_Word()
lastWord = last_Word()
x = 0


if lines > 7:
print "Content-Type: text/html"
    for line in lines:
print
        neat = urlparse.parse_qs(line.rstrip())
        print """
        <p> """+neat["entry"][0]+""" </p>
        """
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'>
     <form method='post'>
     <textarea name='textcontent' cols='40' rows='4'>
     <input type='text' name ='textcontent' id='reply' size='121' class ='exquis' placeholder='"""+lastWord+"""'/>  
    """+lastWord+"""
     <input type='submit' value='Contribute!' class ='button'/>
    </textarea>
     <input type='submit' value='Publish, please!' />
     </form>
     </form>
     </body>
     </body>
     </html> """
     </html> """
</source>
</syntaxhighlight>
 
[[File:Talesofnonsense.png|755px]]
 
<syntaxhighlight lang="python">
#!/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>"""
</syntaxhighlight>

Latest revision as of 21: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>"""