Tridion 2011 GUI Extension, how to include css file? - tridion

I've been building a JavaScript and CSS only GUI extension.
I followed the instructions in Albert's post here:
http://albertromkes.com/2012/01/30/tridion-gui-extensions-how-to-load-a-javascript-without-showing-a-gui-element/
The JavaScript loads in OK but I can't get the CSS included, am I missing something?
Here's an approximation of my configuration file:
<?xml version="1.0" ?>
<Configuration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge"
xmlns:cfg="http://www.sdltridion.com/2009/GUI/Configuration"
xmlns:ext="http://www.sdltridion.com/2009/GUI/extensions"
xmlns:cmenu="http://www.sdltridion.com/2009/GUI/extensions/ContextMenu">
<resources cache="true">
<cfg:filters/>
<cfg:groups>
<cfg:group name="Rob.Prototype.Extensions"
merger="Tridion.Web.UI.Core.Configuration.Resources.CommandGroupProcessor"
merge="always">
<cfg:domainmodel name="Rob.Prototype.Extensions.Domain">
<cfg:fileset>
<cfg:file type="script">/Scripts/script1.js</cfg:file>
<cfg:file type="script">/Scripts/script2.js</cfg:file>
<cfg:file type="style">/CSS/styles.css</cfg:file>
</cfg:fileset>
<cfg:services/>
</cfg:domainmodel>
</cfg:group>
</cfg:groups>
</resources>
<definitionfiles/>
<extensions>
<ext:editorextensions/>
<ext:dataextenders/>
</extensions>
<commands/>
<contextmenus/>
<localization/>
<settings>
<defaultpage>/Views/Default.aspx</defaultpage>
<navigatorurl>/Views/Default.aspx</navigatorurl>
<editurls/>
<listdefinitions/>
<itemicons/>
<theme>
<path>/CSS/</path>
</theme>
<customconfiguration/>
</settings>
</Configuration>

The domain model is supposed contain non-visual things only, so Tridion only processes non-visual file types. You should not include CSS files in a domainmodel, but instead put them in a separate fileset outside of any domainmodel.
This requires that you have a GUI element that uses the group that your CSS is in. If you weren't planning to add any GUI elements, you could add a dummy ribbon button to links to the CSS.

I don't have the answer Rob but the following blog post from #poeticGeek may help you out.
Setting up a Tridion 2011 GUI extension in 8 steps

This might help you
How does the Tridion GUI Extensions CommandSet map to js methods?
The same should apply to CSS as for JS.
If that doesn't work, have you tried incrementing the modification attribute in System.config stored at C:\Program Files (x86)\Tridion\web\WebUI\WebRoot\Configuration

Here is the config from an extension I wrote that 'injected' javascript into the publish dialog view, maybe worth giving it a shot to see if it also includes any css:
<?xml version="1.0"?>
<Configuration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge" xmlns:cfg="http://www.sdltridion.com/2009/GUI/Configuration" xmlns:ext="http://www.sdltridion.com/2009/GUI/extensions" xmlns:cmenu="http://www.sdltridion.com/2009/GUI/extensions/ContextMenu">
<resources cache="true">
<cfg:extensiongroups>
<cfg:extensiongroup name="Company.Extensions.Group">
<cfg:extension target="Tridion.Web.UI.Editors.CME.Views.Popups.Publish">
<cfg:insertafter>Company.Extensions.Resources</cfg:insertafter>
</cfg:extension>
</cfg:extensiongroup>
</cfg:extensiongroups>
<cfg:groups>
<cfg:group name="Company.Extensions.Resources">
<cfg:fileset>
<cfg:file type="script">/js/SelectRollbackFailure.js</cfg:file>
<cfg:file type="script">/js/NoPublishItemWarning.js</cfg:file>
</cfg:fileset>
</cfg:group>
</cfg:groups>
</resources>
<definitionfiles/>
<extensions>
<ext:dataextenders/>
<ext:editorextensions />
</extensions>
<commands />
<contextmenus/>
<localization></localization>
<settings>
<defaultpage />
<navigatorurl />
<editurls/>
<listdefinitions/>
<itemicons/>
<theme>
<path></path>
<resourcegroup />
</theme>
<resourceextensions>
<resourceextension>Company.Extensions.Group</resourceextension>
</resourceextensions>
<customconfiguration></customconfiguration>
</settings>
</Configuration>
You'll need to change this part:
<cfg:extension target="Tridion.Web.UI.Editors.CME.Views.Popups.Publish">
To where you'd like the items to be included. If it's not quite right, or you need an explanation let me know.
p.s I also suspect some empty nodes can be stripped out :)

Related

Structuring scorm package with just one item

