LP#1434728: make password_required configurable per library
[sitka/overdrive-evergreen-opac.git] / src / od_config_template.coffee
CommitLineData
8ebc3fff
SC
1# This file represents a template to write a configuration module for the
2# system.
3
4define [
5 'moment'
6], (M) ->
7
8ebc3fff
SC
8 # Default configuration of date formats for Moment object;
9 # see http://devdocs.io/moment/index#customization-long-date-formats
10 M.lang 'en', longDateFormat:
90297bd5
SC
11 LT: "h:mm A"
12 L: "MM/DD/YYYY"
13 LL: "MMMM Do YYYY"
14 LLL: "MMMM Do YYYY LT"
8ebc3fff
SC
15 LLLL: "dddd, MMMM Do YYYY LT"
16
90297bd5
SC
17 # Mapping between long name of home library and Overdrive authorization name
18 longname =
19 'long name one': 'name1'
20 'long name two': 'name2'
21
8ebc3fff
SC
22 return {
23
24 # Define the credentials to use to get client authentication to the
25 # API. The text string is a combination of the client key and client
26 # secret combined in the method described in
27 # https://developer.overdrive.com/apis/client-auth, which can be
28 # expressed by the following function:
29 #
30 # OAuthFormat = (key, secret) -> CryptoJS.enc.Base64.stringify CryptoJS.enc.Utf8.parse "#{key}:#{secret}"
31 #
32 credentials: '' # Base64 encoded text string
33
34 # Define the credentials to use to get patron authentication, as described in
35 # https://developer.overdrive.com/apis/patron-auth
36 accountID: 4321
37 websiteID: 321
38
39 # Define the mapping function between long name and authorization name
40 authorizationname: (id) -> longname[id]
41
27e91a35
JD
42 # Define whether a user password is required to complete patron authentication.
43 # This function takes the home library's long name as a parameter.
44 # You can use this parameter to lookup whether the library requires a password.
45 # If all your libraries do (or don't) require a password, modify this function
46 # to always return 'true' (or 'false').
47 password_required: (libraryname) ->
48 no_password = [ 'long name one' ]
49 if libraryname in no_password then return 'false' else return 'true'
2221a640 50
8b13a139
JD
51 # Main base URL (used for direct links to content provider's site)
52 baseURL: 'http://example.com/ContentDetails.htm'
53
5783f765
JD
54 # Base URL/FQDN(s) for hyperlinks to OverDrive products
55 productbaseURLs: [ 'elm.lib.overdrive.com' ]
56
2221a640
SC
57 # Define a blacklist based on hostname component, eg, abc.domain1 or xyz.domain2
58 blacklisted: ( hn = window.location.hostname, bl = ['abc', 'xyz'] ) ->
59 return unless hn = hn.match(/^(.+?)\./)?[1] # no proper hostname found
60 return unless bl?.length > 0 # no blacklist or is empty
61 return true for v in bl when v is hn # hostname is listed in blacklist
62 return # not listed in blacklist
8ebc3fff 63 }