Fork me on GitHub

core-rewriter 2.2.232

node:

Text

THE
rewrite_js()
FUNCTION
mixer
core-rewriter 2.2.232
category
Modify
{
Overview

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.

*
This function has no arguments
Example
rewrite_js()
»
View Source
node:

Text

THE
rewrite_link()
FUNCTION
mixer
core-rewriter 2.2.232
category
Modify
{
Overview

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.

*
This function has no arguments
Example
$(".//a[@class='internal']") {
  attribute("href") {
    value() {
      rewrite_link()
    }
  }
}
rewrite_link()
»
View Source
node:

XMLNode

THE
rewrite_links()
FUNCTION
mixer
core-rewriter 2.2.232
category
Modify
{
Overview

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.

*
This function has no arguments
Example
$("/html") {
  rewrite_links()
}
»
View Source
node:

XMLNode

mixer
core-rewriter 2.2.232
category
Modify
{
Overview

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.

*
Argument
Type
Name
%selector
Example
rewrite_meta_refresh() # in any XMLNode scope
»
View Source
node:

XMLNode

mixer
core-rewriter 2.2.232
category
Modify
{
Overview

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.

*
Argument
Type
Name
%attr_name
Example
$("(//*[@src])[1]") {
  unproxy("src")
}
»
View Source
node:

XMLNode

mixer
core-rewriter 2.2.232
category
Modify
{
Overview

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.

*
Argument
Type
Name
%selector
Example
$("/html") {
  unproxy_srcs("//img|//script[@src]")
}
»
View Source