Star ratings wrong on Google using Schema - google-schemas

I'm trying to impliment the "Review ratings" schema on my Google listings.
My "total score" structure is as follows:
<div class="span7" itemscope itemtype="http://schema.org/Place">
<div class="stars" onclick="document.location.href='http://www.chambresdhotes.org/cgi-bin/links/review.cgi?ID=65995'" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<span class="badge badge-success">5 avis</span>
<meta itemprop="bestRating" content="10" />
<meta itemprop="worstRating" content="8" />
<meta itemprop="ratingValue" content="9.2" />
<meta itemprop="ratingCount" content="5" />
</div>
</div>
Then, for each of the reviews on that page - I also have:
<div class="reviewBox" itemscope itemtype="http://schema.org/Review">
<meta itemprop="author" content="Patrice" />
<meta itemprop="itemreviewed" content="Les Collinades" />
<div class="reviewRating" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<span class="link-rating"><span class="rating-5"></span></span>
<meta itemprop="bestRating" content="5" />
<meta itemprop="ratingValue" content="5" />
</div>
</div>
This all shows up OK when doing a schema check on the Google tool here:
https://search.google.com/structured-data/testing-tool#url=http%3A%2F%2Fwww.chambresdhotes.org%2FDetailed%2F65995.html
The "overall" ranking / number of reviews etc:
...and then the individual review scores:
However, when you go here its wrong:
https://www.google.fr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=site:www.chambresdhotes.org+Detailed%2F65995.html
I'm a bit baffled as to why its doing this. What am I missing?
Thanks!

It looks like you've filled out bestRating and worstRating with the best and worst ratings your business has received. However, these are intended to be used to define the best possible and worst possible ratings.
Going from your example, I assume your customers can rate your business on a scale of 1 to 10. As such, bestRating would have to be 10 and worstRating would have to be 1.
You then have to calculate the average overall rating yourself, and put that under ratingValue

Related

Replace operation breaks images in table OneNote (Graph API)

I have todo inside table. Also table contains image. Page screenshot
I need to mark "A" as completed. According to a documentation I should perform replace action for whole table.
First I call GET /me/onenote/pages/{pageId}/content?includeIDs=true to find right id of table (see "Page content before the PATCH" ⇩).
Then I send PATCH /me/onenote/pages/{pageId}/content with body:
[
{
"target": "table:{20c31cfe-9865-441d-9dbc-d8c53922d8f5}{21}",
"action": "replace",
"content": "<table border=\"1\"><tr><td><p data-tag=\"to-do:completed\">A</p></td><td><img src=\"https://graph.microsoft.com/v1.0/me/onenote/resources/1-66692d9b618447e9ad0d191137fcf91c!1-9857064f-8cbd-4b01-a41d-10e231bd6349/$value\"/></td></tr></table>"
}
]
API responds 204, and "A" is completed now. But image has been broken: updated page
How can I update a table that contains images?
Page content before the PATCH (Graph API response)
<html lang="en-US">
<head>
<title>Test 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="created" content="2018-10-08T12:03:00.0000000" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div id="div:{9f7149ca-3f9e-4275-8fa2-a51debcdb40c}{136}" style="position:absolute;left:48px;top:115px;width:624px">
<table id="table:{20c31cfe-9865-441d-9dbc-d8c53922d8f5}{21}" style="border:1px solid;border-collapse:collapse">
<tr id="tr:{20c31cfe-9865-441d-9dbc-d8c53922d8f5}{22}">
<td id="td:{20c31cfe-9865-441d-9dbc-d8c53922d8f5}{23}" style="border:1px solid">
<span lang="ru-RU" data-tag="to-do">A</span>
</td>
<td id="td:{20c31cfe-9865-441d-9dbc-d8c53922d8f5}{26}" style="border:1px solid">
<img id="img:{20c31cfe-9865-441d-9dbc-d8c53922d8f5}{54}" width="99" height="35" src="https://graph.microsoft.com/v1.0/users('0c2b9435-52c9-4480-a1d9-9faa92cecf51')/onenote/resources/1-66692d9b618447e9ad0d191137fcf91c!1-9857064f-8cbd-4b01-a41d-10e231bd6349/$value" data-src-type="image/png" data-fullres-src="https://graph.microsoft.com/v1.0/users('0c2b9435-52c9-4480-a1d9-9faa92cecf51')/onenote/resources/1-66692d9b618447e9ad0d191137fcf91c!1-9857064f-8cbd-4b01-a41d-10e231bd6349/$value" data-fullres-src-type="image/png" />
</td>
</tr>
</table>
</div>
</body>
Per the OneNote team, you need to do some transformation to the images before sending your PATCH.
When you do the GET for the page, the images come back with a src attribute like: https://graph.microsoft.com/v1.0/users('0c2b9435-52c9-4480-a1d9-9faa92cecf51')/onenote/resources/1-66692d9b618447e9ad0d191137fcf91c!1-9857064f-8cbd-4b01-a41d-10e231bd6349/$value. This value isn't actually a direct link to an image, but is a Graph request URL to get the image. This is the key problem.
Your app must make a GET on that URL to retrieve the image contents, then encode the binary image returned into base 64, then add that into the <img> tag. That should work around the problem.

