Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: roalddevries/django-fiber
base: beb5dfb198
...
head fork: roalddevries/django-fiber
compare: 614ae2fba8
  • 6 commits
  • 9 files changed
  • 0 commit comments
  • 3 contributors
Commits on Feb 16, 2012
@mvdwaeter mvdwaeter Changed ckeditor height, resize to window height
- credits nvandijk
a6cd868
@mvdwaeter mvdwaeter Added content template choices to frontend admin
- updated docs with how to use templates
- added Dutch translations for content-template name
- updated ckeditor auto height behaviour in backend and frontend admin
- credits to nvandijk
d780f8d
@mvdwaeter mvdwaeter Added documentation on use of FIBER_METADATA_PAGE_SCHEMA and FIBER_ME…
…TADATA_CONTENT_SCHEMA
c9b0c3c
@dbunskoek dbunskoek Improved select styling, fixed typo (trailing comma) c1be7e9
@dbunskoek dbunskoek Merge branch 'master' of github.com:ridethepony/django-fiber b8d3f56
Commits on Feb 21, 2012
Roald de Vries Merge branch 'master' of https://github.com/ridethepony/django-fiber 614ae2f
View
80 docs/advanced-usage.rst
@@ -15,6 +15,7 @@ These settings are optional (default values are shown):
FIBER_DEFAULT_TEMPLATE = 'base.html'
FIBER_TEMPLATE_CHOICES = []
+ FIBER_CONTENT_TEMPLATE_CHOICES = []
FIBER_EXCLUDE_URLS = []
@@ -36,9 +37,9 @@ In this example, the news_item_detail view looks up the Page of the news_item_li
def news_item_detail(request, news_item_slug):
news_item = get_object_or_404(NewsItem, slug=news_item_slug)
-
+
fiber_page = Page.objects.get(url__exact='"news_item_list"')
-
+
t = loader.get_template('news_item_detail.html')
c = RequestContext(request, {
'fiber_page': fiber_page,
@@ -47,6 +48,81 @@ In this example, the news_item_detail view looks up the Page of the news_item_li
return HttpResponse(t.render(c))
+Templates:
+==========
+
+In this example 4 page-templates will be available in the front- and backend-admin:
+
+::
+
+ FIBER_TEMPLATE_CHOICES = (
+ ('', 'Default template'),
+ ('tpl-home.html', 'Home template'),
+ ('tpl-intro.html', 'Intro template'),
+ ('tpl-with-sidebar.html', 'With sidebar template'),
+ )
+
+The first choice '' will load the FIBER_DEFAULT_TEMPLATE, default this is 'base.html'
+
+
+In this example 2 content-templates will be available in the front- and backend-admin:
+
+::
+
+ FIBER_CONTENT_TEMPLATE_CHOICES = (
+ ('', 'Default template'),
+ ('special-content-template.html', 'Special template'),
+ )
+
+The first choice '' will load the default content-template, this is 'fiber/content_item.html'
+
+
+Metadata:
+=========
+
+In this example metadata (key-value pairs) for pages will be available in the backend-admin:
+
+::
+
+ FIBER_METADATA_PAGE_SCHEMA = {
+ 'title': {
+ 'widget': 'select',
+ 'values': ['option1', 'option2', 'option3',],
+ },
+ 'bgcolor': {
+ 'widget': 'combobox',
+ 'values': ['#ffffff', '#fff000', '#ff00cc'],
+ 'prefill_from_db': True,
+ },
+ 'description': {
+ 'widget': 'textarea',
+ },
+ }
+
+The first key key is 'title'. Because it has widget 'select' you will have 3 fixed values to choose from.
+
+The second key is 'bgcolor'. Because it has widget 'combobox' you will have 3 fixed values to choose from and the choice to add your own 'bgcolor'.
+By setting prefill_from_db to True, the custom values you have chosen will also appear in the selectbox of fixed values.
+
+The third key is 'description'. Because it has widget 'textarea' you can enter the value in a big textarea field.
+
+Available widgets are:
+ select
+ combobox
+ textarea
+ textfield (default widget)
+
+Only the combobox can prefill from the database by setting prefill_from_db = True (default=False)
+
+
+The same metadata schema is available for metadata for content:
+
+::
+
+ FIBER_METADATA_CONTENT_SCHEMA
+
+
+
CKEditor config settings
========================
View
19 fiber/admin.py
@@ -5,7 +5,7 @@
from mptt.admin import MPTTModelAdmin
from fiber.editor import get_editor_field_name
-from app_settings import TEMPLATE_CHOICES
+from app_settings import TEMPLATE_CHOICES, CONTENT_TEMPLATE_CHOICES
from models import Page, ContentItem, PageContentItem, Image, File
import admin_forms as forms
@@ -95,9 +95,20 @@ def action_links(self, page):
class FiberAdminContentItemAdmin(fiber_admin.ModelAdmin):
list_display = ('__unicode__',)
form = forms.ContentItemAdminForm
- fieldsets = (
- (None, {'classes': ('hide-label',), 'fields': (get_editor_field_name('content_html'),)}),
- )
+
+ def __init__(self, *args, **kwargs):
+ super(FiberAdminContentItemAdmin, self).__init__(*args, **kwargs)
+
+ # remove content template choices if there are no choices
+ if len(CONTENT_TEMPLATE_CHOICES) == 0:
+ self.fieldsets = (
+ (None, {'classes': ('hide-label',), 'fields': (get_editor_field_name('content_html'), )}),
+ )
+ else:
+ self.fieldsets = (
+ (None, {'classes': ('hide-label',), 'fields': (get_editor_field_name('content_html'), )}),
+ (None, {'classes': ('select-box',), 'fields': ('template_name', )}),
+ )
class FiberAdminPageAdmin(fiber_admin.MPTTModelAdmin):
View
7 fiber/admin_forms.py
@@ -3,7 +3,7 @@
from mptt.forms import TreeNodeChoiceField
-from app_settings import TEMPLATE_CHOICES
+from app_settings import TEMPLATE_CHOICES, CONTENT_TEMPLATE_CHOICES
from models import Page, ContentItem
from utils.urls import is_quoted_url
@@ -13,6 +13,11 @@ class ContentItemAdminForm(forms.ModelForm):
class Meta:
model = ContentItem
+ def __init__(self, *args, **kwargs):
+ super(ContentItemAdminForm, self).__init__(*args, **kwargs)
+ if len(CONTENT_TEMPLATE_CHOICES) > 0:
+ self.fields['template_name'] = forms.ChoiceField(choices=CONTENT_TEMPLATE_CHOICES, required=False, label=_('Content template'))
+
class PageForm(forms.ModelForm):
View
1  fiber/app_settings.py
@@ -3,6 +3,7 @@
DEFAULT_TEMPLATE = getattr(settings, 'FIBER_DEFAULT_TEMPLATE', 'base.html')
TEMPLATE_CHOICES = getattr(settings, 'FIBER_TEMPLATE_CHOICES', [])
+CONTENT_TEMPLATE_CHOICES = getattr(settings, 'FIBER_CONTENT_TEMPLATE_CHOICES', [])
EXCLUDE_URLS = getattr(settings, 'FIBER_EXCLUDE_URLS', [])
FILES_DIR = getattr(settings, 'FIBER_FILES_DIR', 'uploads/files')
View
BIN  fiber/locale/nl/LC_MESSAGES/django.mo
Binary file not shown
View
124 fiber/locale/nl/LC_MESSAGES/django.po
@@ -7,9 +7,9 @@ msgid ""
msgstr ""
"Project-Id-Version: Django Fiber\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-01-10 16:02+0100\n"
-"PO-Revision-Date: 2012-01-10 16:06+0100\n"
-"Last-Translator: Bram Simons <bsimons@leukeleu.nl>\n"
+"POT-Creation-Date: 2012-02-16 10:42+0100\n"
+"PO-Revision-Date: 2012-02-16 10:45+0100\n"
+"Last-Translator: Michael <mvandewaeter@leukeleu.nl>\n"
"Language-Team: Ride The Pony <info@ridethepony.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -42,18 +42,22 @@ msgstr "Voeg een subpagina toe"
msgid "Actions"
msgstr "Acties"
-#: admin_forms.py:20
+#: admin_forms.py:19
+msgid "Content template"
+msgstr "Content sjabloon"
+
+#: admin_forms.py:25
msgid "Redirect page"
msgstr "Automatische doorverwijzing"
-#: admin_forms.py:35
-msgid "A named url can't be combined with a redirect page"
-msgstr "Een 'named url' kan niet worden gecombineerd met een automatische doorverwijzing"
-
-#: admin_forms.py:42
+#: admin_forms.py:33
msgid "Template"
msgstr "Sjabloon"
+#: admin_forms.py:45
+msgid "A named url can't be combined with a redirect page"
+msgstr "Een 'named url' kan niet worden gecombineerd met een automatische doorverwijzing"
+
#: admin_views.py:25
msgid "This account is inactive."
msgstr "Dit account is inactief."
@@ -62,33 +66,33 @@ msgstr "Dit account is inactief."
msgid "Please enter a correct username and password. Note that both fields are case-sensitive."
msgstr "Voer een correcte gebruikersnaam en wachtwoord in. Let op, de velden zijn hoofdlettergevoelig."
-#: managers.py:41
+#: managers.py:43
msgid "used more than once"
msgstr "meerdere keren gebruikt"
-#: managers.py:42
+#: managers.py:44
msgid "unused"
msgstr "ongebruikt"
-#: managers.py:43
+#: managers.py:45
msgid "used once"
msgstr "één keer gebruikt"
-#: managers.py:44
+#: managers.py:46
msgid "recently changed"
msgstr "recent gewijzigd"
#: models.py:21
-#: models.py:66
-#: models.py:211
-#: models.py:237
+#: models.py:73
+#: models.py:250
+#: models.py:276
msgid "created"
msgstr "aangemaakt"
#: models.py:22
-#: models.py:67
-#: models.py:212
-#: models.py:238
+#: models.py:74
+#: models.py:251
+#: models.py:277
msgid "updated"
msgstr "bijgewerkt"
@@ -103,7 +107,7 @@ msgid "Content"
msgstr "Content"
#: models.py:26
-#: models.py:78
+#: models.py:85
msgid "protected"
msgstr "beschermd"
@@ -112,90 +116,94 @@ msgid "metadata"
msgstr "metadata"
#: models.py:28
-#: models.py:75
+#: models.py:82
msgid "template name"
msgstr "sjabloonnaam"
-#: models.py:33
-#: models.py:202
+#: models.py:29
+msgid "used on pages"
+msgstr "gebruikt op pagina's"
+
+#: models.py:34
+#: models.py:233
msgid "content item"
msgstr "content item"
-#: models.py:34
-#: models.py:79
+#: models.py:35
+#: models.py:86
msgid "content items"
msgstr "content items"
-#: models.py:43
+#: models.py:44
msgid "[ EMPTY ]"
msgstr "[ LEEG ]"
-#: models.py:68
+#: models.py:75
msgid "parent"
msgstr "parent"
-#: models.py:70
-#: models.py:214
-#: models.py:240
+#: models.py:77
+#: models.py:253
+#: models.py:279
msgid "title"
msgstr "titel"
-#: models.py:72
+#: models.py:79
msgid "redirect page"
msgstr "automatische doorverwijzing"
-#: models.py:73
+#: models.py:80
msgid "mark current regexes"
msgstr "reguliere expressies markeren als current"
-#: models.py:76
+#: models.py:83
msgid "show in menu"
msgstr "toon in menu"
-#: models.py:77
+#: models.py:84
msgid "is public"
msgstr "is openbaar"
-#: models.py:86
-#: models.py:203
+#: models.py:93
+#: models.py:234
msgid "page"
msgstr "pagina"
-#: models.py:87
+#: models.py:94
msgid "pages"
msgstr "pagina’s"
-#: models.py:204
+#: models.py:235
msgid "block name"
msgstr "block naam"
-#: models.py:205
+#: models.py:236
msgid "sort"
msgstr "sortering"
-#: models.py:213
-#: models.py:219
+#: models.py:252
+#: models.py:258
msgid "image"
msgstr "afbeelding"
-#: models.py:215
+#: models.py:254
msgid "width"
msgstr "breedte"
-#: models.py:216
+#: models.py:255
msgid "height"
msgstr "hoogte"
-#: models.py:220
+#: models.py:259
msgid "images"
msgstr "afbeeldingen"
-#: models.py:239
-#: models.py:243
+#: models.py:278
+#: models.py:282
msgid "file"
msgstr "bestand"
-#: models.py:244
+#: models.py:283
msgid "files"
msgstr "bestanden"
@@ -211,53 +219,53 @@ msgstr "Backend"
msgid "Pages"
msgstr "Pagina’s"
-#: utils/date.py:27
+#: utils/date.py:34
msgid "just now"
msgstr "zojuist"
-#: utils/date.py:29
+#: utils/date.py:36
#, python-format
msgid "%s seconds ago"
msgstr "%s seconden geleden"
-#: utils/date.py:33
+#: utils/date.py:40
#, python-format
msgid "%s minutes ago"
msgstr "%s minuten geleden"
-#: utils/date.py:35
+#: utils/date.py:42
msgid "an hour ago"
msgstr "1 uur geleden"
-#: utils/date.py:37
+#: utils/date.py:44
#, python-format
msgid "%s hours ago"
msgstr "%s uur geleden"
-#: utils/date.py:39
+#: utils/date.py:46
msgid "yesterday"
msgstr "gisteren"
-#: utils/date.py:41
+#: utils/date.py:48
#, python-format
msgid "%s days ago"
msgstr "%s dagen geleden"
-#: utils/date.py:43
+#: utils/date.py:50
msgid "a week ago"
msgstr "1 week geleden"
-#: utils/date.py:45
+#: utils/date.py:52
#, python-format
msgid "%s weeks ago"
msgstr "%s weken geleden"
-#: utils/date.py:47
+#: utils/date.py:54
#, python-format
msgid "%s months ago"
msgstr "%s maanden geleden"
-#: utils/date.py:48
+#: utils/date.py:55
#, python-format
msgid "%s years ago"
msgstr "%s jaar geleden"
View
23 fiber/static/fiber/css/admin.css
@@ -264,7 +264,7 @@ ins.jstree-icon {
}
li.hidden-in-menu,
-li.not-public, {
+li.not-public {
opacity: 0.5;
filter: alpha(opacity=50);
}
@@ -478,7 +478,7 @@ div.ui-dialog form select,
margin: 0 0 5px 0;
border: 1px solid #666;
outline: none;
- padding: 0 3px;
+ padding: 0;
height: 22px;
display: block;
text-align: left;
@@ -495,6 +495,11 @@ div.ui-dialog form select,
clear: none;
}
+div.ui-dialog form select {
+ font-size: 13px;
+ padding: 3px;
+}
+
div.ui-dialog form p.errornote,
div.ui-dialog form p.help {
margin-top: 5px;
@@ -563,6 +568,19 @@ div.ui-widget-overlay {
position: fixed;
}
+.ui-dialog-buttonset select#id_template_name {
+ margin: 0 0 5px 0;
+ border: 1px solid #666;
+ outline: none;
+ padding: 3px;
+ max-width: 200px;
+ position: absolute;
+ bottom: 10px;
+ left: 15px;
+ font-size: 13px;
+ background-color: #fff;
+}
+
#df-layer .ui-droppable {
position: absolute;
height: 16px;
@@ -640,7 +658,6 @@ span.nobr {
.df-admin #page_form select {
border: auto;
- padding-right: 0;
width: 100%;
}
View
31 fiber/static/fiber/js/admin.js
@@ -24,6 +24,21 @@ Fiber.enhance_combobox = function(select) {
$(select).combobox();
};
+Fiber.enhance_content_template_select = function(select) {
+ var template_name = $(select);
+ var fieldset_of_template_name = $('select#id_template_name').parents('fieldset')[0];
+ var hidden_template_name = $('<input type="hidden" name="template_name" id="id_template_name_hidden">');
+
+ hidden_template_name.val(template_name.val());
+ $(fieldset_of_template_name).append(hidden_template_name);
+ $(fieldset_of_template_name).hide();
+ $('.ui-dialog-buttonset').append(template_name);
+
+ template_name.change(function() {
+ $('#id_template_name_hidden').val($(this).val());
+ });
+};
+
Fiber.enhance_jsontextarea = function(textarea) {
// hide the textarea
$(textarea).hide();
@@ -497,9 +512,9 @@ var ChangeFormDialog = AdminFormDialog.extend({
}
});
-function enhance_textareas(container) {
+function enhance_textareas(container, auto_height) {
container.find('textarea.fiber-editor').each(function() {
- Fiber.enhance_textarea(this);
+ Fiber.enhance_textarea(this, auto_height);
});
}
@@ -515,6 +530,12 @@ function enhance_jsontextareas(container) {
});
}
+function enhance_content_template_select(container) {
+ container.find('select#id_template_name').each(function() {
+ Fiber.enhance_content_template_select(this);
+ });
+}
+
var ChangeForm = AdminForm.extend({
set_styling: function() {
@@ -531,9 +552,10 @@ var ChangeForm = AdminForm.extend({
// TODO: add Django-like behavior:
// - fieldsets should be split into tabs
// - collapsible areas should work, etc.
- enhance_textareas(this.form);
+ enhance_textareas(this.form, true);
enhance_comboboxes(this.form);
enhance_jsontextareas(this.form);
+ enhance_content_template_select(this.form);
},
destroy: function() {
@@ -1744,9 +1766,10 @@ var adminPage = {
},
init_backend: function() {
- enhance_textareas($(document.body));
+ enhance_textareas($(document.body), false);
enhance_comboboxes($(document.body));
enhance_jsontextareas($(document.body));
+
var backend_toolbar = $('<div id="fiber-backend-toolbar"></div>');
var frontend_button = $('<p class="frontend"></p>').appendTo(backend_toolbar);
var link = $(document.createElement('a')).text(gettext('Frontend')).attr('href', '/').attr('title', gettext('Frontend')).appendTo(frontend_button);
View
6 fiber/static/fiber/js/fiber.ckeditor.js
@@ -1,6 +1,6 @@
(function($) {
-Fiber.enhance_textarea = function(textarea) {
+Fiber.enhance_textarea = function(textarea, auto_height) {
if (window.CKEDITOR_CONFIG_STYLES_SET) {
if (!CKEDITOR.stylesSet.get('config_styles_set')) {
@@ -20,6 +20,10 @@ Fiber.enhance_textarea = function(textarea) {
['Source']
];
+ if (auto_height) {
+ CKEDITOR.config.height = window.innerHeight - (($('.ui-dialog').height() - $(textarea).height()) + 140);
+ }
+
CKEDITOR.replace(textarea, {
language: LANGUAGE_CODE,
extraPlugins: 'fpagelink,ffilelink,fimagelink,fcustomlink,funlink,fimage,ftable,tabletools',

No commit comments for this range

Something went wrong with that request. Please try again.