-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeconf.py
250 lines (223 loc) · 8.85 KB
/
feconf.py
1
2
3
4
5
6
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# coding: utf-8
#
# Copyright 2014 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Stores various configuration options and constants for Oppia."""
import os
# Whether to unconditionally log info messages.
DEBUG = False
# The platform for the storage backend. This is used in the model-switching
# code in core/platform.
PLATFORM = 'gae'
# Whether we should serve the development or production experience.
if PLATFORM == 'gae':
DEV_MODE = (
not os.environ.get('SERVER_SOFTWARE')
or os.environ['SERVER_SOFTWARE'].startswith('Development'))
else:
raise Exception('Invalid platform: expected one of [\'gae\']')
TESTS_DATA_DIR = 'core/tests/data'
SAMPLE_EXPLORATIONS_DIR = 'data/explorations'
WIDGETS_DIR = 'extensions/widgets'
RULES_DIR = 'extensions/rules'
INTERACTIVE_WIDGETS_DIR = 'extensions/widgets/interactive'
NONINTERACTIVE_WIDGETS_DIR = 'extensions/widgets/noninteractive'
OBJECT_TEMPLATES_DIR = 'extensions/objects/templates'
OBJECTS_DIR = 'extensions/objects'
SKINS_TEMPLATES_DIR = 'extensions/skins'
FRONTEND_TEMPLATES_DIR = ('core/templates/dev/head' if DEV_MODE
else 'core/templates/prod/head')
DEPENDENCIES_TEMPLATES_DIR = 'extensions/dependencies'
VALUE_GENERATORS_DIR = 'extensions/value_generators'
# The id and name for the final state of an exploration.
END_DEST = 'END'
# The default number of items to show on a page in a paged view.
DEFAULT_PAGE_SIZE = 50
# The default widget used for a new state.
DEFAULT_WIDGET_ID = 'TextInput'
# Default name for the initial state of an exploration.
DEFAULT_STATE_NAME = '(untitled state)'
# Name (and description) of the default rule.
DEFAULT_RULE_NAME = 'Default'
# A dict containing the accepted image formats (as determined by the imghdr
# module) and the corresponding allowed extensions in the filenames of uploaded
# files.
ACCEPTED_IMAGE_FORMATS_AND_EXTENSIONS = {
'jpeg': ['jpg', 'jpeg'],
'png': ['png'],
'gif': ['gif']
}
# Prefixes for widget ids in the datastore.
INTERACTIVE_PREFIX = 'interactive'
NONINTERACTIVE_PREFIX = 'noninteractive'
# The total number of non-interactive widgets. Used as a sanity check.
NONINTERACTIVE_WIDGET_COUNT = 4
# The total number of interactive widgets. Used as a sanity check.
INTERACTIVE_WIDGET_COUNT = 12
DEFAULT_EDITOR_PREREQUISITES_AGREEMENT = """
I understand and agree that any contributions I make to this site will be
licensed under CC-BY-SA v4.0, with a waiver of the attribution requirement. I
will not contribute material to the site (including images and files that are
part of an exploration) whose licensing is not compatible with CC-BY-SA v4.0.
"""
# Static file url to path mapping
PATH_MAP = {
'/css': 'core/templates/dev/head/css',
'/extensions/widgets': 'extensions/widgets',
'/favicon.ico': 'static/images/favicon.ico',
'/images': 'static/images',
'/img': 'third_party/bootstrap/img',
'/lib/static': 'lib/static',
'/third_party/static': 'third_party/static',
}
# Format string for displaying datetimes in the UI.
HUMAN_READABLE_DATETIME_FORMAT = '%b %d %Y, %H:%M UTC'
# A string containing the disallowed characters in state or exploration names.
# The underscore is needed because spaces in names must be converted to
# underscores when displayed as part of a URL or key. The other conventions
# here are derived from the Wikipedia guidelines for naming articles.
INVALID_NAME_CHARS = u':#/|_%<>[]{}\ufffd\\' + chr(127)
for ind in range(32):
INVALID_NAME_CHARS += chr(ind)
# Prefix for data sent from the server to the client via JSON.
XSSI_PREFIX = ')]}\'\n'
# A regular expression for alphanumeric characters
ALPHANUMERIC_REGEX = r'^[A-Za-z0-9]+$'
# Committer id for system actions.
ADMIN_COMMITTER_ID = 'admin'
ADMIN_EMAIL_ADDRESS = 'admin@oppia'
# The maximum size of an uploaded file, in bytes.
MAX_FILE_SIZE_BYTES = 1048576
# An ordered list of links to stand-alone pages to display in the 'About' tab.
# Each item is a dict with two keys: the human-readable name of the link and
# the URL of the page.
ABOUT_PAGES = [{
'name': 'About this site',
'url': '/about'
}, {
'name': 'How to use this site',
'url': '/site_guidelines',
}, {
'name': 'Blog',
'url': 'https://oppiablog.blogspot.com',
}, {
'name': 'Contact',
'url': '/contact',
}]
# Ids and locations of the permitted widgets.
ALLOWED_WIDGETS = {
NONINTERACTIVE_PREFIX: {
'Collapsible': {
'dir': 'extensions/widgets/noninteractive/Collapsible'
},
'Image': {
'dir': 'extensions/widgets/noninteractive/Image'
},
'Link': {
'dir': 'extensions/widgets/noninteractive/Link'
},
'Math': {
'dir': 'extensions/widgets/noninteractive/Math'
},
'Tabs': {
'dir': 'extensions/widgets/noninteractive/Tabs'
},
'Video': {
'dir': 'extensions/widgets/noninteractive/Video'
},
},
INTERACTIVE_PREFIX: {
'Continue': {
'dir': 'extensions/widgets/interactive/Continue'
},
'MultipleChoiceInput': {
'dir': 'extensions/widgets/interactive/MultipleChoiceInput'
},
'NumericInput': {
'dir': 'extensions/widgets/interactive/NumericInput'
},
'TextInput': {
'dir': 'extensions/widgets/interactive/TextInput'
},
'InteractiveMap': {
'dir': 'extensions/widgets/interactive/InteractiveMap'
},
'SetInput': {
'dir': 'extensions/widgets/interactive/SetInput'
},
'FileReadInput': {
'dir': 'extensions/widgets/interactive/FileReadInput'
},
'TarFileReadInput': {
'dir': 'extensions/widgets/interactive/TarFileReadInput'
},
'CodeRepl': {
'dir': 'extensions/widgets/interactive/CodeRepl'
},
'MusicNotesInput': {
'dir': 'extensions/widgets/interactive/MusicNotesInput'
},
}
}
# Demo explorations to load on startup. The id assigned to each exploration
# is based on the index of the exploration in this list, so if you want to
# add a new exploration and preserve the existing ids, add that exploration
# to the end of the list.
# Each item is represented as a tuple: (filepath, title, category). If the
# filepath is a yaml file it should end with '.yaml', otherwise it should
# be the path to the directory WITHOUT a trailing '/'.
DEMO_EXPLORATIONS = [
('welcome.yaml', 'Welcome to Oppia!', 'Welcome'),
('multiples.yaml', 'Project Euler Problem 1', 'Coding'),
('binary_search', 'The Lazy Magician', 'Mathematics'),
('root_linear_coefficient_theorem.yaml', 'Root Linear Coefficient Theorem',
'Mathematics'),
('counting.yaml', 'Three Balls', 'Mathematics'),
('cities.yaml', 'World Cities', 'Geography'),
('boot_verbs.yaml', 'Boot Verbs', 'Languages'),
('hola.yaml', u'¡Hola!', 'Languages'),
# This exploration is included to show other applications of Oppia, but
# please note that Oppia lacks many of the features of a full interactive
# fiction engine!
('adventure.yaml', 'Parameterized Adventure', 'Interactive Fiction'),
('pitch_perfect.yaml', 'Pitch Perfect', 'Music'),
('tar_about.yaml', 'About Tar', 'Open Source'),
('tar_creating', 'Creating Tar Archives', 'Open Source'),
('tar_unpacking', 'Unpacking Tar Archives', 'Open Source')
]
# TODO(sll): Add all other URLs here.
CLONE_EXPLORATION_URL = '/contributehandler/clone'
CONTRIBUTE_GALLERY_URL = '/contribute'
CONTRIBUTE_GALLERY_DATA_URL = '/contributehandler/data'
EDITOR_PREREQUISITES_URL = '/editor_prerequisites'
EDITOR_PREREQUISITES_DATA_URL = '/editor_prerequisites_handler/data'
EDITOR_URL_PREFIX = '/create'
EXPLORATION_RIGHTS_PREFIX = '/createhandler/rights'
EXPLORATION_DATA_PREFIX = '/createhandler/data'
EXPLORATION_URL_PREFIX = '/explore'
EXPLORATION_INIT_URL_PREFIX = '/explorehandler/init'
EXPLORATION_TRANSITION_URL_PREFIX = '/explorehandler/transition'
LEARN_GALLERY_URL = '/learn'
LEARN_GALLERY_DATA_URL = '/learnhandler/data'
NEW_EXPLORATION_URL = '/contributehandler/create_new'
RECENT_COMMITS_DATA_URL = '/recentcommitshandler/recent_commits'
UPLOAD_EXPLORATION_URL = '/contributehandler/upload'
SPLASH_PAGE_URL = '/'
NAV_MODE_ABOUT = 'about'
NAV_MODE_CONTACT = 'contact'
NAV_MODE_CONTRIBUTE = 'contribute'
NAV_MODE_CREATE = 'create'
NAV_MODE_EXPLORE = 'explore'
NAV_MODE_LEARN = 'learn'
NAV_MODE_PROFILE = 'profile'