Skip to content

Commit

Permalink
Introduce Webpack to the codebase (oppia#6324)
Browse files Browse the repository at this point in the history
* initial work

* lot of work

* ignore and remove dist directory

* add copyright notice, fix linting

* fix linting

* fix JS linting

* add try-catch blocks

* fix prod mode

* remove template.html

* work

* work

* add require to files

* work

* replace relative paths with absolute

* add require to other files

* add require to next batch of files

* add require to other batch of files

* other batch of files

* batch of work

* next batch of work

* batch of work

* batch of work

* one file

* batch of work

* add error page

* custom landing pages

* add thanks page

* add splash pages

* add teach and get_started pages

* add contact page

* add library page

* add profile and sognup page

* add creator_dashboard and admin

* batch of work

* batch

* batch work

* first go on frontend test

* change .js in require to .ts

* enable webpack with typescript

* batch of work

* batch of work

* batch of work

* batch of work

* batch of work

* linting

* tests

* backend tests

* fix some stuff

* remove relative imports

* add linter for relative import in require()

* fix some tests

* fix linter

* other work

* e2e tests

* e2e tests

* dev mode

* e2e tests

* e2e tests

* e2e tests

* e2e tests

* e2e tests

* add AutoplayedVideosService to required pages

* e2e test

* add linting for webpack stuff

* intendation in HTML

* fix comments

* remove unused require

* remove script-imports

* remove NormalizeFilter from tsconfig

* require normalizer

* fix exploration editor

* return removed line

* improve comment message
  • Loading branch information
vojtechjelinek authored and seanlip committed May 16, 2019
1 parent 9d30f9e commit bce009c
Show file tree
Hide file tree
Showing 603 changed files with 6,604 additions and 1,854 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ assets/hashes.js
backend_prod_files/*
local_compiled_js/*
core/templates/prod/*
core/templates/dev/head/dist/*
core/tests/.browserstack.env
node_modules/*
.coverage*
Expand Down
9 changes: 7 additions & 2 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ handlers:
expiration: "90d"

# DEVELOPMENT STATIC
- url: /dist
static_dir: core/templates/dev/head/dist
secure: always
application_readable: true
expiration: "0"
- url: /assets
static_dir: assets
secure: always
Expand All @@ -61,9 +66,9 @@ handlers:
upload: local_compiled_js/core/templates/dev/head/(.*\.(js))$
secure: always
expiration: "0"
- url: /templates/dev/head/(.*directive\.html)$
- url: /templates/dev/head/(.*\.(html))$
static_files: core/templates/dev/head/\1
upload: core/templates/dev/head/(.*directive\.html)$
upload: core/templates/dev/head/(.*\.(html))$
secure: always
expiration: "0"
application_readable: true
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get(self):
'role_graph_data': role_services.get_role_graph_data()
})

self.render_template('pages/admin/admin.html')
self.render_template('dist/admin.html')


class AdminHandler(base.BaseHandler):
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def _render_exception_json_or_html(self, return_type, values):
self.render_template(
'pages/error/error_iframed.html', iframe_restriction=None)
else:
self.render_template('pages/error/error.html')
self.render_template('dist/error.html')
else:
if return_type != feconf.HANDLER_TYPE_JSON and (
return_type != feconf.HANDLER_TYPE_DOWNLOADABLE):
Expand Down
4 changes: 3 additions & 1 deletion core/controllers/collection_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from core.controllers import acl_decorators
from core.controllers import base
from core.domain import collection_services
from core.domain import interaction_registry
from core.domain import rights_manager
from core.domain import search_services
from core.domain import summary_services
Expand Down Expand Up @@ -67,9 +68,10 @@ def get(self, collection_id):
feconf.SHOW_COLLECTION_NAVIGATION_TAB_STATS),
'TAG_REGEX': feconf.TAG_REGEX,
'title': collection.title,
'INTERACTION_SPECS': interaction_registry.Registry.get_all_specs(),
})

self.render_template('pages/collection_editor/collection_editor.html')
self.render_template('dist/collection_editor.html')


class EditableCollectionDataHandler(CollectionEditorHandler):
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/collection_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get(self, collection_id):
'meta_description': utils.capitalize_string(collection.objective)
})

self.render_template('pages/collection_player/collection_player.html')
self.render_template('dist/collection_player.html')


class CollectionDataHandler(base.BaseHandler):
Expand Down
4 changes: 2 additions & 2 deletions core/controllers/creator_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get(self):
'meta_description': feconf.CREATOR_DASHBOARD_PAGE_DESCRIPTION,
})
self.render_template(
'pages/notifications_dashboard/notifications_dashboard.html')
'dist/notifications_dashboard.html')


class NotificationsDashboardHandler(base.BaseHandler):
Expand Down Expand Up @@ -145,7 +145,7 @@ def get(self):
interaction_templates),
'dependencies_html': jinja2.utils.Markup(dependencies_html)
})
self.render_template('pages/creator_dashboard/creator_dashboard.html')
self.render_template('dist/creator_dashboard.html')


class CreatorDashboardHandler(base.BaseHandler):
Expand Down
4 changes: 2 additions & 2 deletions core/controllers/custom_landing_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get(self, subject, topic):
"""Handles GET requests."""
if subject in feconf.AVAILABLE_LANDING_PAGES:
if topic in feconf.AVAILABLE_LANDING_PAGES[subject]:
self.render_template('pages/landing/topic_landing_page.html')
self.render_template('dist/topic_landing_page.html')
else:
raise self.PageNotFoundException
else:
Expand All @@ -54,4 +54,4 @@ class StewardsLandingPage(base.BaseHandler):
def get(self):
"""Handles GET requests."""
self.render_template(
'pages/landing/stewards/landing_page_stewards.html')
'dist/landing_page_stewards.html')
2 changes: 1 addition & 1 deletion core/controllers/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def get(self, exploration_id):
'TAG_REGEX': feconf.TAG_REGEX,
})

self.render_template('pages/exploration_editor/exploration_editor.html')
self.render_template('dist/exploration_editor.html')


class ExplorationHandler(EditorHandler):
Expand Down
4 changes: 2 additions & 2 deletions core/controllers/email_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class EmailDashboardPage(base.BaseHandler):
@acl_decorators.can_manage_email_dashboard
def get(self):
"""Handles GET requests."""
self.render_template('pages/email_dashboard/email_dashboard.html')
self.render_template('dist/email_dashboard.html')


class EmailDashboardDataHandler(base.BaseHandler):
Expand Down Expand Up @@ -168,7 +168,7 @@ def get(self, query_id):
'query_id': query_id,
})
self.render_template(
'pages/email_dashboard/email_dashboard_result.html')
'dist/email_dashboard_result.html')

@acl_decorators.can_manage_email_dashboard
def post(self, query_id):
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/learner_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LearnerDashboardPage(base.BaseHandler):
@acl_decorators.can_access_learner_dashboard
def get(self):
"""Handles GET requests."""
self.render_template('pages/learner_dashboard/learner_dashboard.html')
self.render_template('dist/learner_dashboard.html')


class LearnerDashboardHandler(base.BaseHandler):
Expand Down
4 changes: 2 additions & 2 deletions core/controllers/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get(self):
self.user_id and
user_services.has_fully_registered(self.user_id)),
})
self.render_template('pages/library/library.html')
self.render_template('dist/library.html')


class LibraryIndexHandler(base.BaseHandler):
Expand Down Expand Up @@ -157,7 +157,7 @@ def get(self):
self.user_id and
user_services.has_fully_registered(self.user_id)),
})
self.render_template('pages/library/library.html')
self.render_template('dist/library.html')


class LibraryGroupIndexHandler(base.BaseHandler):
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/moderator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ModeratorPage(base.BaseHandler):
@acl_decorators.can_access_moderator_page
def get(self):
"""Handles GET requests."""
self.render_template('pages/moderator/moderator.html')
self.render_template('dist/moderator.html')


class FeaturedActivitiesHandler(base.BaseHandler):
Expand Down
24 changes: 12 additions & 12 deletions core/controllers/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def get(self):
})

if not c_value:
self.render_template('pages/splash/splash.html')
self.render_template('dist/splash.html')
else:
try:
self.render_template('pages/splash/splash_%s.html' % c_value)
self.render_template('dist/splash_%s.html' % c_value)
except Exception:
# Old c values may have been deprecated, in which case we
# revert to the default splash page URL. When redirecting,
Expand All @@ -74,7 +74,7 @@ def get(self):
self.values.update({
'meta_description': feconf.ABOUT_PAGE_DESCRIPTION,
})
self.render_template('pages/about/about.html')
self.render_template('dist/about.html')


class GetStartedPage(base.BaseHandler):
Expand All @@ -86,7 +86,7 @@ def get(self):
self.values.update({
'meta_description': feconf.GET_STARTED_PAGE_DESCRIPTION,
})
self.render_template('pages/get_started/get_started.html')
self.render_template('dist/get_started.html')


class TeachPage(base.BaseHandler):
Expand All @@ -98,7 +98,7 @@ def get(self):
self.values.update({
'meta_description': feconf.TEACH_PAGE_DESCRIPTION,
})
self.render_template('pages/teach/teach.html')
self.render_template('dist/teach.html')


class ContactPage(base.BaseHandler):
Expand All @@ -110,7 +110,7 @@ def get(self):
self.values.update({
'meta_description': feconf.CONTACT_PAGE_DESCRIPTION,
})
self.render_template('pages/contact/contact.html')
self.render_template('dist/contact.html')


class DonatePage(base.BaseHandler):
Expand All @@ -122,7 +122,7 @@ def get(self):
self.values.update({
'meta_description': feconf.DONATE_PAGE_DESCRIPTION,
})
self.render_template('pages/donate/donate.html')
self.render_template('dist/donate.html')


class ThanksPage(base.BaseHandler):
Expand All @@ -134,7 +134,7 @@ def get(self):
self.values.update({
'meta_description': feconf.THANKS_PAGE_DESCRIPTION,
})
self.render_template('pages/thanks/thanks.html')
self.render_template('dist/thanks.html')


class ForumRedirectPage(base.BaseHandler):
Expand All @@ -155,7 +155,7 @@ def get(self):
'meta_description': feconf.TERMS_PAGE_DESCRIPTION,
})

self.render_template('pages/terms/terms.html')
self.render_template('dist/terms.html')


class PrivacyPage(base.BaseHandler):
Expand All @@ -164,7 +164,7 @@ class PrivacyPage(base.BaseHandler):
@acl_decorators.open_access
def get(self):
"""Handles GET requests."""
self.render_template('pages/privacy/privacy.html')
self.render_template('dist/privacy.html')


class AboutRedirectPage(base.BaseHandler):
Expand Down Expand Up @@ -200,7 +200,7 @@ class ConsoleErrorPage(base.BaseHandler):
@acl_decorators.open_access
def get(self):
"""Handles GET requests."""
self.render_template('pages/tests/console_errors.html')
self.render_template('dist/console_errors.html')


class MaintenancePage(base.BaseHandler):
Expand All @@ -209,4 +209,4 @@ class MaintenancePage(base.BaseHandler):
@acl_decorators.open_access
def get(self, *args, **kwargs):
"""Handles GET requests."""
self.render_template('pages/maintenance/maintenance.html')
self.render_template('dist/maintenance.html')
2 changes: 1 addition & 1 deletion core/controllers/practice_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get(self, topic_name):
raise self.PageNotFoundException(
Exception('The topic with the given name doesn\'t exist.'))

self.render_template('/pages/practice_session/practice_session.html')
self.render_template('dist/practice_session.html')


class PracticeSessionsPageDataHandler(base.BaseHandler):
Expand Down
6 changes: 3 additions & 3 deletions core/controllers/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get(self, username):
self.values.update({
'PROFILE_USERNAME': user_settings.username,
})
self.render_template('pages/profile/profile.html')
self.render_template('dist/profile.html')


class ProfileHandler(base.BaseHandler):
Expand Down Expand Up @@ -108,7 +108,7 @@ def get(self):
self.values.update({
'meta_description': feconf.PREFERENCES_PAGE_DESCRIPTION,
})
self.render_template('pages/preferences/preferences.html')
self.render_template('dist/preferences.html')


class PreferencesHandler(base.BaseHandler):
Expand Down Expand Up @@ -261,7 +261,7 @@ def get(self):
'meta_description': feconf.SIGNUP_PAGE_DESCRIPTION,
'CAN_SEND_EMAILS': feconf.CAN_SEND_EMAILS,
})
self.render_template('pages/signup/signup.html')
self.render_template('dist/signup.html')


class SignupHandler(base.BaseHandler):
Expand Down
4 changes: 2 additions & 2 deletions core/controllers/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def get(self, exploration_id):
self.values.update(exploration_data_values)
self.values['iframed'] = True
self.render_template(
'pages/exploration_player/exploration_player.html',
'dist/exploration_player.html',
iframe_restriction=None)


Expand Down Expand Up @@ -234,7 +234,7 @@ def get(self, exploration_id):
self.values.update(exploration_data_values)
self.values['iframed'] = False
self.render_template(
'pages/exploration_player/exploration_player.html')
'dist/exploration_player.html')


class ExplorationHandler(base.BaseHandler):
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/skill_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get(self, skill_id):
'dependencies_html': jinja2.utils.Markup(dependencies_html)
})

self.render_template('pages/skill_editor/skill_editor.html')
self.render_template('dist/skill_editor.html')


def check_can_edit_skill_description(user):
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/story_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get(self, topic_id, story_id):
'story_title': story.title,
})

self.render_template('pages/story_editor/story_editor.html')
self.render_template('dist/story_editor.html')


class EditableStoryDataHandler(base.BaseHandler):
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/topic_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def get(self, topic_id):
'dependencies_html': jinja2.utils.Markup(dependencies_html)
})

self.render_template('pages/topic_editor/topic_editor.html')
self.render_template('dist/topic_editor.html')


class EditableSubtopicPageDataHandler(base.BaseHandler):
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/topic_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get(self, topic_name):
self.values.update({
'topic_name': topic.name
})
self.render_template('/pages/topic_viewer/topic_viewer.html')
self.render_template('dist/topic_viewer.html')


class TopicPageDataHandler(base.BaseHandler):
Expand Down
4 changes: 1 addition & 3 deletions core/controllers/topics_and_skills_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def get(self):
if not constants.ENABLE_NEW_STRUCTURE_EDITORS:
raise self.PageNotFoundException

self.render_template(
'pages/topics_and_skills_dashboard/'
'topics_and_skills_dashboard.html')
self.render_template('dist/topics_and_skills_dashboard.html')


class TopicsAndSkillsDashboardPageDataHandler(base.BaseHandler):
Expand Down
Loading

0 comments on commit bce009c

Please sign in to comment.