How do i go from the auto-binding template to a 'my-app' structure and still keep the build structure, web sync, etc. working?
<body unresolved>
<my-app></my-app>
</body>
Related
I am new to Spring and I am trying to make a beautiful Web Application, and so far I set up everything, and if I run my page on the browser it shows as it is supposed. But if I run it with tomcat on port 8080 (I am using Intelijj) it doesn't load css and js files not even pictures.
I have literally searched this problem and open all the StackOverflow similar questions, I tried to write a configuration file, but it doesn't do anything, and I am uncertain about this approach because I have seen examples of people that did not write any configuration, but still they managed to make all their static resources load, and so on. Is it some secret application properties that need to write? Or there is a config code that has to write?
My resources folder looks like this:
-resources
-static
-CSS
-things.css
-JS
-datepicker.js
-Images
-many pictures
-templates
-Home.html and other pages
And the code that I used to refer to static-CSS-things.css is like this:
link href="../static/CSS/things.css" th:href="#{/CSS/things.css}" rel="stylesheet" media="all" type="text/css"
I thought this would make my css file to load, but it doesn't. Same for the js and the pictures. Thank you!
Ensure your css and js files are in the following structure:
src/main/resources/static/css/things.css
src/main/resources/static/js/things.js
Ensure you are calling your static resources from pages that are under the spring boot template folder, which is in src/main/resources/templates
Always refer to your resources using the thymeleaf tag, because this way no matter the port you are running your application, it will always load properly.
src/main/resources/templates/example.html
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<!-- CSS -->
<link th:href="#{/css/things.css}" rel="stylesheet"></link>
<!-- JS -->
<script th:src="#{/js/things.js}" type="text/javascript"></script>
</head>
<body>
</body>
</html>
If still not working, try to use the inspect from Google Chrome, go to Network tab and check what error is returning from your css and js files, then comment here.
Assuming you have css and js folder under static folder then use it like this -
<link href="css/custom.css" rel="stylesheet">
<script src="js/custom.js"></script>
you might wanna take a look at these too -
https://www.springboottutorial.com/spring-boot-with-static-content-css-and-javascript-js
https://www.baeldung.com/spring-mvc-static-resources
Worth noting, make sure you have thymeleaf dependency(ies) and tags appropriately.
Currently getting used to using Express, Angularjs and Nodejs. Is it possible using these frameworks to create a reusable or template head tag section to use in multiple html files.
For example, head.html contains
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
and files file1.html and file2.html want to include the same head from head.html. Is it possible to achieve this using these frameworks? Are there any alternative/better solutions?
You can certainly do that but as far as I know you'd be looking at using a templating engine like Jade or Ejs.
They have include statements where you just include it in the file.
However if you are using Angular I don't see much of a point to do this at all. Angular will bootstrap your entire webpage from one document usually index.html or app.html it really depends on what you name it. This way that stuff will only ever load once.
That way you don't actually need to include it in multiple files, it will all be included from the get go.
Does that make sense?
I have a site with nearly much pages with the same look. the only difference is the content of them. each page is stored in an HTML file.
The problem of the site is that during maintenance (i.e. for changing the site theme and look) the CSS is done very nice (because all the pages are linked to a single CSS file) but changing a small <div> block can be really annoying to apply individually for all of the pages.
Is there any other way to use to avoid this? like a theme for a blog.
My own idea was to place the new page contents (section part) into a bare HTML page and place it in the site's homepage using <iframe> then I will only have one page that is the main page. and posts are loaded into an <iframe> in the section part of the main page.
But this would reduce the site's SEO. because of having only one page.
What else can I do?
I want to do the same thing a separate CSS file does to the page style, to the htmls content. I want the theme to be unique in all the pages. and if changed, the changes applies on all of the pages.
There are a few ways to do this:
1) PHP: Using PHP, you can simply include an html file into another one
<?php include('fileOne.html'); ?>
2) jQuery: Using jQuery, you can load an HTML page dynamically into another (this is kind of hacky in my opinion):
<html>
<head>
<script src="jquery.js"></script>
<script>
$(function(){
$("#includedContent").load("b.html");
});
</script>
</head>
<body>
<div id="includedContent"></div>
</body>
</html>
Source: Include HTML Page via jQuery
3) Framework: Using a framework like Python/Django, you can use {% include %} blocks to create standalone html files that can be reused like blocks.
<html>
{% include 'navbar.html' %}
</html>
My honest recommendation is #2 if you have to stay with just raw html, otherwise, if you are using PHP then includes are a no brainer. The last option is the frameworks, and that is really only if you have other heavy-duty functions you would need.
I have created a core-scaffold based element in the Polymer Designer.
Using the Polymer Generator with Yeoman, I created a basic app and it displayed the page as expected. https://github.com/yeoman/generator-polymer/
I want to use the output from the designer in my app. I renamed designer.html (from gist) to dashboard.html, changed
<polymer-element name="my-element"> to
<polymer-element name="dashboard">
saved the designer output as: app/elements/dashboard/dashboard.html
changed all of the imports to the correct path, e.g.
<link rel="import" href="../core-scaffold/core-scaffold.html"> to
<link rel="import" href="../../bower_components/core-scaffold/core-scaffold.html">
when I add
<link rel="import" href="dashboard/dashboard.html">
to elements.html and the page reloads, it is now blank. This is without changing anything in index.html
Hints as to what else needs to be changed in the designer output for it to be imported to this app?
The problem is that all Polymer elements MUST be hyphenated.
I have made a web site using Polymer.js and using templates extensively.
The URL endpoint pages have very little on them and import a template that acts as a Master Page, and on each of these i import other element templates for headers, footers, etc.
This allows very quick page construction, and i love how it works.
Its kind of like a client side CMS
But i cant seem to get rid of FOUC !! The page flashes badly.
Body unresolved is meant to work, but its failing miserable.
Can someone have a look and make a suggestion please.
Here is the root on git hub.
https://github.com/bmadmin/bm-www/tree/master/public/project/hempbuild
Polymer's FOUC prevention uses the unresolved attribute, not a class name:
http://www.polymer-project.org/docs/polymer/styling.html#fouc-prevention
Have you tried this?:
<body unresolved>
<polymer-home></polymer-home>
</body>
The other issue I see is that you're using <body> inside polymer-home. However, <body> can only be a child of <html> according to the spec. The browser will discard that <body class="unresolved"> from your element.