I want to create a set of widgets (tables, calendars, etc) that can be include in HTML emails we send out via Mandrill. I already have these widgets build as components pulled into web pages, I would like to reuse them in emails but in order to do that I need to inline the CSS.
I have tried using https://github.com/roverdotcom/django-inlinecss, which appears to do what I want but doesn't appear to support S3 as a staticfiles source and I can't get it to run locally. Using the tag {% inlinecss "/css/main.css" %} gives an error:
"The joined path (/css/main.css) is located outside of the base path component ([my local path]/static)" from the contrib.staticfile.find_location call to safe_join.
Question 1: can I use django-inlinecss with S3 as a staticfiles repo as it stands or would I have to fork and enhance it?
Question 2: if 1 is possible, what do I need to do to get django-inlinecss running successfully locally?
Question 3: if 1 is not possible does anyone have any alternative suggestions for inlining css using the django tempting framework.
Thanks in advance - Guy.
In the end Mandrill already solved this problem. I the message dict of the API call to mandrill you can tell Mandrill to inline the css for you.
message['inline_css'] = True
Related
There are 2 ways to use a script with in a script manager
linking to a script by an URL
manually entering in the script.
The handle bar objects don't seem to work while linking to a script by an URL but works when manually entering it. An example script is very simple as below:
console.log("{{product.id}}");
I just wanted to find a solution or a workaround to make the handlebar objects work seamlessly when the script is hosted on a CDN.
Screenshot below:
Consider using 2 scripts. One is an inline script to instantiate certain JS variables your CDN script needs, and the other is your CDN script which checks for window.your_data when it evaluates.
So your first script might be:
<script>
window.currentProductName = "{{product.name}}";
</script>
And your CDN script will check for window.currentProductName when it evaluates.
As script order is not guaranteed within the same insertion target, it's best to put the inline script in the header and the CDN script in the footer (generally better for site speed as well).
I'm not sure if this is what you're looking for but you should be able to accomplish this with the inject & jsContext handlebars helpers. See both here, with a 'console.log' example.
https://developer.bigcommerce.com/stencil-docs/reference-docs/handlebars-helpers-reference#inject
When you reference a script via the URL option it is added to the page via a script tag. This means it gets loaded and run on the client side as the page loads. It would not have access to handlebars.
When you directly enter the script in the manager it is first processed server side and the result is directly placed on the pages. It does have access to handlebars.
You may want to do a combination. A manual script to gather and store the data you need, then a url script to load the main js that can access the data you stored.
You could merge them as one by having the manual script dynamically add the script tag for your external script.
I need to add a css file or javascript to each of the NetSuite pages to make the page direction RTL.
I tried adding it through :
SuiteScript >> Client >> Deployment : All Records,
And already succeeded in adding them to some pages. But I need to add the code to all pages of the NetSuite.
NetSuite does not provide an option to add CSS/JS to every page. Only certain pages are scriptable as you have discovered.
You could use something like Tamerpermonkey to achieve this. However that would require installation on each end user's machine.
There are 2 questions:
How to do the routing for different customers under same domain e.g.
For customer A the url looks like: http://cusA.mydomain.com
For customer B the url looks like: http://cusB.mydomain.com
And according to different url(the above urls) to load different themes.
For question 1: I know we have sub-domain concept which talking about something more like :
www.mydomain.com/cusA and www.mydomain.com/cusB.
So I don't know whether it is capable of doing the sub-domain in front of mydomain
For question 2: If the question 1 gets solved, then I think I could read and parse the url and loading different themes according to the cusA or cusB part by using ASP.NET MVC theme stuff.
Could anybody provide some thoughts and technologies to use in my case?
Thank you.
Update:
Tried to use "Request.ApplicationPath" but doesn't work.
Here is the code
<h2>Site 2 Home Page</h2>
Go to Contact
<label>The Application Path is #Request.ApplicationPath.Substring(1)</label>
My answer is not necessarily best practice, but rather how we have approached it in our product.
We have multiple sites running of the same application binaries, but each in a different application pool on the server. Each web-share has a config- and CSS file corresponding to the name of the share. We then use the config- and CSS files based on the Application's name on the server (i.e. Request.ApplicationPath).
In your case, you would have a web-share named CusA and another named CusB. You would have CSS files also named CusA.css and CusB.css respectively. You can then just include the CSS file based on the name of the application...
An example of including the stylesheet might be as follows:
<link href="<%=Request.ApplicationPath.Substring(1)%>.css" type="text/css" rel="stylesheet" />
That will link to "CusB.css" if the web-share's name is "CusB". The above snippet needs to be included in your view as a style include, but the view engine you use would obviously influence the syntax a bit.
I'm trying to register a custom content type, similar to this question on MSDN forums: I want to register a custom extension that is essentially an HTML file, e.g.:
[Export]
[DisplayName("My Custom Markup")]
[Name("mycustom")
[BaseDefinition("html")]
internal static ContentTypeDefinition MyCustomContentType;
[Export]
[FileExtension(".mycustom")]
[ContentType("mycustom")]
internal static FileExtensionToContentTypeDefinition MyCustomFileExtensionDefinition;
So by specifying BaseDefinition as html, I am able to get HTML highlighting in .mycustom files, unfortunately I get nothing else, in particular, the HTML intellisense. From the above link it seems that the only way to have Visual Studio recognize custom extensions as a specific editor type, but I'd have to hack the registry (or more specifically, provide this via the ProvideEditorExtension attribute, but it's only applicable on a VSPackage).
So my question is, basically, is there an alternative way to register a custom extension to an editor programmatically, but without creating a custom VSPackage for it? Other than hacking the registry, of course?
(I could be totally wrong with the approach, in which case your help is very much appreciated!)
The easiest way is to use the technique demoed here:
http://blogs.msdn.com/b/noahric/archive/2010/03/01/new-extension-css-is-less.aspx
This is effectively "hacking the registry" but in a supported way. You're simply wrapping the needed keys in a .pkgdef file (essentially a .reg file) that can be contained in an editor 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.