openshift-evangelists / workshopper

Workshop content rendering tool
63 stars 40 forks source link

Ability to supply custom CSS or JS #59

Open jamesfalkner opened 6 years ago

jamesfalkner commented 6 years ago

This particular RFE is because, by default Markdown links like [some text](http://somelink) will open in the same browser tab, taking the user away from the workshopper content. It would be nice to automatically declare (via CSS or some other mechanism, not sure which is best) that every link should open in a new tab.

As a workaround, I currently add {:target="_blank"} to every single link (in Markdown) and that's kinda ugly (but not super painful).

marekjelen commented 6 years ago

How do you handle this in your content @jorgemoralespou @siamaksade @thoraxe ?

thoraxe commented 6 years ago

I have not been handling it at all in ops content.

jorgemoralespou commented 6 years ago

@marekjelen, I don't think I've care about this, but it's a good idea.

siamaksade commented 6 years ago

Low prio

GrahamDumpleton commented 5 years ago

FWIW. Have similar requirement.

As first pass on solution, am going to add in a workshopper.css and workshopper.js in public directory and then update app/views/layouts/application.html.erb to include workshopper.css in <head> and include workshopper.js at end of <body>. The two files will be empty but could then be replaced, by either replacing the files themselves, or possibly allowing an environment variable to be set which extends list of paths checked for static files so overrides can be found in an alternate directory first.

Suggestions on how to better integrate welcome.

GrahamDumpleton commented 5 years ago

Once have this capability for workshopper.css and workshopper.js that you can safely override, someone wanting custom application, can drop in workshopper.js file containing:

$(document).ready(function() {
    $('div#lab-content a').each(function() {
        if (!(location.hostname === this.hostname || !this.hostname.length)) {
            $(this).attr('target','_blank');
        }
    });
});

Thus, any external link will have target set to _blank and open in a new browser window/tab.