Sha256: ef92379ca6161dd2c1e0dfd50f81928b6ee86c21e42aaed8032ea0b6e3120acf

Contents?: true

Size: 860 Bytes

Versions: 4

Compression:

Stored size: 860 Bytes

Contents

require "groupdate"
require "whois-parser"

module PandaCms
  class Admin::DashboardController < ApplicationController
    before_action :set_initial_breadcrumb, only: %i[show]
    before_action :authenticate_admin_user!

    # GET /admin
    def show
      @domain_expiry = domain_expiry
    end

    private

    def set_initial_breadcrumb
      add_breadcrumb "Dashboard", PandaCms.route_namespace
    end

    def domain_expiry
      return "" if request.domain == "localhost"

      begin
        whois_record = Whois.whois(request.domain)
        if (parser = whois_record&.parser)
          " (expiry date: #{parser.expires_on&.strftime("%d %b %Y")})"
        else
          " (error parsing WHOIS data)"
        end
      rescue => e
        if defined?(Sentry)
          Sentry.capture_exception(e)
        end

        ""
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
panda_cms-0.6.3 app/controllers/panda_cms/admin/dashboard_controller.rb
panda_cms-0.6.2 app/controllers/panda_cms/admin/dashboard_controller.rb
panda_cms-0.6.1 app/controllers/panda_cms/admin/dashboard_controller.rb
panda_cms-0.6.0 app/controllers/panda_cms/admin/dashboard_controller.rb