From ba50f7d317dea91c0449d8d6d5cafb5731731076 Mon Sep 17 00:00:00 2001 From: Issac Kelly Date: Sat, 19 Mar 2011 16:38:51 -0400 Subject: [PATCH] Example project is working, and the documentation is at least accurate to the code, It still needs a lot of work. --- README.md | 14 ++----- docs/index.txt | 2 - docs/inlines.txt | 18 +++++++- docs/installation.txt | 7 ++++ docs/sample_projects.txt | 7 ++-- docs/toolbar.txt | 0 docs/wysiwyg.txt | 13 +----- example_project/fixtures/initial_data.json | 2 +- .../{image => sample_image_insert}/_add.html | 0 .../_detail.html | 0 .../{image => sample_image_insert}/_list.html | 2 +- .../_render.html | 0 example_project/servee_extensions/models.py | 1 + example_project/settings.py | 5 ++- .../templates/registration/login.html | 42 +++++++++++++++++++ example_project/urls.py | 9 ++-- servee/frontendadmin/sites.py | 14 ++----- servee/requirements.txt | 13 ------ .../static/servee/wysiwyg/js/tinymce.js | 3 +- setup.py | 4 ++ 20 files changed, 96 insertions(+), 60 deletions(-) delete mode 100644 docs/toolbar.txt rename example_project/sample_image_insert/templates/servee/wysiwyg/insert/{image => sample_image_insert}/_add.html (100%) rename example_project/sample_image_insert/templates/servee/wysiwyg/insert/{image => sample_image_insert}/_detail.html (100%) rename example_project/sample_image_insert/templates/servee/wysiwyg/insert/{image => sample_image_insert}/_list.html (94%) rename example_project/sample_image_insert/templates/servee/wysiwyg/insert/{image => sample_image_insert}/_render.html (100%) create mode 100644 example_project/templates/registration/login.html delete mode 100644 servee/requirements.txt diff --git a/README.md b/README.md index 822225b..5b36aec 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,13 @@ This is an alpha version of servee and may contain many bugs. First you should put servee in your environment: pip install -e git+git://github.com/servee/servee.git@features/replace_frontendadmin#egg=django-servee - # servee is on PyPI as django-servee, but it is out of date + # servee is on PyPI as django-servee, but it is out of date if you're looking for the + # development version or download and ./setup.py develop -I pip is not setup to read the other dependancies from there so navigate to your servee folder in your path now (/src/servee, or wherever you downloaded from) and do pip install -r requirements.txt - Then add servee to installed apps and add the two middleware packages. INSTALLED_APPS = [ @@ -22,18 +21,11 @@ Then add servee to installed apps and add the two middleware packages. "uni_form", #servee - "servee", - "improved_inlines", + "servee.frontendadmin", "servee.wysiwyg", "servee.wysiwyg.tinymce", ] -Also Add this setting to settings.py - - # Currently, it's overkill, since there is just one WYSIWYG - # Editor supported. Please write and submit another :) - SRV_WYSIWYG_EDITOR = "tinymce" - Then syncdb, or migrate and collectstatic (if you are on production) It's important to add servee urls and frontendadmin urls diff --git a/docs/index.txt b/docs/index.txt index a2de8f7..6738364 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -15,8 +15,6 @@ Contents: installation wysiwyg inlines - menus - toolbar sample_projects Indices and tables diff --git a/docs/inlines.txt b/docs/inlines.txt index 2d8eabc..cda1177 100644 --- a/docs/inlines.txt +++ b/docs/inlines.txt @@ -6,4 +6,20 @@ Inlines Inlines are a very powerful tool for putting content inside another piece of content. The most comment use-case is to put a small representation of a Model (like an Image) -onto your content area. \ No newline at end of file +onto your content area. + +Included in the example_project is a very simple image insert + model, based on ModelInsert. + +Inserts have three primary views: + +* List: A list of available items to be inserted +* Detail: Shows More information about the item, as well as the button for rendering the insert onto the current content block. +* Render: Returns a partial HTML template that gets inserted onto the page at the cursor. + +Model Inserts also work off of an idea that you can add one by only putting in the required fields +For our Image example, the only required field is the `image = models.ImageField...` field. + +We are using uploadify to allow you to add several images to the site at once. + +If you don't specify an add_form when creating your ModelInsert class, it will create one for you based +on the required fields. \ No newline at end of file diff --git a/docs/installation.txt b/docs/installation.txt index e69de29..5627fb1 100644 --- a/docs/installation.txt +++ b/docs/installation.txt @@ -0,0 +1,7 @@ + +========= + +========= + +Servee is on PyPI as django-servee + diff --git a/docs/sample_projects.txt b/docs/sample_projects.txt index ef2665f..7812bd5 100644 --- a/docs/sample_projects.txt +++ b/docs/sample_projects.txt @@ -10,7 +10,7 @@ Sample projects should get you started with a working version of servee. Bare Essentials =============== -This is a bare django project + flatpages + required settings and installed apps for servee + contrib. +This is a bare django project + flatpages + required settings and installed apps for servee. To build it, these instructions assume you have virtualenv + virtualenv wrapper installed. @@ -19,13 +19,12 @@ Creating the Project:: mkvirtualenv servee cd ~/Path/to/servee/ python manage.py develop - pip install -r requirements.txt - cd example_projects/bare_necessities + cd example_project/ python manage.py syncdb python manage.py runserver -Go to http://localhost:8000/admin/flatpages/add/ and add a flatpage with the url / +Login at http://localhost:8000/ Go to http://localhost:8000/ to edit it. diff --git a/docs/toolbar.txt b/docs/toolbar.txt deleted file mode 100644 index e69de29..0000000 diff --git a/docs/wysiwyg.txt b/docs/wysiwyg.txt index 01499fb..48f4c99 100644 --- a/docs/wysiwyg.txt +++ b/docs/wysiwyg.txt @@ -5,12 +5,10 @@ WYSIWYG ======= The goal of the wysiwyg components of servee is to best emulate the final version of the site. -The included engine is built on a customized version of tinyMCE. +The included engine is built on tinyMCE, which is already in the source tree. The wysiwyg tools abstract the function calls of the engine so that it should be fairly simple to swap out the rendering engine if you prefer something like FCKeditor or WYMeditor. -All wysiwyg tools only show up if you are logged in (controlled via middleware). - Basic Tools =========== @@ -32,11 +30,4 @@ Insert Dialog ============= This is how you insert media (pictures, videos, text) or inline representation of a model or models. You can create your own insert dialogs for things like forms, products, blog posts, or user profiles. - -Creating a Dialog ------------------ - -Dialogs are based off of the class InsertPanel, should have an interface - -Styles -====== \ No newline at end of file +This is populated through the inserts \ No newline at end of file diff --git a/example_project/fixtures/initial_data.json b/example_project/fixtures/initial_data.json index 3aed51f..402c0b2 100644 --- a/example_project/fixtures/initial_data.json +++ b/example_project/fixtures/initial_data.json @@ -10,7 +10,7 @@ "sites": [ 1 ], - "content": "

