general: adapt to wcs changes in static files (#11355)

This commit is contained in:
Frédéric Péters 2016-06-14 23:32:52 +02:00
parent 71dc5cecd9
commit fdcc42658b
4 changed files with 3 additions and 93 deletions

View File

@ -1,7 +1,6 @@
from quixote import get_publisher, get_response, get_request, redirect, get_session
from quixote.directory import Directory
from quixote.html import TemplateIO, htmltext
from quixote.util import StaticDirectory
from wcs.qommon.misc import get_variadic_url, simplify
@ -822,6 +821,9 @@ class AlternateRootDirectory(OldRootDirectory):
if not self.backoffice:
self.backoffice = get_publisher().backoffice_directory_class()
if path and path[0] in self.static_directories:
return self.serve_statics(path)
try:
return Directory._q_traverse(self, path)
except errors.TraversalError, e:
@ -848,21 +850,6 @@ class AlternateRootDirectory(OldRootDirectory):
def _q_lookup(self, component):
if component == 'qo':
dirname = os.path.join(get_publisher().data_dir, 'qommon')
return StaticDirectory(dirname, follow_symlinks = True)
if component == 'aq':
dirname = os.path.join(get_publisher().data_dir, 'qommon', 'auquotidien')
return StaticDirectory(dirname, follow_symlinks = True)
# maps /leaflet/ to the directory provided by the libjs-openlayers package
if component == 'leaflet':
return StaticDirectory('/usr/share/javascript/leaflet')
if component in ('css','images'):
return OldRootDirectory._q_lookup(self, component)
# is this a category ?
try:
category = Category.get_by_urlname(component)

View File

@ -63,6 +63,5 @@ distutils.core.setup(
data_tree('share/wcs/themes/auquotidien', 'theme') +\
data_tree('share/wcs/themes/', 'data/themes/') + \
data_tree('share/auquotidien/apache-errors', 'apache-errors') +\
data_tree('share/wcs/qommon/auquotidien', 'static') +\
[('share/wcs/', ['au-quotidien-wcs-settings.xml',])]
)

View File

@ -1,38 +0,0 @@
$(function() {
var iframe = $('<iframe frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>');
var dialog = $("<div></div>").append(iframe).appendTo("body").dialog({
autoOpen: false,
modal: true,
resizable: false,
width: "auto",
height: "auto",
close: function () {
iframe.attr("src", "");
}
});
$('p.use-file-from-msp span').click(function(e) {
e.preventDefault();
var base_widget = $(this).parents('.file-upload-widget');
document.set_token = function (token, title) {
if (token) {
$(base_widget).find('.filename').text(title);
$(base_widget).find('.fileinfo').show();
$(base_widget).find('input[type=hidden]').val(token);
$(base_widget).find('input[type=file]').hide();
}
document.set_token = undefined;
dialog.dialog('close');
}
var src = $(this).data('src');
var title = $(this).data("title");
var width = $(this).data("width");
var height = $(this).data("height");
iframe.attr({
width: +width,
height: +height,
src: src
});
dialog.dialog("option", "title", title);
dialog.dialog("open");
});
});

View File

@ -1,38 +0,0 @@
$(function() {
$('p.use-file-from-strongbox span').click(function(e) {
var url = $(this).data('url');
var base_widget = $(this).parents('.file-upload-widget');
$.ajax({
url: url,
beforeSend: function(xhr) {xhr.setRequestHeader('X-Popup', 'true'); },
success: function(html) {
console.log('success');
var title = $(html).find('h2').text();
var dialog = $(html).dialog({
modal: true,
title: title,
width: 'auto'
});
$(dialog).find('h2').remove();
$(dialog).find('.buttons a').click(function() { $(dialog).dialog('destroy'); return true;});
$(dialog).find('input[name=cancel]').click(function() { $(dialog).dialog('destroy'); return false;});
$(dialog).find('input[name=pick]').click(function() {
var json_url = url + '&select=true&val=' + $(dialog).find('input[name=file]:checked').val();
console.log('json url:', json_url);
$.getJSON(json_url, function(data, textStatus, jqXHR) {
console.log('data:', data);
$(base_widget).find('.filename').text(data.filename);
$(base_widget).find('.fileinfo').show();
$(base_widget).find('input[type=hidden]').val(data.token);
$(base_widget).find('input[type=file]').hide();
}
);
$(dialog).dialog('destroy');
return false;
});
return false;
}
});
return false;
});
});