Projet

Général

Profil

« Précédent | Suivant » 

Révision fdcc4265

Ajouté par Frédéric Péters il y a presque 8 ans

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

Voir les différences:

extra/modules/root.py
1 1
from quixote import get_publisher, get_response, get_request, redirect, get_session
2 2
from quixote.directory import Directory
3 3
from quixote.html import TemplateIO, htmltext
4
from quixote.util import StaticDirectory
5 4

  
6 5
from wcs.qommon.misc import get_variadic_url, simplify
7 6

  
......
822 821
        if not self.backoffice:
823 822
            self.backoffice = get_publisher().backoffice_directory_class()
824 823

  
824
        if path and path[0] in self.static_directories:
825
            return self.serve_statics(path)
826

  
825 827
        try:
826 828
            return Directory._q_traverse(self, path)
827 829
        except errors.TraversalError, e:
......
848 850

  
849 851

  
850 852
    def _q_lookup(self, component):
851
        if component == 'qo':
852
            dirname = os.path.join(get_publisher().data_dir, 'qommon')
853
            return StaticDirectory(dirname, follow_symlinks = True)
854

  
855
        if component == 'aq':
856
            dirname = os.path.join(get_publisher().data_dir, 'qommon', 'auquotidien')
857
            return StaticDirectory(dirname, follow_symlinks = True)
858

  
859
        # maps /leaflet/ to the directory provided by the libjs-openlayers package
860
        if component == 'leaflet':
861
            return StaticDirectory('/usr/share/javascript/leaflet')
862

  
863
        if component in ('css','images'):
864
            return OldRootDirectory._q_lookup(self, component)
865

  
866 853
        # is this a category ?
867 854
        try:
868 855
            category = Category.get_by_urlname(component)
setup.py
63 63
            data_tree('share/wcs/themes/auquotidien', 'theme') +\
64 64
            data_tree('share/wcs/themes/', 'data/themes/') + \
65 65
            data_tree('share/auquotidien/apache-errors', 'apache-errors') +\
66
            data_tree('share/wcs/qommon/auquotidien', 'static') +\
67 66
            [('share/wcs/', ['au-quotidien-wcs-settings.xml',])]
68 67
    )
static/js/msp.js
1
$(function() {
2
  var iframe = $('<iframe frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>');
3
  var dialog = $("<div></div>").append(iframe).appendTo("body").dialog({
4
        autoOpen: false,
5
        modal: true,
6
        resizable: false,
7
        width: "auto",
8
        height: "auto",
9
        close: function () {
10
            iframe.attr("src", "");
11
        }
12
  });
13
  $('p.use-file-from-msp span').click(function(e) {
14
    e.preventDefault();
15
    var base_widget = $(this).parents('.file-upload-widget');
16
    document.set_token = function (token, title) {
17
       if (token) {
18
         $(base_widget).find('.filename').text(title);
19
         $(base_widget).find('.fileinfo').show();
20
         $(base_widget).find('input[type=hidden]').val(token);
21
         $(base_widget).find('input[type=file]').hide();
22
       }
23
       document.set_token = undefined;
24
       dialog.dialog('close');
25
    }
26
    var src = $(this).data('src');
27
    var title = $(this).data("title");
28
    var width = $(this).data("width");
29
    var height = $(this).data("height");
30
    iframe.attr({
31
        width: +width,
32
        height: +height,
33
        src: src
34
    });
35
    dialog.dialog("option", "title", title);
36
    dialog.dialog("open");
37
  });
38
});
static/js/strongbox.js
1
$(function() {
2
  $('p.use-file-from-strongbox span').click(function(e) {
3
    var url = $(this).data('url');
4
    var base_widget = $(this).parents('.file-upload-widget');
5
    $.ajax({
6
        url: url,
7
        beforeSend: function(xhr) {xhr.setRequestHeader('X-Popup', 'true'); },
8
        success: function(html) {
9
            console.log('success');
10
            var title = $(html).find('h2').text();
11
            var dialog = $(html).dialog({
12
                modal: true,
13
                title: title,
14
                width: 'auto'
15
            });
16
            $(dialog).find('h2').remove();
17
            $(dialog).find('.buttons a').click(function() { $(dialog).dialog('destroy'); return true;});
18
            $(dialog).find('input[name=cancel]').click(function() { $(dialog).dialog('destroy'); return false;});
19
            $(dialog).find('input[name=pick]').click(function() {
20
                 var json_url = url + '&select=true&val=' + $(dialog).find('input[name=file]:checked').val();
21
                 console.log('json url:', json_url);
22
                 $.getJSON(json_url, function(data, textStatus, jqXHR) {
23
                       console.log('data:', data);
24
                       $(base_widget).find('.filename').text(data.filename);
25
                       $(base_widget).find('.fileinfo').show();
26
                       $(base_widget).find('input[type=hidden]').val(data.token);
27
                       $(base_widget).find('input[type=file]').hide();
28
                     }
29
                 );
30
                 $(dialog).dialog('destroy');
31
                 return false;
32
            });
33
            return false;
34
        }
35
    });
36
    return false;
37
  });
38
});

Formats disponibles : Unified diff