Module: Grandstand

Defined in:
lib/grandstand.rb,
lib/grandstand/helper.rb,
lib/grandstand/session.rb,
lib/grandstand/controller.rb,
lib/grandstand/application.rb,
lib/grandstand/form_builder.rb,
lib/generators/grandstand/install/install_generator.rb

Overview

The Grandstand module is the central place to configure all of Grandstand’s options and what-have-yous. The basic things to look out for are S3 storage settings, the various image_sizes you may want to enable your users to embed on the site, and the routing options for the admin interface, which allow you to scale security up or down as you see fit.

Defined Under Namespace

Modules: Controller, FormBuilder, GalleriesHelper, Generators, Helper, ImagesHelper, MainHelper, PagesHelper, PostsHelper, SessionsHelper, TemplatesHelper, UsersHelper Classes: Application, GalleriesController, Gallery, Image, ImagesController, MainController, Page, PageSection, PagesController, Post, PostsController, Session, SessionsController, Template, TemplatesController, User, UsersController

Class Method Summary collapse

Class Method Details

.app_nameObject

:nodoc:



17
18
19
# File 'lib/grandstand.rb', line 17

def app_name # :nodoc:
  @app_name ||= 'Grandstand'
end

.bcrypt_costObject



21
22
23
# File 'lib/grandstand.rb', line 21

def bcrypt_cost
  @bcrypt_cost ||= 13
end

.bcrypt_cost=(new_bcrypt_cost) ⇒ Object



25
26
27
# File 'lib/grandstand.rb', line 25

def bcrypt_cost=(new_bcrypt_cost)
  @bcrypt_cost = new_bcrypt_cost.to_i
end

.digest_stretchesObject



29
30
31
# File 'lib/grandstand.rb', line 29

def digest_stretches
  @digest_stretches ||= 10
end

.digest_stretches=(new_digest_stretches) ⇒ Object



33
34
35
# File 'lib/grandstand.rb', line 33

def digest_stretches=(new_digest_stretches)
  @digest_stretches = new_digest_stretches.to_i
end

.image_sizesObject

Image sizes returns the current hash of custom image sizes you’ve set up for your users. You can add and image size like so:

Grandstand.image_sizes[:large] = "800x600#"

Where the key is the name and the value is the ImageMagick geometry instructions.



43
44
45
# File 'lib/grandstand.rb', line 43

def image_sizes
  @images_sizes ||= {}
end

.image_sizes=(new_image_sizes) ⇒ Object

You can completely set your image_sizes hash here if you don’t want to tweak on a per-key basis, so something like this is also possible:

Grandstand.image_sizes = {:icon => '75x75#', :large => '800x600>'}


51
52
53
# File 'lib/grandstand.rb', line 51

def image_sizes=(new_image_sizes)
  @images_sizes = new_image_sizes
end

.multiple_uploadObject



55
56
57
# File 'lib/grandstand.rb', line 55

def multiple_upload
  @multiple_upload ||= false
end

.multiple_upload=(new_multiple_upload) ⇒ Object



59
60
61
# File 'lib/grandstand.rb', line 59

def multiple_upload=(new_multiple_upload)
  @multiple_upload = !!new_multiple_upload
end

.page_sectionsObject

:nodoc:



63
64
65
# File 'lib/grandstand.rb', line 63

def page_sections # :nodoc:
  @page_sections ||= %w(main)
end

.page_sections=(new_page_sections) ⇒ Object

:nodoc:



67
68
69
# File 'lib/grandstand.rb', line 67

def page_sections=(new_page_sections) # :nodoc:
  @page_sections = new_page_sections
end

.routingObject

Returns a hash for the Grandstand interface’s routing configuration. Options include

:ssl => Require SSL whenever a user is in the Grandstand interface


74
75
76
# File 'lib/grandstand.rb', line 74

def routing
  @routing ||= {}
end

.routing=(new_routing) ⇒ Object

Pass in a hash to set multiple routing options at once.



79
80
81
# File 'lib/grandstand.rb', line 79

def routing=(new_routing)
  @routing = new_routing
end

.routing_optionsObject

:nodoc:



83
84
85
86
87
88
89
# File 'lib/grandstand.rb', line 83

def routing_options # :nodoc:
  routing_options = {}
  # if Grandstand.routing[:domain]
  #   routing_options.merge!(:path => '', :constraints => {:domain => Grandstand.routing[:domain]})
  # end
  routing_options
end

.s3Object

Grandstand uses Paperclip to process and store uploaded gallery images to S3. By default, it reads those configuration options from config/s3.yml, but you can also specify credentials or anything else here, like so:

Grandstand.s3[:credentials] = {:access_key_id => "foo", :secret_access_key => "bar"}

Note that you must set a :bucket key or Grandstand will not know where to upload files. Currently, it does not support any other storage engines. Sorry!



99
100
101
102
103
104
# File 'lib/grandstand.rb', line 99

def s3
  @s3 ||= {
    :bucket => nil,
    :credentials => File.join(Rails.root, 'config', 's3.yml')
  }
end

.s3=(new_s3) ⇒ Object

You can also set a completely fresh hash of S3 options if you don’t like setting a key at time, like so:

Grandstand.s3 = {:bucket => "yourmom", :credentials => {:access_key_id => "foo", :secret_access_key => "bar"}}


109
110
111
# File 'lib/grandstand.rb', line 109

def s3=(new_s3)
  @s3 = new_s3
end

.site_keyObject



113
114
115
# File 'lib/grandstand.rb', line 113

def site_key
  @site_key ||= %(They say the truth shall come to the light, so everybody grab your shades cuz ya boy's that bright)
end

.site_key=(new_site_key) ⇒ Object



117
118
119
# File 'lib/grandstand.rb', line 117

def site_key=(new_site_key)
  @site_key = new_site_key.to_s
end