This is the homepage.

\r\n

 

\r\n

Here we go!

", + "content": "

This is the homepage.

\r\n

 

\r\n

Login to see the edit buttons. They'll be at the bottom.

", "enable_comments": false } } diff --git a/example_project/sample_image_insert/templates/servee/wysiwyg/insert/image/_add.html b/example_project/sample_image_insert/templates/servee/wysiwyg/insert/sample_image_insert/_add.html similarity index 100% rename from example_project/sample_image_insert/templates/servee/wysiwyg/insert/image/_add.html rename to example_project/sample_image_insert/templates/servee/wysiwyg/insert/sample_image_insert/_add.html diff --git a/example_project/sample_image_insert/templates/servee/wysiwyg/insert/image/_detail.html b/example_project/sample_image_insert/templates/servee/wysiwyg/insert/sample_image_insert/_detail.html similarity index 100% rename from example_project/sample_image_insert/templates/servee/wysiwyg/insert/image/_detail.html rename to example_project/sample_image_insert/templates/servee/wysiwyg/insert/sample_image_insert/_detail.html diff --git a/example_project/sample_image_insert/templates/servee/wysiwyg/insert/image/_list.html b/example_project/sample_image_insert/templates/servee/wysiwyg/insert/sample_image_insert/_list.html similarity index 94% rename from example_project/sample_image_insert/templates/servee/wysiwyg/insert/image/_list.html rename to example_project/sample_image_insert/templates/servee/wysiwyg/insert/sample_image_insert/_list.html index 313efbb..4275f18 100644 --- a/example_project/sample_image_insert/templates/servee/wysiwyg/insert/image/_list.html +++ b/example_project/sample_image_insert/templates/servee/wysiwyg/insert/sample_image_insert/_list.html @@ -1,6 +1,6 @@ {% load insert_tags %} {% load uni_form_tags %} -
+ {% csrf_token %} {{ form|as_uni_form }}
diff --git a/example_project/sample_image_insert/templates/servee/wysiwyg/insert/image/_render.html b/example_project/sample_image_insert/templates/servee/wysiwyg/insert/sample_image_insert/_render.html similarity index 100% rename from example_project/sample_image_insert/templates/servee/wysiwyg/insert/image/_render.html rename to example_project/sample_image_insert/templates/servee/wysiwyg/insert/sample_image_insert/_render.html diff --git a/example_project/servee_extensions/models.py b/example_project/servee_extensions/models.py index e69de29..5ef44f2 100644 --- a/example_project/servee_extensions/models.py +++ b/example_project/servee_extensions/models.py @@ -0,0 +1 @@ +# just here because apps expect a models file. \ No newline at end of file diff --git a/example_project/settings.py b/example_project/settings.py index b791a6c..bffb1bf 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -124,4 +124,7 @@ # for the flatpages app. This is the convention for adding servee # frontend editing to 3rd party apps. "servee_extensions", -] \ No newline at end of file +] + +LOGIN_URL = "/login/" +LOGIN_REDIRECT_URL = "/" \ No newline at end of file diff --git a/example_project/templates/registration/login.html b/example_project/templates/registration/login.html new file mode 100644 index 0000000..37307a0 --- /dev/null +++ b/example_project/templates/registration/login.html @@ -0,0 +1,42 @@ +{% extends "site_base.html" %} +{% load i18n uni_form_tags %} + +{% block bodyclass %}login{% endblock %} + +{% block content %} +{% if form.errors and not form.non_field_errors and not form.this_is_the_login_form.errors %} +

