Motivating users to move to a new Oxygen release

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
chrispitude
Posts: 326
Joined: Thu May 02, 2019 2:32 pm

Motivating users to move to a new Oxygen release

Post by chrispitude » Wed Mar 03, 2021 7:31 pm

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: 829
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu » Thu Mar 04, 2021 5:04 pm

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: 326
Joined: Thu May 02, 2019 2:32 pm

Re: Motivating users to move to a new Oxygen release

Post by chrispitude » Thu Mar 11, 2021 5:56 pm

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: 829
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu » Fri Mar 12, 2021 2:07 pm

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: 326
Joined: Thu May 02, 2019 2:32 pm

Re: Motivating users to move to a new Oxygen release

Post by chrispitude » Fri Mar 12, 2021 10:23 pm

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: 829
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu » Mon Mar 15, 2021 4:09 pm

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: 326
Joined: Thu May 02, 2019 2:32 pm

Re: Motivating users to move to a new Oxygen release

Post by chrispitude » Fri Mar 19, 2021 4:34 pm

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 342 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 342 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 23 times

alex_jitianu
Posts: 829
Joined: Wed Nov 16, 2005 11:11 am

Re: Motivating users to move to a new Oxygen release

Post by alex_jitianu » Tue Mar 23, 2021 9:47 am

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

Post Reply