Open MatrixFr opened 6 years ago
Same issue here. When I try to create one js file at the /assets/javascripts folder, and then put the follow content:
construct: function(e) {
var default_options = {
display: "block",
fallback: "",
placement: "",
prefix: "native",
targetClass: "native-ad",
visibleClass: "native-show"
};
if (typeof e == "undefined") return default_options;
Object.keys(default_options).forEach((key, index) => {
if (typeof e[key] == "undefined") {
e[key] = default_options[key];
}
});
return e;
},
init: function(zone, options) {
options = this.construct(options);
this.className = options["targetClass"];
this.displayStyle = options["display"];
this.fallback = options["fallback"];
this.visibleClassName = options["visibleClass"];
this.prefix = options["prefix"];
this.placement = options["placement"];
let jsonUrl = `https://srv.buysellads.com/ads/${zone}.json?callback=_native_go`;
if (options["placement"] !== "") {
jsonUrl += "&segment=placement:" + options["placement"];
}
let srv = document.createElement("script");
srv.src = jsonUrl;
document.getElementsByTagName("head")[0].appendChild(srv);
},
sanitize: function(ads) {
return ads
.filter(ad => {
return Object.keys(ad).length > 0;
})
.filter(ad => {
return ad.hasOwnProperty("statlink");
});
},
pixel: function(p, timestamp) {
let c = "";
if (p)
p.split("||").forEach((pixel, index) => {
c += '<img src="' + pixel.replace("[timestamp]", timestamp) + '" style="display:none;" height="0" width="0" />';
});
return c;
}
};
var _native_go = function(json) {
let ads = _native.sanitize(json["ads"]);
if (ads.length < 1) {
document.querySelectorAll("." + _native.className).forEach((className, index) => {
document.getElementsByClassName(_native.className)[index].innerHTML = _native.fallback;
if (_native.fallback !== "") document.getElementsByClassName(_native.className)[index].className += " " + _native.visibleClassName;
});
return "No ads found";
}
document.querySelectorAll("." + _native.className).forEach((className, index) => {
if (ads[index] && className) {
let adElement = document.getElementsByClassName(_native.className)[index].innerHTML;
let ad = adElement
.replace(new RegExp("#" + _native.prefix + "_bg_color#", "g"), ads[index]["backgroundColor"])
.replace(new RegExp("#" + _native.prefix + "_bg_color_hover#", "g"), ads[index]["backgroundHoverColor"])
.replace(new RegExp("#" + _native.prefix + "_company#", "g"), ads[index]["company"])
.replace(new RegExp("#" + _native.prefix + "_cta#", "g"), ads[index]["callToAction"])
.replace(new RegExp("#" + _native.prefix + "_cta_bg_color#", "g"), ads[index]["ctaBackgroundColor"])
.replace(new RegExp("#" + _native.prefix + "_cta_bg_color_hover#", "g"), ads[index]["ctaBackgroundHoverColor"])
.replace(new RegExp("#" + _native.prefix + "_cta_color#", "g"), ads[index]["ctaTextColor"])
.replace(new RegExp("#" + _native.prefix + "_cta_color_hover#", "g"), ads[index]["ctaTextColorHover"])
.replace(new RegExp("#" + _native.prefix + "_desc#", "g"), ads[index]["description"])
.replace(new RegExp("#" + _native.prefix + "_index#", "g"), _native.prefix + "-" + ads[index]["i"])
.replace(new RegExp("#" + _native.prefix + "_img#", "g"), ads[index]["image"])
.replace(new RegExp("#" + _native.prefix + "_link#", "g"), ads[index]["statlink"])
.replace(new RegExp("#" + _native.prefix + "_logo#", "g"), ads[index]["logo"])
.replace(new RegExp("#" + _native.prefix + "_color#", "g"), ads[index]["textColor"])
.replace(new RegExp("#" + _native.prefix + "_color_hover#", "g"), ads[index]["textColorHover"])
.replace(new RegExp("#" + _native.prefix + "_title#", "g"), ads[index]["title"]);
document.getElementsByClassName(_native.className)[index].innerHTML = null;
document.getElementsByClassName(_native.className)[index].innerHTML += ad + _native.pixel(ads[index]["pixel"], ads[index]["timestamp"]);
document.getElementsByClassName(_native.className)[index].style.display = _native.displayStyle;
if (_native.className !== "") document.getElementsByClassName(_native.className)[index].className += " " + _native.visibleClassName;
} else {
document.getElementsByClassName(_native.className)[index].innerHTML = null;
document.getElementsByClassName(_native.className)[index].style.display = "none";
}
});
};
It raises on Production (ElasticBeanStalk):
Uglifier::Error: Invalid assignment
/opt/rubies/ruby-2.5.1/bin/bundle:23:in `load'
/opt/rubies/ruby-2.5.1/bin/bundle:23:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace) (Executor::NonZeroExitStatus)
The issue seems to be with ES6 support.
I added this to production.rb as specified in the Readme and its working.
config.assets.js_compressor = Uglifier.new(harmony: true)
I tried that approach before but I had the same result.
On 13 Jul 2018, at 10:33, Rushil Agrawal notifications@github.com wrote:
The issue seems to be with ES6 support.
I added this to production.rb as specified in the Readme and its working.
config.assets.js_compressor = Uglifier.new(harmony: true) — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lautis/uglifier/issues/132#issuecomment-404834602, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKbloBMPqctPjMZQiz-rJH_czbxNagSks5uGKGPgaJpZM4Sn4Oc.
I update my rails app to pass at 5.1.X to day, but surprise, my config to minimify JS and CSS dosn't works now...
config.assets.js_compressor = Uglifier.new(output: {comments: /^!/})
if I comment the line, it works, but JS are not minimify and there is inaccessible on site... like all others assets, but there are present in cache in /public folder... I don't understand why asset pipeline doesn't works now?!