Commits

Anonymous committed 39e328a

Docs;
Small urls.py tweak to 'no slash' after admin url;
Comments to eagtypes.py;
Page slug field onchange event now slugifies it's value;

Comments (0)

Files changed (5)

docs/eagadmin_ref.rst

 :class:`eagadmin.models.pages.Page` --- Page class
 --------------------------------------------------
 
+.. _class-page:
+
 .. class:: Page
 
    `google.appengine.ext.db.polymodel.PolyModel <http://code.google.com/appengine/docs/python/datastore/polymodelclass.html>`_ sublcass.
 .. module:: eagadmin.types
 .. currentmodule:: eagadmin.types
 
+.. _object-register:
+
 .. data:: register
 
    Global Register object you should use to register new site tree's page types::

docs/tutorial.rst

 
 EAG cms is as simple as possible CMS for Google App Engine (GAE) and Django
 
-EAG cms yra sukurtas naudojantis Google App Engine (GAE) ir Django
-bibliotekomis. Taigi, aš primigtinai rekomenduočiau pirma susipažinti su
-pastarųjų dokumentacija (Žinoma, jeigu dar nesate susipažinęs):
+EAG cms is made using these technologies: Google App Engine and Django. So, I
+highly recommend You to read their documentation (and tutorials) first:
 
 `Google App Engine Docs <http://code.google.com/appengine/docs/python/overview.html>`_
 
 Getting started
 ===============
 
-EAG cms yra visiškai priklausomas nuo GAE. Taigi, vienintelis būdas jį
-publikuoti yra publikuoti kaip GAE aplikaciją.
+EAG cms completely depends from GAE. So, only way to publish something created
+with it is through GAE. This means that You will be creating GAE application -
+nothing less, nothing more.
 
-Bet mums nereikia nieko publikuoti - dabar mes tiesiog norime pasileisti pačią
-aplikaciją ir testuoti ją namuose - localhost'e. Bent jau aš darau tokią
-prielaidą, kad jūs to norite...
+Now we do not need to publish (And You can find that topic in GAE
+documentation) - we need to test something in localhost. At least I am
+thinking You want to do that...
 
-Prepare dev enviroment
-----------------------
+Prepare dev environment
+-----------------------
 
-Visos žemiau pateiktos komandos testuotos tik linux OS. Tuo tarpu Windows
-ir/ar Mac OS savininkų teks atsiprašyti - aš neturi priėjimo prie pastarųjų
-OS. Bet jums yra pasiekiamas GAE SDK GUI. Peržvelgę linux komandas ir pridėję
-sveiką nuovoką, manau, turėtumėte išsisukti.
+All commands are tested in Linux OS only. I am sorry, but I can not make
+instructions for Windows and/or Mac OS users - I do not have these OS's.
+On the other hand, these OS's have GUI tools. So, use my instruction, these
+tools and common sense and I think You will do just fine.
 
-Parsisiųskite GAE SDK. Išarchyvuokite jį į pasirinktą katalogą. Užeikite į direktoriją.::
+Download GAE SDK, unzip it and enter newly created directory.::
 
    wget http://googleappengine.googlecode.com/files/google_appengine_<last-version>.zip
    unzip google_appengine_<last-version>.zip
    cd google_appengine/
 
-Django siuntimą galite praleisti, jeigu jį jau esate instaliavę ir jis yra
-pasiekiamas PYTHON_PATH kintamajame. SVARBU: jums reikalinga django 1.1.*
-versija!
+You can skip Django installation step if You have installed it already. But
+(It is important!!!) You need 1.1.* Django's version.
 
-Parsisiųskite Django 1.1. Išarchyvuokite jį į tą patį katalogą ir padarykite taip, kad anas būtų
-pasiekiamas iš GAE SDK.::
+Download Django 1.1.*, untar it and make it local library for GAE SDK.::
 
    wget http://media.djangoproject.com/releases/1.1.1/Django-1.1.1.tar.gz
    tar zxf Django-1.1.1.tar.gz
    mv Django-1.1.1/django/ ./
    rm -r Django-1.1.1
 
-Parsisiųskite EAG cms versiją. Išskleiskite ją į katalogą projects/eagcms.::
+Download EAG cms, untar it into projects/eagcms directory.::
 
    mkdir -p projects
    wget TODO
    tar zxf TODO projects/eagcms
 
-Pervadinkite main.py.sample į main.py
-Pervadinkite eagproject/settings.py.sample į eagproject/settings.py::
+Rename main.py.sample into main.py
+Rename eagproject/settings.py.sample into eagproject/settings.py::
 
    mv projects/eagcms/main.py.sample projects/eagcms/main.py
    mv projects/eagcms/eagproject/settings.py.sample projects/eagcms/eagproject/settings.py.sample
 
-Paleiskite testinę aplinką::
+Run dev environment::
 
   ./dev_appserver.py projects/eagcms
 
-Pagal nutylėjimą administratoriaus pultas bus pasiekiamas adresu
-`http://localhost:8080/admin <http://localhost:8080/admin>`_, o frontend'as
-`http://localhost:8080/site <http://localhost:8080/site>`_.
+Default url of backend is `http://localhost:8080/admin <http://localhost:8080/admin>`_.
 
