HTML5 validator failing on Facebook OpenGraph XML Namespace xmlns:og - facebook

HTML 5 validator is failing on my code despite me following the Facebook documentation to the letter. There are a variety of problems but let's start with one example to start with.
I'm following the Facebook "Getting Started" documentation and using th5is code:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
The only difference is I precede this with <!DOCTYPE html> for HTML5. When running it through the W3C HTML5 validator I get this error:
Attribute xmlns:og not allowed here
The only things I can think of what the error are:
Facebook's documentation is wrong
I'm supposed to add some kind of namespace to the <!DOCTYPE html> declaration.
However, in either case I don't know what the fix is. Would love some help!

fb's documentation isn't wrong, but their approach to open web is. those are fb proprietary attribute values, so they're not going to ever validate, unless w3c makes them standards. that may sound gloomy, but as long as those are your only validation errors, don't worry about it. validation is an awesome tool, but remember, it's just a tool.

So I have run across a version of this same error, 3 years later it seems. Trying to validate my site using HTML5 and although it is experimental, everything validates except these xmlns attributes.
for example..
Error Line 2, Column 105: Attribute xmlns:fb not allowed here. …b="http://ogp.me/ns/fb#" xmlns:addthis="http://www.addthis.com/help/api-spec" >
Warning Line 2, Column 105: Attribute with the local name xmlns:fb is not serializable as XML 1.0. …b="http://ogp.me/ns/fb#" xmlns:addthis="http://www.addthis.com/help/api-spec" >
Error Line 2, Column 105: Attribute xmlns:addthis not allowed here. …b="http://ogp.me/ns/fb#" xmlns:addthis="http://www.addthis.com/help/api-spec" >
Warning Line 2, Column 105: Attribute with the local name xmlns:addthis is not serializable as XML 1.0. …b="http://ogp.me/ns/fb#" xmlns:addthis="http://www.addthis.com/help/api-spec" >
Line 2 of my code is as follows:
2.<html lang="en-US" xmlns:fb="http://ogp.me/ns/fb#" xmlns:addthis="http://www.addthis.com/help/api-spec" >
having researched this error, which mirrors your error, it seems that even 3 years later, there is no viable fix for this. However, it seems that plugins that are following this technique are doing so when there is correct HTML5 code available. So make sure you select the correct code if doing the addin on your site such as the following link for facebook:
HTML5 Facebook Info
That should take care of your errors at the least, for those of us trying to use a plugin to handle multiple likes, shares, and plus ones, it might be best to just do each instance by itself.

Related

Jekyll compilation: Process completed with exit code 1 on Github

I am using cayman theme for github for writing scientific articles which i can host on Github pages. I am using mathjax to render equations.
I have pasted the following lines inside the cayman/_includes/head-custom.html file.
<script type="text/javascript" id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax#3/es5/tex-mml-chtml.js">
</script>
Mathjax renders the math equations correctly (local and remote), but it produces an error on Github (image attached). I can not make anything out of this error, I am a little concerned that it may create bigger issue later on.
Any guesses why this error and how to fix it.
It appears that your html-proofer test script implementation is set to check for CORS/SRI on external js resources and thus is throwing a validation error because it's expecting a couple of additional attributes on all <script> tags (that aren't there currently on the tags in question), crossorigin="anonymous" and integrity="...insert-sha256-value-here..."
My understanding is that SRI needs to be supported by the developer and therefore the integrity value should be coming from them.
If MathJax hasn't provided an integrity value along with their CDN script code then I think you may need to disable checking for CORS/SRI to eliminate the error.
Do you have access to the script that contains the command that runs html-proofer, and if so, can you see if it's checking for SRI? Might look something like this:
htmlproofer --check-sri ...
According to the html-proofer docs, --check-sri defaults to false, so if this option is being set and you can disable it, I'd give that a try.

GWT 2.7: Warn users they are using an unsupported browser

