Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12 лет назад
12 лет назад
12 лет назад
12 лет назад
12 лет назад
12 лет назад
12 лет назад
12 лет назад
12 лет назад
12 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/usr/bin/env python
  2. import os
  3. import tempfile
  4. import sys
  5. JS = [
  6. 'js/Three.js',
  7. 'js/RequestAnimationFrame.js',
  8. 'js/pannellum.js'
  9. ]
  10. CSS = [
  11. 'css/pannellum.css'
  12. ]
  13. HTML = [
  14. 'pannellum.htm'
  15. ]
  16. def merge(files):
  17. buffer = []
  18. for filename in files:
  19. with open(os.path.join('..', 'src', filename), 'r') as f:
  20. buffer.append(f.read())
  21. return "".join(buffer)
  22. def read(filename):
  23. with open(os.path.join('..','src',filename), 'rb') as f:
  24. return f.read()
  25. def output(text, filename):
  26. with open(os.path.join('..', 'build', filename), 'wb') as f:
  27. f.write(text)
  28. def JScompress(text):
  29. in_tuple = tempfile.mkstemp()
  30. with os.fdopen(in_tuple[0], 'w') as handle:
  31. handle.write(text)
  32. out_tuple = tempfile.mkstemp()
  33. os.system("java -jar compiler.jar --language_in=ECMASCRIPT5 --js %s --js_output_file %s" % (in_tuple[1], out_tuple[1]))
  34. with os.fdopen(out_tuple[0], 'r') as handle:
  35. compressed = handle.read()
  36. os.unlink(in_tuple[1])
  37. os.unlink(out_tuple[1])
  38. return compressed
  39. def cssCompress(text):
  40. in_tuple = tempfile.mkstemp()
  41. with os.fdopen(in_tuple[0], 'w') as handle:
  42. handle.write(text)
  43. out_tuple = tempfile.mkstemp()
  44. os.system("java -jar yuicompressor-2.4.7.jar %s --type css -o %s --charset utf-8 -v" % (in_tuple[1], out_tuple[1]))
  45. with os.fdopen(out_tuple[0], 'r') as handle:
  46. compressed = handle.read()
  47. os.unlink(in_tuple[1])
  48. os.unlink(out_tuple[1])
  49. return compressed
  50. def htmlCompress(text):
  51. in_tuple = tempfile.mkstemp()
  52. with os.fdopen(in_tuple[0], 'w') as handle:
  53. handle.write(text)
  54. out_tuple = tempfile.mkstemp()
  55. os.system("java -jar htmlcompressor-1.5.3.jar --remove-intertag-spaces --remove-quotes --compress-js --js-compressor closure -o %s %s" % (out_tuple[1], in_tuple[1]))
  56. with os.fdopen(out_tuple[0], 'r') as handle:
  57. compressed = handle.read()
  58. os.unlink(in_tuple[1])
  59. os.unlink(out_tuple[1])
  60. return compressed
  61. def addHeader(text):
  62. text = text.replace('<!DOCTYPE HTML>','');
  63. header = '<!DOCTYPE HTML>\n<!-- Pannellum ' + read('../VERSION') + ', http://pannellum.sf.net/ -->\n'
  64. return header + text
  65. def build(files, css, html, filename):
  66. folder = ''
  67. cssfilename = filename + '.css'
  68. htmlfilename = filename + '.htm'
  69. filename = filename + '.js'
  70. print "=" * 40
  71. print "Compiling", filename
  72. print "=" * 40
  73. js = merge(files)
  74. js = JScompress(js)
  75. print "=" * 40
  76. print "Compiling", cssfilename
  77. print "=" * 40
  78. css = merge(css)
  79. css = css.replace("'img/grab.png'","'data:image/png;base64," + read('css/img/grab.png').encode('base64').replace('\n', '') + "'")
  80. css = css.replace("'img/grabbing.png'","'data:image/png;base64," + read('css/img/grabbing.png').encode('base64').replace('\n', '') + "'")
  81. css = css.replace("'img/loading.svg'","'data:image/svg+xml;base64," + read('css/img/loading.svg').encode('base64').replace('\n', '') + "'")
  82. css = cssCompress(css)
  83. css = css.replace("'img/sprites.png'","'data:image/png;base64," + read('css/img/sprites.png').encode('base64').replace('\n', '') + "'")
  84. print "=" * 40
  85. print "Compiling", htmlfilename
  86. print "=" * 40
  87. html = merge(html)
  88. html = html.replace('<link type="text/css" rel="Stylesheet" href="css/pannellum.css" />','<style type="text/css">' + css + '</style>')
  89. html = html.replace('<script type="text/javascript" src="js/Three.js"></script>','')
  90. html = html.replace('<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>','')
  91. html = html.replace('<script type="text/javascript" src="js/pannellum.js"></script>','<script type="text/javascript">' + js + '</script>')
  92. html = html.replace('"_blank">Pannellum</a></span>','"_blank">Pannellum</a> ' + read('../VERSION') + '</span>')
  93. html = htmlCompress(html)
  94. output(addHeader(html), folder + htmlfilename)
  95. def main():
  96. build(JS, CSS, HTML, 'pannellum')
  97. if __name__ == "__main__":
  98. main()