preview package

This commit is contained in:
Xuan Sang LE 2018-03-01 01:21:11 +01:00
parent fb29ce4e43
commit 8589c2be9a
8 changed files with 55657 additions and 1 deletions

View File

@ -22,7 +22,7 @@ coffees= src/core/core.coffee\
packages = CoreServices NotePad wTerm ActivityMonitor DummyApp Files MarkOn MarketPlace Blogger
packages = CoreServices NotePad wTerm ActivityMonitor DummyApp Files MarkOn MarketPlace Blogger Preview
main: build_coffees build_tags build_themes schemes libs build_packages
- cp src/index.html $(BUILDDIR)/

View File

@ -0,0 +1,11 @@
coffee_files = main.coffee
jsfiles = pdf.js
cssfiles = main.css
copyfiles = pdf.worker.js scheme.html package.json
PKG_NAME=Preview
include ../pkg.mk

View File

@ -0,0 +1,35 @@
class Preview extends this.OS.GUI.BaseApplication
constructor: (args) ->
super "Preview", args
main: () ->
me = @
url = "https://os.localhost:9195/test.pdf"
@view = @find "view"
PDFJS.workerSrc = @_api.handler.get + "/#{@path()}/pdf.worker.js"
#PDFJS.workerSrc = "packages/Preview/pdf.worker.js"
#PDFJS.disableWorker = true
console.log PDFJS.workerSrc
PDFJS.getDocument(url)
.then (pdf) ->
fn = (p) ->
return if p > pdf.numPages
pdf.getPage(p).then (page) ->
scale = 1.5
viewport = page.getViewport scale
div = ($ "<div/>").attr("id", "page-" + (page.pageIndex + 1))
($ me.view).append div
canvas = ($ "<canvas/>")[0]
div.append canvas
context = canvas.getContext '2d'
canvas.height = viewport.height
canvas.width = viewport.width
renderContext =
canvasContext: context
viewport: viewport
page.render renderContext
fn(p+1)
fn(1)
this.OS.register "Preview", Preview

View File

@ -0,0 +1,10 @@
afx-app-window[data-id = "preview-win"] afx-hbox[data-id="container"] {
display: block;
overflow:auto;
}
afx-app-window[data-id = "preview-win"] afx-hbox[data-id="container"] canvas{
margin-left: auto;
margin-right: auto;
display: block;
}

View File

@ -0,0 +1,13 @@
{
"app":"Preview",
"name":"Preview",
"description":"Media files viewer",
"info":{
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.1a",
"category":"Utils",
"iconclass":"fa fa-eye",
"mimes":["[^\/]*/.*pdf"]
}

13922
src/packages/Preview/pdf.js Normal file

File diff suppressed because it is too large Load Diff

41660
src/packages/Preview/pdf.worker.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
<afx-app-window data-id = "preview-win" apptitle="Preview" width="600" height="400">
<afx-hbox data-id = "container">
<div data-id="view" ></div>
</afx-hbox>
</afx-app-window>