+{% blocktrans count form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %} +

+{% endif %} + +{% if form.non_field_errors or form.this_is_the_login_form.errors %} +{% for error in form.non_field_errors|add:form.this_is_the_login_form.errors %} +

+ {{ error }} +

+{% endfor %} +{% endif %} + +
+{% csrf_token %} +
+ {% if not form.this_is_the_login_form.errors %}{{ form.username.errors }}{% endif %} + {{ form.username }} +
+
+ {% if not form.this_is_the_login_form.errors %}{{ form.password.errors }}{% endif %} + {{ form.password }} + + +
+
+ +
+ + + +
+{% endblock %} diff --git a/example_project/urls.py b/example_project/urls.py index d514d39..dc25565 100644 --- a/example_project/urls.py +++ b/example_project/urls.py @@ -10,11 +10,14 @@ (r"^admin/doc/", include("django.contrib.admindocs.urls")), (r"^admin/", include(admin.site.urls)), (r"^servee/", include(frontendadmin.site.urls)), + + (r"^login/$", "django.contrib.auth.views.login", {"template_name": "registration/login.html"}), + (r"^logout/$", "django.contrib.auth.views.logout", {"template_name": "registration/logout.html", "next_page": "/"}), ) if settings.DEBUG: - urlpatterns += patterns('', - url(r'^site_media/media/(?P.*)$', 'django.views.static.serve', { - 'document_root': settings.MEDIA_ROOT, + urlpatterns += patterns("", + url(r"^site_media/media/(?P.*)$", "django.views.static.serve", { + "document_root": settings.MEDIA_ROOT, }), ) \ No newline at end of file diff --git a/servee/frontendadmin/sites.py b/servee/frontendadmin/sites.py index 13f8d21..339cf5f 100644 --- a/servee/frontendadmin/sites.py +++ b/servee/frontendadmin/sites.py @@ -1,4 +1,5 @@ from django.contrib.admin.sites import AdminSite, AlreadyRegistered +from django.conf import settings class ServeeAdminSite(AdminSite): """ @@ -7,7 +8,6 @@ class ServeeAdminSite(AdminSite): """ insert_classes = {} - #toolbar_classes = [] custom_views = [] def register_view(self, path, view, name=None): @@ -35,14 +35,6 @@ def register_insert(self, class_registered): # Add to registry of instantiated models self.insert_classes[insert_class.base_url()] = insert_class - - #def register_toolbar(self, class_registered): - # """ - # ... Yet Unimplemented - # """ - # self.toolbar_classes.append(class_registered) - - def get_urls(self): """Add our custom views to the admin urlconf.""" urls = super(ServeeAdminSite, self).get_urls() @@ -59,13 +51,15 @@ def get_urls(self): urls += patterns("", (r"^insert/%s/%s/" % (insert.model._meta.app_label, insert.model._meta.module_name), include(insert.urls)) ) - return urls def __init__(self, *args, **kwargs): super(ServeeAdminSite, self).__init__(*args, **kwargs) + + ##@@ TODO Fix so that this can be properly namespaced self.name = "servee" self.app_name = "servee" + self.uses_wysiwyg = "servee.wysiwyg" in settings.INSTALLED_APPS self.index_template = ["servee/index.html", "admin/index.html"] self.login_template = ["servee/login.html", "admin/login.html"] diff --git a/servee/requirements.txt b/servee/requirements.txt deleted file mode 100644 index 9e0db6c..0000000 --- a/servee/requirements.txt +++ /dev/null @@ -1,13 +0,0 @@ -## Django>=1.3, 1.2.X works, but static media takes 1.3 conventions --e git+http://github.com/django/django.git#egg=Django - -# Django-classy-tags is so -# much more readable, and easier -# to implement, that it's an acceptable -# dependency. -django-classy-tags - -# It's presumed that django-uni-form will -# Very soon have some support for fieldsets. -# That's great. I assume the 0.8.0 release -django-uni-form diff --git a/servee/wysiwyg/tinymce/static/servee/wysiwyg/js/tinymce.js b/servee/wysiwyg/tinymce/static/servee/wysiwyg/js/tinymce.js index 7794dc2..c97ccff 100644 --- a/servee/wysiwyg/tinymce/static/servee/wysiwyg/js/tinymce.js +++ b/servee/wysiwyg/tinymce/static/servee/wysiwyg/js/tinymce.js @@ -30,8 +30,7 @@ function load_wysiwyg($par){ //Auto resize theme_advanced_resizing_min_width : 50, - theme_advanced_resizing_min_height : 50, - + theme_advanced_resizing_min_height : 350, setup: function (ed) { ed.onPostRender.add(function(ed,evt){ diff --git a/setup.py b/setup.py index 9eb4bde..88a817b 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,10 @@ packages=find_packages(exclude=['ez_setup']), include_package_data=True, zip_safe=False, # because we're including media that Django needs + requires = [ + 'django-classy-tags', + 'django-uni-form', + ], classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Web Environment',