I recently packaged a Scorm course, and everything looks ok, but when they launch the course they have to click first in one menu button from the LMS, and open a submenu and they have to click again, in other courses they just click in the parent item. I think it's something to do with the structure in the Manifest file, the thing is that I have just one item so the menu is not really necesary.
This is what my client sees:
<?xml version="1.0" standalone="no" ?>
<!--
Single SCO content packaging example. SCORM 2004 2nd Edition.
Provided by Rustici Software - http://www.scorm.com
This example demonstrates the simplest possible manifest, containing just one SCO and
no metdata or sequencing information.
-->
<!--
The manifest node contains a unique identifer for this course and the course's version number.
The schema declartions are important to ensure you are delivering valid XML. For the most part
these should remain static. Other schema prefixes are allowed, but can limit interoperabilty.
-->
<manifest identifier="com.scorm.golfsamples.contentpackaging.singlesco.20042nd" version="1"
xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"
xmlns:adlcp="http://www.adlnet.org/xsd/adlcp_v1p3"
xmlns:adlseq="http://www.adlnet.org/xsd/adlseq_v1p3"
xmlns:adlnav="http://www.adlnet.org/xsd/adlnav_v1p3"
xmlns:imsss="http://www.imsglobal.org/xsd/imsss"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1 imscp_v1p1.xsd
http://www.adlnet.org/xsd/adlcp_v1p3 adlcp_v1p3.xsd
http://www.adlnet.org/xsd/adlseq_v1p3 adlseq_v1p3.xsd
http://www.adlnet.org/xsd/adlnav_v1p3 adlnav_v1p3.xsd
http://www.imsglobal.org/xsd/imsss imsss_v1p0.xsd">
<!--The metadata node simply declares which SCORM version this course operates under.
"CAM 1.3" is the notation for SCORM 2004 2nd Edition.-->
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>CAM 1.3</schemaversion>
</metadata>
<!-- There is just one organization. The organization contains just one item.-->
<organizations default="control_interno" adlseq:objectivesGlobalToSystem="false">
<organization identifier="control_interno">
<title>Control Interno</title>
<item identifier="item_1" identifierref="resource_1">
<title>Control Interno</title>
</item>
<imsss:sequencing>
<imsss:controlMode choice="true" flow="true" />
</imsss:sequencing>
</organization>
</organizations>
<!--
There is just one resource that represents the single SCO that comprises the entirety of this course.
The href attribute points to the launch URL for the course and all of the files required by the course
are listed.
-->
<resources>
<resource identifier="resource_1" type="webcontent" adlcp:scormType="sco" href="./control_interno/index.html">
<file href="./control_interno/index.html"/>
</resource>
</resources>
</manifest>

Adding nonce value to #Scripts.Render ASP.Net MVC razor pages with NWebSec

I am trying to implement Content-Security-Policy with the NWebSec NuGet package
The basic configuration level is working at this moment but trying to add nonce for each script and style in the project.
How to add a nonce to the below tags for inline?
#Styles.Render("~/Content/css/file")
For BundleConfig,
bundles.Add(new ScriptBundle("~/Content/Scripts").Include(
"~/Content/Scripts/General.js"
));
I tried with a new class and it's working but with the NWebSec package I going nowhere.
Below is their solution with #Html.CspScriptNonce() directives and this is working.
<script #Html.CspScriptNonce()>document.write("Hello world")</script>
<style #Html.CspStyleNonce()>
h1 {
font-size: 10em;
}
</style>
The solution I tried was to use #Styles.RenderFormat in the following way:
#Styles.RenderFormat("<link href=\"{0}\" rel=\"stylesheet\" " + #Html.CspStyleNonce() +"/>","~/Content/css/file")
When using NWebSec with ASP.Net MCV Bundles, you can not apply a Nonce, but luckily you don't need to.
There might be something you need to change in your web.config though. In the nwebsec > httpHeaderSecurityModule > securityHttpHeaders > content-Security-Policy section, make sure that self="true" for both style-src and script-src. self="true" is the default, though, so if you don't need those elements for any other declarations, you can omit them.
Here's the nwebsec section in my web.config. I'm using both style and script bundles, and have no third-party scripts.
<nwebsec>
<httpHeaderSecurityModule xmlns="http://nwebsec.com/HttpHeaderSecurityModuleConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="NWebsecConfig/HttpHeaderSecurityModuleConfig.xsd">
<securityHttpHeaders>
<content-Security-Policy enabled="true">
<default-src self="true" />
<font-src self="true">
<add source="https://fonts.gstatic.com" />
</font-src>
<object-src none="true" />
<style-src self="true">
<add source="https://fonts.googleapis.com" />
</style-src>
<base-uri none="true" />
</content-Security-Policy>
</securityHttpHeaders>
</httpHeaderSecurityModule>
</nwebsec>

Alfresco: Finding out the type of a piece of content

