JSONP convert function in Simile 3.0 - jsonp

I'm using Simile to display some data. I have a JSONP file which I have to format correctly before using it. Using JSONP example from Exhibit website I have been able to do so using 2.2 version of the Exhibit API:
<link rel="exhibit/data" type="application/jsonp"
href="http://www.editgrid.com/user/ecmanaut/font-names.exhibit.jsonp"
ex:jsonp-callback="editgridCallback" ex:converter="fontConverter" />
I want to update my code to exhibit 3.0 and I am using the following code:
<link rel="exhibit/data" type="application/jsonp"
href="http://www.editgrid.com/user/ecmanaut/font-names.exhibit.jsonp"
data-ex-jsonp-callback="cbfunc" data-ex-converter="fontConverter" />
But fontConverter function does not execute. What am I doing wrong?

Related

How to play hls inside VAST 4.2 using open-source players?

My site uses video.js with the videojs-ima plugin, but it didn't work with hls inside VAST.
I tested the xml using the Google service https://googleads.github.io/googleads-ima-html5/vsi/ and I see the error Ad error: AdError 400: There was an error playing the video ad. Caused by: Error: Error: There was an error playing the video ad.
I tried the videojs-vast-vpaid plugin, but it throws an error about the inability to work with VAST 4.2.
I tried other free players - plur, openplayerjs, fluid player-but none of them worked with my xml.
my VAST 4.2 sample xml looking like that (Warning! NSFW content inside):
<VAST xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.iab.com/VAST" version="4.2">
<Ad id="1" adType="video">
<InLine>
<AdSystem version="1">stripcash.com</AdSystem>
<AdTitle>Naked girl get cum on face</AdTitle>
<Creatives>
<Creative sequence="1" id="1">
<Linear skipoffset="00:00:05">
<Duration>00:00:05</Duration>
<MediaFiles>
<MediaFile id="1" delivery="progressive" type="video/mp4" width="480" height="640">
<![CDATA[ https://b-hls-25.strpst.com/hls/48371204/48371204.m3u8 ]]>
</MediaFile>
</MediaFiles>
<VideoClicks>
<ClickThrough id="1">
<![CDATA[ https://go.xxxjmp.com/api/goToTheRoom?campaignId=59eb46ec7c05df0507091.......]]>
</ClickThrough>
</VideoClicks>
</Linear>
<UniversalAdId idRegistry="unknown">unknown</UniversalAdId>
</Creative>
</Creatives>
<Impression id="">
<![CDATA[ https://go.xxxjmp.com/eye.gif?campaignId=59eb46ec7c05df0507091cccc8a....... ]]>
</Impression>
</InLine>
</Ad>
</VAST>
The IMA SDK creates it's own video element to play the creative. That will only be able to formats the browser can natively support. HLS would work on Safari.

How can I use pagemap with google custom search refinements?

I'm trying to add refinements to my google custom search.
I have meta tags on just about every page of the site, such as
<meta name="type-id" content="241" />
Where there are many different types, and I want to have one refinement for each type.
In the docs, it says
You can also use these more:pagemap: operators with refinement labels
But I have been unable to do that.
Note that I have had success using more:pagemap:metatags-type-id:241 in the search input, or as a webSearchQueryAddition - but despite googles docs, I haven't been able to get it to work with a refinement.
Here's a sample from my cse.xml (removing some attributes from the CustomSearchEngine tag):
<?xml version="1.0" encoding="UTF-8"?>
<CustomSearchEngine>
<Title>Test</Title>
<Context>
<Facet>
<FacetItem>
<Label name="videos" mode="FILTER">
<Rewrite>more:p:metatags-article-keyword:121</Rewrite>
</Label>
<Title>Videos</Title>
</FacetItem>
</Facet>
</Context>
</CustomSearchEngine>
Is this supposed to work? Am I using wrong syntax in the rewrite rule? Has anyone else done something like this?
Your label in the facet should be mode="BOOST" if you want to restrict to a structured data field within the scope of your engine.
<Facet>
<FacetItem>
<Label name="videos" mode="BOOST">
<Rewrite>more:p:metatags-article-keyword:121</Rewrite>
</Label>
<Title>Videos</Title>
</FacetItem>
</Facet>

Access request's URL parameters in stencil

Can I access the request’s query params in stencil?
So if you go to http://example.com/?name=Bob
Can I render something like:
Hello {{url.name}}!
It has to be server-side rendered, not browser JavaScript.
Why? Well, I actually want to share the results of a quiz on Facebook, so the og:image tag needs to point at a picture of the score. So I share a link like http://example.com/quiz/?quizScore=encodedscoreresult and the page then contains:
<meta property="og:image"
content="https://myapi.example.com/quizresultsimage?quizScore=encodedscoreresult" />
Not a full solution, as you can't access an individual parameter's value, but...
The settings.facebook_like_button.href does contain the request URL, URL encoded as https%3A%2F%2Fexample.com%2Fquiz%3FquizScore%3Dencodedscoreresult
You can extract the whole query string from the URL using:
<meta property="og:image"
content="https://myapi.example.com/quizresultsimage{{get "search" (getObject "search" (urlParse (decodeURI settings.facebook_like_button.href)))}}" />
However, that will include all the query parameters, so that may be a security risk passing extra parameters from your stencil site to the api that aren't desired.
Simpler (and perhaps safer), you can pass the whole URL as a parameter in the meta tag, and then the API will have to decode it:
<meta property="og:image"
content="https://myapi.example.com/quizresultsimage?url={{settings.facebook_like_button.href}}" />
which results in:
<meta property="og:image"
content="https://myapi.example.com/quizresultsimage?url=https%3A%2F%2Fexample.com%2Fquiz%3FquizScore%3Dencodedscoreresult" />
Because there is only one parameter in the query string, you can be sure you're not passing anything undesired to the target URL.
If you just need the decoded URL you can use:
{{assignVar "requestUrl" (decodeURI settings.facebook_like_button.href) }}
{{getVar "requestUrl"}}

<meta name="msapplication-config" content="none"> for browserconfig.xml not working

We are developing a site for a client. We were getting a number of 404 requests for /browserconfig.xml. Then I read over here : http://msdn.microsoft.com/en-us/library/ie/dn320426(v=vs.85).aspx that if you do not want to support a browserconfig request you could add meta name="msapplication-config" content="none" in the head section.
However, even after adding the above meta tag still I am getting 404's for /browserconfig.xml.
Any pointers on this?
Adding a meta tag might or might not work. We also added this tag, but we still received 404 errors for browserconfig.xml requests all the time. At the end we decided to do a simple browserconfig.xml and after that we had no problems.
Our browserconfig.xml looks like this and basically it just tells where 4 images are located.
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/mstile-70x70.png"/>
<square150x150logo src="/mstile-150x150.png"/>
<wide310x150logo src="/mstile-310x150.png"/>
<square310x310logo src="/mstile-310x310.png"/>
<TileColor>#8bc53f</TileColor>
<TileImage src="/mstile-150x150.png" />
</tile>
</msapplication>
</browserconfig>

What is the suitable replacement for this.__LZtextclip.text in Open laszlo 5.0

I want to know what is the suitable replacement for this line.
this.__LZtextclip.text
I am using this to get the string present in the text node. This works fine in Openlaszlo 3.3 but in 4.9 and 5.0 it's giving a problem
I tried updating it to
this.sprite.__LZtextclip.text
And i am getting an error:
79: Error: Access of possibly undefined property __LZtextclip through a reference with static type LzSprite, in line: Debug.write(this.sprite.__LZtextclip.text);
Any idea why this problem is happening?
If you are trying to access the text content of a text field, why don't you just access the attribute text?
<canvas>
<text name="sample" id="gRead" />
<handler name="oninit">
gRead.setAttribute('text',"HI");
Debug.info(gRead.text);
</handler>
</canvas>
In OpenLaszlo 3.3 there is method getText(), which gives you the same value. Accessing mx.textfield in your code does not work for the DHTML runtime.
Edit: Added information regarding the stripping of HTML tags
The Flash Textfield class flash.text.Textfield provides an API to enable HTML tag content in a Textfield instance. There are two different properties, one called text, the other one htmlText. If you want to directly access the Flash Textfield object of an lz.text instance, it's a property of the display object of the lz.text instance:
// Flash Textfield instance
gRead.getDisplayObject().textfield
// Pure text content
gRead.getDisplayObject().textfield.text
// Formatted text
gRead.getDisplayObject().textfield.htmlText
You should be aware of the fact that Flash automatically adds HTML format to any textstring you set as content. When you do
gRead.setAttribute('text',"HI");
the textfield.htmlText value is
<P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="11" COLOR="#000000" LETTERSPACING="0" KERNING="1">HI</FONT></P>
For the DHTML runtime, the text content is added as the innerHTML of a <div> tag, and there is no standardized API to retrieve the pure text content of a DOM structure for a tag with content. You could write your own function to extract the text content, or use JavaScript functions from existing frameworks - like the jQuery text() function - to achieve the same result for the DHTML runtime.
I guess the reason is that Laszlo started using the Dojo based rich text editor for text input with HTML formatting since OpenLaszlo 4.0 or 4.1.
The best approach to have consistent behavior across runtimes when stripping tags is to do the conversion on the server-side. That's especially needed if you wan to have consistent whitespace treatment in multiline text, since there differences in how browsers treat whitespace. The question how to best strip tags from strings in JavaScript has been answered before on Stackoverflow, e.g. JavaScript: How to strip HTML tags from string?
Here is a cross-runtime example which works in DHTML with Firefox, Chrome, and it should work with IE9+:
<canvas>
<text name="sample" id="gRead" />
<handler name="oninit"><![CDATA[
gRead.setAttribute("text", 'Hello <b>World</b> OL');
Debug.info("gRead.text=" + gRead.text);
if ($dhtml) {
Debug.info(gRead.getDisplayObject().textContent);
} else {
Debug.info(gRead.getDisplayObject().textfield.text);
}
]]></handler>
</canvas>
I found what is the problem. The problem is that i have to declare a variable and have to refer the property from that.
<canvas>
<library>
<text name="sample" id="gRead">
<method name="getTextFrom">
Debug.write("this.text" , this.sprite);
var mx = this.sprite;
Debug.write("this.text" , mx.textfield.text);
</method>
</text>
</library>
<handler name="oninit">
gRead.setAttribute('text',"HI");
gRead.getTextFrom();
</handler>
</canvas>