I recently upgraded my application to GWT 2.7 from GWT 2.5. This has caused me to drop support for IE6 and IE7.
I would like to provide users with IE6 or IE7 with a warning that their browser is outdated and will not work. At the moment if you go to the app with one of those browsers, you get a blank screen.
I know there are a couple ways that I could hack something together but I would rather use the GWT way, rather than some hack. Is there a GWT hook for unsupported browsers?
Option (hack) One
Drop this into my main.html:
if(document.documentMode === 6 || document.documentMode === 7){
myUnsupportedBrowserWarningFunction();
}
Potential problem with this is that if someone is using a browser that GWT doesn't recognise and I don't recognise (mobile opera? Some other browser), they will still get a blank page.
Option (hack) Two
GWT looks for the compiled JS here:
gwt/myApp/ASDFKLSDJFLSFDJSLDFJLSJDFSDES.cache.js
When someone is using an unsupported browser the following is requested (and is not found):
gwt/myApp/undefined.cache.js
It would be possible to create undefined.cache.js and put your unsupported browser code there. This is obviously a brittle solution and will break with future GWT updates.
Option Three
A recent patch (available in GWT 2.7) allows you to provide a default
permutation (e.g. safari) if GWT can not detect the browser and with
deferred binding you can display a warning that the provided app might not
work correctly as the browser is generally unsupported by GWT.
-- J.
Source
I don't want to set a default permutation for unsupported browsers. I want the site to not work and to display a warning. So this solution doesn't really provide what I am looking for.
Similar Questions & Posts
The same question was asked for an eariler version of GWT in 2009. I hope that GWT has added some kind of hook or best practice in the last 6 years.
More info on setting a default (fallback) permutation
You should be able to use onLoadErrorFn for that: https://code.google.com/p/google-web-toolkit/issues/detail?id=8135
<script>
function gwtLoadError(errMsg) {
// GWT app couldn't load, reason in errorMsg
}
</script>
<meta name="gwt:onLoadErrorFn" content="gwtLoadError">
or possibly onPropertyErrorFn:
<script>
function gwtPropError(propName, allowedValues, actualValue) {
if (propName == 'user.agent') {
// unsupported browser
}
}
</script>
<meta name="gwt:onPropertyErrorFn" content="gwtPropError">
(I don't think user.agent.runtimeWarning would help in this case, but maybe have a look)
There is an easy way:
Conditional Comments
<!--[if lt IE 8]>
<p>You are using an unsupportet browser. Please perform an update</p>
<![endif]-->
I think Option 3 may be the best one, but there is a problem: This will start the actual application (which still may be incompatible).
If this is an issue and you want a clear warning, you can rewrite the permutation selection script (You would need to update the script with the upcoming GWT releases)
You will need to copy this source:
https://gwt.googlesource.com/gwt/+/2.7.0/user/src/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java
You could add something like:
$wnd.Location.replace('nosupported.html');
between line 90 and 91

EL Validation - How do I detect invalid EL from JSF xhtml in eclipse?

Many times, when I am developing, I start a JSF app and only when I hit the page, it detects some invalid EL value, or even worse, it's not interpreted and silently ignored, without any warning.
Is there any way to validate EL values from xhtml files with eclipse while writing the xhtml file?
ps. even a compile-time solution would be nice too.
Had same question.
Try Window > Preference > Web > JavaServer Faces Tools > Validation > Identifier Resolution > Member not found... set it to Error.
This gave me at least give an error in the xhtml page when writing the EL expression wrong. However, it doesnt give an error when you refactor your manged beans in such a way that the EL expression get broken. Bit strange. There is probably another button somewhere to initialize JSF/EL validation on xhtml pages when changing java-files/managed beans to fix it, but havnt found it.

Nancy.SassAndCoffee: Trouble Getting Started

I am brand new to NancyFX and currently enthralled by its low-ceremony approach to web application development. Throwing myself in at the deep-end, I also want to use CoffeeScript and investigate the benefits of Sass.
The Set-Up
To enable this combination I have created a new Empty Web Application using the VS2010 template (found in the Nancy Accessories project). I have then used the VS PackageManager to Nancify my application and add the SassAndCoffee support:
PM> Install-Package Nancy
PM> Install-Package Nancy.SassAndCoffee
So far so good. I then created an ~/Content/scripts folder and in there I have placed a file called home.coffee containing the following line of CoffeeScript.
alert "Hello Nancy!"
Now things start to get a bit fuzzy. I want to run this script on the client so I create an view called ~/Views/home.sshtml (and associated NancyModule with Get["/"] route - not shown). The view's html looks like this:
<head>
<title>Hello Nancy</title>
<script type="text/javascript" src="/content/scripts/home.js"></script>
</head>
<body>
<p>Hello #Model.User</p>
</body>
</html>
The view works just fine but the link to the home.js file just returns a 404: Not Found.
I am hoping that somehow Nancy will magically work out that I need my CoffeeScript compiled to JavaScript when it looks for the referenced home.js file and finds the home.coffee instead. This didn't work - so much for inspired guesswork.
If I change the script tag above to point to the existing home.coffee instead then the file is found but processed as a normal JavaScript file giving errors concerning the lack of tiresome ceremony namely: "unexpected string"
The Question
Now you know my set-up and simple requirements, here then is my question:
How do I get CoffeeScript to 'just work' using the NancyFX framework?
Thank you
Update
Steven Robbins (below) has answered this question by pointing to the demo code. But just in case you don't want to pull MBs of source from GitHub, here are the lines required to get things going. First add a class called Bootstrapper.cs to your project. Now add the following code (it worked like a charm for me):
public class Bootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
StaticConfiguration.DisableErrorTraces = false;
Hooks.Enable(pipelines, new InMemoryCache(), container.Resolve<IRootPathProvider>());
}
}
The SassAndCoffee project doesn't hook into the static content bit in Nancy, it (or something similar) may in the future, but at the moment it's just a separate pipeline hook.
If you take a look at the sample project on github:
https://github.com/NancyFx/Nancy.SassAndCoffee/tree/master/src/Nancy.SassAndCoffee.Demo
That should show you how to get it going.

