Use local assets in SonarQube 6.3.1 custom plugin's web page - plugins

I would like to insert some pictures in my custom web page for SonarQube 6.3.1. I tried to put it in resources/static like javascript files and call it with <img src="image.png"></img>but it doesn't work.
I do not really understand how SonarQube manage custom pages within the static folder. I followed the official guide but I do not understand for example how to use external resources (images, html templates, etc.) in the js file of my page.
Thank you for your help,
BenoƮt

I have finally found how to use my assets:
Put your assets in src/main/ressources/static, for example I added an image here src/main/ressources/static/images/loading.gif
Let myplugin my plugin's identifier
I am able to use my gif in src/main/ressources/static/page.js like this <img src="../../static/myplugin/static/images/loader.gif"></img>
Maybe it can help somebody...

Related

Neos CMS: Add <script> to HTML element

i'm trying to add <script> ... </script> to HTML element in Neos CMS, could you please tell me how to do it, because HTML element in Neos CMS doesn't accept js. Is there any alternative how to do it please. Thanks for any recommendations.
There is a package available with wich the editor can add source code like that. But be careful with this feature as with great power (of the editor) comes great responsibility!
Depending on what your use case is, it may be more secure to provide a custom NodeType for the editor which then adds this JS code via fusion.
One thing you may want to think about is loading things from external sources might be problematic for GDPR compliance.

Loading a Vue file's content into a JavaScript variable for routing

I've been trying to use the vue-router package for days without figuring out how it works, and it kind of drives me crazy.
My problem: I want to make a Single Page Application using VueJS, and I have taken the vue-router package since it is the routing package officially supported by the VueJS development team.
I've read a lot of "getting started" articles, lots of them start by hard-writing the template like this:
const Foo = { template: '<div>foo</div>' }
But since I'm not really into writing my entire template between those two quotes marks, I searched for a way to write my template into a file, and then load the file's content into a JS variable.
It seems that it's possible to write the templates into .vue files, and then load them into variables using:
import App from './App.vue';
But when I do this that way I get this error: "Unexpected token import".
I'm really frustrated by that, haven't they thought about a really convenient way for the template loading to be compatible on every browser? What did I miss?
I suggest you look into Vue CLI for helping you set up a desired scaffold for your project. Based on the options you choose you can end up with a webpack backed template along with the vue-router included. Webpack will take care of bundling your project so you don't encounter errors like that one.
Generally what you want to do is use vue files. A vue file is divided into three parts, and would look something like this:
<template>
// Your HTML for this component goes here
</template>
<script>
// Your JS for this component goes here
</script>
<style>
// Your CSS for this component goes here
</style>
Once you have your components organized like this, handling routing is pretty straightforward. You designate a file to contain the router object that handles the routing.
These are pretty much basics, so I won't go into details here but you can learn a lot more on the official Vue docs page. Here is also an example project that shows how to construct simple components in vue files and how to properly use the vue-router.

How to create a base template and use it to wrap other templates in Ionic framework?

I couldn't find anything about this. basically i want to create a base template, with all the head tag and container in body or menu, etc... so that other templates can extend it.
how would i achieve this with Ionic framework?
The way you have phrased your question leads one to think you have not quite understood how Ionic works...
A typical Ionic app has only one index.html file with a <head>. The rest of the .html files are just content templates to be rendered as the content of that page. So you don't need the "base template" you are asking about, that is all taken care of by Ionic, from the index.html.
I would suggest reading and following http://ionicframework.com/docs/guide/starting.html

Ionic adding pages

I just started using the ionic-framework and I know that with jQueryMobile you need to add the pages inside the same html with a page id and link to it.
But how do multiple pages work with the Ionic Framework?
On this example:
http://codepen.io/ionic/pen/AjgEB
I see that they use
<script id="file.html" type="text/ng-template">
Am I supposed to do it that way?
No. Normally, one adds the pages in separate files.
The above notation is just used for codepens or similar sites, where you can not add additional files into your online code.
You should take a look at an ionic starter app. Create one by writing
ionic start myApp
into your console.
This may be old post, but i created a tool with ability to generate ionic seed apps with all required pages. For ex., if you need a profile page for your app, using this tool, you can specify pages you need and it will generate the app with all necessary files and references in index.html.
Link for the tool:
http://ionic-sarav.rhcloud.com/#/ionicbuilder/home

How to add CSS, Images to a page in CQ5?

I am creating a new template and then a page from SCRATCH in CQ5. But I can't find the option to add my own CSS/images/JS to the page.
I mean a place to add/upload the actual files.
All the tutorials I've seen talk only about creating a template based on an existing template. Is there any tutorial on how to create the page from scratch ?
Your CSS and JavaScript go into nodes under /etc/designs/[your project's name]/clientlibs. (Ordinarily, you would set the page property cq:designPath of your content's home page to be /etc/designs/[your project's name] to point to this.) It's common practice to set up a subfolder of clientlibs called default, where your general-purpose style sheets and JavaScript go; you can set up other clientlibs for special-case script and style sheets. The simplest way to incorporate your script and style sheets into your page template is the <cq:includeClientLib> JSP tag.
The Adobe docs on clientlibs will also be useful to you, and explains how to use the tag.
#David , thanks for your answer, but for now, I got a better way to add and then use external files using WebDAV with CQ5.
The basic integration of WebDAV with CQ5 application is mentioned in this page