Pull/Display a list of MHTML files in the Public folder and embed them as IFrames in my Rails application views - ruby-on-rails-3

I have a client that uses SQL Server Reporting Services to generate reports and exports them in MHTML. The Client wants to just push the MHTML in a pre-defined directory structure to my Rails public/reports folder.
Is there any way in Rails to "Take in" the directory structure, create a list of files recursively, generate an unordered list and then create routes dynamically for each MHTML file? I know MHTML files can be embedded with Iframes (although with limited browser support, this is not an issue for me)
The predefined Directory structure is Public/Reports/Dashboard/Exceptions/
Dashboard will contain 1 MHTML file and exceptions (which will be a sort of subnav or child of Dashboard) will contain an undefined amount.
The layout template will be a sort of wrapper.
Anyone who has experience with Rails know the best way of achieving the desired result?
Any help will be sincerely appreciated. I am using Rails 3.0.20 (which doesn't have the Asset pipeline), this will won't be hosted on Heroku (I am aware of no-write permissions)

(Sorry, I'm not super familiar with MHTML files, so I'm going to assume these are just static files that a browser can interpret.)
There is nothing in particular in Rails that provides the behavior that you're referring to. Rails is just a framework to help serve dynamic responses, and the functionality you want is in relation to the filesystem, which Rails mostly abstracts away.
There's a couple options I can think of.
Roll your own
Ruby has file and directory utilities which you could use to read in the contents of a directory in public and render the kind of response you'd like. I would start here:
http://www.ruby-doc.org/core-1.9.3/Dir.html
And play around with ruby's directory globbing to get a file listing.
Use Rack
Rails is built ontop of Rack, a standard webserver interface that most ruby application server implement now. Rack provides some libraries that make serving static assets like a traditional web server a little easier.
Here's a couple of resources to check out:
http://quickleft.com/blog/rack-130-serving-static-files
http://edgeguides.rubyonrails.org/rails_on_rack.html

Related

Add CSS File to WebCenter Sites application

I have a WebCenter Sites installation. Separately, I have site.js and site.css files. How can I make a WebCenter Sites template use these two files? Where do i put those files so they can be consumed?
What I've done so far is set up a simple HTTP server outside of WebCenter Sites and used <link> and <script> tags to point to those files on the external server. This does indeed work, but I prefer having the files served from the sites application.
I see sites exposes a CSS type asset, but it seems to be tied to their widget framework. I was thinking to just make an empty widget with CSS, then I could reference the widget/asset in the <link href=. Again there aren't many examples of this online.
Can anyone give me some ideas on how to serve files from within WebCenter Sites?
There are alternatives to storing files directly in the webapp, such as using a custom basic assettype to contain the files, and then delivering them via blobserver (or just rendering inline). The advantage to this is that you are managing assets to keep environments in sync, rather than updating the webapp & redeploying.
The path needs to be relative to the web application context. There are probably better ways to reference it in Sites, but the lowest-common denominator approach that will work for all J2EE web applications is to use pageContext.request.contextPath, so the link would look like:
href="${pageContext.request.contextPath}/src/stylesheets/css/styles.css"
So if this were used with a JSK, the src folder would be under [JSK_HOME]\App_Server\apache-tomcat-7.0.42\Sites\webapps\cs

What is BIg Commerce Development process?

I am finding it difficult locating resources for custom programming, e.g. themes, including and changing JS, altering or adding PHP files, etc.
For instance, does uploading files overwrite installed template files? Like child-themes?
Any pointers appreciated.
For custom programming you are meant to use their API - could I just check you have reviewed the developer documentation here: https://developer.bigcommerce.com/
You are not able to upload server side code like PHP to the big commerce server so it you want to pull Big Commerce data you will need to run the PHP on an external server and then use the Big Commerce API.
Regarding templates, you can create custom templates files by uploading prefixing the template file with an underscore "_" e.g. _CustomCategory.html. By using this approach you will not overwrite the existing template files and your modifications will be easier to maintain in the future.

How to store images on other server

We have a CMS application written in Ruby On Rails 3 and it is using Paperclip to handle file uploads and ImageMagick to do image manipulating. It has been working great, and we are very happy.
For a new customer we want to make a deployment: the application server is in a public network and the uploaded content + the database is stored on a secured computer in their internal environment.
We have 2 main tracks right now:
Make 2 applications from the application we have right now:
A media asset application (to be developed by us) to handle all of the uploaded files using a REST-based API. Images will represented by a GUID, and we would add functions so that the images can be scaled and cropped.
Another application to be most of the application server excluding the image scaling part and storing part. When an uploaded image is requested, it will function as an adapter to the media asset application to get all the files in the correct sizes and layouts.
Pros:
We have control over what's happening
Might be a cool application in itself
Cons:
A project that might grow and be very complex
Need to make a huge change in our current application
Need to run several Rails applications locally while developing
Make an OpenStack installation:
The other option is to make an OpenStack installation and configure Paperclip to use it. If we have understood correctly, Amazon S3 is using something similar to OpenStack and Paperclip should be possible to configure against a custom installation.
Pros:
Paperclip and our setup will not be affected that much
Cons:
Will not be simple to run a local installation
Might be difficult to setup OpenStack
Very little knowledge on the product if it would fail
Any ideas, thoughts, experiences?

Homework: What to submit as part of a Rails project

I have a very simple Ruby on Rails project that has an ActiveRecords model with some validations, and a pretty basic view and controller that allows basic add/update/delete/search interaction with database.
I'd like for the professor to be able to use the website, assuming he has Rails3 installed.
What would be a good way to submit this project? Specifically: what files and folders should I include, and what files should I exclude? What about directions for the professor? Anything else that I should include?
I think that a good idea will be to develop your project locally and then uploaded to a github repository for the professor to see your code. If you want a free, easy and EXCELLENT place to host your application try heroku, it is a cloud application platform where you can host your project(if you use a shared database < 5MB you will be able to do it with the free plan). I recommend you to include a README file a the root of your app where you add all your directions.

Where to save the uploaded files?

I am developing a web application to upload .mp3 files and need to play them. I successfully uploaded the files and saving them in C:/uploads folder. I understand that as it's a web application we need to save them in the Apache web server it self. But I am not sure, where to save them.
Thanks,
Serenity.
You can use content repositories to store uploaded data, I think this is common approach. For instance, take a look at the Apache JackRabbit CR, applying it you won't easy look for uploaded files on hard drive, but you will have web interface, and also some other tools available to connect to repository and show you files there etc.
As alternative to JackRabbit, you can try Alfresco CMS, they both implement JCR, other implementations are listed here (you will them at the bottom of that page).