Custom Lift tags don't work

The following types of tags in Lift do not seem to work for me:
<lift:snippet type="MyClass:render" />
<lift:MyClass.render/>
<lift:MyClass/>
Using these tags results in a Class Not Found error. If I attempt to call a class using
<div class=lift:myclass.mymethod />
it can work. Or if I call it using span tags. For instance, the Hello World example in Pollak's Simply Lift works for me, successfully displaying the Howdy method with the following code:
<span class="lift:helloWorld.howdy">
Welcome to your Lift app at <span id="time">Time goes here</span>
</span>
Currently, my problem is coming from attempting to implement Exploring Lift's (aka The Lift Book) OpenID example in Chapter 13.1. I have downloaded OpenID4Java using sbt as well as the lift-openid library. That example can be found at http://exploring.liftweb.net/master/index-13.html. I have implemented the change to the Boot class, and created the OpenID class and the SimpleOpenIDVendor class. But creating an html file containing
<lift:OpenID.form>
<openId:renderForm/>
</lift:OpenID.form>
causes the following error to be displayed in the browser:
Error processing snippet: openid.form
Reason: Class Not Found
XML causing this error:
<lift:openid.form xmlns="http://www.w3.org/1999/xhtml">
<openid:renderform>
</openid:renderform></lift:openid.form>
The class OpenID was placed in a package that starts with the package code, which is being implicitly found by Lift. It is included in the Boot.scala file with the line
LiftRules.addToPackages("code")
So, I am at a loss. Any ideas?
Note that other lift tags such as lift:bind-at and lift:surround and the like work fine.
As dave posted under my original comment, the problem was the HTML5 parser. Lift is case-sensitive, and cannot find a class with varying case. Since the HTML5 parser automatically makes tags lowercase, you can't use custom lift tags anymore. Instead, you have to use something like
<div class="Lift:MyClass.render"></div>
Note that you CANNOT have
<div class="Lift:MyClass.render" />
as HTML5 apparently does not support such tags.
My OpenID4Java problem is therefore resolved by using:
<div class="lift:OpenID.renderForm">
</div>
Why I don't need to use openid.form still is uncertain. It could be possible I'm implementing it slightly off, but I confirmed that it will take me to an openid login page if I put in the openid link, so it is indeed functional.
Sources:
http://groups.google.com/forum/#!topic/liftweb/H-xe1uRLW1c
https://groups.google.com/group/liftweb/browse_thread/thread/3948df1eee6ec271/ (thanks fmpwizard)