Including CSS File in my Plone add-on - plone

I want to add a simple stylesheet to a plone 4 product. Therfore I added
<browser:resourceDirectory
name="groovecubes.portlet.gallery.css"
directory="css"
/>
to [product dir]/browser/configure.zcml, which should me enable to browse stylesheets in this folder with this syntax: ++resource++groovecubes.portlet.gallery.css/mycss.css. But it doesn't. Not even after a buildout.
Every declaration in [product dir]/profiles/default/cssregistry.xml are therefore not found. What am I missing? Is it the package name?
The packages main configure.zcml contains the line
<include package=".browser" />
which should execute browser/configure.zcml
But is does not. I pasted the packages configure.zcml and browser/configure.zcml
Update II:
It gets even weirder. When I modifiy the head of browser/configure.zcml the file is recognized as malformed when I try to start the instance. But when I modify the relevant entry, startup continues normal.
Update III:
I've tested various things now, but what I found out, is that any malformed tags in .zcml files is ignored by the SaxParser. In every product on my dev and productive instance (Plone 4.2 / Plone 4.1). Is that maybe a new feature, I may have missed?
Update IV:
Solved: I removed the interface declaration from browser/configure.zcml that accidently used the same name. That made my .css available. But I'm still wondering about the described parser behaviour.

You declare the name groovecubes.portlet.gallery.css but try to access it as ++resource++groovecubes.portlet.gallery instead (note the missing .css there).
Either use ++resource++groovecubes.portlet.gallery.css/mycss.css or remove the .css part from the resourceDirectory registration.
If that was just a typo, check that the ZCML file is actually being loaded; the registration itself is fine if the names match.

Related

Trying to override templates in FOSUserBundle, but having no effect

I'm trying to modify the skin of the register.html.twig template found in FOSUserBundle/Resources/views/Registration/register.html.twig.
I've basically followed the instructions in the documentation down to a T.
Like it told to do so, I created /app/Resources/views/FOSUserBundle/views/Registration/register.html.twig.
Cleared the cache (and browser cache just to be sure)
NO effect! I've put a blank file in register.html.twig, but no matter what I put there, when I go to /register/, I still see the default template.
Yep, these things happen all the time.
It should be:
/app/Resources/FOSUserBundle/views/Registration/register.html.twig
Reference

How can we save multimedia components using external resource types if the URL doesn’t end in with a file extension?

We have a Tridion use case related to curated content where we are creating multimedia components for images associated with our content which are pointing to External resource types instead of uploaded resource types.
One of the issues we have run into with this use case is that despite explicitly setting the Multimedia Type for the resource, if the URL of the image has either a query string in it: http://cdn.hw.net/UploadService/1c8b7f28-bb12-4e02-b888-388fdff5836e.jpg?w=160&h=120&mode=crop&404=default or uses a ‘friendly url’: http://www.somewhere.com/images/myimage/ when we save the component, Tridion barfs with error messages similar to : ‘Invalid value for property 'Filename'. Unexpected file extension: jpg?w=160&h=120&mode=crop&404=default. Expecting: jpg,jpeg,jpe.’
So far, the only way we’ve been able to figure out to potentially get around this issue is to do something hacky like appending an extra query string parameter to the very end of the urls which end with the expected file extension: http://cdn.hw.net/UploadService/1c8b7f28-bb12-4e02-b888-388fdff5836e.jpg?w=160&h=120&mode=crop&404=default&ext=.jpg Obviously, this is not the best solution and in fact may not work for some images if the site they are being served from strictly validates the requested URL.
Does anyone have any ideas on how we can work around this issue?
Unfortunately I can't really think of an easy solution to this, since Tridion "detects" the Mime type by checking the file extension.
You could perhaps add it while saving and remove it when reading (via Event System)? Definitely a worthwhile enhancement request, to my knowledge this behavior has not been changed for the soon-coming Tridion 2013... See comment below, it has been changed for 2013.
+1 for Nuno's answer. Recognizing that the title of your question is specific to multimedia components, you may want to consider another approach which is to use normal Components, not Multimedia Components. You can create a normal component schema called something like "External Image" that has an External Url field to store your extentionless url.
Content authors will then include these images via regular component linking mechanisms in the Tridion GUI.
You will then need a custom link resolver TBB that will parse the Output item (via Regex) looking for any Tridion anchor tags <a tridion:href="tcm:x-y-z"> and for each one replace them with an <img src=...> tag where the src path would come from this linked component.
For an example of a similar approach, but with videos, and sample code for a custom link resolver TBB have a look at the code in the following post: http://www.tridiondeveloper.com/integration-sdl-tridion-jw-media-player.

