Returning a page template without diazo - plone

Running: Plone 5.0.0 with Diazo.
How does one permanently bypass the diazo theme applying in BrowserView templates? (Not with the diazo.off=1)
Example:
I have a diazo theme. I have a template that I'm returning via a BrowserView's ViewPageTemplateFile:
class ExhibitView(BrowserView):
template = ViewPageTemplateFile("exhibit.pt")
def __call__(self):
return self.template()
The exhibit.pt file is as follows:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
i18n:domain="plone"
lang="en">
<body>
Is it just this text?
</body>
</html>
I removed the plone master template, it is still applying the diazo rules. I just want it to return a barebone template, unthemed by diazo. We used to be able to do that before Diazo as I shown above.
Also making a Diazo rule to skip this is out of the question because it has to be installed in many places, I don't want to apply rules to everyone's site themes to make this work. That is hacky.
Thanks in advance!

According to this line:
https://github.com/plone/plone.app.theming/blob/5ba9447150776f7edbfd73b528b9b62f31dd14b5/src/plone/app/theming/policy.py#L79
If you have an header called 'X-Theme-Disabled' the transform is not applied. Two lines later you see the condition that is checking for "diazo.off".
So you should modify your __call__ method in a way that it sets the header before returning the template.
Something line this:
def __call__(self):
self.request.response.setHeader('X-Theme-Disabled', '1')
return self.template()
The control panel is doing the same:
https://github.com/plone/plone.app.theming/blob/fbbdc3bfdbccf2315cef069fe827fea863feb1c8/src/plone/app/theming/browser/controlpanel.py#L72
Caveat: I did not tested this :)

Related

Include og: tags in Meteor App

I have read How to integrate Facebook's Open Graph in a Meteor application? and followed it closely, however, the og tags are still not registered):
I would just like to set several images to ensure that several thumbnails appear when u type http://bubble.meteor.com in facebook
Here are my codes:
(Updated)
<head>
...
<meta property="og:image" content="http://bubble.meteor.com/img/ogimage1.png">
<meta property="og:url" content="http://bubble.meteor.com">
<meta property="og:title" content="Emory Bubble">
</head>
Am I doing anything wrongly? Thanks!
First of all, an <html> tag does not belong inside the <head>. Meteor always uses the HTML5 doctype definition. Even if you would manage to change it to XHTML, you will probably end up with invalid XHTML, because extension packages that inject HTML assume HTML5.
Second, there is no need to declare any namespace for the OpenGraph tags. Strings like "og:title" are just opaque data inside a property and they do not affect the HTML parser.
UPDATE
I checked it using Facebook's debug page and it does not work indeed:
http://developers.facebook.com/tools/debug
This yielded an "Error parsing input URL, no data was scraped" error.
I also checked the page using the special escaped fragment URL that should trigger the spiderable package:
http://bubble.meteor.com/?_escaped_fragment_=
The resulting page contains no HTML content and the Javascript tags were still present, suggesting that the spiderable package does not work. Did you add that one to your project? (meteor add spiderable).
If you added it, it does not work. The spiderable package returns the normal page if running PhantomJS fails. You should check it on your local development version, use the above URL to trigger spiderable.
I also noticed that you are using 'school' as og:type, which is not a valid type as far as I know. Try 'website' instead.
UPDATE 2
Also checkout this screencast by Chris Mather about the spiderable package:
http://www.eventedmind.com/posts/meteor-the-spiderable-package
In this screencast he mentions a potential problem with subscriptions that are never marked as ready and make the spiderable package fail. Maybe this is causing your issues?

How to convert .aspx pages and master pages to html pages?

I am doing one project in asp .net.Its completed,then the same project will be done in html5. How to convert the .aspx pages and master pages to html 5? Is it possible?If any one know please tell me.
You can technically make the page HTML5 by changing the doctype...
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
It is also recommended that you specify a lang attribute on the html tag and include the meta tag to define your character set.
This won't give you instant HTML5 semantics, but this is essentially step one. Using the right elements for the right kinds of content will be down to you, for example deciding when to use header, article, section, footer instead of plain div elements and so on.
You should also be able to select "DOCTYPE:HTML5" from the toolbar in Visual Studio - I don't know what version you are using, but I think in the previous version you could download a HTML5 language extension, I'm pretty sure it is included by default in Visual Studio 2012.
what you can do... if I understand your question correctly is, rightclick and say view page source and copy your html or install google chrome and the on each page you can go rightclick and inspect element. you can copy and paste the html of each page including the masterpage content. Its a sloppy way but will work if you only want the html
One of the way that i think you can do is to use http://modernizr.com/ kind of framework to switch between html5 and normal html easily .