Rails Conditional Facebook OG Tags

I have a Rails personality test app that uses AJAX to render the questions and show the results.
I have been attempting to share personality test results via Facebook by sending the variable to one of my dashboard Rails controller to dynamically create tags.
However, the variable is nil when the page is first loaded (which causes an error), so I fixed it by adding a conditional (in application.html.erb):
<% if #cat %>
<meta property="og:title" content="You got <%= #cat.name %>!"/>
<meta property="og:image" content="<%= #cat.picture %>" />
<meta property="og:description" content="<%= #cat.description%>" />
<meta property="og:url" content="https://mysite" />
<meta property="fb:app_id" content= "<%=ENV['FACEBOOK_APP_ID']%>" />
<meta property="og:type" content="website">
<% end %>
Facebook does not recognize the tags when I checked the sharing debugger. I also tried initializing with another object (home controller):
def index
if params.has_key?("cat")
#cat = Cat.find_by(name: params["cat"])
else
#cat = Cat.find_by(name: "Colonel Meow")
end
end
With this, Facebook does not render the new value, but renders the old value instead. I put a debugger in my application.html to make sure the variables were changing (they did). Facebook did not refresh though.
Is there a way to use a conditional when assigning the tags? Or to refresh the tags so Facebook uses the new variable?

Getting syntax highlighter to work with my rails blog

I am trying to use Syntax Highlighter to make my embedded code look great. I can do it on a html file but when I try on my rails blog it doesn't work.
My gut tells me it is something to do with my controller:
<pre class="brush: ruby;">
puts "Do you use Facebook? (Y/N)"
</pre>
<p>
<b>Entry:</b>
</p>
<%=sanitize #thought.entry %>
But the bit of html at the top is still running just fine...
<!DOCTYPE html>
<html>
<head>
<title>Blog</title>
<script src="/assets/shCore.js?body=1" type="text/javascript"></script>
<script src="/assets/shBrushRuby.js?body=1" type="text/javascript"></script>
<link href="/assets/shCoreDefault.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript">SyntaxHighlighter.all();</script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="1OAMJ6dGJ8c7CHunEe9IBkNrcIJwrfYdwtskSFRGvUQ=" name="csrf-token" />
</head>
<body>
<p id="notice"></p>
<p>
<b>Title:</b>
Facehook
</p>
<p>
<b>Entry:</b>
</p>
<pre class="brush: ruby;">
puts "Do you use Facebook? (Y/N)"
facehooked = gets
if facehooked == "Y" #upper- or lower-case?
puts "How many friends do you have?"
friends = gets
if friends > 30
puts "I asked how many friends you have. Not how many friends you have on Facebook. You are Facehooked."
elsif friends == 0
puts "I am sorry to hear that."
else
#How sociable are you in the real world?
#TODO - data-type checking
puts "Please answer the following questions with a number:\nHow many people would you like to see on a weekly basis?"
buddies = gets
puts "How many people do you happen to see on a weekly basis?"
acquaintances = gets
puts "How many people that you do not like do you have to see on a daily basis?"
forced = gets
puts "How many people would you love to see on a daily basis?"
true_friends = gets
people = buddies + acquaintances + forced + true_friends
#ratios
true_friends_to_buddies = true_friends / buddies
buddies_to_acquaintances = buddes / acquaintances
true_friends_to_acquaintances = true_friends / aquaintances
puts "How many 'friends' do you have on Facebook?"
facehooks = gets
if people == 0
puts "You are ninja. You drift among this world without a connection. Please do not kill me."
elsif people >= 500
puts "You are one social motherfucker!"
else
end
end
elsif facehooked == "N"
puts "You do not have a hook in your face. Congratulations."
else
puts "That question required a yes or no answer."
end
puts "You should follow #ricburton on Twitter - he likes talking to new people, making acquaintances and building friendships."
</pre>
Edit |
Back
</body>
</html>
Any help would be much obliged!
Any help would be much obliged!
For syntax highlighting on rails, i would recommend using using prism.js via the gem highlighting
The integration is extremely simple. You can read more on how to integrate with rails here https://github.com/ytbryan/highlighting

Grails g:include can it be done?

