Ability to use private asciicast as "demo" on homepage

This commit is contained in:
Marcin Kulik 2017-04-18 17:12:17 +02:00
parent 0353c8c25d
commit 1acf2b8347
2 changed files with 6 additions and 2 deletions

View File

@ -8,6 +8,10 @@ SECRET_KEY_BASE=
DATABASE_URL=postgresql://postgres@postgres/postgres DATABASE_URL=postgresql://postgres@postgres/postgres
REDIS_URL=redis://redis:6379 REDIS_URL=redis://redis:6379
## ID of the "demo" asciicast displayed on the homepage.
## Default: first public asciicast
# HOME_ASCIICAST_ID=1
### E-mail delivery ### E-mail delivery
## Outgoing mail hostname, used by namshi/smtp container. ## Outgoing mail hostname, used by namshi/smtp container.

View File

@ -12,7 +12,7 @@ module Asciinema
attribute :s3_region, String attribute :s3_region, String
attribute :carrierwave_storage_dir_prefix, String, default: 'uploads/' attribute :carrierwave_storage_dir_prefix, String, default: 'uploads/'
attribute :google_analytics_id, String attribute :google_analytics_id, String
attribute :home_asciicast_id, Integer attribute :home_asciicast_id, String
attribute :secret_key_base, String attribute :secret_key_base, String
attribute :admin_ids, Array[Integer] attribute :admin_ids, Array[Integer]
attribute :smtp_settings, Hash attribute :smtp_settings, Hash
@ -20,7 +20,7 @@ module Asciinema
def home_asciicast def home_asciicast
if home_asciicast_id if home_asciicast_id
Asciicast.find(home_asciicast_id) Asciicast.find_by_id_or_secret_token!(home_asciicast_id)
else else
Asciicast.non_private.order(:id).first Asciicast.non_private.order(:id).first
end end