~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/forum/__init__.py

Split ivle.webapp.forum.ForumView's board and topic special cases into
Forum{Board,Topic}View.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
        forum_base = "php/phpBB3"
42
42
 
43
 
        # Process URL for special directives
44
 
        url = urlparse.urlparse(self.path)
45
 
        hierarchical_part = url[2]
46
 
 
47
 
        forum_page = "" # use the default forum page
48
 
        framequery = "?"
49
 
 
50
 
        board = re.match('board/(.*?)(/|$)',hierarchical_part)
51
 
        if board:
52
 
            framequery += 'f=' + board.group(1) + "&"
53
 
            forum_page = "viewforum.php"
54
 
 
55
 
        topic = re.search('topic/(.*?)(/|$)',hierarchical_part)
56
 
        if topic:
57
 
            framequery += 't=' + topic.group(1)
58
 
            forum_page = "viewtopic.php"
59
 
 
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
63
 
        location = self.path
64
 
        if board or topic:
65
 
            location = forum_page + framequery
66
 
 
67
 
        frameurl = ivle.util.make_path(os.path.join(forum_base,location))
68
 
        ctx['url'] = frameurl + framequery
 
43
        ctx['url'] = ivle.util.make_path(os.path.join(forum_base, self.path))
 
44
 
 
45
class ForumBoardView(ForumView):
 
46
    def __init__(self, req, board):
 
47
        self.path = 'viewforum.php?f=' + board
 
48
 
 
49
class ForumTopicView(ForumView):
 
50
    def __init__(self, req, topic):
 
51
        self.path = 'viewtopic.php?t=' + topic
69
52
 
70
53
def make_forum_cookie(user):
71
54
    secret = ivle.conf.forum_secret
87
70
class Plugin(ViewPlugin, CookiePlugin):
88
71
    urls = [
89
72
        ('forum', ForumView, {'path': ''}),
 
73
        ('forum/+board/:board', ForumBoardView),
 
74
        ('forum/+topic/:topic', ForumTopicView),
90
75
        ('forum/*path', ForumView),
91
76
    ]
92
77