I want to dynamically display a certain server status in an asciidoc (rendered in gitlab)
Something like
:status-server-1: 1
ifeval::[{status-server-1} == 1]
image::green_dot.png[green_dot,20,20]
endif::[]
Now how to dynamically set the attribute?
Is there a way the change the attribute with javascript or similar?
asciidoctor doesn't process JavaScript. It transforms Asciidoc markup to HTML (or other formats). JavaScript only comes into play when the resulting HTML is loaded into a browser.
It would be possible to run a JavaScript program before you run asciidoctor to determine the server status and set an environment variable that could then be used during asciidoctor processing. For example:
STATUS=`node status.js`; asciidoctor -a server_status="$STATUS" <file.adoc>
A different approach would be to use Docinfo files to add custom JS or CSS. Custom JS would allow you to perform an XHR request to discover the current server status and then adjust the classes/styles/images needed to reflect that status.
Related
I have an mydocument.adoc document including a link to the pdf version of itself,
How to not include it in the pdf itself, (generated using asciidoctor-pdf)
... still including it when generating the html-5 version, using asciidoctor ?
// tag::pdflink[]
link:mydocument.pdf[pdf version,window=_blank]
// end::pdflink[]
To conditionally exclude (or include) content, you need to use conditionals.
When you run asciidoctor, the default converter (aka the "backend") is html5. You can wrap the content you want to exclude in a conditional that checks the intrinsic backend attribute:
ifeval::["{backend}" == "html5"]
link:mydocument.pdf[pdf version,window=_blank]
endif::[]
For any other backend, such as the pdf backend, that link won't be included.
See intrinsic attributes for other attributes that asciidoctor sets automatically for you. Any of them can be used in conditionals.
I want to have a template variable pre-processed in a markdown doc.
I tried converting the filename to file.html.md.eco but it just comes out as plain text - ie the markdown plugin doesn't seem to get applied.
The file just as html.md renders fine.
Is it needed to add the plugins to the docpad.coffee to make sure they're applied when using multiple passes?
the FAQ states how to use multiple processors
http://docpad.org/docs/faq
... Alternatively, we can get pretty inventive and do something like this: .html.md.eco which means process this with Eco, then Markdown and finally render it as HTML.
I am using file_get_contents to acquire html. From the html page I extract the css, and js. Right now I am using a very expensive function.
$css_elements = $doc->getElementsByTagName('link');
foreach ($css_elements as $css_element) {
$Jdocument->addStyleSheet($css_element->getAttribute('href'));
}
I would like to save the csss links to a file, and then read the file and add the links as a whole to the head tag of the HTML page.
I was wondering is Joomla has an in build function that allows for one to add unwrapped text to the head tag.
Thanx everyone!
I recommend using the Flexi Custom Code module to do this in Joomla:
http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules/15251
This module allows us to insert any code like php, javascript PHP, CSS and html at site modules positions. For example, It's can be used for simple code, simple function, embed code, adsense code, affiliation code and others copy and paste codes for Joomla site.
Main Features:
1. Available for PHP, HTML, JAVASCRIPT and CSS codes
2. Available to set the target of this module
3. Easy and flexible
When I set a cffunction's access to remote--so I can call it through AJAX--the call returns the HTML I have in my Application.cfm template.
Is there any way around this, or do I have to move the HTML out of Application.cfm?
This would be considered expected behavior. I'd suggest not outputting content within your Application.cfm. Consider using custom tags for wrapping your pages or better yet switch to using Application.cfc and use custom tags.
Is there any way to fetch the raw contents of a CSS file?
Lets imagine that I wanted to fetch any vendor-specific css properties from a CSS file. I would need to somehow grab the CSS contents and parse them accordingly. Or I could just use the DOM to access the rules of a CSS file.
The problem is that in while using the DOM, mostly all browsers (except for <= IE8) tend to strip out all of the custom properties that do not relate to their browser engine (webkit strips out -moz and -o and -ms). Therefore it wouldn't be possible to fetch the CSS contents.
If I were to use AJAX to fetch the contents of the CSS file, then if that CSS file hosted on another domain, then the same origin policy would break and the CSS contents could not be fetched.
If one were to use a cross-domain AJAX approach then there would only be a JSONP solution which wouldn't work since we're not parsing any javascript code (therefore there is no callback).
Is there any other way to fetch the contents?
If a CSS file is on the same domain as the page you're running the script on, you can just use AJAX to pull in the CSS file:
$.get("/path/to/the.css", function(data) {/* ... */});
If not, you could try using Yahoo! Pipes as a proxy and get the CSS with JSONp.
As for parsing, you can check out Sizzle to parse the selectors. You could also use the CSS grammar (posted in the CSS standards) to use a JS lex/yacc parser to parse out the document. I'll leave you to get creative with that.
Good luck!
No, you've pretty much covered it. Browsers other than IE strip out unknown rules from their object models both in the style/currentStyle objects and in the document.styleSheets interface. (It's usually IE6-7 whose CSS you want to patch up, of course.)
If you wanted to suck a stylesheet from an external domain you would need proxy-assisted-AJAX. And parsing CSS from would be a big nasty job, especially if you needed to replicate browser quirks. I would strenuously avoid any such thing!
JSONP is still a valid solution, though it would hurt the eyes somewhat. Basically, in addition to the callback padding, you would have to add one JSON property "padding" and pass the CSS as a value. For example, a call to a script, http://myserver.com/file2jsonp/?jsonp=myCallback&textwrapper=cssContents could return this:
myCallback("cssContents":"body{text-decoration:blink;}\nb{text-size:10em;}");
You'd have to text-encode all line breaks and wrap the contents of the CSS file in quotes (after encoding any existing quotes). I had to resort to doing this with a Twitter XML feed. It felt like such a horrible idea when I built it, but it did its job.