Files
docuseal/lib/docuseal.rb
T

76 lines
2.0 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
module Docuseal
2023-06-26 00:46:01 +03:00
PRODUCT_URL = 'https://www.docuseal.co'
2023-07-01 13:43:46 +03:00
NEWSLETTER_URL = "#{PRODUCT_URL}/newsletters".freeze
2023-10-21 15:33:10 +03:00
ENQUIRIES_URL = "#{PRODUCT_URL}/enquiries".freeze
2023-06-26 00:46:01 +03:00
PRODUCT_NAME = 'DocuSeal'
DEFAULT_APP_URL = 'http://localhost:3000'
2023-07-04 23:05:22 +03:00
GITHUB_URL = 'https://github.com/docusealco/docuseal'
2023-07-10 00:13:49 +03:00
DISCORD_URL = 'https://discord.gg/qygYCDGck9'
2023-07-04 23:05:22 +03:00
TWITTER_URL = 'https://twitter.com/docusealco'
2023-07-04 23:21:49 +03:00
TWITTER_HANDLE = '@docusealco'
2023-07-08 17:07:07 +03:00
SUPPORT_EMAIL = 'support@docuseal.co'
2023-08-29 20:47:56 +03:00
HOST = ENV.fetch('HOST', 'localhost')
2023-08-05 11:02:00 +03:00
CONSOLE_URL = if Rails.env.development?
'http://console.localhost.io:3001'
2023-08-30 14:39:14 +03:00
elsif ENV['MULTITENANT'] == 'true'
2023-08-29 20:47:56 +03:00
"https://console.#{HOST}"
2023-08-30 14:39:14 +03:00
else
'https://console.docuseal.co'
2023-08-05 11:02:00 +03:00
end
2023-08-25 23:44:14 +03:00
CDN_URL = if Rails.env.development?
'http://localhost:3000'
2023-08-30 14:39:14 +03:00
elsif ENV['MULTITENANT'] == 'true'
2023-08-29 20:47:56 +03:00
"https://cdn.#{HOST}"
2023-08-30 14:39:14 +03:00
else
'https://cdn.docuseal.co'
2023-08-25 23:44:14 +03:00
end
2023-06-30 20:31:17 +03:00
CERTS = JSON.parse(ENV.fetch('CERTS', '{}'))
2023-12-02 18:14:33 +02:00
TIMESERVER_URL = ENV.fetch('TIMESERVER_URL', nil)
2024-01-06 22:58:26 +02:00
VERSION_FILE_PATH = Rails.root.join('.version')
2023-06-30 20:31:17 +03:00
DEFAULT_URL_OPTIONS = {
2023-08-30 14:39:14 +03:00
host: HOST,
2023-10-29 19:10:41 +02:00
protocol: ENV['FORCE_SSL'].present? ? 'https' : 'http'
2023-06-30 20:31:17 +03:00
}.freeze
module_function
2024-01-06 22:58:26 +02:00
def version
@version ||= VERSION_FILE_PATH.read.strip if VERSION_FILE_PATH.exist?
end
2023-06-26 00:46:01 +03:00
def multitenant?
2023-06-30 20:31:17 +03:00
ENV['MULTITENANT'] == 'true'
2023-06-26 00:46:01 +03:00
end
2023-07-05 00:22:05 +03:00
def demo?
ENV['DEMO'] == 'true'
end
def active_storage_public?
ENV['ACTIVE_STORAGE_PUBLIC'] == 'true'
end
def default_url_options
2023-06-30 20:31:17 +03:00
return DEFAULT_URL_OPTIONS if multitenant?
@default_url_options ||= begin
value = EncryptedConfig.find_by(key: EncryptedConfig::APP_URL_KEY)&.value
value ||= DEFAULT_APP_URL
url = Addressable::URI.parse(value)
{ host: url.host, port: url.port, protocol: url.scheme }
end
end
2023-10-11 21:05:42 +03:00
def product_name
PRODUCT_NAME
end
def refresh_default_url_options!
@default_url_options = nil
end
end