15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
# This is an IVLE application.
23
# A SMF forum application for IVLE.
18
# Author: David Coles, Will Grant
30
from ivle import interpret
34
Handler for the Forum application.
36
This application implements a general purpose PHP CGI loader
41
forum_base = "php/phpBB3"
43
# Set request attributes
45
req.styles = ["media/forum/forum.css"]
47
# Process URL for special directives
48
url = urlparse.urlparse(req.path)
49
hierarchical_part = url[2]
51
forum_page = "" # use the default forum page
54
board = re.match('board/(.*?)(/|$)',hierarchical_part)
56
framequery += 'f=' + board.group(1) + "&"
57
forum_page = "viewforum.php"
59
topic = re.search('topic/(.*?)(/|$)',hierarchical_part)
61
framequery += 't=' + topic.group(1)
62
forum_page = "viewtopic.php"
64
# If the tail of the forum url is empty or a known special request
65
# then wrap the page in the headers and footer and load the default or
66
# special page in the ivlebody frame
69
location = forum_page + framequery
71
frameurl = util.make_path(os.path.join(forum_base,location))
72
req.content_type = "text/html"
73
req.write_html_head_foot = True
74
req.write('<object class="fullscreen" type="text/html" data="%s">'%
75
(frameurl + framequery))
25
from urllib import quote
27
from ivle.webapp.base.xhtml import XHTMLView
28
from ivle.webapp.base.plugins import ViewPlugin, CookiePlugin
32
class ForumView(XHTMLView):
35
def __init__(self, req, path):
38
def populate(self, req, ctx):
39
self.plugin_styles[Plugin] = ['forum.css']
41
forum_base = "php/phpBB3"
43
# Process URL for special directives
44
url = urlparse.urlparse(self.path)
45
hierarchical_part = url[2]
47
forum_page = "" # use the default forum page
50
board = re.match('board/(.*?)(/|$)',hierarchical_part)
52
framequery += 'f=' + board.group(1) + "&"
53
forum_page = "viewforum.php"
55
topic = re.search('topic/(.*?)(/|$)',hierarchical_part)
57
framequery += 't=' + topic.group(1)
58
forum_page = "viewtopic.php"
60
# If the tail of the forum url is empty or a known special request
61
# then wrap the page in the headers and footer and load the default or
62
# special page in the ivlebody frame
65
location = forum_page + framequery
67
frameurl = ivle.util.make_path(os.path.join(forum_base,location))
68
ctx['url'] = frameurl + framequery
70
def make_forum_cookie(user):
71
secret = ivle.conf.forum_secret
73
login = quote(user.login)
74
nick = quote(user.nick)
76
if user.email != None:
77
email = quote(user.email)
79
role = quote(str(user.role))
81
hashtext = login + nick + email + role + secret
82
hash = hashlib.md5(hashtext).hexdigest()
83
data = quote(login + ':' + nick + ':' + email + ':' + role + ':' + hash)
87
class Plugin(ViewPlugin, CookiePlugin):
89
('forum', ForumView, {'path': ''}),
90
('forum/*path', ForumView),
93
cookies = {'ivleforumcookie': make_forum_cookie}