How to change common styles for redmine email messages? - ruby-on-rails

I need to make some styles available for every html email message in my custom redmine plugin. So I should do something with mailer layout https://github.com/redmine/redmine/blob/master/app/views/layouts/mailer.html.erb
As this file doesn't contain any hook ( http://www.redmine.org/projects/redmine/wiki/Plugin_Tutorial#Using-hooks ) only thing I can imagine to do it in this case is to override the layout in the plugin.
Is there any way to avoid overriding?

There is a gem deface which can help you.
I changed some parts of the view on the fly using deface. Please see this commit.

Related

How to customize HTML structure in ActiveAdmin layout?

I am trying to change the structure and design of the components of the ActiveAdmin layout, such as the navbar menu, icons and customize it to my style. Is this possible?
I need to overwrite the source code to be able to change the HTML structure, but I have tried to do it by placing files in the / lib folder and I have not succeeded. How could I overwrite the ActiveAdmin source code within my Rails project?
It is possible but many developers have discovered it is not easy. If you look through the various plugins you will find examples like Custom Layout, Sidebar, Menu and SubNav that may inspire you. However, if you are new to ActiveAdmin and your first priority is to customize the layout heavily then consider Administrate or vanilla Rails instead: they are still difficult, but you will be fighting the framework less.

Override Mailboxer Views in Rails 4

I'm using Mailboxer into my app but I'm having some problems with the generated views (with rails g mailboxer:views). Seems to be the internal Mailboxer mailer are using some "hidden" templates and any changes over the existing views are not reflected on the sent emails.
Can anyone help me with that? One known alternative could be to program my own mailer class, but I think that it's a bit more of work to achieve the same thing.
Thanks.
It may be a bug. I am experiencing the same thing:
https://github.com/mailboxer/mailboxer/issues/324
The origin of the problem is that "rails g mailboxer:views" copies the gem templates folders into "app/views" folder and the engine searches inside app/views/mailboxer.
The solution consists in moving the two generated (message_mailer and notification_mailer) folders into a subfolder "app/views/mailboxer".

Sharing colors between SASS files and Rails erb templates

I'm working on an email newsletter using ActionMailer that's associated to our Rails 3.0.7 application. So against all my instincts, I'm using inline styles like mad since that seems to be the only way to do things in html email. I'd also like to keep the color scheme consistent with the website in a DRY fashion.
Is there any way to share SASS color variables between a Rails application and its SCSS files for use in inline styling?
The only way I'm aware you can do this is to add .erb onto your sass files so that they're processed by Rails, then you can use application level constants:
<%= APP_CONFIG[:yourkey] %>
Similar question / more reading
Coding emails is such a heinous task that I try to turn off all the higher thinking regions of my brain that worry about good programming principles every time I have to do it. Unless email is the central part of this project I'd resist letting the constraints there affect the rest of your application design.
Best solution I've found so far is the premailer gem: https://github.com/alexdunae/premailer/
Post-processing your HTML with premailer inlines all the CSS defined in a separate stylesheet, letting you specify whatever you want in a SASS or CSS file.

How do i password protect a page in refinery cms?

Basically i am trying to set up a password for a single page in refinery. Is there an extension which can do such a thing for me automatically or should i override internal parts?
Thanks in advance.
There is no way to do this with a default install of Refinery, you'll have to write an engine or override some internal methods/before filters to do this. Unpack the refinerycms-core gem and look at the crud.rb file, where all the crudify methods are generated. It should help shed some light on what you'll need to do to make this happen.
Or look here: https://github.com/resolve/refinerycms/blob/master/core/lib/refinery/crud.rb

Rails HTML/TEXT UserMailer Templates

Currently for my Rails 3 mailer templates, I need to create an html and text version in the views/user_mailer directory.
Why is that necessary? Why can't rails look at the html version and automatically format it to a text/plain version?
This is not required. You can simply provide one of those templates. For instance, if you don't need HTML, you can create the TEXT file only.
Likewise, you can provide the HTML template only. Readers will attempts to extract the information.
However, if you use HTML, you should provide an alternative TEXT version to make sure the readers won't mess the content of your email.
By the way, Rails doesn't force you to provide both templates.
This question seems to be similar to yours and might be helpful to you:
Graceful degradation/progressive enhancement for Action Mailer templates?
Also, here are some direct links to some gems that help to solve this problem of duplication between html and text mailer templates:
https://github.com/plataformatec/markerb
https://github.com/Mange/roadie
https://github.com/fphilipe/premailer-rails3

Resources