Module: Lesli::AssetsHelper

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

Instance Method Summary collapse

Instance Method Details

#application_stylesheet_engine_pathObject

Return a string path to load the main engine stylesheet



57
58
59
60
61
62
63
# File 'app/helpers/lesli/assets_helper.rb', line 57

def application_stylesheet_engine_path
    lesli_engine = lesli_engine(:code)
    return "administration/application" if is_lesli_administration?
    return "onboardings/application" if is_lesli_onboarding?

    "#{lesli_engine}/application"
end

#faviconObject



101
102
103
104
105
106
107
108
# File 'app/helpers/lesli/assets_helper.rb', line 101

def favicon
    icon_path = customization_instance_logo_url(logo: "favicon")
    "
    <link href=\"#{icon_path}\" rel=\"alternate icon\">
    <link href=\"#{icon_path}\" rel=\"icon\" type=\"image/svg+xml\">
    <link href=\"#{icon_path}\" rel=\"mask-icon\" color=\"#ff8a01\">
    ".html_safe
end

#javascript_apple_mapkit_jsObject



92
93
94
95
96
97
98
99
# File 'app/helpers/lesli/assets_helper.rb', line 92

def javascript_apple_mapkit_js
    token = Rails.application.credentials.dig(:providers, :apple, :mapkit_token)

    "<script type=\"application/javascript\" src=\"https://cdn.apple-mapkit.com/mk/5.45.0/mapkit.js\"></script>
    <script type=\"application/javascript\">
        const ampkt = \"#{token}\"
    </script>".html_safe
end

#javascript_googlemaps_sdkObject



86
87
88
89
90
# File 'app/helpers/lesli/assets_helper.rb', line 86

def javascript_googlemaps_sdk
    "<script type=\"application/javascript\" src=\"https://maps.googleapis.com/maps/api/js?key=#{Rails.application.credentials.dig(
        :providers, :google, :maps_sdk_token
    )}\"></script>".html_safe
end

#lesli_application_javascript_pathObject

Return a string path to load the main javascript app of the engine



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/helpers/lesli/assets_helper.rb', line 66

def lesli_application_javascript_path
    # get the namespace to load specific javascript file
    # for engine or specific javascript file for core controller
    # path_segments = controller_path.split("/")
    # lesli_engine = path_segments.shift

    # return "onboardings/application" if is_lesli_onboarding?



    # Get current engine information
    lesli_engine_code = lesli_engine(:code)

    # Rails main host app stylesheets
    return "application" if lesli_engine_code == "root"

    # Rails engines stylesheets
    "#{lesli_engine_code}/application"
end

#lesli_application_stylesheet_path(engine = nil) ⇒ Object

Return a string path to load the template stylesheet by default we always return the latest version of the template lesli_application_stylesheet_path() -> stylesheet from main app lesli_application_stylesheet_path(:lesli) -> stylesheet from Lesli lesli_application_stylesheet_path(:engine) (TODO) -> stylesheet from engine current lesli_application_stylesheet_path(:cloud_driver) -> stylesheet from engine specific



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/helpers/lesli/assets_helper.rb', line 41

def lesli_application_stylesheet_path(engine = nil)

    # Stylesheets from specific engine
    return "#{engine}/templates/application" if engine

    # Get current engine information
    lesli_engine_code = lesli_engine(:code)

    # Rails main host app stylesheets
    return "application" if lesli_engine_code == "root"

    # Rails engines stylesheets
    "#{lesli_engine_code}/application"
end