I'm switching from Velocity to Thymeleaf and I'm trying to find an example of a template with absolute URLs.
Everything I find says to use WebContext, but tying my service to HttpRequestServlet and HttpResponseServlet seems wrong.
The following examples are taken from the Thymeleaf documentation:
Absolute URLs allow you to create links to other servers. They start
by specifying a protocol name (http:// or https://)
<a th:href="#{http://www.thymeleaf/documentation.html}">
They are not modified at all (unless you have an URL Rewriting filter
configured at your server):
<a href="http://www.thymeleaf/documentation.html">
Related
How to tell TYPO3 v10 (globally) to generate absolute links in frontend? config.absRefPrefix doesn't seem to work any longer. Also, using absolute urls as base in site configuration doesn't have any effect. Still relative links in frontend.
EDIT:
config.absRefPrefix seems to work for embedded resources (script, img etc.) but not for usually generated hyperlinks (MenuProcessor, RTE links etc.). Do i really need to set option absolute=1 for all my links generated by view helpers and configure RTE processing to generate absolute links? Thought that's why the global option "absRefPrefix" exists...
This problem already exists since TYPO3 v9. There is a ticket in the bug tracker regarding this issue. I assume that in TYPO3 v12 config. absRefPrefix might be removed completely.
In the ticket comments you can find a number of hints, how to implement absolute links in various places:
use (NO/ACT/...).stdWrap.typolink.forceAbsoluteUrl = 1 for HMENU
for links in the CKEditor RTE this config make every link absolute:
lib.parseFunc_RTE.tags.a.typolink {
forceAbsoluteUrl = 1
forceAbsoluteUrl.scheme = https
}
if you want to globally rewrite all links to absolute links, you can implement the middleware mentioned in the ticket.
I'm trying to integrate a vue.js application into a typo3 page.
I have a full functional TYPO3 instance where I can create own pages, edit the content and more. Now I want to add an existing vue.js application within this page.
Therefore I created an extension which added all necessary resources (js, css) and added an own content type which controls the integrations and configurations. The content type outputs a vue.js entry point. So far everything works. Smaller vue.js applications works as they should.
Now comes the challenge: When I want to create a more complex application which relies on the router functionality, I run into a problem.
Let's assume, I integrate my application into the page /shop and my application tries to render a product under /shop/product/some-id. This doesn't work. The URL processing is done by TYPO3 (as designed).
I tried to find a solution within the documentation but I'm not sure what I should search. I need a way to output the same page (/shop) regardless the following path. Does someone have a hint?
I found a solution. Within TYPO3 v8 is it possible to use the realurl extension for this purpose.
It is possible to define an own decode preprocessing function and analyse the current url.
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['decodeSpURL_preProc'][] = RealUrlManipulation::class . '->decodeSpURL_preProc';
Within this method is it possible to change the url for TYPO3 inner processing and set it to an known url.
In this question "integrated" refers to an angular app invoked from some path within another web app, whereas, "self hosted" refers to running from a tools such as VS Code using the ng serve --open command where the root url is set to the src folder.
In MVC there are directives such as Url.Action() and Url.Conntent() that can be used to normalize relative pathing at any location within the app.
I have been reading about APP_BASE_REF, however, I don't think that will work. Is it possible to use a mechanism that would allow a similar construct as --> <img ng-fromAppRoot('~/assets/my.png')>.
Also, in css constructs such as background:url("~/assets/my.png") will work in "integrated" but not "self hosted" and vice/versa.
Passing the root url in as part of the app initializer when "Integerated" may be part of the solution.
How is this usually handled, I am looking for a solution that will not require code changes to switch between debug/release?
If you don't care about nice URLs, you can use HashLocationStrategy (docs) and remove base url all together. Just use relative links to your assets like <img src="assets/logo.svg">.
If you need nice URLs, then you should make your own function which will work like Url.Action() and Url.Content() you're describing.
I use HAProxy for load-balancing and ssl termination. Behind it I have several Grails apps, one of which is a sort of CMS for semi-technical users.
Problem
When the user links to a Javascript library in the CMS like this:
<link href="/js/fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" />
They get redirected by Grails to the hashed version:
http://test.com/static/qnzsUX0FP3vbKVmIdNgR3SKbHRAuosgVLRMgegqUyzc.js
The issue is that the browser sees the redirect to an insecure page, and doesn't actually load the javascript.
How do I allow users to access the resources under /web-app/js without having them redirected to the hashed version?
What I think I need is either:
1) Some way of telling Grails that it either should not redirect to the hashed static version via some kind of parameter in the url (?hash=no), it should just serve the Javascript file.
2) Or the request should redirect to the https or http version, depending on what protocol accessed it.
Environment
I am using Grails version is 2.3.7 and resources is 1.2.7.
I do like the benefits that the hashing provides, and it works well anywhere I can use the resource plugin, but would like to skip it in these specific instances.
Updating to Grails 2.4.2 and using the asset pipeline plugin would likely solve this, but also take more time than I want to spend debugging Javascript right now.
in my Asp.Net MVC web project i always use anchors url as
which is making my urls working good. output is like below
if in host
if in development
I am using Search Engine Optimization Toolkit (http://www.iis.net/download/seotoolkit) for finding errors in my webpage.
What I see in results is "broken hyperlinks". When I looked to the results link that start with "/xxx" is not like "domain.com/xxx" seo toolkit sense url like "domain.com/currentpage/xxx".
What is the problem is in here?
Am I doing wrong with writing links start with "/" ? Is it wrong?
Instead of hardcoding urls I would recommend you using HTML helpers:
<%= Html.ActionLink("link text", "someAction", "someController") %>
This will generate proper relative URLs no matter whether you are running on development or production server inside virtual directories, etc...
I suggest that you mark your anchors as runat="server" and change / with ~/ in your URLs.
Let ASP.NET resolve your relative paths to absolute ones.
"/" is for specifying that your path starts at the root of your Web Site. That's good in most of the cases, but what happens if your application is nested in some other virtual directory? Your URL would be invalid in this case.
"~/" resolves your path as an absolute path, but of your Web Application, that's you've nested applications, this "magic" will render the full path to the application's folder.
Does it help?