Diazo add unwanted html header into json response

I have a blank Plone 4.1 site with only collective.quickupload installed. The upload portlet worked fine until I install plone.app.theming and apply my theme. The files were still uploaded, but the web client got "Failed" status.
Inspecting the ajax response from server I found that they were wrapped by html header.
The old response (before install diazo & apply my theme) was simply
{"success":true}
The new response (after install diazo and apply my theme) was being wrapped by a html tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><body><p>{"success":true}</p></body></html>
I've pasted my rule.xml file here (nothing special, there is only one rule conditioned by css:if-content="#visual-portal-wrapper"): http://pastebin.com/SaK13Fni
What should I do to work around this ?
Thanks
To avoid this behavior you have to add an exception in your rules.xml that specify to not apply your theme to your specific view , like this:
<notheme if-path="myjson_view"/>
edit:
I've tried with one of my diazo themes and a json view and I didn't have your issue. So I think the problem is either in your rules.xml or in your json view. You should try one of these two way:
change your rules.xml this way:
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Prevent theme usage in zmi-->
<rules css:if-content="#visual-portal-wrapper">
<theme href="index.html" />
</rules>
have you already specified the "Content-type" of the output in
your json view? Like this:
self.request.response.setHeader("Content-type","application/json")
return json_data
If not, that's probably the problem.
Watch out for using Chrome inspector... it adds the html head and pre tags around your json when you inspect it...it's not actually there if you look at view:source of the page (old school)...

Correct content type for html use?

I was using XHTML on my website but that completely destroyed jQuery and its plugins.
Therefore, I want to go back to html 4. I am defining some custom attributes for my html, like so:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd" [
<!ATTLIST mytag myattribute CDATA #IMPLIED>
]>
This seems to be valid html for, but when I pass such a page from my server with a content type of text/html, my browser displays ']>' - it can't parse the doctype properly.
Is there a different content type I should be using?
From A List Apart
If you run such a file through the W3C validator, you find that it
validates wonderfully well. If you download the sample files for this
article and validate file internal.html, you can see this for
yourself. Unfortunately, when you display the file in a browser, the
]> shows up on the screen. There’s no way around this bug, so this
approach is right out.
So this basically isnt going to work. To get it to work you need to copy the DTD you want the server/local machine, edit it appropriately and put it in a publically accessible place. See the article for more detail.
As far as jQuery is concerned, it should work fine if you quit trying to customize the DTD in the fashion that you are. Im not sure about using a custom DTD as I have never done it, but just adding the attributes to the elements and not defining them in the DTD shouldnt cause a problem with jq. Granted the document wont validate, but validation is just a tool and not overly important in the grand scheme of things.

Is it possible to remove base and Content-Type + alter HTML attributes in Diazo?

I am trying to make a HTML5/CSS3 theme with Diazo from a Plone site, using plone.app.theming 1.0b8. It is working like a charm in the BODY part. But the HTML tag and HEAD part are more difficult. To me at least :)
I have tried to:
remove xmlns and xml:lang attributes in the HTML tag
<drop attributes="xmlns xml:lang" theme="/html/" />
remove base tag
<drop theme="/html/head/base/" />
remove meta tag where http-equiv="Content-Type"
<drop theme="/html/head/meta[#http-equiv='Content-Type']" />
I am wondering if plone.app.theming or Diazo is forcing these things into the output, or if it's my xpath which is buggy? I have searched around but found no answers.
BR
Your xpaths probably should not end with a trailing '/', though I don't think this is the problem here.
It won't be possible to remove the xmlns attribute as that is added by XMLSerializer in XHTML mode (at least under common circumstances). You could set an HTML serialization instead with <xsl:output method="html"/> inside your root rules tag.
In XHTML mode, the XMLSerializer will add an xml:lang to match the lang attribute. Again, try setting the html serialization.
Normally the base tag gets copied from the content into the theme - there ought to be no reason to have a base tag in a theme html file. If you don't copy it over, it won't end up in the output. However it is advisable to always include a base tag in output from Zope as the same page will be rendered at both http://localhost/some_url and http://localhost/some_url/, which will lead to differences with any relative urls.
The content-type header is added by libxslt is unconditionally added by libxslt and is impossible to suppress.

Resources