mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Production scripts
This commit is contained in:
parent
81a55651ed
commit
0075007d49
8 changed files with 68 additions and 114 deletions
36
Makefile
36
Makefile
|
@ -41,16 +41,27 @@ server:
|
||||||
|
|
||||||
test: pdfjs shell-test browser-test
|
test: pdfjs shell-test browser-test
|
||||||
|
|
||||||
|
#
|
||||||
|
# Create production output (pdf.js, and corresponding changes to web files)
|
||||||
|
#
|
||||||
|
production: | bundle
|
||||||
|
@echo "Preparing production viewer..."; \
|
||||||
|
cd web; \
|
||||||
|
sed '/PDFJSSCRIPT_REMOVE/d' viewer.html > viewer-1.tmp; \
|
||||||
|
sed '/PDFJSSCRIPT_INCLUDE_BUILD/ r viewer-snippet.html' viewer-1.tmp > viewer-production.html; \
|
||||||
|
rm -f *.tmp; \
|
||||||
|
cd ..
|
||||||
|
|
||||||
#
|
#
|
||||||
# Bundle pdf.js
|
# Bundle pdf.js
|
||||||
#
|
#
|
||||||
pdfjs:
|
bundle:
|
||||||
@echo "Bundling source files..."
|
@echo "Bundling source files into pdf.js..."
|
||||||
@mkdir -p $(BUILD_DIR)
|
@mkdir -p $(BUILD_DIR)
|
||||||
@cd src; \
|
@cd src; \
|
||||||
cat $(PDF_JS_FILES) > all_files.tmp; \
|
cat $(PDF_JS_FILES) > all_files.tmp; \
|
||||||
sed '/INSERT_POINT/ r all_files.tmp' pdf.js > ../$(PDFJS_TARGET); \
|
sed '/PDFJSSCRIPT_INCLUDE_ALL/ r all_files.tmp' pdf.js > ../$(PDFJS_TARGET); \
|
||||||
rm -f all_files.tmp; \
|
rm -f *.tmp; \
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# make browser-test
|
# make browser-test
|
||||||
|
@ -127,13 +138,14 @@ lint:
|
||||||
# TODO: Use the Closure compiler to optimize the pdf.js files.
|
# TODO: Use the Closure compiler to optimize the pdf.js files.
|
||||||
#
|
#
|
||||||
GH_PAGES = $(BUILD_DIR)/gh-pages
|
GH_PAGES = $(BUILD_DIR)/gh-pages
|
||||||
web: | pdfjs extension compiler pages-repo \
|
web: | production extension compiler pages-repo \
|
||||||
$(addprefix $(GH_PAGES)/, $(PDFJS_TARGET)) \
|
$(addprefix $(GH_PAGES)/, $(PDFJS_TARGET)) \
|
||||||
$(addprefix $(GH_PAGES)/, $(wildcard web/*.*)) \
|
$(addprefix $(GH_PAGES)/, $(wildcard web/*.*)) \
|
||||||
$(addprefix $(GH_PAGES)/, $(wildcard web/images/*.*)) \
|
$(addprefix $(GH_PAGES)/, $(wildcard web/images/*.*)) \
|
||||||
$(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/*.xpi))
|
$(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/*.xpi))
|
||||||
|
|
||||||
@cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html;
|
@cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html;
|
||||||
|
@mv -f $(GH_PAGES)/web/viewer-production.html $(GH_PAGES)/web/viewer.html;
|
||||||
@cd $(GH_PAGES); git add -A;
|
@cd $(GH_PAGES); git add -A;
|
||||||
@echo
|
@echo
|
||||||
@echo "Website built in $(GH_PAGES)."
|
@echo "Website built in $(GH_PAGES)."
|
||||||
|
@ -191,15 +203,16 @@ PDF_WEB_FILES = \
|
||||||
web/compatibility.js \
|
web/compatibility.js \
|
||||||
web/viewer.css \
|
web/viewer.css \
|
||||||
web/viewer.js \
|
web/viewer.js \
|
||||||
web/viewer.html \
|
web/viewer-production.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
extension: | pdfjs
|
extension: | production
|
||||||
# Copy a standalone version of pdf.js inside the content directory
|
# Copy a standalone version of pdf.js inside the content directory
|
||||||
@rm -Rf $(EXTENSION_SRC)/$(CONTENT_DIR)/
|
@rm -Rf $(EXTENSION_SRC)/$(CONTENT_DIR)/
|
||||||
@mkdir -p $(EXTENSION_SRC)/$(CONTENT_DIR)/$(BUILD_DIR)
|
@mkdir -p $(EXTENSION_SRC)/$(CONTENT_DIR)/$(BUILD_DIR)
|
||||||
@mkdir -p $(EXTENSION_SRC)/$(CONTENT_DIR)/web
|
@mkdir -p $(EXTENSION_SRC)/$(CONTENT_DIR)/web
|
||||||
@cp $(PDFJS_TARGET) $(EXTENSION_SRC)/$(CONTENT_DIR)/$(BUILD_DIR)
|
@cp $(PDFJS_TARGET) $(EXTENSION_SRC)/$(CONTENT_DIR)/$(BUILD_DIR)
|
||||||
@cp -r $(PDF_WEB_FILES) $(EXTENSION_SRC)/$(CONTENT_DIR)/web/
|
@cp -r $(PDF_WEB_FILES) $(EXTENSION_SRC)/$(CONTENT_DIR)/web/
|
||||||
|
@mv -f $(EXTENSION_SRC)/$(CONTENT_DIR)/web/viewer-production.html $(EXTENSION_SRC)/$(CONTENT_DIR)/web/viewer.html
|
||||||
|
|
||||||
# Create the xpi
|
# Create the xpi
|
||||||
@cd $(EXTENSION_SRC); zip -r $(EXTENSION_NAME) *
|
@cd $(EXTENSION_SRC); zip -r $(EXTENSION_NAME) *
|
||||||
|
@ -219,12 +232,5 @@ clean:
|
||||||
help:
|
help:
|
||||||
@echo "Read the comments in the Makefile for guidance.";
|
@echo "Read the comments in the Makefile for guidance.";
|
||||||
|
|
||||||
#
|
.PHONY:: production watch test browser-test font-test shell-test \
|
||||||
# Watch for file changes, regenerate pdf.js if change found
|
|
||||||
#
|
|
||||||
watch:
|
|
||||||
@echo "Watching for file changes in src/"
|
|
||||||
@python watch.py src/*.js - 'make pdfjs'
|
|
||||||
|
|
||||||
.PHONY:: all pdfjs watch test browser-test font-test shell-test \
|
|
||||||
shell-msg lint clean web compiler help server
|
shell-msg lint clean web compiler help server
|
||||||
|
|
|
@ -2,8 +2,26 @@
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<!-- PDF.js-specific -->
|
<!-- In production, only one script (pdf.js) is necessary -->
|
||||||
<script type="text/javascript" src="../../build/pdf.js"></script>
|
<script type="text/javascript" src="../../src/core.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/util.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/canvas.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/obj.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/function.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/charsets.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/cidmaps.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/colorspace.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/crypto.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/evaluator.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/fonts.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/glyphlist.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/image.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/metrics.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/parser.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/pattern.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/stream.js"></script>
|
||||||
|
<script type="text/javascript" src="../../src/worker.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="hello.js"></script>
|
<script type="text/javascript" src="hello.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ var useWorker = false;
|
||||||
// In production, it will be declared outside a global wrapper
|
// In production, it will be declared outside a global wrapper
|
||||||
// In development, it will be declared here
|
// In development, it will be declared here
|
||||||
if (typeof PDF === 'undefined') {
|
if (typeof PDF === 'undefined') {
|
||||||
var PDF = {};
|
PDF = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPdf()
|
// getPdf()
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
var PDF = {};
|
var PDF = {};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
// Use strict in our context only - users might not want it
|
// Use strict in our context only - users might not want it
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Files are inserted below - see Makefile
|
// Files are inserted below - see Makefile
|
||||||
/* INSERT_POINT */
|
/* PDFJSSCRIPT_INCLUDE_ALL */
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
77
watch.py
77
watch.py
|
@ -1,77 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# Python port of Ian Piumarta's watch.c
|
|
||||||
# BSD Licensed - http://eschew.org/txt/bsd.txt
|
|
||||||
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
import string
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
maxfiles = 64
|
|
||||||
|
|
||||||
def usage():
|
|
||||||
return """usage: %(watch)s <paths...> - <commands...>
|
|
||||||
<paths...> is/are the file/s to be monitored
|
|
||||||
<commands...> is/are the commands to execute (quote if args required)
|
|
||||||
Note: occurrences of '${file}' in command strings will be replaced
|
|
||||||
with updated filename before execution.
|
|
||||||
e.g.: %(watch)s *.txt - 'echo ${file}'
|
|
||||||
""" % { 'watch': sys.argv[0] }
|
|
||||||
|
|
||||||
def try_get_mtime(path):
|
|
||||||
try:
|
|
||||||
buf = os.stat(path)
|
|
||||||
except OSError:
|
|
||||||
time.sleep(1)
|
|
||||||
try:
|
|
||||||
buf = os.stat(path)
|
|
||||||
except OSError:
|
|
||||||
print "%(watch)s: %(file)s: file not found"
|
|
||||||
sys.exit(1)
|
|
||||||
return buf.st_mtime
|
|
||||||
|
|
||||||
def execute_commands(commands, filename):
|
|
||||||
for command in commands:
|
|
||||||
cmd = string.Template(command).safe_substitute(file=filename)
|
|
||||||
cmd_pieces = re.split('\s+', cmd)
|
|
||||||
subprocess.Popen(cmd_pieces)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
files = []
|
|
||||||
commands = []
|
|
||||||
seeing_paths = True
|
|
||||||
for part in sys.argv[1:]:
|
|
||||||
if part == '-':
|
|
||||||
seeing_paths = False
|
|
||||||
elif seeing_paths:
|
|
||||||
files.append(part)
|
|
||||||
else:
|
|
||||||
commands.append(part)
|
|
||||||
|
|
||||||
if len(commands) == 0:
|
|
||||||
print usage()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if len(files) > maxfiles:
|
|
||||||
print "%(watch)s: too many files to watch" % sys.argv[0]
|
|
||||||
|
|
||||||
mtimes = dict([(f, try_get_mtime(f)) for f in files])
|
|
||||||
done = False
|
|
||||||
while not done:
|
|
||||||
for f in files:
|
|
||||||
old_mtime = mtimes[f]
|
|
||||||
new_mtime = try_get_mtime(f)
|
|
||||||
if new_mtime != old_mtime:
|
|
||||||
mtimes[f] = new_mtime
|
|
||||||
execute_commands(commands, f)
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
try:
|
|
||||||
main()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
1
web/.gitignore
vendored
Normal file
1
web/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
viewer-production.html
|
2
web/viewer-snippet.html
Normal file
2
web/viewer-snippet.html
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<!-- This snippet is used in production, see Makefile -->
|
||||||
|
<script type="text/javascript" src="../build/pdf.js"></script>
|
|
@ -4,24 +4,26 @@
|
||||||
<title>Simple pdf.js page viewer</title>
|
<title>Simple pdf.js page viewer</title>
|
||||||
<link rel="stylesheet" href="viewer.css"/>
|
<link rel="stylesheet" href="viewer.css"/>
|
||||||
|
|
||||||
<script type="text/javascript" src="../src/core.js"></script>
|
<!-- PDFJSSCRIPT_INCLUDE_BUILD -->
|
||||||
<script type="text/javascript" src="../src/util.js"></script>
|
|
||||||
<script type="text/javascript" src="../src/canvas.js"></script>
|
<script type="text/javascript" src="../src/core.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/obj.js"></script>
|
<script type="text/javascript" src="../src/util.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/function.js"></script>
|
<script type="text/javascript" src="../src/canvas.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/charsets.js"></script>
|
<script type="text/javascript" src="../src/obj.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/cidmaps.js"></script>
|
<script type="text/javascript" src="../src/function.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/colorspace.js"></script>
|
<script type="text/javascript" src="../src/charsets.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/crypto.js"></script>
|
<script type="text/javascript" src="../src/cidmaps.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/evaluator.js"></script>
|
<script type="text/javascript" src="../src/colorspace.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/fonts.js"></script>
|
<script type="text/javascript" src="../src/crypto.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/glyphlist.js"></script>
|
<script type="text/javascript" src="../src/evaluator.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/image.js"></script>
|
<script type="text/javascript" src="../src/fonts.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/metrics.js"></script>
|
<script type="text/javascript" src="../src/glyphlist.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/parser.js"></script>
|
<script type="text/javascript" src="../src/image.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/pattern.js"></script>
|
<script type="text/javascript" src="../src/metrics.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/stream.js"></script>
|
<script type="text/javascript" src="../src/parser.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
<script type="text/javascript" src="../src/worker.js"></script>
|
<script type="text/javascript" src="../src/pattern.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
|
<script type="text/javascript" src="../src/stream.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
|
<script type="text/javascript" src="../src/worker.js"></script> <!-- PDFJSSCRIPT_REMOVE -->
|
||||||
|
|
||||||
<script type="text/javascript" src="compatibility.js"></script>
|
<script type="text/javascript" src="compatibility.js"></script>
|
||||||
<script type="text/javascript" src="viewer.js"></script>
|
<script type="text/javascript" src="viewer.js"></script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue