User custom theme support with rails assets pipeline - ruby-on-rails

I have a rails app that allows users to create their own website easily but they share the same page structure.
I plan to switch my classic rails views for a templating language such as liquid or handlebars.
The goal is that my users could upload their own version of templates and css to completely customize the look and feel of their website.
Example of workflow :
User upload a theme folder containing Templates and Css files
Their website automatically uses this new templates and designs
Is it possible to do that and continue to take advantages of the Rails Assets pipeline?
Thanks a lot for your answers !

This might be something you can try: http://www.krautcomputing.com/blog/2012/03/27/how-to-compile-custom-sass-stylesheets-dynamically-during-runtime/.
I've used this in a Rails 3.2x project and it works fine, but I'm having difficulties getting it working in a different (somewhat modified Rails 4 project).
It's older article about compiling css on the fly using the Sprockets::StaticCompiler class.

Related

How does Bootstrap work with Ruby on Rails?

I'm unfamiliar with how Bootstrap is implemented on a web app built on Ruby on Rails. I've been asked to create the front-end ,HTML/CSS for new pages. I strictly have been working with small, static sites so I don't know the way to go about this. I've seen that the CSS files only include the specific code that your page requires?
Does that mean that I will have to copy each component's Boostrap CSS to a separate CSS file for my page?
You can choose one of the following gems to get all the required components of bootstrap in your rails application:
Twitter Bootstrap Rails
Less Rails Bootstrap
Furthermore detailed info to implement it on pages can be get # http://www.gotealeaf.com/blog/integrating-rails-and-bootstrap-part-1

What is the easiest way to integrate static pages into Rails project

I have a landing page that was passed to me by a designer, the Structure is like this
|_startup
|_common-files
|_css
|_fonts
|_icons
|_img
|_js
|_less
|_flat-ui
|_bootstrap
|_css
|_fonts
|_js
|_fonts
|_icons
|_img
|_js
|_less
|_ui-kit
|_static
|_css
|_less
index.html
I didn't type the whole structure, but the idea is, it's quite a bit of directory, and it might be tough to separate it into javascript, css, image assets, and fonts(I am not sure where fonts go). My thoughts are, should I just have a subdomain and put this about page? I do want to integrate the page into my rails project. My question is, is there an easy way to integrate an independent page into my rails project?
From the book Learn Ruby on Rails:
A Rails application can deliver static web pages just like an ordinary
web server. The pages are delivered fast and no Ruby code is required.
The Rails application server looks for any pages in the public folder
by default.
So you can drop the directory into your application public/ folder.

Can an admin template be used in a Ruby on Rails web app?

I have been doing UI research and have come across admin templates at http://themeforest.net/. I was wondering how do you apply these onto a web app built on Rails. These templates look very similar to wordpress themes. Are they that easy to configure? Is it just as simple as setting up a link to the database to make the fields form capture data? I've been looking at this theme.
For admin templates I recommend using Active Admin. It's relatively easy to implement and gives you great admin screens with little effort.
Yes, You can. I'm trying to solve the same problem and so far I have a couple options:
1.) do it by hand, I've done this before, it works but takes a lot of time to truly understand how your theme is put together. First I would recommend using the included themes assets exactly as they are bundled with the theme. Don't assume that just because you have twitter-bootstrap-rails gem that the bootstrap classes in the theme will work. Link the assets statically and slowly extract out the static assets and replace them in the asset pipeline once you know they work.
2.) Use the strategy suggested in the install_theme gem (http://drnicwilliams.com/2009/10/06/install-any-html-themetemplate-into-your-rails-app/) the gem itself is not maintained any longer (i'm not sure about any forks), but the strategy is sound. Extract the core parts of the template into partials.
The short answer is yes, but there is no straight forward way to "import to rails"

Rails static pages CMS engine

I need simple CMS to allow non-tech folks edit some static text in app I maintaing. App is in rails 3.2 and is multilingual. What would here fit best?
You might want to take a look at Refinery which is now a mountable engine. Version 2.0 has been released a few days ago.
There is also a bunch of other CMS, it all depend on your needs:
Locomotive. There is a 2.0.0.rc branch which is now a mountable engine. This looks promising with custom content type!!!
Comfortable Mexican Sofa (editorial: best CMS name, ever!)
Browser CMS
Radiant CMS
and a lot more...see most of them on Ruby-Toolbox
my suggestion is just add a WYSIWYG like CKeditor to text box. ckeditor gem
ps. rails it self can be a simple cms ... just rails g scaffold
tinyMCE will allow you to do images etc, but really if you're using rails for this stuff i would (and do), use tinyMCE for text then add paperclip to add the images and video (possibly also swfupload if the videos are big).
Then you can build your template as required and pull stuff in based on the page.id or other identified.
back to multilingual:
you'll want to model up 'my_cms_item' eg. news_item and 'my_cms_item_translation' e.g. 'news_item_translation' and create a 1-Many for these so that when a user creates a news_item they can select to add additional translations in whichever language and the system just detects and pulls if available. You can make it either hide the item or default to a translation as required.

Help with rails and tinyMce

I have been using tinyMce_hammer plugin to use tinymce in my rails app... but right now I also want a way for my users to upload photos and insert them into their wysiwyg editor.... is there a simple way to get this done??.. is there any other wysiwyg editor that works with rails and comes with this feature built in??... what do you reccomend?
These two plugins claim to offer it - Rails 2.3 - https://github.com/andreferraro/rails_tiny_mce
Rails 3 - https://github.com/sandipransing/rails_tiny_mce
I don't think there's an easy way to do this in any of the common rich text editors. I usually have a separate section where users can upload photos and then choose from a variety of layout options.
TinyMCE has a couple of commercial image and file management plugins, but they are based on PHP and .Net. However, I haven't seen a Rails version. It's not particularly hard to build your own image manager using a plugin like paperclip and hook into TinyMCE.

Resources