1. petraszd
  2. eagcms


Petr...@gmail.com  committed 5819453

At last - documentation is finished!

  • Participants
  • Parent commits b3c3321
  • Branches default

Comments (0)

Files changed (3)

File docs/tutorial.rst

View file
 Go to `http://localhost:8080/ <http://localhost:8080/>`_.
-TODO: pic
+.. image:: http://lh6.ggpht.com/_THWKK-dlQng/S3iJEu8fYaI/AAAAAAAAAPY/FqjZHC2e6mw/s800/site-start.png
 Your site is empty. Go to `http://localhost:8080/admin/ <http://localhost:8080/admin/>`_.
 and add three pages:
 * 'Bar' with
   top = 'Main Menu', title = 'Bar', slug = 'bar', type = 'Text'
-TODO: pic
+.. image:: http://lh3.ggpht.com/_THWKK-dlQng/S3iJEptU5gI/AAAAAAAAAPc/TJl8oL7IT7s/s800/admin-after-menu.png
 Now Your site has a menu
-TODO: pics
+.. image:: http://lh3.ggpht.com/_THWKK-dlQng/S3iJEjac3jI/AAAAAAAAAPg/zccCC4FxxeE/s800/site-with-menu.png
 Enter some stupid (Example: 'foo foo foo') text to Foo's content.
-TODO: pics
+.. image:: http://lh3.ggpht.com/_THWKK-dlQng/S3iJE2lLoVI/AAAAAAAAAPk/94_ELEGVTnw/s800/edit-content.png
 Types' templates
    # `-- types
    #     `-- text.html
-This is templates where You can customize Your site's look and feel. 'types'
-are folder where You can put custom types' templates. Take a look at
+.. highlight:: django
+This is templates where You can (and You should) customize Your site's look
+and feel. 'types' are folder where You can put custom types' templates. Take a
+look at text.html::
    {% extends "eagsite/page.html" %}
    {% block custom %}
      Copyright (c) &lt;Year&gt; &lt;Name Surname|Company's Name&gt;
-You probrabably can replace 'Site Name' and copyright by hand in template
+You probably can replace 'Site Name' and copyright by hand in template
 because there is almost zero change they are going to change. But now We are
-learning stuff and You are going to learn how to make these fields changanble
+learning stuff and You are going to learn how to make these fields changeable
 via root page ('Home Page').
+.. highlight:: python
 Go into 'eagproject/eagtypes.py', add and register 'Home' class::
    class Home(Page):
 We are going to use it's title as site's name and footer as footer.
+.. highlight:: django
 Go to 'base.html' and change::
    <h1 id="SiteName">&lt;Site Name&gt;</h1> --> <h1 id="SiteName">{{ root.title }}</h1>
-TODO: pic
+.. image:: http://lh6.ggpht.com/_THWKK-dlQng/S3iJFIxJ8UI/AAAAAAAAAPo/i2OaR0e34MQ/s800/site-double-header.png
 Ok, that double mention of 'My site' is a little bit annoying. So, let's
 change it.
    <h1 style="text-align: center;">Welcome!!!</h1>
    {% endblock %}
-TODO: pic
+.. image:: http://lh6.ggpht.com/_THWKK-dlQng/S3iJ4hzPQRI/AAAAAAAAAPw/5WNcDiTP1GI/s800/site-finish.png
 That's better.
 are PolyModels too. Each Page object has `top` and `order` params - these two
 are enough to calculate order of each node in site tree.
+.. highlight:: python
 Page class specifies some common attributes (:ref:`more details <class-page>`), but
 "real" data attributes must be specified by project. This is done by using
 EAGCMS_TYPES settings option and :ref:`register <object-register>` object::
 django.forms.Form subclass, make *content* field's widget as SemiWYSIWYGWidget
 (or WYSIWYGWidget) and pass it as second param to registers.add method.
-Second: Link. It is more intresting class becauses it shows some inner stuff
+Second: Link. It is more interesting class because it shows some inner stuff
 EAG cms does to render pages.
-*get_link_target* method returns self.target, wich can be '_self' or '_blank'.
+*get_link_target* method returns self.target, which can be '_self' or '_blank'.
 Page's implementation returns '_blank'. This method is used for rendering
 site's menu(s).
