URL of a file in WebContent folder of an XPages project - xpages

I want to import font awesome in xpages. I have found that importing files in Webcontent folder makes them accessible from xpages but i cannot find the url to refer to them.
Now i have the whole folder of font awesome under WebContent folder and i want to import as a resource to the xpage the stylesheet file: WebContent/font-awesome-4.3.0/css/font-awesome.css
i am using this code
<xp:this.resources>
<xp:styleSheet href="WebContent/font-awesome-4.0.3/css/font-awesome.css"></xp:styleSheet>
</xp:this.resources>
and i have tried many different url in href attribute.
What is the correct url?

It is the correct location. The url should be without WebContent/.

Related

Embed pdf in .ejs file

I have a web app using express.js and I've tried to embed a pdf into a .ejs file as follows:
embed src="mypdf.pdf" width="500" height="375" />
This gives me the following error when I load that page: Cannot GET /mypdf.pdf
What is the correct way to display a pdf embedded in an .ejs file using express.js (I only want the pdf to take up a portion of the page)?
You need to give the correct path for your pdf.
Check the similar line in your app.js
app.use(express.static(path.join(__dirname, 'public')));
Here public is the directory which you are telling express to consider for static resources and can be accessed directly with root path.
Now create a new folder in this public folder called docs or you can put pdf directly in the public folder
change embed tag as following
<embed src="/doc/mypdf.pdf" width="500" height="375" type="application/pdf">
if you put pdf directly in a public folder then change the path to /mypdf.pdf.

Unable to load GLTF file in ASP.NET View implementing A-FRAME

One of the views (.cshtml file) of my ASP.NET MVC application is using A-Frame. I am trying to load a 3-D model using GLTF file inside the <a-scene> tag.
<body>
<a-scene>
<a-assets timeout="5000">
<a-asset-item id="tree" src="~/Assets/scene.gltf">
</a-assets>
<a-gltf-model src="#tree"></a-gltf-model>
</a-scene>
</body>
I have already tested the src path in the same page by putting a .png file and loading it in <img/>, it works. The problem is just with the .gltf file.
What is possibly wrong with the .gltf file in particular?
The URL doesn't seem like a valid URL. It seems like a Unix path. Host the GLTF somewhere the website can reach it (like the same directory) and fix the path. src="scene.gltf".

Include js/css in Liferay DXP JSP Hook (module fragment)

I am working on Liferay DXP SP3 with fix pack 24 installed. I have created a module fragment project to override (hook) the edit_permissions JSP. I have CSS and Javascript that is very specific to this custom JSP so I would like to include it with the module rather than with the theme. Based on this documentation, it sounds like I should be able to do this by making the module a "theme contributor" module. I have set the Liferay-Theme-Contributor-Type and Web-ContextPath attributes in the bnd.bnd file, like this:
Liferay-Theme-Contributor-Type: portlet.config.jsp.overrides
Web-ContextPath: /edit-permissions-theme-contributor
I have created a /src/main/resources/META-INF/resources/js folder and placed my custom javascript files in this folder. It is my understanding that with this configuration I should be able to include the custom javascript files in my JSP hook using a regular script tag with a path like this:
<script type="text/javascript" src="/o/edit-permissions-theme-contributor/js/my-custom-script.js"></script>
I have tried many variations of the URL (with and without the "o", etc.). However, I always get a 404 on my script file. Am I doing this incorrectly? Is there a better way to include static files in a fragment module?

Current theme for Liferay error page

I have a liferay service with many sites. Those sites has the same theme but each has different color scheme. How to set a theme to a /html/portal/status.jsp ( error page) of the current site ? I don't want to create an error page for each site and I don't want all the sites to have the same error page.
One way is override this JSP (using hook / ext) and create themeCSSPath using themeDisplay, as following:
themeCSSPath is the path of the main.css of the theme applied on current page.
CSS path
String themeCSSPath = themeDisplay.getPortalURL() +
themeDisplay.getPathThemeCss() + "/main.css";
CSS link
<link rel="stylesheet" type="text/css" href="<%=themeCSSPath %>" />
I don't want to create an error page for each site and I don't want
all the sites to have the same error page."
This doesn't make sense.
"/html/portal/status.jsp" is an external JSP page, not part of Portal/Site pages. So, Liferay theme plugin won't work here. You have to design the JSP pages similar to you have on Portal/Site pages.

import js file to header all jsp in liferay

I'm going to import a js file to the header of all pages exist in liferay portal.
I know I have to do in Hook.I put import this js into init.jsp in ..\html\common , but was import to all elements of the liferay pages.
I don't know where put this file?
You don't have to do this in a hook. Do it in your theme as the theme is responsible for generating the whole document, including the <html> and <head> sections.
In the theme, override templates/portal_normal.vm. It should be obvious where to put the script reference.
You'll override this file by creating a docroot/_diffs/templates folder and copy docroot/templates/portal_normal.vm to that location. Then edit the file in docroot/_diffs/templates, build and deploy your theme.

Resources