[svn] Updates to allow subcave tree with nice admin.

This commit is contained in:
substantialnoninfringinguser
2009-05-21 19:47:19 +01:00
parent 99949d466a
commit 54a62999c0
46 changed files with 1931 additions and 33 deletions

View File

@@ -0,0 +1,227 @@
{% extends "admin/change_form.html" %}
{% load i18n admin_modify adminmedia %}
{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}
{% block coltype %}{% if ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %}
{% block extrahead %}{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" />
<script type="text/javascript" src="../../../jsi18n/"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery-1.3.min.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery.ui.all.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery.livequery.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery.alerts.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}helper.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}listener.js"></script>
<script type="text/javascript" src="/media/sys/feinheit/tinymce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode: "none",
theme: "advanced",
language: "en",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_buttons1: "fullscreen,|,formatselect,image,media,code,|,cut,copy,paste,|,bold,italic,|,bullist,numlist,|,link,unlink",
theme_advanced_buttons2: "",
theme_advanced_buttons3: "",
theme_advanced_path: false,
theme_advanced_blockformats: "p,h2,h3",
theme_advanced_resizing: true,
width: '600',
height: '300',
content_css: "/path_to_your_media/css/preview.css",
plugins: "advimage,advlink,fullscreen,table,preview,media,inlinepopups",
advimage_update_dimensions_onchange: true,
//file_browser_callback: "CustomFileBrowser",
relative_urls: false
});
function init_pagecontent() {
// handle special page content type needs
// this is not really extensible, but it works for now
$('.order-machine textarea[name*=richtext]:visible').each(function(){
tinyMCE.execCommand('mceAddControl', true, this.id);
});
}
IMG_ARROW_DOWN_PATH = "{{ FEINCMS_ADMIN_MEDIA }}img/arrow_down.gif";
IMG_ARROW_RIGHT_PATH = "{{ FEINCMS_ADMIN_MEDIA }}img/arrow_right.gif";
IMG_CIRCLE_PATH = "{{ FEINCMS_ADMIN_MEDIA }}img/circle.gif";
IMG_DELETELINK_PATH = "{{ FEINCMS_ADMIN_MEDIA }}img/icon_deletelink.gif";
IMG_MOVE_PATH = "{{ FEINCMS_ADMIN_MEDIA }}img/icon_move.gif";
REGIONS = [];
REGION_MAP = [];
{% for region in page.template.regions.all %}
REGIONS.push('{{ region.key }}');
REGION_MAP.push('{{ region.id }}');
{% endfor %}
ACTIVE_REGION = 0;
CONTENT_NAMES = {
{% for name, value in content_types %}'{{ value }}': '{{ name }}'{% if not forloop.last %},{% endif %}
{% endfor %}};
$(document).ready(function(){
// move contents into their corresponding regions and do some simple formatting
$("div[id$=_set]").children().each(function(){
if (!($(this).hasClass("header"))) {
$(this).find("select[name$=region]").addClass("region-choice-field").parents("tr").hide();
$(this).find("input[name$=DELETE]").addClass("delete-field").parents("tr").hide();
$(this).find("input[name$=ordering]").addClass("order-field").parents("tr").hide();
$(this).find("input[name$=id]").hide().prev().hide();
$(this).find("input[name$=parent]").hide().prev().hide();
var region_id = $(this).find(".region-choice-field").val();
region_id = REGION_MAP.indexOf(region_id);
var content_type = $(this).attr("id").substr(0, $(this).attr("id").indexOf("_"));
region_append(region_id,$(this), CONTENT_NAMES[content_type]);
set_item_field_value($(this),"region-choice-field",region_id)
}
});
// register regions as sortable for drag N drop
$(".order-machine").sortable({
handle: '.handle',
helper: 'clone',
stop: function(event, ui) {
richify_poor($(ui.item));
}
});
// hide content on drag n drop
$(".handle").mousedown(function(){
poorify_rich($(this).parents(".order-item"));
});
$(".handle").mouseup(function(){
richify_poor($(this).parents(".order-item"));
});
// convert text areas to rich text editors.
init_pagecontent();
if(window.location.hash) {
$(window.location.hash+'_tab').trigger('click');
}
// bring order to chaos
zucht_und_ordnung(true);
{% block extra-init-js %}{% endblock %}
});
</script>
<link rel="stylesheet" type="text/css" href="{{ FEINCMS_ADMIN_MEDIA }}css/layout.css" />
<link rel="stylesheet" type="text/css" href="{{ FEINCMS_ADMIN_MEDIA }}css/jquery.alerts.css" media="screen" />
{% endblock %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="../../../">{% trans "Home" %}</a> &rsaquo;
<a href="../../">{{ opts.app_label|capfirst|escape }}</a> &rsaquo;
<a href="../">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
{{ page.title|truncatewords:"18" }}
</div>
{% endblock %}
{% block content %}
<div id="content-main">
{% block object-tools %}
<ul class="object-tools">
{% if page.get_absolute_url %}
<li><a target="_blank" href="{{ page.get_absolute_url }}" class="viewsitelink">{% trans "View on site" %}</a></li>
{% endif %}
</ul>
{% endblock %}
<hr/>
<form name="main_form" enctype="multipart/form-data" action="." method="post" id="{{ opts.module_name }}_form">
<div id="overview">
<p style="float:right;" class="deletelink-box"><a href="delete/" class="deletelink">{% trans "Delete" %}</a></p>
{% for field in top_fieldset %}
{{ field.label_tag }}
<span>{{ field }}{{ field.errors }}</span>
{% endfor %}
<input type="submit" class="submit_form" value="{% trans 'Save' %}" />
<hr/>
{{ page_form.template.label_tag }}
<span>{{ page_form.template }}{{ page_form.template.errors }}</span>
<input type="button" class="cancel" value="{% trans 'Change Template' %}" />
<hr/>
</div>
<div id="main_wrapper">
<div class="navi_tab tab_active" id="settings_tab">Settings</div>
{% for region in page.template.regions.all %}<div class="navi_tab tab_inactive" id="{{ region.key }}_tab">{{ region.title }}</div>{% endfor %}
<div id="main">
<div id="settings_body">
<table>
{{ settings_fieldset.as_table }}
</table>
</div>
{% for region in page.template.regions.all %}
<div id="{{ region.key }}_body" class="panel">
<div class="empty-machine-msg">
{% trans "Region empty" %}
</div>
<div class="empty-machine-msg" style="margin-left:20px; margin-top:20px;">
{% if region.inherited %}
{% trans "Content from the parent site is automatically inherited. To override this behaviour, add some content." %}
{% endif %}
</div>
<div class="order-machine">
</div>
<div class="machine-control">
<div class="control-unit">
<span>Add New item:</span> <br/>
<select name="order-machine-add-select">
{% for n,v in content_types %} <option value="{{ v }}">{{ n }}</option> {% endfor %}
</select>
<input type="button" class="order-machine-add-button button" value="OK" />
</div>
<div class="control-unit">
<span>Move selected item to:</span> <br/>
<select name="order-machine-move-select">
{% for r in page.template.regions.all %} {% ifnotequal region r %} <option value="{{ r.key }}">{{ r.title }}</option> {% endifnotequal %} {% endfor %}
</select>
<input type="button" class="order-machine-move-button button" value="OK" />
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<div id="inlines" style="display:none">
{% for formset in inline_formsets %}
<div id="{{ formset.rel_name }}">
<div class="header">
{{ formset.management_form }}
<h3>{{ formset.rel_name }}</h3>
</div>
{% for form in formset.forms %}
<div id="{{ formset.rel_name }}_item_{{ forloop.counter0 }}">
<table>
{{ form.as_table }}
</table>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
</form>
</div>
{% endblock %}

View File

@@ -0,0 +1,145 @@
{% extends "admin/change_list.html" %}
{% load i18n admin_modify adminmedia mptt_tags %}
{% block title %}{{ block.super }}{% endblock %}
{% block extrahead %}{{ block.super }}
<script type="text/javascript" src="../../../jsi18n/"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery-1.3.min.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery.ui.all.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery.livequery.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery.alerts.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}helper.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}listener.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery.treeTable.js"></script>
<script type="text/javascript" src="{{ FEINCMS_ADMIN_MEDIA }}jquery.json-1.3.js"></script>
<script type="text/javascript">
ancestors = [{% for page in object_list %}'{{ page.parent_id|default_if_none:"0" }}'{% if not forloop.last %},{% endif %} {% endfor %}];
tablestr = '';
{% for page in object_list %}tablestr += add_row({{ forloop.counter }}, {{ page.id }}, "{{ page.parent_id|default_if_none:"-1" }}", "{{ page.title }}", ["{{ page.active }}", "{{ page.in_navigation }}"]);
{% endfor %}
function add_row(node_id, page_id, parent_id, page_title, attrs) {
var str = '<tr id="node-' + node_id + '" class="page-id-' + page_id + ' ';
if (parseInt(parent_id) >= 0)
str += 'child-of-node-'+ancestors.indexOf(parent_id);
str += '">';
str += '<td><div class="wrap nohover">';
str += '<div class="insert-as-child"></div>';
str += '<span class="title-col"><a href="'+page_id+'"><strong>'+page_title+'</strong></a><img class="move-node" src="{{ FEINCMS_ADMIN_MEDIA }}img/icon_move.gif" /></span>';
str += '<div class="insert-as-sibling"></div>';
str += '</div></td>';
for (key in attrs)
str += '<td>'+attrs[key]+'</td>';
str += '<td><img class="del-page" src="{{ FEINCMS_ADMIN_MEDIA }}img/icon_deletelink.gif"/></td></tr>';
return str;
}
$(document).ready(function() {
// build table
$("#sitetree tbody").append(tablestr);
// register
$("#sitetree").treeTable();
// configure draggable
$("#sitetree .title-col").draggable({
helper: function(){ return $(this).parent().clone(); } ,
handle: ".move-node",
opacity: .75,
refreshPositions: true,
revert: "invalid",
revertDuration: 300,
scroll: true
});
// configure droppable to insert as child
$("#sitetree .insert-as-child").each(function() {
$(this).droppable({
accept: ".title-col",
tolerance: "intersect",
drop: function(e, ui) {
handle_drop_event($(ui.draggable).parents("tr"), $(this).parents("tr"), "child")
},
over: function(e, ui) {
$(this).parent().removeClass("nohover").addClass("hover-as-child");
},
out: function(e, ui) {
$(this).parent().removeClass("hover-as-child").addClass("nohover");
}
});
});
// configure droppable to insert as sibling
$("#sitetree .insert-as-sibling").each(function() {
$(this).droppable({
accept: ".title-col",
tolerance: "intersect",
drop: function(e, ui) {
handle_drop_event($(ui.draggable).parents("tr"), $(this).parents("tr"), "sibling")
},
over: function(e, ui) {
var row = '<div style="background-color:#bcf; height:4px; width:100%; margin:-8px 0px 4px -5px; position:relative; z-index:10;"></div>'
$(row).insertBefore($(this).parent());
},
out: function(e, ui) {
$(this).parent().prev().remove();
}
});
});
$(".wrap").live('click',function() {
if ($(this).find(".expander").length > 0)
$(this).parents("tr").toggleBranch();
});
$(".save_tree").click(function(){
save_page_tree();
});
$(".del-page").click(function(){
handle_page_delete($(this).parents("tr"));
});
});
</script>
<link rel="stylesheet" type="text/css" href="{{ FEINCMS_ADMIN_MEDIA }}css/layout.css" />
<link rel="stylesheet" type="text/css" href="{{ FEINCMS_ADMIN_MEDIA }}css/jquery.alerts.css" media="screen" />
<link href="{{ FEINCMS_ADMIN_MEDIA }}css/jquery.treeTable.css" rel="stylesheet" type="text/css" />
{% endblock %}
{% block content %}
<div id="content-main">
{% block object-tools %}
{% if has_add_permission %}
<ul class="object-tools"><li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}</a></li></ul>
{% endif %}
{% endblock %}
</div>
<input type="button" value="save tree" class="save_tree" style="margin: 20px 5px -10px 460px;"/>
<div id="sitetree-wrapper">
<table id="sitetree" border="1">
<thead>
<tr id="table_header">
<th width="400">{% trans "Page" %}</th>
<th>{% trans "active" %}</th>
<th>{% trans "in navi" %}</th>
<th>{% trans "delete" %}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
{% endblock %}

View File

@@ -0,0 +1,8 @@
<h2><a href="{{ feed_link }}">{{ feed_title }}</a></h2>
<ul>
{% for entry in entries %}
<li><a href="{{ entry.link }}">{{ entry.title }}</a></li>
{% endfor %}
</ul>