From cbec8b7a7fa59033d1f9461db6645e082cd75914 Mon Sep 17 00:00:00 2001 From: febbweiss Date: Tue, 14 Nov 2017 14:35:31 +0000 Subject: [PATCH] Feature: add .gitignore --- .gitignore | 1 + README.md | 30 ++++++++++++++++ bower.json | 30 ++++++++++++++++ index.html | 82 ++++++++++++++++++++++++++++++++++++++++++++ js/pdf-reader.js | 53 ++++++++++++++++++++++++++++ partials/viewer.html | 13 +++++++ 6 files changed, 209 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 bower.json create mode 100644 index.html create mode 100644 js/pdf-reader.js create mode 100644 partials/viewer.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbe05fc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bower_components/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..f9415fc --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +PDF-Reader is a small web application listing PDF documents and allowing to visualize them. + + +Building : +--- + +This project is built using [Bower](http://bower.io). +Just install it and run : + +``` +bower install +``` + +How it works : +--- + +Written in AngularJS, PDF-Reader calls a resource (_/data/documents.json_) providing a list of documents such as : + +``` +[{"title": "My report", "link": "report.pdf"] +``` + +The list is rendering such as a paginated table with a quick filter input. Clicking on the _View_ button load the document in the right side pane. + +Documents are stored in a _documents_ folder. + +Licence : +---------- + +Source code is under [MIT Licence](http://opensource.org/licenses/mit-license.php) \ No newline at end of file diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..1205721 --- /dev/null +++ b/bower.json @@ -0,0 +1,30 @@ +{ + "name": "pdf-reader", + "authors": [ + "febbweiss " + ], + "description": "A webpage to read stored pdf", + "main": "index.html", + "keywords": [ + "pdf", + "reader" + ], + "license": "MIT", + "homepage": "", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "angular": "angularjs#1.6.6", + "angular-pdf": "^2.0.0", + "bulma": "^0.6.1", + "font-awesome": "fontawesome#^4.7.0", + "bower": "*", + "install": "^1.0.4", + "angularUtils-pagination": "angular-utils-pagination#^0.11.1" + } +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..31b9b79 --- /dev/null +++ b/index.html @@ -0,0 +1,82 @@ + + + + + + + Hello... + + + + + + + + + + + + + + + + + + + +
+
+
+
+ Documents +
+
+
+
+ + + + +
+
+
+
+ + + + + + + + + + +
{{pdf.title}}
+ + +
+
+
+
+ + {{pdfName}} + + {{progress}}% +
+
+ +
+
+ + diff --git a/js/pdf-reader.js b/js/pdf-reader.js new file mode 100644 index 0000000..3d2c521 --- /dev/null +++ b/js/pdf-reader.js @@ -0,0 +1,53 @@ +angular.module('pdfReader', ['pdf', 'angularUtils.directives.dirPagination']) + .controller('PdfListController', function($scope, $http) { + + $scope.search = ''; + $scope.pdfName = undefined; + $scope.pdfUrl = undefined; + $scope.scroll = 0; + $scope.loading = 'is-invisible'; + $scope.progress = 0; + $scope.errorStatus = 'is-invisible none'; + $scope.error = undefined; + + $scope.getNavStyle = function(scroll) { + if(scroll > 100) return 'pdf-controls fixed'; + else return 'pdf-controls'; + } + + $scope.onError = function(error) { + console.log(error); + $scope.$apply(function(){$scope.errorStatus = ''}); + $scope.$apply(function(){$scope.error=error.message;}) + } + + $scope.onLoad = function() { + $scope.errorStatus = 'is-invisible none' + $scope.loading = ''; + } + + $scope.onProgress = function (progressData) { + var value = progressData.loaded / progressData.total * 100; + if( (value - $scope.progress) >= 10 || value >= 100 ) { + $scope.$apply(function(){$scope.progress = value;}); + } + + if( value >= 100 ) { + $scope.loading = 'is-invisible'; + } + }; + + + $scope.view = function(pdf) { + $scope.pdfUrl = '/documents/' + pdf.link; + $scope.pdfName = pdf.title; + $scope.progress = 0; + }; + + $scope.pdfs = []; + + $http.get("/data/documents.json").then(function(response){ + $scope.pdfs = response.data; + }); + +}); \ No newline at end of file diff --git a/partials/viewer.html b/partials/viewer.html new file mode 100644 index 0000000..f81e16c --- /dev/null +++ b/partials/viewer.html @@ -0,0 +1,13 @@ + +
+ {{error}} +
\ No newline at end of file