Skip to content

Commit

Permalink
Example project is working, and the documentation is at least accurat…
Browse files Browse the repository at this point in the history
…e to the code, It still needs a lot of work.
  • Loading branch information
issackelly committed Mar 19, 2011
1 parent bcc3eee commit ba50f7d
Show file tree
Hide file tree
Showing 20 changed files with 96 additions and 60 deletions.
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,25 @@ 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 (<env>/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 = [
#servee_dependancies
"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
Expand Down
2 changes: 0 additions & 2 deletions docs/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Contents:
installation
wysiwyg
inlines
menus
toolbar
sample_projects

Indices and tables
Expand Down
18 changes: 17 additions & 1 deletion docs/inlines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
7 changes: 7 additions & 0 deletions docs/installation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

=========

=========

Servee is on PyPI as django-servee

7 changes: 3 additions & 4 deletions docs/sample_projects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

Empty file removed docs/toolbar.txt
Empty file.
13 changes: 2 additions & 11 deletions docs/wysiwyg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========
Expand All @@ -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
======
This is populated through the inserts
2 changes: 1 addition & 1 deletion example_project/fixtures/initial_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"sites": [
1
],
"content": "<p>This is the homepage.</p>\r\n<p>&nbsp;</p>\r\n<p>Here we go!</p>",
"content": "<p>This is the homepage.</p>\r\n<p>&nbsp;</p>\r\n<p><a href='/login/' >Login to see the edit buttons. They'll be at the bottom.</a></p>",
"enable_comments": false
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load insert_tags %}
{% load uni_form_tags %}
<form id="srv_upload_image" method="POST" enctype="multipart/form-data" class="servee uniform" action="{% url servee:insert_image_image_add %}">
<form id="srv_upload_image" method="POST" enctype="multipart/form-data" class="servee uniform" action="{% url servee:insert_sample_image_insert_image_add %}">
{% csrf_token %}
{{ form|as_uni_form }}
<div class="buttonHolder">
Expand Down
1 change: 1 addition & 0 deletions example_project/servee_extensions/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# just here because apps expect a models file.
5 changes: 4 additions & 1 deletion example_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,7 @@
# for the flatpages app. This is the convention for adding servee
# frontend editing to 3rd party apps.
"servee_extensions",
]
]

LOGIN_URL = "/login/"
LOGIN_REDIRECT_URL = "/"
42 changes: 42 additions & 0 deletions example_project/templates/registration/login.html
Original file line number Diff line number Diff line change
@@ -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 %}
<p class="errornote">
{% blocktrans count form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
</p>
{% 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 %}
<p class="errornote">
{{ error }}
</p>
{% endfor %}
{% endif %}

<div id="content-main">
<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
<div class="form-row">
{% if not form.this_is_the_login_form.errors %}{{ form.username.errors }}{% endif %}
<label for="id_username" class="required">{% trans 'Username:' %}</label> {{ form.username }}
</div>
<div class="form-row">
{% if not form.this_is_the_login_form.errors %}{{ form.password.errors }}{% endif %}
<label for="id_password" class="required">{% trans 'Password:' %}</label> {{ form.password }}
<input type="hidden" name="this_is_the_login_form" value="1" />
<input type="hidden" name="next" value="{{ next }}" />
</div>
<div class="submit-row">
<label>&nbsp;</label><input type="submit" value="{% trans 'Log in' %}" />
</div>
</form>

<script type="text/javascript">
document.getElementById('id_username').focus()
</script>
</div>
{% endblock %}
9 changes: 6 additions & 3 deletions example_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
urlpatterns += patterns("",
url(r"^site_media/media/(?P<path>.*)$", "django.views.static.serve", {
"document_root": settings.MEDIA_ROOT,
}),
)
14 changes: 4 additions & 10 deletions servee/frontendadmin/sites.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib.admin.sites import AdminSite, AlreadyRegistered
from django.conf import settings

class ServeeAdminSite(AdminSite):
"""
Expand All @@ -7,7 +8,6 @@ class ServeeAdminSite(AdminSite):
"""

insert_classes = {}
#toolbar_classes = []
custom_views = []

def register_view(self, path, view, name=None):
Expand Down Expand Up @@ -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()
Expand All @@ -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"]
Expand Down
13 changes: 0 additions & 13 deletions servee/requirements.txt

This file was deleted.

3 changes: 1 addition & 2 deletions servee/wysiwyg/tinymce/static/servee/wysiwyg/js/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit ba50f7d

Please sign in to comment.