app/controllers/landing_page_controller.rb
# Shorthand for accessing CustomLandingPage service namespace
Shorthand for accessing CustomLandingPage service namespace
Shorthand for accessing CustomLandingPage service namespace
def index
    return if perform_redirect!
    com = community(request)
    cid = com.id
    is_private = com.private?
    user_logged_in = user(request).present?
    cta = is_private && !user_logged_in ? "signup" : "search" 
    default_locale = community(request).default_locale
    version = CLP::LandingPageStore.released_version(cid)
    locale_param = params[:locale]
    script_digest = Digest::MD5.hexdigest(custom_head_scripts.to_s)
    begin
      content = nil
      cache_meta = CLP::Caching.fetch_cache_meta(cid, version, locale_param, cta, script_digest)
      cache_hit = true
      if cache_meta.nil?
        cache_hit = false
        content = build_html(
          community_id: cid,
          default_locale: default_locale,
          locale_param: locale_param,
          version: version,
          cta: cta
        )
        cache_meta = CLP::Caching.cache_content!(
          cid, version, locale_param, content, CACHE_TIME, cta, script_digest)
      end
      if stale?(etag: cache_meta[:digest],
                last_modified: cache_meta[:last_modified],
                template: false,
                public: true)
        content = CLP::Caching.fetch_cached_content(cid, version, cache_meta[:digest])
        if content.nil?
          cache_hit = false
          content = build_html(
            community_id: cid,
            default_locale: default_locale,
            locale_param: locale_param,
            version: version,
            cta: cta
          )
        end
        self.status = 200
        self.response_body = content
      end
      headers[CACHE_HEADER] = cache_hit ? "1" : "0"
      if is_private
        expires_now
      else
        expires_in(CACHE_TIME, public: true)
      end
    rescue CLP::LandingPageContentNotFound
      render_not_found()
    end
  end
def index return if perform_redirect! com = community ( request ) cid = com . id is_private = com . private? user_logged_in = user ( request ) . present? cta = is_private && ! user_logged_in ? "signup" : "search" default_locale = community ( request ) . default_locale version = CLP :: LandingPageStore . released_version ( cid ) locale_param = params [ :locale ] script_digest = Digest :: MD5 . hexdigest ( custom_head_scripts . to_s ) begin content = nil cache_meta = CLP :: Caching . fetch_cache_meta ( cid , version , locale_param , cta , script_digest ) cache_hit = true if cache_meta . nil? cache_hit = false content = build_html ( community_id : cid , default_locale : default_locale , locale_param : locale_param , version : version , cta : cta ) cache_meta = CLP :: Caching . cache_content! ( cid , version , locale_param , content , CACHE_TIME , cta , script_digest ) end if stale? ( etag : cache_meta [ :digest ] , last_modified : cache_meta [ :last_modified ] , template : false , public : true ) content = CLP :: Caching . fetch_cached_content ( cid , version , cache_meta [ :digest ] ) if content . nil? cache_hit = false content = build_html ( community_id : cid , default_locale : default_locale , locale_param : locale_param , version : version , cta : cta ) end self . status = 200 self . response_body = content end headers [ CACHE_HEADER ] = cache_hit ? "1" : "0" if is_private expires_now else expires_in ( CACHE_TIME , public : true ) end rescue CLP :: LandingPageContentNotFound render_not_found ( ) end end
Shorthand for accessing CustomLandingPage service namespace
Shorthand for accessing CustomLandingPage service namespace
# cta: Call to action # This should not happen since html is cached longer than metadata # There's an implicit else here because stale? has the # side-effect of setting response to HEAD 304 if we have a match # for conditional get. # Don't add browser cache to private marketplaces # In private marketplaces, we need to render different # HTML is the user is logged in