-Rekomenduoju pasiskaityti `Čia <http://code.google.com/appengine/docs/python/gettingstarted/devenvironment.html>`_.
+Frontend: `http://localhost:8080/site <http://localhost:8080/site>`_.
+
+`More about dev environment <http://code.google.com/appengine/docs/python/gettingstarted/devenvironment.html>`_.
 
 
 .. _tut-admin-interface:
 Admin Interface
 ===============
 
-TODO
+.. image:: http://lh5.ggpht.com/_THWKK-dlQng/S3c0vDDlSAI/AAAAAAAAAOk/XCAMtnXCqGg/s800/index-hl.png
+
+1. Add new page to site tree
+2. To reorder site tree
+3. Page's title
+4. Page's type
+5. Page's controls
 
 
 .. _tut-settings-vars:
 
 Optional. `Picasa Web <http://picasaweb.google.com/>`_ user's name
 which public galleries are used to retrieve images for EAG cms wysiwyg
-and image widget (:ref:`PicasaWidget <class-picasa-widget>`)::
+and image widget (:ref:`PicasaWidget <class-page>`)::
 
    EAGCMS_PICASA_USER = 'some-user-name'
 
 EAG Types concept
 =================
 
-TODO
+Site tree consist of :ref:`Page <class-page>` objects (direct or
+subclasses). Page is subclass of GAE PolyModel class. So all Page's subclasses
+are PolyModels too. Each Page object has `top` and `order` params - these two
+are enough to calculate order of each node in site tree.
+
+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::
+
+   # settings.py:
+   EAGCMS_TYPES = ('eagtypes',)
+
+   # eagtypes.py:
+   from eagadmin.types import register
+   from google.appengine.ext import db
+   from eagadmin.forms import SemiWYSIWYGWidget
+   from django.http import HttpResponseRedirect
+   from django import forms
+
+   class Text(Page):
+       content = db.TextProperty(required=False)
+
+   class TextForm(forms.Form):
+       content = forms.CharField(widget=SemiWYSIWYGWidget)
+
+   class Link(Page):
+       url = db.StringProperty()
+       target = db.StringProperty(choices=['_self', '_blank'])
+
+       def get_link_target(self):
+           return self.target
+
+       def get_response(self, request):
+           return HttpResponseRedirect(self.url)
+
+       def get_absolute_url(self):
+           return self.url
+
+   register.add(Text, TextForm)
+   register.add(Link)
+
+This code sample registers two page types: *Text* and *Link*.
+
+First: Text classes objects will have content field. Default TextProperty's
+fields objects are rendering using simple textarea. If You do not want that and
+want to have WYSIWYG editor to enter HTML content You can create
+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
+EAG cms does to render pages.
+
+*get_link_target* method returns self.target, wich 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
+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
+itself renders content. It is small violation of MVC pattern, but it lets you
+to define intrenting Page types (Link for example).
+
+Section below talks about real Page's *get_response* implementation.
 
 
 .. _tut-look-and-feel:
 Customizing look and feel
 =========================
 
-TODO
+So, if you do not change Page's subclasses default *get_response*
+implementation, each page would be rendered using this algorithm:
+
+* Template var *current* is set to current page
+* Template var *breadcrumb* is set to list of page's breadcrumb
+* Template 'eagsite/types/<class-name-lowercase.html is rendered using
+  those vars
+* If such template does not exists - template 'eagsite/page.html' is rendered
+
+So site at least must have 'eagsite/page.html' template. It simple django
+template - you must edit it (and/or 'eagsite/types/\*.html') to change Yours
+applications look and feel.
 
 
 .. _tut-app-integration:

eagproject/eag-static/js/pageinfo.js

 
     $('id_slug').addEvent('change', function () {
         $('id_title').removeEvent('keyup', toSlug);
+        this.set('value', slugify(this.get('value')));
     });
 });

eagproject/eagtypes.py

 class Text(Page):
     content = db.TextProperty(required=False)
 
+# Should be forms.Form subclass
 class TextForm(forms.Form):
     content = forms.CharField(widget=SemiWYSIWYGWidget)
 
     url = db.StringProperty()
     target = db.StringProperty(choices=['_self', '_blank'])
 
+    # This is used by eagsite eagsite_list_menu template tag
+    # to get link's target (_blank, _self)
     def get_link_target(self):
         return self.target
 
+    # Response is redirect just in case some literally enters
+    # this page's url
     def get_response(self, request):
         return HttpResponseRedirect(self.url)
 
+    # Django's way
     def get_absolute_url(self):
         return self.url
 

eagproject/urls.py

 from django.conf.urls.defaults import *
 
 urlpatterns = patterns('',
+    (r'^admin/', include('eagadmin.urls', namespace='eagadmin')),
     (r'^admin', include('eagadmin.urls', namespace='eagadmin')),
-    (r'^admin/', include('eagadmin.urls', namespace='eagadmin')),
     (r'^(.*)$', 'eagadmin.views.site')