-*get_absolute_url* is standart django's way of returning models' urls. The only
+*get_absolute_url* is standard django's way of returning models' urls. The only
 different - it is not django's ORM model, it is GAE model object.
-*get_response*. It is really intresting method, because this method is
-responsible for returting response of a Page. So if You enter page's url page
+*get_response*. It is really interesting method, because this method is
+responsible for returning response of a Page. So if You enter page's url page
 itself renders content. It is small violation of MVC pattern, but it lets you
-to define intrenting Page types (Link for example).
+to define interesting Page types (Link for example).
 Section below talks about real Page's *get_response* implementation.
 Fictional Django app integration (Advanced topic)
+.. highlight:: python
+I am goning to show You how to integrate Django application into EAG cms. It
+is advanced part of tutorial - so, I am going to rush through code without a
+lot of explanation.
+Lets start by creating application nothing (We are in 'eagproject' dir)::
+   mkdir nothing
+   touch nothing/__init__.py
+   touch nothing/views.py
+   touch nothing/urls.py
+   from django.template import RequestContext
+   from django.shortcuts import render_to_response
+   from eagadmin.account import admin_required
+   @admin_required
+   def admin(request):
+       return render_to_response('nothing/admin.html', {},
+               context_instance=RequestContext(request))
+   def site(request):
+       return render_to_response('nothing/site.html', {},
+               context_instance=RequestContext(request))
+   from django.conf.urls.defaults import *
+   urlpatterns = patterns('nothing.views',
+           url(r'^admin/$', 'admin', name='admin'),
+           url(r'^.*$', 'site', name='site'),
+   )
+Edit settings.py by adding nothing to applications list::
+       'eagtypes',
+       'nothing',
+   )
+Edit urls.py::
+   from django.conf.urls.defaults import *
+   urlpatterns = patterns('',
+       (r'^nothing/', include('nothing.urls', namespace='nothing')),
+       # Rest of file ...
+Prepare existing templates for nothing integration.
+.. highlight:: django
+   {# ... #}
+   <ul id="Menu">
+     <li class="home {% ifequal current root %}current{% endifequal %}"><a href="{{ root.get_absolute_url }}">{{ root.menu_title}} </a>
+     {% eagsite_list_menu "main-menu" %}
+     <li class="{% block nothing_menu %}{% endblock %}" ><a href="{% url nothing:site %}">Nothing</a>
+   </ul>
+   {# ... #}
+   <ul id="TopMenu">
+     <li class="{% block menu_sitetree %}{% endblock %}">
+       <a href="{% url eagadmin:index %}">{% trans "Site Tree" %}</a>
+     </li>
+     <li class="{% block menu_nothing %}{% endblock %}">
+       <a href="{% url nothing:admin %}">{% trans "Nothing" %}</a>
+     </li>
+   </ul>
+Now You can create templates for Your new django's application::
+   mkdir templates/nothing
+   touch templates/nothing/site.html
+   touch templates/nothing/admin.html
+   {% extends "eagsite/base.html" %}
+   {% block nothing_menu %}current{% endblock %}
+   {% block content %}
+   Nothing here...
+   {% endblock %}
+   {% extends "eagadmin/base.html" %}
+   {% block menu_nothing %}active{% endblock %}
+   {% block content %}Nothing here...{% endblock %}
+And finnaly You have application 'nothing' who does nothing:
+.. image:: http://lh5.ggpht.com/_THWKK-dlQng/S3iJ4l7yuBI/AAAAAAAAAP0/EJfT-MGZi4I/s800/site-nothing.png
+.. image:: http://lh3.ggpht.com/_THWKK-dlQng/S3iJ4w63SbI/AAAAAAAAAP4/ImSp_FfLAI4/s800/admin-nothing.png

File eagproject/eagadmin/templatetags/eagsite.py

View file
             cl = []
             if not i:
-            if p == current:
+            if current and p == current:
             elif p in breadcrumb:

File eagproject/templates/eagadmin/base.html

View file
     {% block head_end %}{% endblock %}
   {% endblock %}
+{% load i18n %}{# If someone desides to extend this template #}
   <div id="Everything">
     <div id="Header">
         <li class="{% block menu_sitetree %}{% endblock %}">
           <a href="{% url eagadmin:index %}">{% trans "Site Tree" %}</a>
-        {% block menu_items %}{% endblock %}
       <div class="clear"></div>
     {% endblock %}