Personal wiki notebook (not under development)

Header.py 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. from Tags import Div, A, Img, Span, B
  2. from config.Version import VERSION, TRIAL
  3. class Header( Div ):
  4. def __init__( self, user, first_notebook, login_url, logout_url, note_title, rate_plan = None ):
  5. title_image = Img(
  6. src ="/static/images/luminotes_title.png",
  7. class_ = u"luminotes_title", width = u"193", height = u"60",
  8. alt = u"Luminotes",
  9. )
  10. trial_expired = False
  11. if TRIAL:
  12. from pytz import utc
  13. from datetime import datetime, timedelta
  14. trial_age = datetime.now( tz = utc ) - first_notebook.revision
  15. if trial_age > timedelta( days = 30 ):
  16. trial_expired = True
  17. if rate_plan and rate_plan.get( u"name" ) == u"desktop":
  18. Div.__init__(
  19. self,
  20. Div(
  21. ( note_title == u"home" ) and title_image or
  22. A( title_image, href = u"http://luminotes.com/", target = "_new" ),
  23. Div(
  24. ( TRIAL and u"trial" or u"" ), u"version", VERSION, u" | ",
  25. A( u"upgrade", href = u"http://luminotes.com/download", target = "_new", class_ = trial_expired and "trial_upgrade_link" or u"" ), u" | ",
  26. A( u"community", href = u"http://luminotes.com/community", target = "_new" ), u" | ",
  27. A( u"blog", href = u"http://luminotes.com/blog/", target = "_new" ), u" | ",
  28. A( u"close", href = u"/close" ),
  29. class_ = u"header_links",
  30. ),
  31. class_ = u"wide_center_area",
  32. ),
  33. id = u"header",
  34. class_ = u"header",
  35. )
  36. return
  37. Div.__init__(
  38. self,
  39. Div(
  40. ( note_title == u"home" ) and title_image or A( title_image, href = u"/" ),
  41. ( login_url and user.username == u"anonymous" ) and Div(
  42. A(
  43. u"login",
  44. href = login_url,
  45. id = u"login_link",
  46. class_ = u"bold_link",
  47. ),
  48. class_ = u"header_user_links",
  49. ) or Div(
  50. u"logged in as %s" % ( user.username or u"a guest" ),
  51. u" | ",
  52. ( note_title != u"wiki" ) and first_notebook and Span(
  53. A(
  54. u"my wiki",
  55. href = u"/notebooks/%s" % first_notebook.object_id,
  56. ),
  57. u" | ",
  58. ) or None,
  59. user.username and note_title == u"wiki" and Span(
  60. A(
  61. u"settings",
  62. href = u"#",
  63. title = u"Update your account settings.",
  64. id = u"settings_link",
  65. ),
  66. " | ",
  67. ) or None,
  68. A(
  69. u"logout",
  70. href = logout_url,
  71. id = u"logout_link",
  72. title = u"Sign out of your account.",
  73. ),
  74. class_ = u"header_user_links",
  75. ),
  76. Div(
  77. ( note_title == u"home" ) and Span( u"home", class_ = u"bold_link" ) or A( u"home", href = u"/" ), u" | ",
  78. ( note_title == u"tour" ) and Span( u"tour", class_ = u"bold_link" ) or A( u"tour", href = u"/tour" ), u" | ",
  79. ( 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,
  80. ( note_title == u"community" ) and Span( u"community", class_ = u"bold_link" ) or A( u"community", href = u"/community" ), u" | ",
  81. ( note_title == u"download" ) and Span( u"download", class_ = u"bold_link" ) or \
  82. A(
  83. u"download",
  84. href = u"/download",
  85. title = u"Download Luminotes to run on your own computer.",
  86. class_ = u"bold_link",
  87. ),
  88. " | ",
  89. ( user.username and user.username != u"anonymous" ) and Span(
  90. A(
  91. u"upgrade",
  92. href = u"/pricing",
  93. title = u"Upgrade your Luminotes account.",
  94. class_ = u"bold_link",
  95. ),
  96. ) or Span(
  97. ( note_title == u"pricing" ) and Span( u"sign up", class_ = u"bold_link" ) or \
  98. A(
  99. u"sign up",
  100. href = u"/pricing",
  101. title = u"Sign up for an online Luminotes account.",
  102. class_ = u"bold_link",
  103. ),
  104. ) or None,
  105. #( note_title == u"support" ) and Span( u"support", class_ = u"bold_link" ) or A( u"support", href = u"/support" ), u" | ",
  106. #( note_title == u"team" ) and Span( u"team", class_ = u"bold_link" ) or A( u"team", href = u"/meet_the_team" ), u" | ",
  107. #( note_title == u"blog" ) and Span( u"blog", class_ = u"bold_link" ) or A( u"blog", href = u"/blog" ), u" | ",
  108. #( note_title == u"privacy" ) and Span( u"privacy", class_ = u"bold_link" ) or A( u"privacy", href = u"/privacy" ),
  109. class_ = u"header_links",
  110. ),
  111. class_ = u"wide_center_area",
  112. ),
  113. id = u"header",
  114. class_ = u"header",
  115. )