2009-02-23 08:11:48 +00:00
|
|
|
from Tags import Div, A, Img, Span, B
|
|
|
|
from config.Version import VERSION, TRIAL
|
2008-04-04 05:39:40 +00:00
|
|
|
|
|
|
|
class Header( Div ):
|
2008-08-21 03:50:41 +00:00
|
|
|
def __init__( self, user, first_notebook, login_url, logout_url, note_title, rate_plan = None ):
|
2008-04-04 05:39:40 +00:00
|
|
|
title_image = Img(
|
|
|
|
src ="/static/images/luminotes_title.png",
|
|
|
|
class_ = u"luminotes_title", width = u"193", height = u"60",
|
|
|
|
alt = u"Luminotes",
|
|
|
|
)
|
|
|
|
|
2009-02-23 08:11:48 +00:00
|
|
|
trial_expired = False
|
|
|
|
if TRIAL:
|
|
|
|
from pytz import utc
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
|
|
trial_age = datetime.now( tz = utc ) - first_notebook.revision
|
|
|
|
if trial_age > timedelta( days = 30 ):
|
|
|
|
trial_expired = True
|
|
|
|
|
2008-08-21 03:50:41 +00:00
|
|
|
if rate_plan and rate_plan.get( u"name" ) == u"desktop":
|
|
|
|
Div.__init__(
|
|
|
|
self,
|
|
|
|
Div(
|
|
|
|
( note_title == u"home" ) and title_image or
|
|
|
|
A( title_image, href = u"http://luminotes.com/", target = "_new" ),
|
|
|
|
Div(
|
2009-02-23 08:11:48 +00:00
|
|
|
( TRIAL and u"trial" or u"" ), u"version", VERSION, u" | ",
|
|
|
|
A( u"upgrade", href = u"http://luminotes.com/download", target = "_new", class_ = trial_expired and "trial_upgrade_link" or u"" ), u" | ",
|
2008-12-03 21:13:43 +00:00
|
|
|
A( u"community", href = u"http://luminotes.com/community", target = "_new" ), u" | ",
|
2009-02-16 21:19:05 +00:00
|
|
|
A( u"blog", href = u"http://luminotes.com/blog/", target = "_new" ), u" | ",
|
|
|
|
A( u"close", href = u"/close" ),
|
2008-08-21 03:50:41 +00:00
|
|
|
class_ = u"header_links",
|
|
|
|
),
|
|
|
|
class_ = u"wide_center_area",
|
|
|
|
),
|
|
|
|
id = u"header",
|
|
|
|
class_ = u"header",
|
|
|
|
)
|
|
|
|
return
|
|
|
|
|
2008-04-04 05:39:40 +00:00
|
|
|
Div.__init__(
|
|
|
|
self,
|
|
|
|
Div(
|
|
|
|
( note_title == u"home" ) and title_image or A( title_image, href = u"/" ),
|
|
|
|
( login_url and user.username == u"anonymous" ) and Div(
|
|
|
|
A(
|
|
|
|
u"login",
|
|
|
|
href = login_url,
|
|
|
|
id = u"login_link",
|
|
|
|
class_ = u"bold_link",
|
|
|
|
),
|
|
|
|
class_ = u"header_user_links",
|
|
|
|
) or Div(
|
|
|
|
u"logged in as %s" % ( user.username or u"a guest" ),
|
|
|
|
u" | ",
|
|
|
|
( note_title != u"wiki" ) and first_notebook and Span(
|
|
|
|
A(
|
|
|
|
u"my wiki",
|
|
|
|
href = u"/notebooks/%s" % first_notebook.object_id,
|
|
|
|
),
|
|
|
|
u" | ",
|
|
|
|
) or None,
|
2008-05-08 03:37:24 +00:00
|
|
|
user.username and note_title == u"wiki" and Span(
|
2008-05-08 03:05:35 +00:00
|
|
|
A(
|
|
|
|
u"settings",
|
|
|
|
href = u"#",
|
|
|
|
title = u"Update your account settings.",
|
|
|
|
id = u"settings_link",
|
|
|
|
),
|
|
|
|
" | ",
|
|
|
|
) or None,
|
2008-11-15 21:15:51 +00:00
|
|
|
A(
|
|
|
|
u"logout",
|
|
|
|
href = logout_url,
|
|
|
|
id = u"logout_link",
|
|
|
|
title = u"Sign out of your account.",
|
|
|
|
),
|
|
|
|
class_ = u"header_user_links",
|
|
|
|
),
|
|
|
|
Div(
|
|
|
|
( note_title == u"home" ) and Span( u"home", class_ = u"bold_link" ) or A( u"home", href = u"/" ), u" | ",
|
|
|
|
( note_title == u"tour" ) and Span( u"tour", class_ = u"bold_link" ) or A( u"tour", href = u"/tour" ), u" | ",
|
|
|
|
( user.username in ( None, u"anonymous" ) ) and Span( ( note_title == u"wiki" ) and Span( u"demo", class_ = u"bold_link" ) or A( u"demo", href = u"/users/demo" ), u" | " ) or None,
|
|
|
|
( note_title == u"community" ) and Span( u"community", class_ = u"bold_link" ) or A( u"community", href = u"/community" ), u" | ",
|
2008-08-29 04:19:55 +00:00
|
|
|
( note_title == u"download" ) and Span( u"download", class_ = u"bold_link" ) or \
|
|
|
|
A(
|
|
|
|
u"download",
|
|
|
|
href = u"/download",
|
|
|
|
title = u"Download Luminotes to run on your own computer.",
|
|
|
|
class_ = u"bold_link",
|
|
|
|
),
|
|
|
|
" | ",
|
2008-11-15 21:15:51 +00:00
|
|
|
( user.username and user.username != u"anonymous" ) and Span(
|
2008-04-04 05:39:40 +00:00
|
|
|
A(
|
|
|
|
u"upgrade",
|
|
|
|
href = u"/pricing",
|
|
|
|
title = u"Upgrade your Luminotes account.",
|
|
|
|
class_ = u"bold_link",
|
|
|
|
),
|
|
|
|
) or Span(
|
2008-08-29 04:19:55 +00:00
|
|
|
( note_title == u"pricing" ) and Span( u"sign up", class_ = u"bold_link" ) or \
|
2008-04-04 05:39:40 +00:00
|
|
|
A(
|
2008-08-29 04:19:55 +00:00
|
|
|
u"sign up",
|
2008-04-04 05:39:40 +00:00
|
|
|
href = u"/pricing",
|
2008-08-29 04:19:55 +00:00
|
|
|
title = u"Sign up for an online Luminotes account.",
|
2008-04-04 05:39:40 +00:00
|
|
|
class_ = u"bold_link",
|
|
|
|
),
|
|
|
|
) or None,
|
2008-11-15 21:15:51 +00:00
|
|
|
|
|
|
|
#( note_title == u"support" ) and Span( u"support", class_ = u"bold_link" ) or A( u"support", href = u"/support" ), u" | ",
|
|
|
|
#( note_title == u"team" ) and Span( u"team", class_ = u"bold_link" ) or A( u"team", href = u"/meet_the_team" ), u" | ",
|
|
|
|
#( note_title == u"blog" ) and Span( u"blog", class_ = u"bold_link" ) or A( u"blog", href = u"/blog" ), u" | ",
|
|
|
|
#( note_title == u"privacy" ) and Span( u"privacy", class_ = u"bold_link" ) or A( u"privacy", href = u"/privacy" ),
|
2008-04-04 05:39:40 +00:00
|
|
|
class_ = u"header_links",
|
|
|
|
),
|
|
|
|
class_ = u"wide_center_area",
|
|
|
|
),
|
2008-04-18 23:54:09 +00:00
|
|
|
id = u"header",
|
2008-04-04 05:39:40 +00:00
|
|
|
class_ = u"header",
|
|
|
|
)
|
|
|
|
|