Skip to content

Commit 5b9f6e6

Browse files
committed
Merge branch 'master' into search
2 parents 10d13fe + b7f8a66 commit 5b9f6e6

File tree

510 files changed

+4923
-1890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

510 files changed

+4923
-1890
lines changed

LICENSE.txt

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README

Whitespace-only changes.

README.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
Description
3+
===========
4+
5+
Djity Portal (referred to as Djity to make things shorter), is an open source Web development framework and Website engine built on top of Django (http://www.djangoproject.com/). It's purpose is to help us (and maybe you !) build dynamic Web applications and publish them effortlessly on the Web.
6+
7+
Djity comes with a lot of things pre-processed for you: front-end site administration in AJAX, applications contained in tabulations, contextual portlets, skeletons for new applications and projects, shortcuts for asynchronous communications, Javascript libraries, a shared client and server side context dictionary, installation and documentation utilities, on page WYSIWYG HTML edition, easy internationalization, theming, etc.
8+
9+
A lot of the boilerplate stuff is taken care of. Applications can be exchanged and plugged on a server. That's nice, but of course there is a down side: all this comes with technical choices, constraints and an homogenized look and feel. Your choice !
10+
11+
We are focused on Web development using the latest standards (HTML5, CSS3, etc.), compatibility with older browsers is not a priority.
12+
13+
WARNING ! Djity is still in an early development phase. If you are willing to look into it you should be prepared for gaps in functionalities and documentation, and for the occasional bug.
14+
15+
General info
16+
============
17+
18+
Authors:
19+
* Youen Péron (youen.peron<at>gmail.com)
20+
* Alban Mouton (alban.mouton<at>gmail.com)
21+
22+
License: GPL v3
23+
24+
Links
25+
=====
26+
27+
Homepage (roadmap, bug reports, etc.): http://redmine.djity.net/projects/djityportal
28+
Git page (forks, patches, etc.): https://github.com/djity/djity
29+
Official documentation: http://pypi.python.org/pypi/djity
30+
31+
Features
32+
========
33+
34+
* Projects tree (multiple projects on the same site, with different styles,
35+
users, etc.)
36+
* Users management (subscriptions, login, roles in projects, etc.)
37+
* 100% Ajax interface
38+
* Pluggable applications (instanciated in tabs of projects)
39+
* Easy generation of new Django instances and applications (using Skeleton)
40+
* Easy Ajax application developement (custom shortcuts and proxy objects based
41+
on Dajax and Dajaxice, integration of jquery and jquery-ui)
42+
* Enriched contextual dictionary both server and client side (with information about the current session,
43+
project, tab, users permissions, etc)
44+
* Online edition of the styles of the projects (using a custom themeroller
45+
inspired by jquery-ui)
46+
* Contextual portlets (per project and per instance of application in a
47+
project)
48+
* Easy internationalization of interface and user content (using i18n, django-localeurl and django-transmeta)
49+
* Rich WYSIWYG HTML edition wherever you want it (using eLRTE)
50+
51+
Incoming features
52+
=================
53+
54+
* Online administration of the portlets
55+
* Fully themable projects (not just some style parameters, but also the layouts)
56+
* Easy migration of data between versions (probably using South)
57+
* Integrated search engine (probably using Haystack)
58+
* User identification through OpenID
59+
* Recent advanced Web standards (PUSH, Websockets, etc)
60+
* Open data linking using standard ontologies (FOAF, SIOC, etc)

djity/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -*- coding:utf-8 -*-
2+
pip_name = "djity"
3+
version = '0.2'
4+
description = "A Web framework built on Django to create rapidly dynamic applications"
5+
author = "Youen Péron and Alban Mouton"
6+
author_email = "contact@djity.net"
7+
url = "http://redmine.djity.net/projects/djityportal"
8+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""
2+
Ajax views for {application_name}.
3+
"""
4+
5+
from django.utils.translation import ugettext_lazy as _
6+
from django.utils.translation import activate, get_language
7+
from djity.utils.decorators import djity_view
8+
from djity.utils.security import sanitize
9+
from djity.transmeta import get_value,set_value
10+
11+
12+
from dajaxice.core import dajaxice_functions
13+
register = lambda name:dajaxice_functions.register_function('{package_name}.ajax',name)
14+
15+
# permission needed to access a view can be 'view', 'edit', 'manage'
16+
@djity_view(perm='view')
17+
def example_ajax(request,js_target,text,context=None):
18+
"""
19+
This function simply transforms a text in upper case and put it in a div given as js_target
20+
21+
Arguments:
22+
* context - standard Djity context built by decorator djity_view using session and url data
23+
* js_target - Proxy object to generate javascript code. Functions called on js_target here will be translated in javascript onto the object passed as target.
24+
* text - text to make upper case
25+
"""
26+
text = text.upper()
27+
js_target.text(text)
28+
js_target.message(_("%s written by ajax function !") % text)
29+
# If you want to reload the page and send a message to display after you can do:
30+
# js_target.message(_"%s written by ajax function !" % text, post=True)
31+
# js_target.reload()
32+
# your view work with js_target and return nothing
33+
34+
#register your view in dajaxice
35+
register('example_ajax')
36+
37+
# save the message in the database
38+
@djity_view(perm='edit')
39+
def save_message(request,js_target,html,lang,context=None):
40+
#get the {module_name}.models.{class_name} for this view from the context
41+
module = context['module']
42+
#filter script tag with the sanitize function
43+
message = sanitize(html)
44+
# set the message in the specific language
45+
set_value(module,'message',lang,message)
46+
module.save()
47+
js_target.message(_("your message '%(text)s' is save in the database for language code %(lang)s") %{{'text':html,'lang':lang}})
48+
register('save_message')
49+
50+
# get the message in a lang for international editing
51+
@djity_view(perm='edit')
52+
def get_message(request,js_target,lang,context=None):
53+
module = context['module']
54+
# get the message for a specific languange
55+
message = get_value(module,'message',lang)
56+
# call the javascript editor methode with the message as parameter
57+
js_target.set_html(message)
58+
59+
register('get_message')
60+
61+
62+
Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,72 @@
1+
"""
2+
Models for Djity application {application_name}
3+
"""
4+
15
from django.db import models
26

37
from djity.project.models import Module
48
from djity.utils.inherit import SuperManager
59
from djity.utils import djreverse
6-
10+
from djity.utils.security import sanitize
11+
from djity.portlet.models import TemplatePortlet, TextPortlet
12+
from djity.transmeta import TransMeta
713

814
class {class_name}(Module):
915
"""
1016
Main class of this new Djity application. This class acts like a proxy between
11-
your application and Djity, allowing Djity to manage his modules in a
17+
your application and Djity, allowing Djity to manage its modules in a
1218
standard way.
1319

1420
At creation, this application simply displays a message in a tab.
1521
"""
1622
#get the module manager
1723
objects = SuperManager()
1824

25+
#use transmeta for international message
26+
__metaclass__ = TransMeta
27+
1928
message = models.CharField(max_length=200, default='Hello World !')
2029

21-
def subnav(self,project_name):
30+
class Meta:
31+
#specify that the field 'message' is translatable
32+
translate = ('message',)
33+
34+
35+
def save(self,*args,**kwargs):
2236
"""
23-
return sub navigation list
37+
Redefine save() from Module in order to attach portlets at creation.
2438
"""
25-
return []
39+
# Is the module new ?
40+
new = (self.id == None)
41+
42+
super({class_name},self).save(*args, **kwargs)
43+
44+
if new:
45+
#A standard text portlet, its content will be automatically editable
46+
TextPortlet(content=sanitize("This is a tab level text portlet edit me !"), container=self,position="left", rel_position=0).save()
47+
48+
# A standard template portlet, it will simply render a template
49+
TemplatePortlet(template="{package_name}/{module_name}_portlet.html",container=self,position="right",rel_position=0).save()
50+
51+
# A custom template defined in models.py of the application
52+
{class_name}Portlet(container=self,position="right",rel_position=0).save()
53+
2654

2755
def djity_url(self,context):
2856
"""
2957
return the application's start page
3058
"""
3159
return djreverse('{module_name}-main',context)
3260

61+
class {class_name}Portlet(TemplatePortlet):
62+
def save(self,*args,**kwargs):
63+
# Is the portlet new ?
64+
new = (self.id == None)
65+
66+
super({class_name}Portlet,self).save(*args, **kwargs)
67+
68+
if new:
69+
self.onload = "$('.{module_name}-load-portlet').{module_name}_widget();"
70+
self.template = "{package_name}/{module_name}_portlet2.html"
71+
super({class_name}Portlet,self).save(*args, **kwargs)
72+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
$.widget("ui.{module_name}_widget",
2+
{{
3+
4+
_init:function()
5+
{{
6+
dj.remote('{package_name}.example_ajax',
7+
{{
8+
js_target:this,
9+
text:this.element.text(),
10+
}});
11+
}},
12+
text : function(text)
13+
//callback function
14+
{{
15+
this.element.text('from ajax: ' +text);
16+
}}
17+
}});
18+

djity/application_skeleton/{package_name}/templates/{package_name}/{module_name}.html

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{% extends "djity/base.html" %}}
2+
3+
{{% block module_head %}}
4+
5+
<script type="text/javascript" src="{{{{STATIC_URL}}}}/{package_name}/js/{module_name}.js"></script>
6+
{{% endblock %}}
7+
8+
9+
{{% block module_onload %}}
10+
11+
//Send the message to the notify framework
12+
dj.message("{{{{message}}}}");
13+
14+
//If user can edit apply the editor widget
15+
if( dj.context.perm.edit )
16+
{{
17+
$('#{module_name}-message').editable({{
18+
// No rich editor
19+
simple:true,
20+
// The ajax function to save the message
21+
save_function:'{package_name}.save_message',
22+
// The ajax function to get the message in a specific language
23+
get_function:'{package_name}.get_message',
24+
// The message language (if the message haven't the version of the current language)
25+
lang:dj.context.{package_name}_lang
26+
}});
27+
}}
28+
29+
30+
{{% endblock %}}
31+
32+
{{% block body %}}
33+
34+
<p>Your message is : <span id="{module_name}-message">{{{{message}}}}</span> </p>
35+
36+
<p>You can edit message : click it!</p>
37+
38+
39+
40+
{{% endblock %}}
41+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{% extends "djity/portlet/portlet.html" %}}
2+
3+
{{% block class%}}{module_name}-portlet {{{{block.super}}}}{{% endblock %}}
4+
{{% block content %}}
5+
<p>This is a template portlet !</p>
6+
7+
<p>Members of this project:
8+
<ul>
9+
{{% for member in project.get_members %}}
10+
<li>{{{{member.user}}}}</li>
11+
{{% endfor %}}
12+
</ul>
13+
</p>
14+
{{% endblock %}}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{% extends "djity/portlet/portlet.html" %}}
2+
3+
{{% block class%}}{module_name}-load-portlet {{{{block.super}}}}{{% endblock %}}
4+
{{% block content %}}
5+
This is another template portlet !
6+
{{% endblock %}}

djity/application_skeleton/{package_name}/views.py_tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from django.contrib import messages
33
from django.utils.translation import ugettext_lazy as _
44

55
from djity.utils.decorators import djity_view
6+
from djity.transmeta import get_lang_version
67

78
@djity_view()
89
def {module_name}_view(request,context=None):
@@ -11,11 +12,12 @@ def {module_name}_view(request,context=None):
1112
"""
1213
# Get the current instance of the module to render
1314
{module_name} = context['module']
15+
context['{package_name}_lang'] = get_lang_version({module_name},'message')
1416
# fetch its message
1517
message = _({module_name}.message)
1618
# will display a notification
1719
messages.add_message(request,messages.INFO,unicode(message))
1820
# update djity's context for templates to render correctly
1921
context.update({{'view':'{module_name}','message':message}})
20-
# render the template en return it
22+
# render the template and return it
2123
return render_to_response('{package_name}/{module_name}.html',context)

djity/locale/en/LC_MESSAGES/django.mo

378 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)