How does Google treat webpages with multiple JSON-LD Schema.org blocks? - schema.org

How do search engines like Google treat webpages with multiple JSON-LD (Schema.org) blocks?
For example, what would happen if a page has both non-conflicting script blocks below?
<script type="application/ld+json">
{ "#context":"http://schema.org",
"#type":"WebPage",
"#id": "#123",
"author": {
"#type": "Person",
"name": "Foo Bar"
}
}
</script>
<script type="application/ld+json">
{ "#context":"http://schema.org",
"#type":"WebPage",
"#id": "#123",
"text": "blah blah blah",
"url":"pageurl"
}
</script>

We can’t know how Google Search actually treats them, but we can know how Google’s Structured Data Testing Tool handles such a case.
Same URI
If objects have the same URI (in JSON-LD: #id), they are the same. Google’s SDTT will display one entry showing properties from all objects with the same URI. So judging from the output in SDTT, Google seems to treat these two cases equally:
<script type="application/ld+json">
{ "#context":"http://schema.org",
"#type":"WebPage",
"#id": "#123",
"url":"pageurl",
"text": "blah blah blah"
}
</script>
<script type="application/ld+json">
{ "#context":"http://schema.org",
"#type":"WebPage",
"#id": "#123",
"url":"pageurl"
}
</script>
<script type="application/ld+json">
{ "#context":"http://schema.org",
"#type":"WebPage",
"#id": "#123",
"text": "blah blah blah"
}
</script>
Different (or no) URI
The default assumption is that the objects describe different things. However, if certain (typically unique) properties have the same values (telephone, address, name etc.), a consumer like Google Search might deduce that the objects describe the same thing -- this is not standardized, though, and if/when consumers do this is not documented.

Related

i18n model not displaying translated text

I have i18n property to bind to the label but when I try to bind the property, it does not work.
i18n_en
TABLE_ItemCateg=Item Category
view.xml
<Label text="{i18n>TABLE_ItemCateg}" />
It displays "TABLE_ItemCateg" rather than "Item Category".
And in i18n.properties, I have no data saved. Also I receive below error:
could not find any translatable text for key 'TABLE_ItemCateg' in bundle '../../sap/xyz_homepage/i18n/i18n.properties'
manifest.json
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "xyz_homepage.i18n.i18n"
}
}
}
definition
you have to add your text to all of your used translation files
i18n.properties
TABLE_ItemCateg=Item Category
i18n_en.properties
TABLE_ItemCateg=Item Category
usage
use the appropriate model
view.xml
text="{i18n>TABLE_ItemCateg}"

$ionicPosition.offset and $ionicPosition.position causing "TypeError: Cannot read property 'getBoundingClientRect' of undefined"

I'm trying to get the position and offset of a dragged list item on release.
However, both $ionicPosition.offset and $ionicPosition.position both return "TypeError: Cannot read property 'getBoundingClientRect' of undefined.
I've included a rudimentary code snippet. Thanks in advance!
var data = {
"week": [{
"name": "Monday",
"activities": [{
"name": "Go running",
"shortname": "go_running"
}, {
"name": "Wash clothes",
"shortname": "wash_clothes"
}]
}, {
"name": "Tuesday",
"activities": [{
"name": "Holiday shopping",
"shortname": "holiday_shopping"
}, {
"name": "Clean bike",
"shortname": "clean_bike"
}]
}]
}
var app = angular.module('activityplan', ['ionic']);
app.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
});
});
app.controller('PlanController', ['$scope','$ionicPosition', function($scope,$ionicPosition) {
$scope.days = data.week;
$scope.releaseTest = function(a) {
console.log($ionicPosition.offset(a));
console.log($ionicPosition.position(a));
}
$scope.moveActivity = function(activity, day, fromIndex, toIndex) {
day.activities.splice(fromIndex, 1);
day.activities.splice(toIndex, 0, activity);
};
}]);
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Activity plan</title>
<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
</head>
<body ng-app="activityplan">
<ion-content ng-controller="PlanController" style="width:360px;">
<div ng-repeat="day in days">
<div class="item item-divider item-dark">
<b>{{ day.name }}</b>
</div>
<ion-list ng-controller="PlanController" show-reorder="true" can-swipe="true">
<ion-item class="item-icon-right" ng-repeat="activity in day.activities track by $index" on-release="releaseTest(activity)">
{{ activity.name }}
<ion-option-button class="button-assertive icon ion-trash-a" ng-click=""></ion-option-button>
<ion-reorder-button class="ion-navicon" on-reorder="moveActivity(activity,day,$fromIndex,$toIndex)"></ion-reorder>
</ion-item>
</ion-list>
</div>
</ion-content>
</body>
</html>
You are doing it all wrong. Method offset(element) and position(element) of $ionicPosition expects DOM element to be part of parameter.
In your case you are passing the JavaScript object from mark-up thats why its failing.
position(element) :
Get the current coordinates of the element, relative to the offset parent. Read-only equivalent of jQuery’s position function.
Its fact that it is very poorly documented in ionic docs.
What I figured out after digging through source code that these methods are jQuery equivalent and jQuery always wraps the matched element inside array, therefore parameter should be an array with 0th index pointing to actual dom as shown below
var element = document.getElementById(id);
var offset = $ionicPosition.offset([element]);
/*it returns the offset of param[0]
where param is the parameter passed to this function
*/
/*note that we need to wrap the dom element inside array as these methods are inspired from jQuery
and jQuery wraps the matched element inside array
If you are using AngularJS's jqLite, please verify if actual DOM is in array 0th position or not
*/

