From d3ed15db29c36793c7ac2c28b44b52c86ca4a54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20B=C3=B6hlke?= Date: Wed, 27 Jan 2016 15:09:49 +0700 Subject: [PATCH] Mediafile pdf presentation with angular-pdf and pdf.js (Fixes #1664). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to André Böhlke for contribution core functionality! Some additional template improvements by Emanuel. --- bower.json | 5 +- gulpfile.js | 10 +- openslides/core/static/js/core/base.js | 1 + .../core/static/templates/projector.html | 1 + openslides/mediafiles/serializers.py | 9 +- .../static/js/mediafiles/projector.js | 55 ++++++++- .../mediafiles/static/js/mediafiles/site.js | 116 +++++++++++++++++- .../templates/mediafiles/mediafile-list.html | 38 +++++- .../templates/mediafiles/slide_mediafile.html | 8 ++ .../mediafiles/slide_mediafile_partial.html | 1 + package.json | 7 +- requirements_production.txt | 3 +- 12 files changed, 239 insertions(+), 15 deletions(-) create mode 100644 openslides/mediafiles/static/templates/mediafiles/slide_mediafile.html create mode 100644 openslides/mediafiles/static/templates/mediafiles/slide_mediafile_partial.html diff --git a/bower.json b/bower.json index 29dd56e47..6045de0e0 100644 --- a/bower.json +++ b/bower.json @@ -31,9 +31,10 @@ "ckeditor": "~4.5.4", "angular-ckeditor": "~1.0.0", "roboto-condensed": "~0.3.0", - "open-sans-fontface": "https://github.com/OpenSlides/open-sans.git#1.4.2.post1" + "open-sans-fontface": "https://github.com/OpenSlides/open-sans.git#1.4.2.post1", + "angular-pdf": "~1.3.0" }, "resolutions": { - "angular": "^1.2.x" + "angular": ">=1.4.9 <1.5" } } diff --git a/gulpfile.js b/gulpfile.js index d33c060f9..62c6dc36e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -21,6 +21,7 @@ var argv = require('yargs').argv, mainBowerFiles = require('main-bower-files'), minifyCSS = require('gulp-minify-css'), path = require('path'), + rename = require("gulp-rename"), through = require('through2'), uglify = require('gulp-uglify'), vsprintf = require('sprintf-js').vsprintf; @@ -69,6 +70,13 @@ gulp.task('ckeditor', function () { .pipe(gulp.dest(path.join(output_directory, 'ckeditor'))); }); +// Extra task only for pdfjs +gulp.task('pdfjs', function () { + return gulp.src(path.join('bower_components', 'pdfjs-dist', 'build', 'pdf.worker.js')) + .pipe(rename(path.join('openslides-libs.worker.js'))) + .pipe(gulp.dest(path.join(output_directory, 'js'))); +}); + // Compiles translation files (*.po) to *.json and saves them in the directory // openslides/static/i18n/. gulp.task('translations', function () { @@ -80,7 +88,7 @@ gulp.task('translations', function () { }); // Gulp default task. Runs all other tasks before. -gulp.task('default', ['js-libs', 'css-libs', 'fonts-libs', 'ckeditor', 'translations'], function () {}); +gulp.task('default', ['js-libs', 'css-libs', 'fonts-libs', 'ckeditor', 'pdfjs', 'translations'], function () {}); /** diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index c80722338..910924b27 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -10,6 +10,7 @@ angular.module('OpenSlidesApp.core', [ 'ngSanitize', // TODO: only use this in functions that need it. 'ui.bootstrap', 'ui.tree', + 'pdf' ]) .config([ diff --git a/openslides/core/static/templates/projector.html b/openslides/core/static/templates/projector.html index 10bc998be..5a21f5f13 100644 --- a/openslides/core/static/templates/projector.html +++ b/openslides/core/static/templates/projector.html @@ -7,6 +7,7 @@ +