Motivating users to move to a new Oxygen release

Having trouble installing Oxygen? Got a bug to report? Post it all here.
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Motivating users to move to a new Oxygen release

Post by chrispitude »

Hi all,

We have a Git-hosted Oxygen project used by about 40 participating writers.

The upcoming release of Oxygen v23.1 has me thinking... what's the best way for me to centrally encourage users to upgrade to the new Oxygen version, but only after I qualify it for use?

If I could find some way to query the Oxygen version from CSS, I could maybe do something like

Code: Select all

:root[-oxy-variable('oxygenVersion') < 23.1)]:before {
 display: block;
 border: 3pt green solid;
 background-color: lightgreen;
 padding: 10pt;
 content: 'Click here to download the latest version of Oxygen XML Author';
 font-size: 16pt;
 -oxy-link: 'https://www.oxygenxml.com/xml_author/download_oxygenxml_author.html';
 text-decoration: underline;
 color: navy;
}
Then by editing the numeric value in the CSS comparison, I can control what Oxygen versions are considered "old" in the CSS file that everyone shares.

Is there a way to query the Oxygen version from CSS? (I made up the oxygenVersion variable; I didn't see it listed in the variables list at https://www.oxygenxml.com/doc/versions/ ... ables.html.)
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu »

Hi Chris,

Unfortunately, such an editor variable doesn't exist. Moreover, we don't expand editor variables in selectors. An Oxygen plugin could use our Java API to detect the Oxygen version and present a notification to the user. The approved version could be in a configuration file or it could sit somewhere on a server and the plugin could read it from there.

I will also add an issue to add a new property, versionGreaterThan, in the @oxygen media type :

Code: Select all

@media oxygen AND  (versionGreaterThan:"23.1") {
   :root {
       content: 'Click here to download the latest version of Oxygen XML Author';
       font-size: 16pt;
      -oxy-link: 'https://www.oxygenxml.com/xml_author/download_oxygenxml_author.html';
    }
}
Best regards,
Alex
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Motivating users to move to a new Oxygen release

Post by chrispitude »

Hi Alex,

Since we're discussing CSS-driven writer reminders, is there a way to query the filename of the current file being edited and display something accordingly? For example, a .dita topic filename has "/_warehouse/" in the directory ancestory, I would want to display a reminder banner to check all references before modifying and committing content.

This is admittedly well beyond what CSS was intended for.
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu »

Hi Cris,

It can be done with the help of oxy_xpath :

Code: Select all

:root:before {
    display: block; 
    color: red;
    content: 
        oxy_xpath("if (contains(base-uri(), '/_warehouse/')) then ('REUSABLE TOPIC') else ('')", evaluate, static);
}
I've marked the XPath as static because otherwise Oxygen would recompute and relayout the element after each change in the document.

Anyway, perhaps an Oxygen plugin that intercepts the save event and warns the user would be more robust,

Best regards,
Alex
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Motivating users to move to a new Oxygen release

Post by chrispitude »

Alex, this is close!! But unfortunately, the CSS selectors to get attention are always applied, and only the content appears or disappears. :(

I thought maybe I could use oxy_label() to apply conditional formatting from the XPath expression, but I get the literally 'oxy_label(...)' text as content:

Code: Select all

content: oxy_xpath("if (contains(base-uri(), '/_warehouse/')) then ('oxy_label(text, \"WAREHOUSE TOPIC\")') else ('')", evaluate, static);
It's too bad we can't somehow use an XPath expression in the :root selector itself to conditionally apply the whole block. Don't spend any more time on this, it was just wishful thinking to give writers an automatic heads-up. I know there's a lot I can do with Java and plugins, but I don't know that stuff yet.
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu »

Hi,

You can use a unique pseudo-element, intended for this label only:

Code: Select all

:root:before(100) {
.....
}
If the content is empty, because of the XPath result, the pseudo-element will not be rendered. In your case I suspect that there is another rule that also matches on :root:before and comes with a different content.

You can use oxy_label too, but put it on the outside:

Code: Select all

:root:before(100) {
    display: block; 
    content: 
        oxy_label(
        text, oxy_xpath("if (contains(base-uri(), '/_warehouse/')) then ('REUSABLE TOPIC') else ('')", evaluate, static), 
        width, 10em, 
        color, red) ;
}
Best regards,
Alex
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Motivating users to move to a new Oxygen release

Post by chrispitude »

Hi Alex,

I'm just exploring this to see where it goes. There's no urgency or need to continue if this proves to be nontrivial.

I created a standalone Oxygen project with only

/* show that CSS is active */
:root { background-color: yellow; }

Code: Select all

:root:before(100) {
    display: block; 
    content: 
      oxy_label(
        text, oxy_xpath("if (contains(base-uri(), '/_warehouse/')) then ('REUSABLE TOPIC') else ('')", evaluate, static),
        width, 10em, color, red, background-color, pink, text-align, center);
}
applied. When the selector matches, I get the banner:

image.png
image.png (2.51 KiB) Viewed 2411 times

but when the selector doesn't match (I change "_warehouse_" to "_Xwarehouse_"), then the banner block element does not disappear; it just becomes empty:

image.png
image.png (1.98 KiB) Viewed 2411 times

I'm attaching the testcase. Just apply the "+ Warehouse CSS" style in the Styles drop-down. What do you think?
oxygen_warehouse_topic_banner.zip
(23.52 KiB) Downloaded 323 times
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu »

Hello,

Now I understand. It is a series of unfortunate events that leads to that empty block. Both a display: block and the usage of oxy_label() have this effect. I will add an issue to investigate. Meanwhile, it works if you write the rule like this:

Code: Select all

:root:before(100) {
    display: inline; 
    width: 10em;
    content: oxy_xpath("if (contains(base-uri(), '/_warehouse/')) then ('REUSABLE TOPIC') else ('')", evaluate, static);
    background-color: pink;
    color: red;
    text-align: center;
}
Best regards,
Alex
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Motivating users to move to a new Oxygen release

Post by chrispitude »

alex_jitianu wrote: Thu Mar 04, 2021 5:04 pmI will also add an issue to add a new property, versionGreaterThan, in the @oxygen media type :

Code: Select all

@media oxygen AND  (versionGreaterThan:"23.1") {
   :root {
       content: 'Click here to download the latest version of Oxygen XML Author';
       font-size: 16pt;
      -oxy-link: 'https://www.oxygenxml.com/xml_author/download_oxygenxml_author.html';
    }
}
Hi Alex,

Is there an issue ID for the versionGreaterThan CSS property idea you mentioned?
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu »

Hi Chris,

The issue ID is EXM-47521 . Looking over the thread again, I think the versionLessThan variant is the one you need.

Best regards,
Alex
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Motivating users to move to a new Oxygen release

Post by chrispitude »

Hi Alex,

Feel free to close EXM-47521. I have filed an enhancement request to have a minimum Oxygen release parameter stored directly in the .xpr file, rather than using CSS to check it indirectly.
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu »

Hi Chris,

I've added your note on the issue, but I will leave it open for awhile. Perhaps we will discover other scenarios in which that feature would be of help.

Best regards,
Alex
Post Reply