Skip to content

Commit bfaba16

Browse files
authored
Merge pull request #1888 from rtibbles/pdfjs
First pass pdfjs integration
2 parents fd0f069 + cae8348 commit bfaba16

File tree

9 files changed

+571
-61
lines changed

9 files changed

+571
-61
lines changed

frontend_build/src/parse_bundle_plugin.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@ var parseBundlePlugin = function(data, base_dir) {
9090
],
9191
};
9292

93+
// Calculate these paths here, so that we can export __publicPath as a variable in the webpack define plugin
94+
var publicPath, outputPath;
95+
96+
if (process.env.DEV_SERVER) {
97+
var devServerConfig = require('./webpackdevserverconfig');
98+
// If running webpack dev server point to that endpoint.
99+
publicPath = devServerConfig.publicPath;
100+
// Set output path to base dir, as no files will be written - all built files are cached in memory.
101+
outputPath = devServerConfig.basePath
102+
? path.resolve(path.join(base_dir, devServerConfig.basePath))
103+
: path.resolve(base_dir);
104+
} else {
105+
publicPath = path.join('/', data.static_url_root, data.name, '/');
106+
outputPath = path.join(data.static_dir, data.name);
107+
}
108+
93109
bundle.plugins = bundle.plugins.concat([
94110
// BundleTracker creates stats about our built files which we can then pass to Django to allow our template
95111
// tags to load the correct frontend files.
@@ -106,27 +122,14 @@ var parseBundlePlugin = function(data, base_dir) {
106122
__events: JSON.stringify(data.events || {}),
107123
__once: JSON.stringify(data.once || {}),
108124
__version: JSON.stringify(data.version),
125+
// This is necessary to allow modules that use service workers to fetch their service worker code
126+
__publicPath: JSON.stringify(publicPath),
109127
}),
110128
new extract$trs(data.locale_data_folder, data.name),
111129
]);
112130

113131
bundle = merge.smart(bundle, local_config);
114132

115-
var publicPath, outputPath;
116-
117-
if (process.env.DEV_SERVER) {
118-
var devServerConfig = require('./webpackdevserverconfig');
119-
// If running webpack dev server point to that endpoint.
120-
publicPath = devServerConfig.publicPath;
121-
// Set output path to base dir, as no files will be written - all built files are cached in memory.
122-
outputPath = devServerConfig.basePath
123-
? path.resolve(path.join(base_dir, devServerConfig.basePath))
124-
: path.resolve(base_dir);
125-
} else {
126-
publicPath = path.join('/', data.static_url_root, data.name, '/');
127-
outputPath = path.join(data.static_dir, data.name);
128-
}
129-
130133
bundle.core_name = data.core_name;
131134
bundle.name = data.name;
132135
bundle.context = base_dir;

kolibri/core/assets/src/state/getters.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ function contentPoints(state) {
7373
return Math.floor(state.core.logging.summary.progress) * MaxPointsPerContent;
7474
}
7575

76+
function sessionTimeSpent(state) {
77+
return state.core.logging.session.time_spent;
78+
}
79+
7680
export {
7781
isUserLoggedIn,
7882
isSuperuser,
@@ -88,4 +92,5 @@ export {
8892
contentPoints,
8993
currentUserId,
9094
facilityConfig,
95+
sessionTimeSpent,
9196
};

0 commit comments

Comments
 (0)