Use a Pygments lexer with no mime type in Trac?

I'd like to have Trac colorize my aspx files but I can't find a way to make it work. I can easily add a mime-type/extension mapping for most Pygments lexers, but the CSharpAspxLexer doesn't have an assigned mime type (see http://pygments.org/docs/lexers/#lexers-for-net-languages). I've tried a couple things but I don't see a way to connect the [mimeviewers] section to Pygments without a mime type. The CSharpLexer works automatically and looks great, but only for .cs files (as it should).
I'm using Mercurial as a repository so I can't set the mime type manually; that's not a good solution anyways. My Trac installation is in Windows. Any thoughts?
I just render it as XML, and the same for a number of other similar files for typical Windows .Net development. My mapping looks like this:
[mimeviewer]
mime_map = text/xml:aspx:ascx:master:resx:config:sitemap:wsdl:disco:map:asmx:mxml:csproj, ...
However, I think you can also enable aspx via the pygments_modes setting (and you need to remove it from the mime_map):
[mimeviewer]
pygments_modes = text/plain:aspx-cs:7
To my knowledge that won't handle ascx and other (very) close relatives of aspx, so I don't use the setting as I find it better to render all variants using the same lexer. And also, I think the XML lexer works really well.

Plone imagemaps error with zopyx.tinymceplugins.imgmap

I'm using Plone 4.2. I had the need to manage imagemaps in my application so I installed the following product: http://pypi.python.org/pypi/zopyx.tinymceplugins.imgmap. This product uses TinyMCE to edit the images and add links to them.
After installing this product, I noticed that I am now unable to view my TinyMCE controls while editing a content type. Looking at my browser's error console, I notice that all my *.kss cannot be read. This is the error that is displayed for all *.kss files:
Error: The stylesheet http://localhost:8082/plone/portal_kss/My%20CMS%20theme/++resource++tinymce.kss/tinymce.kss was not loaded because its MIME type, "text/plain", is not "text/css".
Source File: http://localhost:8082/plone/folder-test/image-maps-test/page-with-imagemap/edit
Line: 0
I do not understand why there should be error regarding the MIME type. Anyone has a clue on how to fix this?
Additionally, I get the following:
GET http://localhost:8082/plone/portal_javascripts/My%20CMS%20theme/plugins/imgmap/editor_plugin.js 500 (Internal Server Error)
Just to answer my own question:
I opened the product's skins.xml file
(i.e. zopyx.tinymceplugins.imgmap-0.3.1/zopyx/tinymceplugins/imgmap/profiles/default/skins.xml)
This is how it looks like:
<?xml version="1.0"?>
<object name="portal_skins" allow_any="False" cookie_persistence="False">
<object name="zopyx_tinymceplugins_imgmap"
meta_type="Filesystem Directory View"
directory="zopyx.tinymceplugins.imgmap:skins/zopyx_tinymceplugins_imgmap"/>
<skin-path name="Plone Default">
<layer name="zopyx_tinymceplugins_imgmap"
insert-after="custom"/>
</skin-path>
<skin-path name="Sunburst Theme">
<layer name="zopyx_tinymceplugins_imgmap"
insert-after="custom"/>
</skin-path>
</object>
It appears that the product has been geared towards specific themes.
Now, my application has a custom theme i.e. MyCustomTheme. When I inspect my portal_skins
Site > Zope Management Interface > portal_skins > properties
I notice that indeed the "Sunburst Theme" has included the zopyx_tinymceplugins_imgmap skin layer in the 'Plone Default' and 'Sunburst Theme', but NOT in my 'MyCustomTheme'. It has added it right after the custom layer.
So I go ahead and manually add zopyx_tinymceplugins_imgmap in MyCustomTheme, just immediately after the custom layer.
This manages to fix it, and I can now view my TinyMCE controls. I believe there must be a better way to have it work.
Hope this helps someone in future.
UPDATE: See this for a better solution.

How to strip out character references inserted by Diazo into text nodes

I'm using plone.app.theming 1.0b5 and Plone 4.1 rc3. Our Diazo rules contain an number of external content includes and we're using one such include to insert Google Analytics script into the result:
<append theme="/html/head" content="/html/head/script"
href="##standard-page-elements" />
Unfortunately the script tag from the view is being mangled during the transform such that any carriage returns are converted to character references (
)
This is due to the way lxml serializes and deserializes (see this Plone bug report).
I'd like a work around in the meantime but can't figure out a Diazo rule that would strip these references out.
As noted above:
The bug has been fixed in the trunk of Diazo (thanks Laurence) so I no longer need to do this. I didn't manage to figure it out: it doesn't seem to me you can alter external content through Diazo, only the main content.

Resources