When I log into http://localhost:8080/alfresco I can navigate to a folder and see four content items. So far so good. But there is no indication as to what the type is of each content type, except for a PDF icon.
Is there a way for me to specify an icon for my custom content types?
I would like the icon to be dependent on my custom type.
<types>
<type name="sc:doc">
<title>Someco Content</title>
<parent>cm:content</parent>
<icon>boring-icon.png</icon> <-- something like this
</type>
<type name="sc:marketingDoc">
<title>Marketing Document</title>
<parent>bnp:doc</parent>
<icon>fancy-marketing-icon.png</icon> <-- something like this
</type>
</types>
If it matters, I am using Alfresco 3.3 (Enterprise).
Take a look here http://docs.alfresco.com/3.4/tasks/kb-code-explorer-add.html
e.g. web-client-config-custom.xml (sc:marketingDocis the Alfresco content type):
<!-- Specify icon for the kb:document instances -->
<config evaluator="string-compare" condition="sc:marketingDoc icons">
<icons>
<icon name="sc_marketingDoc-icon" path="/images/icons/your_custom_icon.gif" />
</icons>
</config>
Are you informed, that Alfresco Explorer is deprecated & you should use Share instead?

How to move the documentactions viewlet from a viewletmanager to another?

Once again back with a Plone question.
I have Plone 4 installed and I need to show the Document action icons at the top instead of bottom. having trouble in getting this to work. can someone help.
If you just need to move that viewlet (with same class and template), first you have to register a viewlet with same class to your desired viewletmanager (let's say for ex. plone.app.layout.viewlets.interfaces.IAboveContentBody):
<browser:viewlet
name="plone.abovecontenttitle.documentactions"
manager="plone.app.layout.viewlets.interfaces.IAboveContentBody"
class="plone.app.layout.viewlets.content.DocumentActionsViewlet"
permission="zope2.View"
/>
and then add this in your genericsetup profile (file viewlets.xml) :
<?xml version="1.0"?>
<object>
<order manager="plone.abovecontentbody" skinname="Plone Default">
<!-- this will place your viewlet before all the others.
you can also use a viewlet's name for a relative position -->
<viewlet name="plone.abovecontenttitle.documentactions" insert-before="*"/>
</order>
<hidden manager="plone.belowcontentbody" skinname="Plone Default">
<viewlet name="plone.abovecontenttitle.documentactions"/>
</hidden>
</object>
More info:
http://plone.org/documentation/kb/customization-for-developers/viewlets
http://collective-docs.readthedocs.org/en/latest/views/viewlets.html

How can I make FlashBuilder use a custom namespace prefix

I have a component library. It has a manifest file that looks like this:
<?xml version="1.0"?>
<componentPackage>
<component id="AutoComplete" class="be.edge.components.AutoComplete" />
<!-- more components left out for brevity -->
</componentPackage>
I compile the library through FlashBuilder with these compiler settings:
When I use the compiled library in other FlashBuilder projects everything works as expected. I get code completion and when I select a suggestion from the code completion a namespace attribute is automatically added to the component, like this:
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:ns="library://ns.edge.be" >
<ns:AutoComplete />
</s:Skin>
But: FlashBuilder automatically creates the prefix 'ns'. I would like to customize this to 'e' for instance. How can I make FlashBuilder use this custom prefix by default?
I have two reasons for this:
'ns' doesn't say anything: it just says A namespace has been used, not what namespace.
when I use other libraries that also start with a url like 'library://ns.' FlashBuilder will probably start numbering the prefixes to resolve the conflict (ns, ns1, ns2, etc.), which would be even more confusing.
EDIT:
I also pass a config.xml to the compiler that has the following declarations relating to namespaces:
<compiler>
<namespaces>
<namespace>
<uri>library://ns.edge.be</uri>
<manifest>manifest.xml</manifest>
</namespace>
</namespaces>
</compiler>
<include-namespaces>
<uri>library://ns.edge.be</uri>
</include-namespaces>
This used to work:
Create a file called design.xml in your /src folder:
<?xml version="1.0" ?>
<design>
<namespaces>
<namespace prefix="mangos" uri="http://com.mangofactory.sample/mxml/2010" />
</namespaces>
</design>
Create a file called manifest.xml in your /src folder:
<componentPackage>
<component id="MyClass" class="com.mangofactory.framework.MyClassTag"/>
</componentPackage>
Configure your Namespace URL, etc in the build properties:
This is supposed to cause flash builder to prompt as follows:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:mangos="http://com.mangofactory.sample/mxml/2010">
<fx:Declarations>
<mangos:MyClass />
</fx:Declarations>
</s:Application>
(Note that the class appears as MyClass instead of MyClassTag, and the namespace appears as mangos)
However, I just tried doing this, and although the class was renamed correctly, the namespace appeared up as ns. I know this used to work in FB3.x, maybe I've either forgotten a step, or FB4.5 has broken it.
If you just change xmlns:ns to xmlns:e or xmlns:foo then the MXML parser will pick up on the change. It's not all that difficult to change, and I don't think there is a way to change how it generates namespaces by default.

Resources