Page 1 of 1

how to extend omero web without modifying the default

PostPosted: Fri Jun 24, 2011 8:29 pm
by bhcho
Hi all,

We are eventually trying to put our codes into omeroweb/searcher.

0.
if we want create "searcher" folder under "omeroweb", we need to modify the setting.py for INSTALLED APP to include omeroweb.searcher, right?

1.
And also in that new folder, we need to write
__init__.py,
urls.py
views.py

is there any restrictions with these files? If there is basic sample files for them, please send me.

2. About the inheritance of the default template pages (such as base.html) .
The basic template files are under /omeroweb/webclient/templates/...

Can you explain how to use those basic template files from an app under /omeroweb/searcher/ ?
I'm asking this question because it looks like the functions in template_loader can only load those template in the same folder.
For example, in the views.py under omeroweb/webclient (I'm playing with omero 4.2.1), the following line

template = "webclient/login.html"

refers to the login.html file under /omeroweb/webclient/templates/webclient/login.html

If I want to use the same login.html file from my own app under /omeroweb/searcher/views.py, could you tell me how to do?


3.
A technically general question about javascript.
We added a button on a default omero web page and when you click it, it executes a javascript function like the following,

Code: Select all
function relevance_feedback_entireDB() {
    if (!isCheckedById("image")) {//&& !isCheckedById("dataset") && !isCheckedById("plate")) {
        alert ("Please select at least one image. Currently you cannot add other objects to basket.");
    } else {
        var productArray = $("input[type='checkbox']:checked");
        var productListQuery = "";
        var datasetID = "0";
        var featureset = "SLF34";
        var numretrieve = "10";

        if (productArray.length > 0 ) {
            productArray.each(function() {
                if(this.checked) {
                    productListQuery += this.id + ",";
                }
            });
        } else {
            productListQuery += productArray.id + ",";
        }
       
        URL = productListQuery+'/'+datasetID+'/'+featureset+'/'+ numretrieve+'/';
          window.location = 'http://omepslid.compbio.cs.cmu.edu/webclient/relevance/' + URL + '';
    }
   
    return false;
}

and it will call our app under /webclient/relevance/.
But, the line at the bottom

Code: Select all
window.location = 'http://omepslid.compbio.cs.cmu.edu/webclient/relevance/' + URL + '';


should be definitely modified to make this function work on any server.
Could you tell me how to do this? (there could be a global variable that directs to the url of the local server)



Best,
BK

Re: how to extend omero web without modifying the default

PostPosted: Thu Jun 30, 2011 3:01 pm
by wmoore
Hi BK,

Most of your questions are answered on the "How to create an app" page that I'm currently editing

http://trac.openmicroscopy.org.uk/ome/w ... /CreateApp

Briefly:

0. Correct - You have to add "searcher" to the INSTALLED APP list in settings.py and also add it to the urls lists in omeroweb/urls.py (should be obvious from the other examples there).

1. For very basic samples, see the link above.

2. I think you should be able to use "webclient/login.html" from another app. I haven't tried this, but I think the reason that the templates are in folders called E.g. webclient/templates/webclient/login.html means that the second "webclient" folder in that path can be used to refer to webclient templates from other apps. See https://docs.djangoproject.com/en/dev/r ... -templates

You can also "extend" templates between apps (see the index.html example code at the above link).

3. At a guess, does this work?
Code: Select all
window.location = '/webclient/relevance/' + URL + '';


The other thing you can try, if the javascript is in a Django html page (not in static media), then you can use Django template to add links into the javascript. This can make the javascript a little ugly but allows you to use "named" Django urls and could solve your problem:
E.g.
Code: Select all
window.location = "{% url relevance URL %}"';


Have a look at webtest/index.html for some examples of this technique to generate thumbnail urls from webgateway.

NB: If your app is "relevance" then the url will not contain "webclient"? Like this?
Code: Select all
http://omepslid.compbio.cs.cmu.edu/relevance/


Will.