houdini/app/views/layouts/_app_data.html.erb
2020-06-18 17:28:54 -05:00

36 lines
2 KiB
Text

<%- # License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE -%>
<script>
var app = {
env: "<%= Rails.env %>"
, ip: "<%= request.remote_ip %>"
, current_user: <%= current_user ? current_user.id : 'undefined' %>
, current_admin: <%= !!(current_user && current_role?(:super_admin)) %>
, nonprofit: <%= @nonprofit ? raw(render('app_data/nonprofit', nonprofit: @nonprofit)) : 'undefined' %>
, nonprofit_id : <%= @nonprofit ? @nonprofit.id : 'undefined' %>
, user: <%= current_user ? raw(render('app_data/user', user: current_user)) : 'undefined' %>
, user_id: <%= current_user ? current_user.id : 'undefined' %>
, profile: <%= current_user&.profile ? raw(render('app_data/profile', profile: current_user.profile)) : 'undefined' %>
, profile_id: <%= current_user&.profile ? current_user.profile.id : 'undefined' %>
, asset_path: "<%= Rails.application.config.assets.prefix %>"
, host_with_port: "//<%= request.host_with_port %>"
, google_api: "<%= ENV['GOOGLE_API_KEY'] %>"
, google_auth_client_id: "<%= ENV['GOOGLE_AUTH_CLIENT_ID'] %>"
, autocomplete: <%= @nonprofit ? @nonprofit.autocomplete_supporter_address : 'undefined'%>
, facebook_app_id: "<%= ENV['FACEBOOK_APP_ID'] %>"
, map_provider: "<%= Houdini.maps&.provider %>"
, map_provider_options: <%= Houdini.maps&.options ? raw(Houdini.maps.options.to_json) : {} %>
, editor: "<%= Houdini.page_editor.editor%>"
<% if Houdini.page_editor&.editor == 'froala' and Houdini.page_editor&.editor_options&.froala_key %>, froala_key: "<%= Houdini.page_editor.editor_options.froala_key %>"<% end %>
<%if @nonprofit&.currency_symbol %>, currency_symbol: "<%= @nonprofit.currency_symbol%>"<% end %>
};
var ENV = {
nonprofitID: <%= @nonprofit ? @nonprofit.id : 'undefined' %>
, nonprofitTimezone: "<%= @nonprofit ? @nonprofit.timezone : '' %>"
, support_user_id: 540
, feeRate: <%= print_percent(CalculateFees::BaseFeeRate) %>
, perTransaction: <%= CalculateFees::PerTransaction %>
};
</script>