Browse Source

Docs for usersites

Rafał Pitoń 11 years ago
parent
commit
6f5f351b55
3 changed files with 61 additions and 22 deletions
  1. 12 11
      docs/developers/index.rst
  2. 37 0
      docs/developers/user_sites.rst
  3. 12 11
      docs/index.rst

+ 12 - 11
docs/developers/index.rst

@@ -31,19 +31,20 @@ Following references cover everything you want to know about writing your own ap
 .. toctree::
    :maxdepth: 1
 
-   coding_style
-   shortcuts
+   acls
    admin_actions
-   views_errors
-   forms
-   decorators
-   settings
-   context_processors
-   mails
+   auth
    cache
    cache_buster
+   coding_style
+   context_processors
+   decorators
+   forms
+   mails
+   markup
+   settings
+   shortcuts
    thread_store
+   user_sites
    validators
-   auth
-   acls
-   markup
+   views_errors

+ 37 - 0
docs/developers/user_sites.rst

@@ -0,0 +1,37 @@
+====================
+Extending User Sites
+====================
+
+There are three sites associated with user accounts:
+
+* User Control Panel
+* User Profiles List
+* User Profile
+
+Each of those sites consists of its own layout and list of pages. For example, User Profile layout displays user name, information about user status, and pages (tabs) with lists of user threads, posts, followers and likes.
+
+Each site is associated to instance of special object, :py:class:`misago.users.sites.Site`, which contains list of all pages belonging to it. Those instances are :py:object:`misago.users.sites.usercp`, :py:object:`misago.users.sites.users_list` and :py:object:`misago.users.sites.user_profile`.
+
+:py:class:`misago.users.sites.Site` instances expose following API:
+
+
+.. function:: add_page(link, name, icon=None, after=None, before=None,
+                 	   visibility_condition=None)
+
+Adds page to site. ``after`` and ``before`` arguments should be value of other page ``link``. ``visibility_condition`` argument accepts callable that will be called with args passed to ``get_pages`` function on page render to resolve if link to page should be displayed.
+
+
+.. function:: get_pages(link, request, profile=None)
+
+Returns list of pages assigned to this site. Each page is a dict of kwargs passed to ``add_page`` with additional ``is_active`` argument that controls if selected page is displayed one.
+
+
+.. function:: get_default_link()
+
+Returns default link name that should be used as argument for ``{% url %}`` template tag.
+
+Default links for Misago sites are available in templates trough following variables:
+
+* **USERCP_URL** - Default link to user control panel site.
+* **USERS_LIST_URL** - Default link to users lists site.
+* **USER_PROFILE_URL** - Default link to user profile site.

+ 12 - 11
docs/index.rst

@@ -20,19 +20,20 @@ Table of Contents
 
    setup_maintenance
    developers/index
-   developers/coding_style
-   developers/shortcuts
+   developers/acls
    developers/admin_actions
-   developers/views_errors
-   developers/forms
-   developers/decorators
-   developers/settings
-   developers/context_processors
-   developers/mails
+   developers/auth
    developers/cache
    developers/cache_buster
+   developers/coding_style
+   developers/context_processors
+   developers/decorators
+   developers/forms
+   developers/mails
+   developers/markup
+   developers/settings
+   developers/shortcuts
    developers/thread_store
+   developers/user_sites
    developers/validators
-   developers/auth
-   developers/acls
-   developers/markup
+   developers/views_errors