Im wondering if it is possible to use g:include to include only the body contents of a given page.
Say i have a main layout page as follows:
<html>
<head>
<title>My start page</title>
<g:layoutHead>
</head>
<body>
<g:layoutBody>
</body>
</html>
Then a main page (index.gsp)
<html>
<head>
<!-- main layout reference -->
<meta name="layout" content="main"/>
</head>
<body>
THIS IS MY INDEX BODY CONTENT WITH AN INCLUDE
<g:include controller="book" action="list"/>
<g:link controller="book" action="list">See the full list!</g:link>
</body>
</html>
And finally the book/list page
<html>
<head>
<!-- main layout reference -->
<meta name="layout" content="main"/>
</head>
<body>
<table>
<g:each in="${books}">
<tr>
<td>${it.author}</td>
<td>${it.title}</td>
<td>${it.price}</td>
</tr>
</g:each>
</table>
</body>
</html>
So what i want to achieve is that the main page (index.gsp) only includes the table defined in the book/list page. However, when i try this it includes the entire html defined (<html> tags and all).
is it possible to do this somehow? i've tried things like <g:include controller="book" action="list" view="someView.gsp"/> however this doesn't work. I really want to avoid having to add a book list logic to the "index controller" i want to reuse my existing controller.
I can't be the first person out there having this usecase, what solutions have you guys come up with?
You can use the applyLayout tag. Simply create an empty.gsp layout with only:
<g:layoutBody/>
And then decorate your include tag with applyLayout:
<g:applyLayout name="empty">
<g:include controller="book" action="list"/>
</g:applyLayout>
See the entry on the Grails guide for further reference.
This is IMHO directly not possible. An idea would be to create a custom tag based on g:include, that strips out parts of the code by e.g. an xpath expression. I'm not aware that this already exists somewhere.
An alternative would be to refactor the body part of book's list.gsp into a template and reference that template from index.gsp using g:render. But this means that the data model has to be available in index.gsp context since g:render does not invoke a controller.
Side note: when using g:include it's a good idea to use the springcache plugin for page fragment caching.
Yes, but you need you need one more level in there. Look at Grails templates. Essentially, you'd have a template: _books.gsp containing:
<table>
<g:each in="${books}">
<tr>
<td>${it.author}</td>
<td>${it.title}</td>
<td>${it.price}</td>
</tr>
</g:each>
</table>
Then your index would be:
<html>
<head>
<!-- main layout reference -->
<meta name="layout" content="main"/>
</head>
<body>
THIS IS MY INDEX BODY CONTENT WITH AN INCLUDE
<g:render template="books">
<g:link controller="book" action="list">See the full list!</g:link>
</body>
</html>
And your list would be:
<html>
<head>
<!-- main layout reference -->
<meta name="layout" content="main"/>
</head>
<body>
<g:render template="books" />
</body>
</html>
(My syntax may not be 100% right, since it's been a couple months since I've done this, but the idea behind templates are short, reusable pieces of GSP code that aren't meant to be displayed on their own.

Grails display gsp inside div

Hey. Imagine i have two separate gsp pages with diferent css formatting (with name conflicts between two). And i want to "display" or render one page with its ows formatation inside a div in the other page. Imagining this scenario:
page1.gsp
...
...
<div id="here"></div>
...
...
page2.gsp
Hello there!
I want my final page to be:
...
...
Hello there!
...
...
Is it possible to do that?
Yes use the g:render tag and create a "fragment" page to contain your content.
then use the g:render tag to pull it in.
Refer to the documentation or tutorials for more detail on this.
This is very similar to a question I posted a couple of days ago:
Can I display an inner dive with an independent stylesheet?
Is this something you want to work for every page? (Like a layout?)
If that is the case, use SiteMesh (built in already)
{app}/grails-app/views/layouts/mylayout.gsp
<html>
<head>
<g:layoutTitle default="My Application" />
<link rel="stylesheet" href="${resource(dir:'css',file:'layout.css')}" />
<g:layoutHead />
</head>
<body>
<div id="here"><g:layoutBody /></div>
</body>
</html>
{app}/grails-app/views/{somefolder}/page1.gsp
<html>
<head>
<meta name="layout" content="mylayout" />
<link rel="stylesheet" href="${resource(dir:'css',file:'page1.css')}" />
</head>
<body>
Hello There!!!!
</body>
</html>
If you already have that, and are just looking at breaking up you pages and keeping them DRY..
{app}/grails-app/views/{somefolder}/page1.gsp
<html>
<head>
<meta name="layout" content="yourLayout" />
<link rel="stylesheet" href="${resource(dir:'css',file:'page1.css')}" />
</head>
<body>
<div id="here2"><g:render template="page2" model="[foo:'bar']"/></div>
</body>
</html>
* The Model property of render is optional, but works for passing data to the template to be rendered
{app}/grails-app/views/{somefolder}/_page2.gsp
* Notice the "_" before the gsp name. (Convention for Template pages)
Hello There
Checkout the documentation for render and templating

Resources