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

12 лет назад
12 лет назад
12 лет назад
12 лет назад
12 лет назад
12 лет назад
12 лет назад
11 лет назад
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. import urllib
  6. JS = [
  7. 'js/libpannellum.js',
  8. 'js/RequestAnimationFrame.js',
  9. 'js/pannellum.js'
  10. ]
  11. CSS = [
  12. 'css/pannellum.css'
  13. ]
  14. HTML = [
  15. 'pannellum.htm'
  16. ]
  17. def merge(files):
  18. buffer = []
  19. for filename in files:
  20. with open(os.path.join('..', 'src', filename), 'r') as f:
  21. buffer.append(f.read())
  22. return "".join(buffer)
  23. def read(filename):
  24. with open(os.path.join('..','src',filename), 'rb') as f:
  25. return f.read()
  26. def output(text, filename):
  27. with open(os.path.join('..', 'build', filename), 'wb') as f:
  28. f.write(text)
  29. def JScompress(text):
  30. in_tuple = tempfile.mkstemp()
  31. with os.fdopen(in_tuple[0], 'w') as handle:
  32. handle.write(text)
  33. out_tuple = tempfile.mkstemp()
  34. os.system("java -jar compiler.jar --language_in=ECMASCRIPT5 --js %s --js_output_file %s" % (in_tuple[1], out_tuple[1]))
  35. with os.fdopen(out_tuple[0], 'r') as handle:
  36. compressed = handle.read()
  37. os.unlink(in_tuple[1])
  38. os.unlink(out_tuple[1])
  39. return compressed
  40. def cssCompress(text):
  41. in_tuple = tempfile.mkstemp()
  42. with os.fdopen(in_tuple[0], 'w') as handle:
  43. handle.write(text)
  44. out_tuple = tempfile.mkstemp()
  45. os.system("java -jar yuicompressor-2.4.7.jar %s --type css -o %s --charset utf-8 -v" % (in_tuple[1], out_tuple[1]))
  46. with os.fdopen(out_tuple[0], 'r') as handle:
  47. compressed = handle.read()
  48. os.unlink(in_tuple[1])
  49. os.unlink(out_tuple[1])
  50. return compressed
  51. def htmlCompress(text):
  52. in_tuple = tempfile.mkstemp()
  53. with os.fdopen(in_tuple[0], 'w') as handle:
  54. handle.write(text)
  55. out_tuple = tempfile.mkstemp()
  56. os.system("java -jar htmlcompressor-1.5.3.jar --remove-intertag-spaces --remove-quotes -o %s %s" % (out_tuple[1], in_tuple[1]))
  57. with os.fdopen(out_tuple[0], 'r') as handle:
  58. compressed = handle.read()
  59. os.unlink(in_tuple[1])
  60. os.unlink(out_tuple[1])
  61. return compressed
  62. def addHeader(text):
  63. text = text.replace('<!DOCTYPE HTML>','');
  64. header = '<!DOCTYPE HTML>\n<!-- Pannellum ' + read('../VERSION') + ', https://github.com/mpetroff/pannellum -->\n'
  65. return header + text
  66. def build(files, css, html, filename):
  67. folder = ''
  68. cssfilename = filename + '.css'
  69. htmlfilename = filename + '.htm'
  70. filename = filename + '.js'
  71. print "=" * 40
  72. print "Compiling", filename
  73. print "=" * 40
  74. js = merge(files)
  75. js = JScompress(js)
  76. print "=" * 40
  77. print "Compiling", cssfilename
  78. print "=" * 40
  79. css = merge(css)
  80. css = css.replace("'img/grab.svg'","'data:image/svg+xml," + urllib.quote(read('css/img/grab.svg'),'') + "'")
  81. css = css.replace("'img/grabbing.svg'","'data:image/svg+xml," + urllib.quote(read('css/img/grabbing.svg'),'') + "'")
  82. css = cssCompress(css)
  83. css = css.replace("'img/sprites.svg'","'data:image/svg+xml," + urllib.quote(read('css/img/sprites.svg'),'') + "'")
  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/libpannellum.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()