Forum OpenACS Q&A: Directly editable CSS in Xowiki?

Collapse
Posted by Richard Hamilton on
I have been using applying CSS files to xowiki FormPages by adding [[css:my_styles.css]] to the Form specification. The ability to add CSS in this way is very flexible and powerful.

Changes to a CSS file applied like this require that the current version be downloaded, edited in a local editor, and re-submitted to the site. The results can then be checked by re-loading the FormPage.

It strikes me that it would be very convenient if a CSS file for a page could be stored as a normally editable xowiki page. This would allow the CSS to be altered by using Xinha or Wym within the browser.

I imagine a syntax as follows:

[[css:{{en:my_styles}}]]

Is this possible in Xowiki at present?

Regards
Richard

Collapse
Posted by Michael Aram on
I am currently using an ::xowiki::Object to realize a similar scenario, i.e. I am using the extra_css parameter of the wiki instance, which points to the Object. I am not using the css: syntax.

The Object's content looks like this:

my proc generate_css {} {
set content "
/* This Stylesheet is generated by an ::xowiki::Object */
.xowiki-content h1 { font-size: 200%; }
.xowiki-content h2 { font-size: 150%; }
.xowiki-content h3 { font-size: 120%; }
"
return $content
}

my proc content {} {
ns_return 200 text/css [my generate_css]
}

This allows for "online editing" of the styles. However, one disadvantage of this approach is, that this object is always among the "recently visited" and "most popular" pages of my wiki instance.

Collapse
Posted by Richard Hamilton on
Michael,

Brilliant idea. Of course, a 'programmable' Xowiki object containing program code to return a simple text stream, referenced in the extra_css parameter.

Wouldn't it be great if this could also be referenced using the css: syntax? In fact, if it were possible to pass any Xowiki object to the css: syntax, it would eliminate the need to embed program code. I guess however that any referenced objects would still appear in the recently visited list.

Perhaps it would also be possible to modify the weblog code to exclude specific objects and their descendent objects from consideration. Thus any objects stored in a folder that you specifically exclude would not appear.

Anyway, thank you for the tip, this grants the immediate wish! 😊

R.