Class: Scribo::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/scribo/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/scribo/configuration.rb', line 7

def initialize
  @logger = Logger.new(STDOUT)
  @logger.level = Logger::INFO
  @base_controller = '::ApplicationController'
  @supported_mime_types = {
    image: %w[image/gif image/png image/jpeg image/bmp image/webp image/svg+xml],
    text: %w[text/plain text/html application/json application/xml],
    style: %w[text/css],
    script: %w[text/javascript application/javascript application/x-javascript],
    audio: %w[audio/midi audio/mpeg audio/webm audio/ogg audio/wav],
    video: %w[video/webm video/ogg video/mp4],
    document: %w[application/msword application/vnd.ms-powerpoint application/vnd.ms-excel application/pdf
                 application/zip],
    font: %w[font/collection font/otf font/sfnt font/ttf font/woff font/woff2 application/font-ttf
             application/x-font-ttf application/vnd.ms-fontobject application/font-woff],
    other: %w[application/octet-stream]
  }
  @default_404_txt = '404 Not Found'
  @default_humans_txt = <<~HUMANS_TXT
    /* TEAM */
    Your title: Your name.
    Site: email, link to a contact form, etc.
    Twitter: your Twitter username.
    Location: City, Country.

                            [...]

    /* THANKS */
    Name: name or url

                            [...]

    /* SITE */
    Last update: YYYY/MM/DD
    Standards: HTML5, CSS3,..
    Components: Modernizr, jQuery, etc.
    Software: Software used for the development
  HUMANS_TXT
  @default_robots_txt = <<~ROBOTS_TXT
    # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
    #
    # To ban all spiders from the entire site uncomment the next two lines:
    # User-agent: *
    # Disallow: /
  ROBOTS_TXT

  # Base64 encoded image/x-icon
  @default_favicon_ico = 'AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAA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v+3dgb/t3YG/7d2Bv+3dgb/t3YG/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAt3YG/wAAAAC3dgb/t3YG/7d2Bv+3dgb/t3YG/7d2Bv+3dgb/t3YG8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAt3YG/7d2Bv+3dgb/t3YG/7d2Bv+3dgb/t3YG/7d2Bv8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC3dgb/t3YG/2hDA3O3dgb/t3YG/7d2Bv+3dgb/t3YG/QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC4dgeJAAAAALd2Bv+3dgb/t3YG/7d2Bv+zcgZ3//8AAL//AADB/wAAgn8AAIA/AACAHwAAgH8AAMAPAADABwAAwAcAAOAHAADgDwAA9AMAAPwDAAD+QQAA/6EAAA=='

  # This needs an array of hashes, each hash MUST include an id, thumbnail and a url:
  # [
  #   { id: '7becd952-ae77-43ad-9bf7-ed4f8feb59fa', thumbnail: 'https://mysite.net/template1.png', url: 'https://mysite.net/template1.zip' }
  # ]
  #
  # The id can be generated using: `SecureRandom.uuid`, or you can use integers
  @templates = []

  # Default site if no site is found, this can be nil, an actual site instance or a proc which will resolve a site instance.
  @default_site = nil
end

Instance Attribute Details

#admin_authentication_moduleObject

Returns the value of attribute admin_authentication_module.



3
4
5
# File 'lib/scribo/configuration.rb', line 3

def admin_authentication_module
  @admin_authentication_module
end

#admin_mount_pointObject

admin_mount_point [String].



78
79
80
# File 'lib/scribo/configuration.rb', line 78

def admin_mount_point
  @admin_mount_point ||= '/'
end

#after_site_create(site) ⇒ Object

What to do after a site create (only for new sites, not imported sites)



93
94
95
# File 'lib/scribo/configuration.rb', line 93

def after_site_create(site)
  instance_exec(site, &@after_site_create) if @after_site_create
end

#base_controllerObject

Returns the value of attribute base_controller.



3
4
5
# File 'lib/scribo/configuration.rb', line 3

def base_controller
  @base_controller
end

#default_404_txtObject

Returns the value of attribute default_404_txt.



3
4
5
# File 'lib/scribo/configuration.rb', line 3

def default_404_txt
  @default_404_txt
end

#default_favicon_icoObject

Returns the value of attribute default_favicon_ico.



3
4
5
# File 'lib/scribo/configuration.rb', line 3

def default_favicon_ico
  @default_favicon_ico
end

#default_humans_txtObject

Returns the value of attribute default_humans_txt.



3
4
5
# File 'lib/scribo/configuration.rb', line 3

def default_humans_txt
  @default_humans_txt
end

#default_robots_txtObject

Returns the value of attribute default_robots_txt.



3
4
5
# File 'lib/scribo/configuration.rb', line 3

def default_robots_txt
  @default_robots_txt
end

#default_site(request = nil) ⇒ Object



73
74
75
# File 'lib/scribo/configuration.rb', line 73

def default_site(request = nil)
  @default_site.is_a?(Proc) ? instance_exec(request, &@default_site) : @default_site
end

#loggerObject

logger [Object].



69
70
71
# File 'lib/scribo/configuration.rb', line 69

def logger
  @logger.is_a?(Proc) ? instance_exec(&@logger) : @logger
end

#scribable_for_request(request) ⇒ Object

Which scribable to use for the current request, should only return one scribable



88
89
90
# File 'lib/scribo/configuration.rb', line 88

def scribable_for_request(request)
  instance_exec(request, &@scribable_for_request) if @scribable_for_request
end

#scribable_objectsObject

Only used to limit what users can see when using admin



83
84
85
# File 'lib/scribo/configuration.rb', line 83

def scribable_objects
  [*instance_exec(&@scribable_objects)] if @scribable_objects
end

#supported_mime_typesObject

Returns the value of attribute supported_mime_types.



3
4
5
# File 'lib/scribo/configuration.rb', line 3

def supported_mime_types
  @supported_mime_types
end

#templatesObject

Returns the value of attribute templates.



3
4
5
# File 'lib/scribo/configuration.rb', line 3

def templates
  @templates
end