Adding Font Awesome icons in the ejs file in Nodejs (with express js) project - node.js

Hey guys i am trying to build a comment system project with Nodejs . At a certain place i want to use Font Awesome icons in my project so i tries 2 ways but failed to render thoses icons
First
inclucing
<link href="https://stackpath.bootstrapcdn.com/.../font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
crossorigin="anonymous">
inside my head tag in ejs file
and then
Second
Download this zip file https://fontawesome.com/how-to-use/on-the-web/setup/hosting-font-awesome-yourself
and open the CSS folder inside and drag the all.min.css file into your public directory in your project.
and then Use a link tag to reference it in your templates/HTML, e.g:
and
Both the ways failed, am i missing something ?

Since you are using the font-awesome solid styles with the fas class, you'll have to include the solid.css styles.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/solid.min.css">

Related

How does material design style icons based on text node children

Based on the code snippet below (and found here), the material library is styling the component based on the text content of mwc-icon. After looking at the source code for mwc-icon found here, there doesn't seem to be any javascript logic doing the styling directly. Somehow this seems to be happening in the css or in the font definition itself.
How is the icon being applied/rendered in place of the text?
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet">
<mwc-icon>shopping_cart</mwc-icon>
<script type="module">
import '#material/mwc-icon';
</script>
The answer for your question is that the font-family property set in the file.
You have imported the Material Icons font and used it. There is where the icon name you enter is defined. Instead of character definitions icon names are defined and mapped to the corresponding svg or png images.refer here

header.ejs and footer.ejs not functioning properly

Good Day!
I am making an app and in it I have various routes. I am using node.js. I have created a "partials" directory with header.ejs and footer.ejs files that contain all the header and footer info such as bootstrap, custom css etc.
Now, this header file works fine, it is also linked correctly, I have tested it by changing the background color to complete red and this color then applies to all the pages that contain <% include header.ejs %> and <% include footer.ejs %>.
In my project, the problem is that the bootstrap and other custom css only work for the root route. For example this is the main directory (Project), this directory contains (Project/app.js, Project/package.json, Project/views, Project/public, and so on...). Project/views contains ejs files for all the routes. For example toyota.ejs file for route "/cars/toyota", honda.ejs file for route "/cars/honda" and so on. All these ejs files are stored in Project/views folder. In the main directory, along with app.js, there is a landing page called "landing.ejs" for route "/cars". The header and footer work absolutely fine for the route "/cars" which renders "landing.ejs" but when I go to different routes such as "/cars/toyota", which will render "toyota.ejs" from views folder, the header and footer stop working, only certain features work such as bootstrap button or certain custom styles.
What I mean is that header.ejs and footer.ejs only works for root route, which is "/", and the main cars route "/cars", which shows all car manufacturing companies. The problems arises only when I try try to use routes that render files from the "Project/views" folder. header.ejs and footer.ejs properties does not get applied to the files contained in the nested folder, which is called "views". Linking is working fine because I have tried changing background colors.
Can you post your code to here?
You can try this:
<%- include('filepath/header.ejs') %>
In your header.ejs file, put a "/" before your css filename in href.
For example, replace:
<link rel="stylesheet" type="text/css" href="car.css">.
with:
<link rel="stylesheet" type="text/css" href="/car.css">.
I got a similar error but my code worked two ways, either by using
<%- include("partials/header"); -%>
or by,
<%- include partials/footer.ejs-%>
also, take care of the spaces in between.
In this example, I am considering that the partials folder in the same directory, update path as per the requirements.
Happy Coding :)

Sass - Setting the font family with material web components

I am using material web components in my project and I would like to change the font family. I was going through their documentation and I have tried to do that by setting the variable in my sass file like this:
$mdc-typography-font-family: Comfortaa, sans-serif !default;
But, that didn't work, in the documentation it also says that sass mixin sets the font:
mdc-typography-base
How can I change the mixin to use a different font-family?
I figured this out by removing !default flag:
$mdc-typography-font-family: Comfortaa, sans-serif;
Also, don't forget to embed Google Fonts in the head tag:
<link href="https://fonts.googleapis.com/css?family=Comfortaa" rel="stylesheet">

merge javascript files in directory with node uglify + watch?

Goal:
I am trying to build an effortless workflow for client side templating development.
Doc Root:
/views/uncompiled/
/static/js/compiled/
We start in /views/uncompiled/
This is where I can build stuff out, like /views/uncompiled/index.html for example.
Im building dust.js templates, so I am using dusterjs too listen for changes in my /views/uncompiled/ directory, and automatically render compiled *.js counterparts in my /static/js/compiled/ directory.
So /views/uncompiled/index.html renders out /static/js/compiled/index.js anytime a change is saved.
Problem:
My layout.html is growing bigger. I need to include a new *.js script everytime I add another template:
<head>
<script src='/static/js/compiled/index.js'></script>
<script src='/static/js/compiled/header.js'></script>
<script src='/static/js/compiled/footer.js'></script>
<script src='/static/js/compiled/baconstrips.js'></script>
...
</head>
Solution:
Use another watch on the /static/js/compiled/ folder too automatically concat *.js into a single app.js that will always be included in my <head> anytime the contents of that folder changes:
<head>
<script src='/static/js/app.js'></script>
</head>
Question:
I would like to use a concatonation tool like Uglify.js that also does compression.
Are there any node packages that automate the solution above?
Is there a native function of Uglify.js that already does this?
Use grunt.js. It has the ability to watch/concentate/minify your files through various contributed modules. Takes a little getting used to (I still am myself) but you will end up with a custom build process that works the way that you want it to work, which is priceless.

WebSeal JSF Context path stripping Junction Name

We are using WAS & IHS as servers and WebSEAL as reverse proxy.
Application is developed using JSF 2.0 and using .xhtml pages for view.
Issue: Using ${facesContext.externalContext.requestContextPath} to generate the context for JavaScript and CSS files.
When the application is accessed through WebSEAL, getting correct context for JavaScript file, but the CSS context is missing the webSEAL junction name.
In Source Code:
JS is included as:
<script src="${facesContext.externalContext.requestContextPath}/js/jquery/jquery-1.6.1.min.js" type="text/javascript"></script>
CSS is included as:
var cssElement = document.createElement("link");
cssElement.setAttribute("rel", "stylesheet");
cssElement.setAttribute("type", "text/css");
cssElement.setAttribute("href", "${facesContext.externalContext.requestContextPath}/css/stylecontent.css");
Links Rendered on Browser:
For JavaScript(it has context name):
<script src="/junction/appcontext/js/jquery/jquery-1.6.1.min.js" type="text/javascript"></script>
For CSS:
<link href="/appcontext/css/stylecontent.css" rel="stylesheet" type="text/css"/>
Hence,
CSS files are not loading on the page.
Anyone has any hints?
Just incase some one is stuck with the same problem:
It got resolved by making some configuration at the WebSEAL junction level.
by default, WebSEAL looks for static resources on the the server itself, hence it strips the junction off.
Settings need to be applied to "look for resources under the junction"

Resources