Facebook Like - displaying the correct image and content

I have a website (not a FB app) that has a page of which I have added a "Like" button to, using the facebook like button generator.
I am having trouble specifying the exact image I want to share along with a specific content.
I have tried the Open Graph meta tags, but these seem to be ignored (possibly they are only for FB apps??)
I'm using the following code for the button:
<div class="fb-like" data-href="https://www.MYURL" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
The functionality itself is working. It will share the link onto FB but not using the content/image I would prefer.
What am I doing wrong?
Debug
{
"og_object": {
"type": "website",
"updated_time": "2014-09-05T09:58:07+0000",
"url": "https://www.MYURL",
"id": "MYNUMBER"
},
"share": {
"comment_count": 0,
"share_count": 0
},
"id": "https://www.MYURL"
}

Polymer REST backend

I have a backend written in golang exposing /api/list interface. It returns lists when called from GET and create new list when it receive POST with parameters.
I can read it with standard core-ajax element, there is a huge amount of examples to do that.
What I didn't understood is what should I do, when I want to create new element through POST? I read the documentation and searched for sample code for half day, can you point me to right direction?
//
Ok, thanks for help, it was really only bad format of json I was sending. There is still dark cloud in my mind telling that I misunderstood something from conceptual view. Is this:
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/core-ajax/core-ajax.html">
<polymer-element name="channels-service" attributes="channels">
<template>
<style>
:host {
display: none;
}
</style>
<core-ajax id="ch_load"
auto
url="/api/list"
on-core-response="{{channelsLoaded}}"
handleAs="json">
</core-ajax>
<core-ajax id="ch_update"
url="/api/list"
on-core-response="{{channelsUpdated}}"
method="POST"
handleAs="json">
</core-ajax>
</template>
<script>
Polymer('channels-service', {
created: function() {
this.channels = [];
},
channelsLoaded: function() {
// Make a copy of the loaded data
this.channels = this.$.ch_load.response.slice(0);
},
newChannel: function(ch_name) {
// this.$.ch_update.body = "ch_name";
this.$.ch_update.body = '{"Name":"pitchalist2"}'
this.$.ch_update.go();
},
channelsUpdated: function() {
//window.log(this.$.ch_update.response.slice(0));
}
});
</script>
</polymer-element>
correctly written data layer? It looks very counterintuitive to me and in examples using local data storage it works way easier.
You can send a POST request by setting the method attribute (method="POST") and the body attribute (body='{"my":"data"}'). Indeed you need a second iron-ajax element for this request.
See the attributes section in the iron-ajax documentation.

How to refresh `ajax` node on click?

There are some nodes that get data from AJAX call in my jsTree.
How can I refresh the data and NOT by reloading the whole tree?
the best would be simple click on the node I wish to refresh
context menu is ok too
How about this?
<html>
<head>
<script language="javascript" type="text/javascript" src="jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.jstree.js"></script>
<script>
var treeConfig = {
"json_data" : {
"data" : [{
"data" : "Root",
"state" : "closed",
"children" : ""
}],
"ajax" : {
"url" : "http://localhost/tree.json",
"data" : function (node) {
return { query : "Value" };
}
}
},
"plugins" : [ "themes", "json_data", "ui" ],
};
$(document).ready(function(){
$("#treeContainer").jstree(treeConfig);
$('#treeContainer a').live('click',function(){
var tree = jQuery.jstree._reference("#treeContainer");
var currentNode = tree._get_node(null, false);
tree.refresh(currentNode);
});
});
</script>
</head>
<body>
<div id="treeContainer"></div>
</body>
</html>
Here's what I'm doing:
using the JSON data plugin (but the concept is similar for HTML and XML plugins)
loading the initial tree node ("Root") from the data config object
setting the AJAX config object so all other nodes request their child data via ajax, when initially opened (applies to any node where 'state' is 'closed' and 'children' is 'empty')
using the AJAX data function to pass the correct query string to get relevant data for the node being opened. My example always fetches http://localhost/tree.json?query=Value but you probably want to do something like set Value to the node id so the server sends back relevant data.
So far this makes an ajax request for the node data only the first time the node is opened. The final step is:
create a click function which causes a single node to refresh its data every time it is clicked