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

From XPUB & Lens-Based wiki
No edit summary
No edit summary
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 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+"""'/>  

Revision as of 20:31, 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

<syntaxhighlight lang="python">

  1. !/usr/bin/env python
  2. -*- 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>
   

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!

   <a href = 'cadavrexquisresults.cgi'>  </a>
   <a href = 'cadavrexquis.cgi'>  </a> 
</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")

</syntax>

Exquis.png

<syntaxhighlight lang="python">

  1. !/usr/bin/env python
  2. -*- 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'></a> 
<a href='cadavrexquisresults.cgi'></a>

The only rule is that you have to start your contribution with \ the word you see on the form!

   <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> """

</syntax>

Talesofnonsense.png

<syntaxhighlight lang="python">

  1. !/usr/bin/env python
  2. -*- 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'></a> 
<a href='cadavrexquis.cgi'></a>
"""

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 """

"""+paragraph+"""

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

</syntax>