Telerik CDN Support - telerik

According to Telerik:
To distribute your web asset group via content delivery network you should use the ContentDeliveryNetworkUrl() method:
<%= Html.Telerik().ScriptRegistrar().Scripts(scripts =>
scripts.AddGroup("CommonScript", group =>
group.Add("~/Scripts/Core.js")
.Add("~/Scripts/Stuff.js")
.Combined(true)
.CacheDurationInDays(365)
.Compress(true)
.ContentDeliveryNetworkUrl("http://mycdn.com/CommonScript.js")
)
I'm confused by this, specifically:
ContentDeliveryNetworkUrl("http://mycdn.com/CommonScript.js")
How does this file get created on the CDN? I assume Core.js and Stuff.js get combined, cached, and compressed then uploaded to my CDN automatically? Or is CommonScript.js another JS file that get's added to the combined script? If so, then the combined script gets served locally still, and not from the CDN?
Telerik say VERY VERY little about how all this work.
Any help is greatly appreciated.
Matt

You need to upload the combined file by yourself. The ContentDeliveryNetworkUrl just tells the script registrar to output that value instead of core.js and stuff.js.

Related

Image hosting with Dropbox in Ruby

Hi I'm trying to use Dropbox as an imaging hosting server. The framework is currently Ruby.
I tried to use /media or /shares to get the data's url. When I use "/media" command, it seems the image can be hosted for a couple of hours but at the end it expires(4? hours roughly). If possible, I want to know how to set the expiration dates for this ( at something like 1 year? ), not manually, but in a programmable manner.
[How I extract "url" in Ruby]
image_1_link = Drop_client.media('path_name')["url"]
pdf_link = Drop_client.shares(''path_name'["url"]
The below is a sample link after using "/media".
"https://dl.dropboxusercontent.com/1/view/e9lr642qerdmgm9/Apps/ringle_records/images/Test_1image_1?dl=1"
When I use "/share", the generated link looks like "https://db.tt/Zs0v4yaffal?dl=1". But it can't host the image if I use it as . If I put this type of address, it leads to dropbox page and ask manual downloading.
I want to know how to generate link for imaging hosting so that can work for 1 year or at least for a couple of months!
Thanks for reading my question!
/media links expire after 4 hours, as documented.
/shares takes a parameter, short_url, that can be set to false to return an unshortened URL. Unfortunately, I believe the v1 Ruby SDK doesn't support this parameter. You can either modify the Ruby SDK yourself or get the shortened URL and unshorten it yourself. (Make an HTTP GET request to the short URL and grab the Location header of the redirect response.)
Once you have an unshortened URL, you can modify it per www.dropbox.com/help/201 to get a link directly to the content. Specifically, you should use the raw=1 query parameter.

How to detect the last Docpad render pass?

Im currently writing a small Docpad plugin to output a documents contentRenderedWithoutLayouts into a separate .json file next to the .html version for loading it via an ajax request later.
The plugin works by overriding Baseplugin's render: (opts) -> method and doing a few checks whether we're rendering a document and to html.
I now noticed that this method gets called multiple times for some documents, which seems to be render pass related. So how can I detect the final render pass per document to avoid writing the .json multiple times per render?
Many Thanks
--
Edit:
found the answer after another look at Docpads events list: http://docpad.org/docs/events
The writeAfter event is the right place to get the final data and have the output directory tree set up so I can put my .json files next to the .html.
In case you're interested find the plugin here: https://github.com/field/docpad-plugin-jsonfragment
Another approach to this would be to use the serverExtend event, and write a router that detects if it is an ajax request (existance of the IS_XHR header) and then sends the necessary json data from that. This would require your hosting platform to support node.js as you'll be using the docpad server.

How should I setup assets in Rails 3.1 to be able to show images that're created on fly?

I've Rails 3.1 application which generates some images in 'public/scene/ticket_123/*.png' on fly. It works normally in development mode, but in production all assets should be precompiled. So I can't use files that I've generated after application started.
Setting config.assets.compile = true hasn't solve my problem. Situation is only worse since ticket number changes - so images are in different directories which are continiously created on fly too.
How should I setup assets to be able to show images that're created after an application was started?
I had the same problem. I only found a work around by copying all my images into "public/images" and changed all the links to the new path.
That worked for me for the moment. I wait until somebody comes up with a better idea.
I hope that helps.
If found solution.
# In view I wrote
<img src=<%= mycontroller_image_get_path :filename=>file_name %> >
# In controller I created GET action
def image_get
send_file params[:filename], :disposition => 'inline', :type => 'image/png'
end
But you should care that file you're trying to send is in "#{Rails.root}/public" directory otherwise send_file says it can't found the file. (May be it is not necessary in /public but in Rails.root anyway). To change this behavior it can be useful to read this topic Can I use send_file to send a file on a drive other than the Rails.root drive?

Ajax file upload in node.js

I want to upload ajax file upload which uses xhr to send file data,
at client m using this
http://valums.com/ajax-upload/
how i will accept this data on node and save the file to server by node.js , which module i need to use in node.js?
I've created an uploader with progress bar using the formidable module, it's really easy to use and provides a lot of useful callbacks.
Have a look here:
https://github.com/felixge/node-formidable (scroll down to get the Docs)
http://debuggable.com/posts/parsing-file-uploads-at-500-mb-s-with-node-js:4c03862e-351c-4faa-bb67-4365cbdd56cb
due to the lack of an example file in valums ajax-uploader, I've just created one.
It catches up the XHR upload if possible, alternatively falling back to the old form-based method.
All in conclusion to valums ajax-uploader.
https://github.com/aldipower/file-uploader/blob/master/server/nodejs.js
Maybe Valums will accept the pull request some time and the sample file gets merged in the standard repository.

Serving Files in Zend Framework MVC

What is the best practice when serving files from the Zend Framework MVC? These files have to be served from the MVC as they are protected.
I know you can read in the file and place it into the Response object but this seems like a bad practice as you would be reading the entire file into memory then serving it. Right now I usually do:
header('Content-type: image/jpeg');
fpassthru(fopen($path, 'rb'));
exit;
But this also doesn't seem right as I'm stopping the execution of the script. Any suggestions?
I see nothing wrong with just exit(); What you will need to be careful of is any output buffering layers you may have on (gzip compression, etc). Large files could blow up those buffers pretty quick, so you'll want to close them out and potentially 'chunk' your output with a fopen/fread loop.
I would suggest building a super-simple script for retrieving files based on ticket system like in CMS you generate ticket to DB - filename, unique-hash and than redirect to the super-simple file-retieving script (file.php?hash=asd52ad3as1g5). It will get the hash from query and based on it fetch the real filename and push that to output as you have written using fpassthru. The hash need to be unique and hard to guess...
You could try using the X-Sendfile header. It is supported by lighttpd and newer versions of apache. Basically the webserver will replace the output of the script with the file you specified. The downside being that it is specific to the configuration of the webserver, so you may be on a host that doesn't support it.

Resources