__access__ = 0
from urllib import urlencode, quote_plus, quote
from copy import copy
from lxml import etree
import sys
sys.path.append("/home/lkcl/src/pyjamas-desktop/pyjamas-web/library")
from __pyjamas__ import init_doc, doc, doc_process
#this is the folderish class that manages ZODB-based chats
class ZCTmainpage:
""" ZCT main page.
"""
def index(self, REQUEST):
""" returns the index page
"""
#sys.path.append("/home/lkcl/src/pyjamas-desktop/pyjamas-web/examples/helloworld/")
#from Hello import Hello
#init_doc("/home/lkcl/src/pyjamas-desktop/pyjamas-web/examples/helloworld/Hello.html")
#m = Hello()
sys.path.append("/home/lkcl/src/pyjamas-desktop/pyjamas-web/examples/gridtest/")
from GridTest import GridTest
init_doc("/home/lkcl/src/pyjamas-desktop/pyjamas-web/examples/gridtest/GridTest.html")
m = GridTest()
return doc_process(GridTest, REQUEST)
def registerpage(self, REQUEST):
""" returns the register page, which comprises
three sections - leftbit, rightbit, mainbit.
i've removed mainbit (it used to contain introsearch).
"""
links = { 'leftbit': 'registerwelcome',
'rightbit': 'register'
}
page = self.tmpl('registerpage')
page.staticlink(links)
return page
def footer(self, REQUEST):
loggedin = self.login_check()
if loggedin:
target = 'centercontent'
else:
target = 'maincontent'
options = { \
'copyright': ("mainmenulink", "copyright", target, "Copyright"),
'termsconditions': ("mainmenulink", "termsnconditions", target, "Terms and Conditions"),
'faq': ("mainmenulink", "faq", target, "FAQ"),
'privacy': ("mainmenulink", "privacy", target, "Privacy"),
'contact': ("mainmenulink", "contact", target, "Contact Us"),
}
page = self.tmpl('footer', REQUEST)
page.dynamiclink(options)
return page
def menu(self, REQUEST):
loggedin = False #self.login_check()
if loggedin:
target = 'centercontent'
else:
target = 'maincontent'
options = { \
'veggies': ("mainmenulink", "veggies", target, "Veggies"),
'besafe': ("mainmenulink", "besafe", target, "Be Safe!"),
'faq': ("mainmenulink", "faq", target, "FAQ"),
#'legal': ("mainmenulink", "legal", target, "Legal"),
#'privacy': ("mainmenulink", "privacy", target, "Privacy"),
#'about': ("mainmenulink", "about", target, "About Us"),
'register_hurrah': ("mainmenulink", "registerpage", target, "Join our Community!")
}
if False: #self.login_check():
REQUEST['loggedin'] = '1'
more = { \
'home': ("mainmenulink", "userhome", target, "Home"),
'search': ("mainmenulink", "search", target, "Search"),
'profile': ("mainmenulink", "profile", target, "Profile"),
'logout': ("mainmenulink", "logout", target, "Logout")}
else:
more = { \
'home': ("mainmenulink", "home", target, "Home"),
'register': ("mainmenulink", "registerpage", target, "Register Free"),
'login': ("mainmenulink", "login", target, "Member Login"),
'about': ("mainmenulink", "about", target, "About Us"),
}
options.update(more)
links = { 'adcontent': 'menuads' }
menu_page = self.tmpl('menu', REQUEST)
menu_page.staticlink(links)
menu_page.dynamiclink(options)
return menu_page
def logincontext(self, REQUEST):
links = { 'messagesmenu': ('messagesunexpand', 'submenustyle') ,
'forumsmenu': ('forumsunexpand', 'submenustyle') }
options = { \
'search': ("mainmenulink", "search", "centercontent", "By Profile"),
'usersearch': ("mainmenulink", "usersearch", "centercontent", "Find User"),
'tagsearch': ("mainmenulink", "tagsearch", "centercontent", "Experimental"),
'profile': ("mainmenulink", "profile", "centercontent", "Update"),
'uploadimage': ("mainmenulink", "uploadimage", "centercontent", "Upload Picture"),
'images': ("mainmenulink", "profileimages", "centercontent", "Pictures"),
'profilecomms': ("mainmenulink", "profilecomms", "centercontent", "Options"),
'profilecomms': ("mainmenulink", "profilecomms", "centercontent", "Options"),
}
login_page = self.tmpl('logincontext', REQUEST)
login_page.dynamiclink(options)
login_page.staticlink(links)
return login_page
def context(self, REQUEST):
search = str(self.tmpl('quicksearchform', {}))
REQUEST['searchform'] = search
return str(self.tmpl('context', REQUEST))
def userhome(self, REQUEST):
options = { \
'search': ("", "search", "centercontent", "search"),
'update': ("", "profile", "centercontent", "update")
}
sessionkey = self.get_session_info()
res = self.db.check_session(sessionkey)
if res:
username, userid = res
else:
userid = None
if userid:
REQUEST['username'] = username
count = int(self.db.s.message(to=userid,read=0).count())
if count:
REQUEST['unreadinboxcount'] = count
REQUEST['messageword'] = 'messages'
if count == 1:
REQUEST['messageword'] = 'message'
options['messages'] = \
("", "inbox", "centercontent", REQUEST['messageword'])
page = self.tmpl('userhome', REQUEST)
page.dynamiclink(options)
return page
def imagetestpage(self, REQUEST):
""" returns an image test page
"""
d = {}
d['zoom_window'] = 'zoom_window'
d['zoom_frame'] = 'zoom_frame'
d['frame_width'] = '400'
d['frame_height'] = '300'
d['frame_image'] = 'Visionary_jpg'
frame_popup = self.tmpl('frame_popup', d)
index_page = self.tmpl('imagetestpage')
index_page['frame_popup_test'] = frame_popup
return str(index_page)
def home(self, REQUEST):
""" displays the anonymous main home page content.
this page is a little odd because it uses an
actual web-page function (searchresultspage) and
sploshes the content into the home page.
i've removed "mainbit" - the introsearch.
"""
links = { 'leftbit': 'homewelcome',
'rightbit': 'login'
}
page = self.tmpl('home')
page.staticlink(links, override=1)
return page
def mainads(self, REQUEST):
url = REQUEST.get('url', 'vegetarian dating for marriage')
d = {}
d['loc'] = quote(self.req.uri)
d['documenturl'] = quote(url)
i = self.get_useful_info()
if i.get("screenwidth", 630) > 820:
d['wide_ads'] = 1
return str(self.tmpl('mainads', d))
def advertising(self, REQUEST):
url = REQUEST.get('url', 'vegetarian dating for marriage')
d = {}
d['loc'] = quote(self.req.uri)
d['documenturl'] = quote(url)
return str(self.tmpl('advertising', d))
def besafe(self, REQUEST): return self.tmpl('besafe', {})
def legal(self, REQUEST): return self.tmpl('legal', {})
def faq(self, REQUEST): return self.tmpl('faq', {})
def tour(self, REQUEST): return self.tmpl('tour', {})
def about(self, REQUEST): return self.tmpl('about', {})
def registerwelcome(self, REQUEST):
options = { \
'registersafety': ("", "registersafety", 'mainbit', "[More]")
}
page = self.tmpl('registerwelcome', REQUEST)
page.dynamiclink(options)
return page
def introsearch(self, REQUEST):
req = copy(REQUEST)
if not req:
req['latest'] = 12
url = 'searchresultspage?%s' % urlencode(req)
links = { 'searchresultspage': url }
page = self.tmpl('introsearch')
page.staticlink(links)
return page
def homewelcome(self, REQUEST):
""" displays the anonymous main home page content.
this page is a little odd because it uses an
actual web-page function (searchresultspage) and
sploshes the content into the home page.
"""
options = { \
'search': ("", "search", "maincontent", "search"),
}
page = self.tmpl('homewelcome')
page.dynamiclink(options)
return page
def menuads(self, REQUEST):
d = {}
d['loc'] = quote(self.req.uri)
d['documenturl'] = quote('vegetarian dating for marriage')
i = self.get_useful_info()
if i.get("screenwidth", 630) > 820:
d['wide_ads'] = 1
return str(self.tmpl('menuads', d))
def veggies(self, REQUEST):
sessionkey = self.get_session_info()
res = self.db.check_session(sessionkey)
loggedin = None
if res:
loggedin = 1
d = {'loggedin': loggedin }
return str(self.tmpl('veggies', d))
def resizeevent(self, REQUEST):
i = self.get_useful_info()
i['screenwidth'] = int(REQUEST.get("width", 630))
i['screenheight'] = int(REQUEST.get("height", 460))
self.set_useful_info(i)
resize = "ajax_dlink('adcontent', 'menuads');"
sessionkey = self.get_session_info()
res = self.db.check_session(sessionkey)
if res:
resize += " ajax_dlink('mainadcontent', 'mainads');"
return "<script> %s </script> " % resize