Skip to content
This repository was archived by the owner on Nov 23, 2026. It is now read-only.
This repository was archived by the owner on Nov 23, 2026. It is now read-only.

Allow to include custom js/html when running ocis web #4735

Closed

Description

@labkode

As and admin I will like to configure ocis web to include snippets of html or js code at runtime without having to compile the whole sourcecode.

The goal is to add tracking Js/ feedback forms directly in the UI when running ocis web --include-js /etc/track.js.

These scripts can be included in the <head> element.

The same functionality can be used to create announcement/interventions banner for the user of the service.

For example, a JIRA banner to collect feedback:

Screenshot 2021-02-11 at 12 17 54

Activity

  1. kulmann commented on Feb 11, 2021

    @kulmann
    Contributor

    I agree that we need this.

    The way we would want to configure this is probably via the config.json. ocis web can get its own arguments for configuring this via CLI.

  2. labkode commented on Feb 11, 2021

    @labkode
    Author

    @kulmann did I read correctly that when running ocis server I can have a custom config for the web service?

  3. kulmann commented on Feb 11, 2021

    @kulmann
    Contributor

    @kulmann did I read correctly that when running ocis server I can have a custom config for the web service?

    Yes, you can provide a custom config file for the web service by running it with WEB_UI_CONFIG="/path/to/config" ocis server.

  4. labkode commented on Feb 11, 2021

    @labkode
    Author

    @kulmann that is nice, do you have at hand what could be changed there? If there are some branding options we can start already playing with it.

  5. kulmann commented on Feb 11, 2021

    @kulmann
    Contributor

    @kulmann that is nice, do you have at hand what could be changed there? If there are some branding options we can start already playing with it.

    It is still the same config like for oC Web with oc10. You can find an example here: https://github.com/owncloud/web/blob/master/config/config.json.sample-ocis

    There are plans to refine the way to load extensions. Right now there are three different keys in the json file for loading extensions. We want to have only one.

    For branding we will come up with a proper solution for this: https://github.com/owncloud/web/tree/master/packages/web-container/themes which will allow to configure the design tokens as well.

    Since we want to maintain compatibility of oC Web with both oC10 and oCIS backends, the config.json is our preferred way for configuration for now.

  6. labkode commented on Feb 11, 2021

    @labkode
    Author

    Thanks @kulmann , what is the recommend way to configure web?

    I've already defined the following configuration env:

    WEB_OIDC_AUTHORITY=https://auth.cern.ch/auth/realms/cern
    WEB_OIDC_METADATA_URL=https://auth.cern.ch/auth/realms/cern/.well-known/openid-configuration
    WEB_OIDC_CLIENT_ID=xxxx
    WEB_UI_CONFIG_SERVER=xxxx
    

    Should I move these env variables to the file and then only use WEB_UI_CONFIG="/path/to/config ?

  7. kulmann commented on Feb 12, 2021

    @kulmann
    Contributor

    @labkode no recommended way. I can draw a picture of pros and cons:

    • using the WEB_UI_CONFIG env var pushes everything into one file (everything in one place), but that will internally load the file on every page load. It also means that you can make changes in the file and a page reload is sufficient, no service restart required.
    • using all the individual env vars keeps everything in memory - but it requires a service restart to take effect.
  8. pascalwengerter commented on May 7, 2021

    @pascalwengerter
    Contributor

    @labkode let's further narrow down the definition of done for this task in a scope that adds value to you/CERN!

    Acceptance criteria
    You can

    • define a number of (remote) scripts in the web config.json
    • optionally can be configured to be async or deferred (see the script docs for details)

    Example:

      "apps": [
        "files",
        "media-viewer"
      ],
      "scripts": [
        {
          "path": "https://example.com/additional.js"
        },
        {
          "path": "https://another-example.com/custom.js",
          "async": "true",
          "defer": "false"
        }
      ],
      "external_apps": [
        {

    These scripts

    • get inserted at the end of the <body> of the web container
    • load additional HTML/JS/CSS that we are taking no guarantee for
    • are not scoped to a specific extension
  9. labkode commented on May 7, 2021

    @labkode
    Author

    Hi @pascalwengerter, one more item:
    When defining the scripts, can we specify a local path like:

      "apps": [
        "files",
        "media-viewer"
      ],
      "scripts": [
        {
          "path": "/var/html/myscripts/tracking.js",
          "async": "true",
          "defer": "false"
        }
      ],
    
    
  10. pascalwengerter commented on May 11, 2021

    @pascalwengerter
    Contributor

    Hi @pascalwengerter, one more item:
    When defining the scripts, can we specify a local path like:

      "apps": [
        "files",
        "media-viewer"
      ],
      "scripts": [
        {
          "path": "/var/html/myscripts/tracking.js",
          "async": "true",
          "defer": "false"
        }
      ],
    

    I'll update the acceptance criteria with the ability of loading scripts from a local path, however giving the learnings from the same topic with theming makes me slightly pessimistic that this will be feasible soon (given oCIS's nature of being a compiled binary and the testability of local files in our CI).

    Is loading scripts locally a hard requirements from your side, or can the job be done by using remote ones for now? Also, can I assume that you're content with the other characteristics of the approach I outlined above?

  11. diocas commented on May 16, 2021

    @diocas
    Contributor

    Can we also have a way to import CSS in the exact same way? I know we can use branding, but that only allows us to set some variables and @elizavetaRa and I were discussing and we think it would be a good addition.

  12. kulmann commented on May 16, 2021

    @kulmann
    Contributor

    Can we also have a way to import CSS in the exact same way? I know we can use branding, but that only allows us to set some variables and @elizavetaRa and I were discussing and we think it would be a good addition.

    Yes, absolutely! Loading custom css was already in a small PoC, we could bring it to the product easily.

  13. labkode commented on May 17, 2021

    @labkode
    Author

    We need an agile process to test changes in the ocis deployment. If changes can happen without having to re-compile is the easiest approach (like it was in OC10 with the theming apps).

  14. pascalwengerter commented on May 18, 2021

    @pascalwengerter
    Contributor

    We need an agile process to test changes in the ocis deployment. If changes can happen without having to re-compile is the easiest approach (like it was in OC10 with the theming apps).

    Agreed, and this would be possible both by referencing external scripts (e.g. through https://raw.githubusercontent.com/example-script.js) or by having them load from a local path (which, as stated above, may be harder to implement and therefore take longer) - no need to recompile oCIS, however it works differently than in OC10

  15. fschade commented on Sep 26, 2022

    @fschade
    Contributor

    done in #7689, currently only for the experimental branch, can be backported later.

  16. fschade commented on Feb 14, 2023

    @fschade
    Contributor

    @labkode finally backported, #8432.
    cc.: @dragotin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions