2008-11-14 20:34:06 +00:00
|
|
|
from Tags import Div, P, Span, H4, A, Strong, Img, Br
|
2007-10-31 07:46:02 +00:00
|
|
|
from Rounded_div import Rounded_div
|
2008-10-24 18:51:19 +00:00
|
|
|
from model.Notebook import Notebook
|
2007-07-16 20:22:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Link_area( Div ):
|
2008-11-14 20:34:06 +00:00
|
|
|
def __init__( self, toolbar, notebooks, notebook, parent_id, notebook_path, updates_path, user, rate_plan ):
|
2007-12-27 22:16:47 +00:00
|
|
|
linked_notebooks = [ nb for nb in notebooks if
|
2008-10-24 18:51:19 +00:00
|
|
|
(
|
|
|
|
nb.read_write == Notebook.READ_WRITE or
|
|
|
|
( nb.read_write == Notebook.READ_ONLY and not nb.name.startswith( u"Luminotes" ) )
|
|
|
|
) and
|
2007-12-27 22:16:47 +00:00
|
|
|
nb.name not in ( u"trash" ) and
|
|
|
|
nb.deleted is False
|
|
|
|
]
|
2007-10-30 23:05:46 +00:00
|
|
|
|
2008-10-24 22:07:36 +00:00
|
|
|
if [ tag for tag in notebook.tags if tag.name == u"forum" ]:
|
|
|
|
forum_tag = True
|
2008-11-15 06:45:24 +00:00
|
|
|
forum_name = tag.value
|
2008-10-24 22:07:36 +00:00
|
|
|
notebook_word = u"discussion"
|
|
|
|
note_word = u"post"
|
|
|
|
else:
|
|
|
|
forum_tag = False
|
2008-11-15 06:45:24 +00:00
|
|
|
forum_name = None
|
2008-10-24 22:07:36 +00:00
|
|
|
notebook_word = u"notebook"
|
|
|
|
note_word = u"note"
|
|
|
|
|
2007-07-16 20:22:38 +00:00
|
|
|
Div.__init__(
|
|
|
|
self,
|
2008-11-14 20:34:06 +00:00
|
|
|
toolbar,
|
2008-11-18 21:28:51 +00:00
|
|
|
( user.username == u"anonymous" ) and self.forum_link( forum_tag, forum_name ) or None,
|
2008-11-15 06:45:24 +00:00
|
|
|
( user.username != u"anonymous" ) and Div(
|
|
|
|
( notebook_path != u"/" ) and Div(
|
2008-07-29 23:38:35 +00:00
|
|
|
H4(
|
2008-10-24 22:07:36 +00:00
|
|
|
u"this %s" % notebook_word,
|
2008-07-29 23:38:35 +00:00
|
|
|
id = u"this_notebook_area_title",
|
|
|
|
),
|
2008-11-18 21:28:51 +00:00
|
|
|
self.forum_link( forum_tag, forum_name ),
|
2007-11-15 01:30:45 +00:00
|
|
|
|
2008-08-21 00:05:21 +00:00
|
|
|
( rate_plan.get( u"notebook_sharing" ) and notebook.name == u"Luminotes blog" ) and Div(
|
2007-11-18 00:25:31 +00:00
|
|
|
A(
|
2008-12-13 08:32:19 +00:00
|
|
|
u"follow",
|
2008-04-04 05:39:40 +00:00
|
|
|
href = u"%s?rss" % notebook_path,
|
2008-04-24 20:32:43 +00:00
|
|
|
id = u"blog_rss_link",
|
2008-04-22 23:42:58 +00:00
|
|
|
title = u"Subscribe to the RSS feed for the Luminotes blog.",
|
2007-11-18 00:25:31 +00:00
|
|
|
),
|
2007-12-11 01:15:03 +00:00
|
|
|
A(
|
2008-11-14 20:34:06 +00:00
|
|
|
Img( src = u"/static/images/rss.png", width = u"14", height = u"14", class_ = u"middle_image padding_left" ),
|
2008-04-04 05:39:40 +00:00
|
|
|
href = u"%s?rss" % notebook_path,
|
2008-04-22 23:42:58 +00:00
|
|
|
title = u"Subscribe to the RSS feed for the Luminotes blog.",
|
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
2008-10-28 21:51:21 +00:00
|
|
|
) or ( updates_path and rate_plan.get( u"notebook_sharing" ) and ( not forum_tag ) and Div(
|
2008-04-22 23:42:58 +00:00
|
|
|
A(
|
2008-12-13 08:32:19 +00:00
|
|
|
u"follow",
|
2008-04-22 23:42:58 +00:00
|
|
|
href = updates_path,
|
2008-04-24 20:32:43 +00:00
|
|
|
id = u"notebook_rss_link",
|
2008-10-24 22:07:36 +00:00
|
|
|
title = u"Subscribe to the RSS feed for this %s." % notebook_word,
|
2008-04-22 23:42:58 +00:00
|
|
|
),
|
|
|
|
A(
|
2008-11-14 20:34:06 +00:00
|
|
|
Img( src = u"/static/images/rss.png", width = u"14", height = u"14", class_ = u"middle_image padding_left" ),
|
2008-04-22 23:42:58 +00:00
|
|
|
href = updates_path,
|
2008-10-24 22:07:36 +00:00
|
|
|
title = u"Subscribe to the RSS feed for this %s." % notebook_word,
|
2007-12-11 01:15:03 +00:00
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
2008-04-23 00:00:30 +00:00
|
|
|
) or None ),
|
2007-12-11 01:15:03 +00:00
|
|
|
|
2008-10-24 18:51:19 +00:00
|
|
|
( notebook.read_write != Notebook.READ_ONLY ) and Div(
|
2008-09-18 06:39:11 +00:00
|
|
|
A(
|
2008-10-24 22:07:36 +00:00
|
|
|
u"nothing but %ss" % note_word,
|
2008-09-18 06:39:11 +00:00
|
|
|
href = u"#",
|
|
|
|
id = u"declutter_link",
|
2008-10-24 22:07:36 +00:00
|
|
|
title = u"Focus on just your %ss without any distractions." % note_word,
|
2008-06-23 19:56:03 +00:00
|
|
|
),
|
2008-09-18 06:39:11 +00:00
|
|
|
class_ = u"link_area_item",
|
|
|
|
) or None,
|
2008-06-23 19:56:03 +00:00
|
|
|
|
2008-10-24 18:51:19 +00:00
|
|
|
( notebook.read_write != Notebook.READ_WRITE and notebook.name != u"Luminotes" ) and Div(
|
2008-09-18 06:39:11 +00:00
|
|
|
A(
|
|
|
|
u"export",
|
|
|
|
href = u"#",
|
|
|
|
id = u"export_link",
|
2008-10-24 22:07:36 +00:00
|
|
|
title = u"Download a stand-alone copy of the entire %s." % notebook_word,
|
2008-09-18 06:39:11 +00:00
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
|
|
|
) or None,
|
|
|
|
|
2009-03-03 00:39:08 +00:00
|
|
|
( notebook.read_write != Notebook.READ_WRITE ) and Div(
|
|
|
|
A(
|
|
|
|
u"print",
|
|
|
|
href = u"/notebooks/export?notebook_id=%s&format=print" % notebook.object_id,
|
|
|
|
id = u"print_notebook_link",
|
|
|
|
target = u"_new",
|
|
|
|
title = u"Print this %s." % notebook_word,
|
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
|
|
|
) or None,
|
|
|
|
|
2008-10-24 18:51:19 +00:00
|
|
|
( notebook.read_write == Notebook.READ_WRITE ) and Span(
|
2008-09-18 06:39:11 +00:00
|
|
|
Div(
|
2008-12-15 07:28:43 +00:00
|
|
|
( notebook.name != u"trash" ) and A(
|
2008-08-08 23:39:53 +00:00
|
|
|
u"import",
|
|
|
|
href = u"#",
|
|
|
|
id = u"import_link",
|
2008-10-24 22:07:36 +00:00
|
|
|
title = u"Import %ss from other software into Luminotes." % note_word,
|
2008-12-15 07:28:43 +00:00
|
|
|
) or None,
|
|
|
|
( notebook.name != u"trash" ) and u"|" or None,
|
2008-09-18 06:39:11 +00:00
|
|
|
A(
|
|
|
|
u"export",
|
|
|
|
href = u"#",
|
|
|
|
id = u"export_link",
|
2008-10-24 22:07:36 +00:00
|
|
|
title = u"Download a stand-alone copy of the entire %s." % notebook_word,
|
2008-09-18 06:39:11 +00:00
|
|
|
),
|
2008-08-08 23:39:53 +00:00
|
|
|
class_ = u"link_area_item",
|
|
|
|
) or None,
|
|
|
|
|
2008-12-15 07:28:43 +00:00
|
|
|
( notebook.name != u"trash" ) and Div(
|
2008-12-13 08:32:19 +00:00
|
|
|
notebook.trash_id and A(
|
|
|
|
u"trash",
|
|
|
|
href = u"/notebooks/%s?parent_id=%s" % ( notebook.trash_id, notebook.object_id ),
|
|
|
|
id = u"trash_link",
|
|
|
|
title = u"Look here for %ss you've deleted." % note_word,
|
|
|
|
) or None,
|
|
|
|
( notebook.owner and notebook.name != u"trash" and notebook.trash_id ) and u"|" or None,
|
|
|
|
( notebook.owner and notebook.name != u"trash" ) and A(
|
2008-06-23 19:56:03 +00:00
|
|
|
u"delete",
|
2008-04-04 05:39:40 +00:00
|
|
|
href = u"#",
|
|
|
|
id = u"delete_notebook_link",
|
2008-10-24 22:07:36 +00:00
|
|
|
title = u"Move this %s to the trash." % notebook_word,
|
2008-12-13 08:32:19 +00:00
|
|
|
) or None,
|
2008-04-04 05:39:40 +00:00
|
|
|
class_ = u"link_area_item",
|
2008-12-15 07:28:43 +00:00
|
|
|
) or None,
|
|
|
|
|
|
|
|
( notebook.owner and notebook.name != u"trash" ) and Div(
|
|
|
|
A(
|
|
|
|
u"rename",
|
|
|
|
href = u"#",
|
|
|
|
id = u"rename_notebook_link",
|
|
|
|
title = u"Change the name of this %s." % notebook_word,
|
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
|
|
|
) or None,
|
2008-04-04 05:39:40 +00:00
|
|
|
|
2008-12-15 07:28:43 +00:00
|
|
|
( notebook.owner and notebook.name != u"trash" and
|
|
|
|
user.username and rate_plan.get( u"notebook_sharing" ) ) and Div(
|
2008-04-04 05:39:40 +00:00
|
|
|
A(
|
|
|
|
u"share",
|
|
|
|
href = u"#",
|
|
|
|
id = u"share_notebook_link",
|
2008-10-24 22:07:36 +00:00
|
|
|
title = u"Share this %s with others." % notebook_word,
|
2008-04-04 05:39:40 +00:00
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
|
|
|
) or None,
|
|
|
|
|
2009-03-03 00:39:08 +00:00
|
|
|
Div(
|
|
|
|
A(
|
|
|
|
u"print",
|
|
|
|
href = u"/notebooks/export?notebook_id=%s&format=print" % notebook.object_id,
|
|
|
|
id = u"print_notebook_link",
|
|
|
|
target = u"_new",
|
|
|
|
title = u"Print this %s." % notebook_word,
|
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
|
|
|
) or None,
|
|
|
|
|
2008-04-04 05:39:40 +00:00
|
|
|
( notebook.name == u"trash" ) and Rounded_div(
|
|
|
|
u"trash_notebook",
|
|
|
|
A(
|
|
|
|
u"trash",
|
|
|
|
href = u"#",
|
|
|
|
id = u"trash_link",
|
2008-10-24 22:07:36 +00:00
|
|
|
title = u"Look here for %ss you've deleted." % note_word,
|
2008-04-04 05:39:40 +00:00
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
|
|
|
) or None,
|
2007-10-16 21:37:12 +00:00
|
|
|
) or None,
|
|
|
|
|
2008-04-04 05:39:40 +00:00
|
|
|
id = u"this_notebook_area",
|
2008-11-15 06:45:24 +00:00
|
|
|
) or None,
|
2008-04-04 05:39:40 +00:00
|
|
|
|
2008-10-27 23:23:27 +00:00
|
|
|
( not forum_tag ) and Div(
|
2008-06-22 05:13:52 +00:00
|
|
|
( len( linked_notebooks ) > 0 ) and H4(
|
|
|
|
u"notebooks",
|
|
|
|
id = u"notebooks_area_title",
|
|
|
|
) or None,
|
2008-04-04 05:39:40 +00:00
|
|
|
[ ( nb.object_id == notebook.object_id ) and Rounded_div(
|
|
|
|
u"current_notebook",
|
2007-10-16 21:37:12 +00:00
|
|
|
A(
|
2008-04-04 05:39:40 +00:00
|
|
|
nb.name,
|
|
|
|
href = u"/notebooks/%s" % nb.object_id,
|
|
|
|
id = u"notebook_%s" % nb.object_id,
|
2007-10-16 21:37:12 +00:00
|
|
|
),
|
2008-04-04 05:39:40 +00:00
|
|
|
( len( linked_notebooks ) > 1 ) and Span(
|
|
|
|
Img( src = u"/static/images/up_arrow.png", width = u"20", height = u"17", id = u"current_notebook_up" ),
|
|
|
|
Img( src = u"/static/images/down_arrow.png", width = u"20", height = u"17", id = u"current_notebook_down" ),
|
|
|
|
Span( id = "current_notebook_up_hover_preload" ),
|
|
|
|
Span( id = "current_notebook_down_hover_preload" ),
|
|
|
|
) or None,
|
2007-10-31 07:46:02 +00:00
|
|
|
class_ = u"link_area_item",
|
2008-04-04 05:39:40 +00:00
|
|
|
) or
|
|
|
|
Div(
|
|
|
|
A(
|
|
|
|
nb.name,
|
|
|
|
href = u"/notebooks/%s" % nb.object_id,
|
|
|
|
id = u"notebook_%s" % nb.object_id,
|
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
|
|
|
) for nb in linked_notebooks ],
|
|
|
|
id = u"notebooks_area"
|
2008-10-27 23:23:27 +00:00
|
|
|
) or None,
|
2008-11-14 20:34:06 +00:00
|
|
|
( not forum_tag ) and Div(
|
|
|
|
Img(
|
|
|
|
src = u"/static/images/toolbar/small/new_note_button.png",
|
|
|
|
width = u"20", height = u"20",
|
|
|
|
id = "new_notebook",
|
|
|
|
class_ = u"middle_image",
|
|
|
|
title = u"Create a new wiki notebook."
|
|
|
|
),
|
|
|
|
class_ = u"link_area_item",
|
2008-07-28 23:15:15 +00:00
|
|
|
) or None,
|
|
|
|
|
2007-10-31 07:46:02 +00:00
|
|
|
Div(
|
2008-04-04 05:39:40 +00:00
|
|
|
id = u"storage_usage_area",
|
|
|
|
),
|
2008-04-09 23:31:30 +00:00
|
|
|
id = u"link_area_holder",
|
2008-11-15 06:45:24 +00:00
|
|
|
) or None,
|
2007-10-16 21:37:12 +00:00
|
|
|
id = u"link_area",
|
2007-07-16 20:22:38 +00:00
|
|
|
)
|
2008-11-18 21:28:51 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def forum_link( forum_tag, forum_name ):
|
|
|
|
if not forum_tag:
|
|
|
|
return None
|
|
|
|
|
|
|
|
if forum_name == u"blog":
|
|
|
|
return Div(
|
|
|
|
A( u"Luminotes %s" % forum_name, href = "/blog/" ),
|
|
|
|
class_ = u"link_area_item",
|
|
|
|
)
|
|
|
|
|
|
|
|
return Div(
|
|
|
|
A( u"%s forum" % forum_name, href = "/forums/%s" % forum_name ),
|
|
|
|
class_ = u"link_area_item",
|
|
|
|
)
|