[ome-users] custom omero.web template

William Moore (Staff) W.Moore at dundee.ac.uk
Tue Aug 15 11:07:05 BST 2017


Hi Felix,

 I’m afraid our documentation on these settings is probably not as clear as it should be (and is actually incorrect - see below).

When you say "I use the custom login setting”, could you tell me what bin/omero config setting you used?

Do you mean: bin/omero config set omero.web.index_template 'mytemplate/index.html'

This setting is not for login page (I think the screenshot there is confusing).
The index_template can be used to provide a custom page for the /index/ location of your OMERO.web.

If you do:


bin/omero config set omero.web.index_template ‘webclient/index.html'

This uses the example template at
https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/index.html

Restart your web and visit /index/ of your OMERO.web and you will see the example page.

If you want to customise this, you can copy that example and tweak the contents (e.g. if I only have this code in my ‘login’ block:

{% block login %}
  <form>
    <h2>Custom Login Page</h2>
  </form>
{% endblock %}

Then save this in a new location, e.g. on my Desktop/custom_index.html:

Then I can config: NB: this is INCORRECT in the docs. We’ll fix that ASAP.

NB: single and double quotes
$ bin/omero config append omero.web.template_dirs '"/Users/wmoore/Desktop"'

$ bin/omero config set omero.web.index_template “custom_index.html"

Restart web and now I see this at /index/

[cid:2987515B-A20B-4389-A4CC-A613EC7A1D72 at lifesci.dundee.ac.uk]


If you want to create your own custom login page, you can manually add the <form> fields to your custom template.
WARNINGS:
 - This will mean that these elements will be hard-coded and won’t update as the original login form does (e.g. won’t show a dynamic list of servers in the drop-down list).
 - Also, it could easily break for new releases of OMERO.web that may use different form elements or names.
 - You need to include the {% csrf_token %} tag to dynamically add the CSRF token required for login

For example, this code works for me using current development version of OMERO, giving a form that looks the same as the original (without the ssl checkbox).

{% block login %}
<form class="standard_form inlined" action="/webclient/login/?url=%2Fwebclient%2F" method="post">
  {% csrf_token %}
  <div id="choose_server">
    <select id="id_server" name="server">
      <option value="1">omero:4064</option>
    </select>
  </div>
  <div>
    <label for="id_username">Username:</label>
    <input autofocus="autofocus" id="id_username" maxlength="50" name="username" size="22" type="text" />
  </div>
  <div>
    <label for="id_password">Password:</label>
    <input autocomplete="off" id="id_password" maxlength="50" name="password" size="22" type="password" />
  </div>
  <input type="submit" value="Login" />
  <div>
    <p><a href="/webadmin/forgottenpassword/">Forgot your password?</a></p>
  </div>
</form>
{% endblock %}


If you are happy to test your form before each upgrade of OMERO then this approach should work OK for you.

I’ll update our docs to fix the bug and make this setting clearer,

 Regards,

  Will.



On 14 Aug 2017, at 18:18, MEYENHOFER Felix <felix.meyenhofer at unifr.ch<mailto:felix.meyenhofer at unifr.ch>> wrote:

Hey Will

thanks for the info.

I use the custom login setting. But this is not picked up either in the context for the index page.

What confuses me a bit, is that in the example of the customization
https://docs.openmicroscopy.org/omero/5.3.3/sysadmins/customization.html#index-page
... the login form seems to work.

in the current state of OMERO.web would this require modification of the index view, would it not?

Felix

On 31 Jul 2017, at 14:49, William Moore (Staff) <W.Moore at dundee.ac.uk> wrote:

Hi Felix,

One option to make smaller customisations of the login page is to add a custom logo: See https://docs.openmicroscopy.org/omero/5.3.3/sysadmins/config.html#omero-web-login-logo.

Otherwise, if you want a more-customised login page, you’ll have to add the form elements to your template instead of using {{ block super }}.

Let us know if you have any more details on what you’d like to achieve,

Regards,

 Will.



On 21 Jul 2017, at 21:15, William Moore (Staff) <wmoore at dundee.ac.uk> wrote:

Hi Felix,

If you want to display the login form, then this needs to be included in the context that
is used to render the page.

See the context that is prepared in ‘handle_not_logged_in()’ at
https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroWeb/omeroweb/webclient/views.py#L220
which includes several variables required by the login page, including the LoginForm required within the {% block login %}.

As you can see here, the Custom page doesn’t include any of these in it’s context.
https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroWeb/omeroweb/webclient/views.py#L149

I’m away on holiday this week, but can give your requirements a bit more thought when I’m back next week…

Regards,

 Will.




On 21 Jul 2017, at 11:53, MEYENHOFER Felix <felix.meyenhofer at unifr.ch> wrote:

Hi

I was playing around with the customization of the web templates. There is the possibility to set a custom index page:;
https://www-legacy.openmicroscopy.org/site/support/omero5.3/sysadmins/customization.html#index-page

So I went and used the webclient/index.html template, which works fine. But then I tried to add the login form on the same page by inserting
{{ block.super }}
into the (% block login %}

the result is not quite what I expected (see screenshot)
https://drive.switch.ch/index.php/s/lTL00RDleui3XFC
When inspecting the page source code, there are comments <!--Form Error-->, where the fields from the login form should appear.

I could not find anything in the omero.web logs nor in the nginx logs.

Is there another easy explanation for this?

Best,

Felix
_______________________________________________
ome-users mailing list
ome-users at lists.openmicroscopy.org.uk
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users



The University of Dundee is a registered Scottish Charity, No: SC015096
_______________________________________________
ome-users mailing list
ome-users at lists.openmicroscopy.org.uk
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users

_______________________________________________
ome-users mailing list
ome-users at lists.openmicroscopy.org.uk
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users


The University of Dundee is a registered Scottish Charity, No: SC015096
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-users/attachments/20170815/dcc3bf85/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2017-08-15 at 10.12.46.png
Type: image/png
Size: 40307 bytes
Desc: Screen Shot 2017-08-15 at 10.12.46.png
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-users/attachments/20170815/dcc3bf85/attachment.png>


More information about the ome-users mailing list