Module: Lesli::CustomizationHelper

Defined in:
app/helpers/lesli/customization_helper.rb

Instance Method Summary collapse

Instance Method Details

#customization_instance_logo(tag: false, logo: "app-logo", variant: "light", mode: "web", options: { alt: "Logo" }) ⇒ Object

Examples:

# Using this from a erb view.
<div class="image">
    <%= customization_instance_logo(options: { alt: "#{@company.company_name}", width: "100" })%>
</div>

Parameters:

  • mode (String) (defaults to: "web")

    Either “web” or “pdf”. This param decides wether the image_tag will be for a web view, or a pdf view

  • options (Hash) (defaults to: { alt: "Logo" })

    Any valid “image_tag” option you want to add (like width, alt, etc)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/helpers/lesli/customization_helper.rb', line 45

def (tag: false, logo: "app-logo", variant: "light", mode: "web",
                                options: { alt: "Logo" })
    # loading logo from builder assets
    logo_path = "#{lesli_instance_code}/brand/#{}.svg"

    # load favicon as PNG for better compatibility between web browsers
    logo_path = "#{lesli_instance_code}/brand/#{}.png" if  == "favicon"

    # loading logo from core, only if builder engine was not installed
    logo_path = "lesli/brand/#{}.svg" if lesli_instance_code == "lesli"

    # custom logo from settings
    logo_path = @lesli[:customization][:logos][.to_sym] if @lesli.dig(:customization, :logos, .to_sym)

    if mode == "pdf"
        wicked_pdf_image_tag(logo_path, options)
    elsif tag
        image_tag(logo_path, options)
    else
        image_url(logo_path, options)
    end
end

#customization_instance_logo_tag(logo: "app-logo", variant: "light", mode: "web", options: { alt: "Logo" }) ⇒ Object



68
69
70
# File 'app/helpers/lesli/customization_helper.rb', line 68

def customization_instance_logo_tag(logo: "app-logo", variant: "light", mode: "web", options: { alt: "Logo" })
    (tag: true, logo: , variant: variant, mode: mode, options: options)
end

#customization_instance_logo_url(logo: "app-logo", variant: "light", mode: "web", options: { alt: "Logo" }) ⇒ Object



72
73
74
# File 'app/helpers/lesli/customization_helper.rb', line 72

def customization_instance_logo_url(logo: "app-logo", variant: "light", mode: "web", options: { alt: "Logo" })
    (tag: false, logo: , variant: variant, mode: mode, options: options)
end

#default_logosObject



76
77
78
79
80
81
82
# File 'app/helpers/lesli/customization_helper.rb', line 76

def default_logos
    {
        "app_icon" => "app-icon.svg",
        "app_logo" => "app-logo.svg",
        "favicon" => "favicon.png"
    }
end