core-rewriter 2.2.232
Rewrites javascript to the correct domain.
The rewrite js function ensures that all javascript points to the correct domain - rewriting anything from a regular desktop link to a modified link. For example, the domain example.com will be rewritten as m.example.com on a mobile site in the javascript.
rewrite_js()
Rewrites links to point to the correct domain.
The rewrite link function takes links on the regular site and rewrites them to modified links. On a mobile site, you do not want the links to point to the desktop site. This function fixes that. For most projects, link rewriting is done automatically via the "rewrite_links()" function found in html.ts. In the example below, we rewrite the links with the class "internal" so that they remain on the Moovweb site.
$(".//a[@class='internal']") { attribute("href") { value() { rewrite_link() } } } rewrite_link()
Rewrites all the links in the pages so that the proxy isn't escaped.
The rewrite_links()
function will rewrite all links on the page so that the host of the resultant link is still the
project's host, not the source host.
$("/html") { rewrite_links() }
Rewrites the meta refreshes on the page.
The rewrite_meta_refresh
will rewrite the meta refreshes on the page so that the host of the redirection url is
still the project's host, not the source host.
rewrite_meta_refresh() # in any XMLNode scope
Unproxies the specified attribute of the scoped XMLNode.
The unproxy
function will turn the specified attributes value into an absolute path if needed, resulting in
the asset not being proxied. It takes into account the nuanced interactions of the base tag, meaning you won't
have to worry about it.
#
The example below will unproxy the src attribute of the first node with one.
$("(//*[@src])[1]") { unproxy("src") }
Unproxies the src attribute of XMLNodes the parameter selects.
The unproxy_srcs
function is a wrapper for the unproxy function. It will use the passed XPath selector
and call unproxy on the src attribute of all nodes that match. The net result is that all src attributes
it touches will be correctly unproxied, taking into account the nuanced interactions of the base tag, should
it exist.
#
The example below will unproxy the src attribute of every img and script that has a src attribute.
$("/html") { unproxy_srcs("//img|//script[@src]") }