2008-11-17 23:23:22 +00:00
|
|
|
import os.path
|
|
|
|
import cherrypy
|
2008-11-18 21:28:51 +00:00
|
|
|
from datetime import datetime
|
2008-10-24 20:15:26 +00:00
|
|
|
from Product_page import Product_page
|
2008-10-31 22:17:59 +00:00
|
|
|
from Page_navigation import Page_navigation
|
2009-05-11 19:18:55 +00:00
|
|
|
from Tags import Div, H1, A, P, Span, Link, Img, B
|
2008-10-24 20:15:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Forum_page( Product_page ):
|
2008-10-31 22:17:59 +00:00
|
|
|
def __init__(
|
|
|
|
self, user, notebooks, first_notebook, login_url, logout_url, rate_plan, groups, forum_name,
|
|
|
|
threads, total_thread_count, start = 0, count = None,
|
|
|
|
):
|
2008-11-17 23:23:22 +00:00
|
|
|
base_path = cherrypy.request.path
|
2008-11-18 21:28:51 +00:00
|
|
|
updates_path = "%s?rss" % base_path
|
2008-11-17 23:23:22 +00:00
|
|
|
|
2008-11-18 21:28:51 +00:00
|
|
|
if forum_name == u"blog":
|
2008-11-17 23:23:22 +00:00
|
|
|
full_forum_name = u"Luminotes %s" % forum_name
|
2008-11-18 21:28:51 +00:00
|
|
|
else:
|
|
|
|
full_forum_name = u"%s forum" % forum_name
|
2008-10-24 20:15:26 +00:00
|
|
|
|
|
|
|
Product_page.__init__(
|
|
|
|
self,
|
|
|
|
user,
|
|
|
|
first_notebook,
|
|
|
|
login_url,
|
|
|
|
logout_url,
|
|
|
|
full_forum_name, # note title
|
2008-11-18 21:28:51 +00:00
|
|
|
Link( rel = u"alternate", type = u"application/rss+xml", title = full_forum_name, href = updates_path ) or None,
|
2008-10-24 20:15:26 +00:00
|
|
|
|
|
|
|
P(
|
|
|
|
H1( full_forum_name ),
|
|
|
|
),
|
|
|
|
Div(
|
2008-11-18 21:28:51 +00:00
|
|
|
P(
|
|
|
|
base_path.startswith( u"/forums/" ) and Span(
|
2009-05-11 19:18:55 +00:00
|
|
|
B( A( u"start a new discussion", href = os.path.join( base_path, u"create_thread" ) ) ),
|
2008-11-18 21:28:51 +00:00
|
|
|
u" | ",
|
|
|
|
A( u"all forums", href = u"/forums/" ),
|
|
|
|
u" | ",
|
|
|
|
) or None,
|
|
|
|
A( u"subscribe to rss", href = updates_path ),
|
|
|
|
A(
|
|
|
|
Img( src = u"/static/images/rss.png", width = u"14", height = u"14", class_ = u"middle_image padding_left" ),
|
|
|
|
href = updates_path,
|
|
|
|
),
|
2008-10-28 21:07:49 +00:00
|
|
|
class_ = u"small_text",
|
2008-11-17 23:23:22 +00:00
|
|
|
) or None,
|
2008-10-24 20:15:26 +00:00
|
|
|
[ Div(
|
|
|
|
A(
|
|
|
|
thread.name,
|
2009-03-17 00:09:31 +00:00
|
|
|
href = ( forum_name == u"blog" ) and \
|
|
|
|
os.path.join( base_path, thread.friendly_id ) or \
|
|
|
|
"%s?posts=%s" % ( os.path.join( base_path, thread.object_id ), thread.note_count ),
|
2008-10-24 20:15:26 +00:00
|
|
|
),
|
2008-11-18 21:28:51 +00:00
|
|
|
Span(
|
|
|
|
self.post_count( thread, forum_name ),
|
|
|
|
class_ = u"small_text",
|
|
|
|
)
|
2008-10-24 20:15:26 +00:00
|
|
|
) for thread in threads ],
|
2008-10-28 21:07:49 +00:00
|
|
|
class_ = u"forum_threads",
|
2008-10-24 20:15:26 +00:00
|
|
|
),
|
2008-11-17 23:23:22 +00:00
|
|
|
Page_navigation( base_path, len( threads ), total_thread_count, start, count ),
|
2008-10-24 20:15:26 +00:00
|
|
|
)
|
2008-11-18 21:28:51 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def post_count( thread, forum_name ):
|
|
|
|
if forum_name != u"blog":
|
|
|
|
if thread.note_count > 1:
|
|
|
|
return u"(%s posts)" % thread.note_count
|
|
|
|
return None
|
|
|
|
|
|
|
|
if thread.note_count == 2:
|
|
|
|
return u"(1 comment)"
|
|
|
|
elif thread.note_count > 2:
|
|
|
|
return u"(%s comments)" % ( thread.note_count - 1 )
|
|
|
|
|
|
|
|
return None
|