Commit 2c7f0e22 authored by frankie's avatar frankie 💬

new packager script

parent 53e4fe3e
......@@ -18,71 +18,69 @@ import uuid
import subprocess
import ftplib
css_files = [ "css/normalize.css", "css/style.css" ]
threejs_files = [
"build/three.min.js",
"js/threejs/loaders/ColladaLoader.js",
"js/threejs/controls/OrbitControls.js",
"js/threejs/Detector.js",
"js/threejs/libs/stats.min.js",
"js/threejs/libs/dat.gui.min.js"
# "js/threejs/postprocessing/EffectComposer.js",
# "js/threejs/postprocessing/RenderPass.js",
# "js/threejs/postprocessing/MaskPass.js",
# "js/threejs/postprocessing/ShaderPass.js",
# "js/threejs/shaders/CopyShader.js",
# "js/threejs/shaders/FXAAShader.js",
# "js/threejs/shaders/ConvolutionShader.js",
# "js/threejs/shaders/LuminosityHighPassShader.js",
# "js/threejs/postprocessing/UnrealBloomPass.js",
]
'''
CONFIGURATION
'''
customjs_files = [
"js/utils/Basics.js",
"js/utils/Interpolation.js",
"js/utils/MorphableMesh.js",
"js/Ground.js",
"js/BoneScalePreset.js",
"js/SysiphusBone.js",
"js/SysiphusAvatar.js",
"js/PantonPouf.js",
"js/TimeManager.js",
"js/ObjectTracker.js",
"js/main.js"
css_files = [
'css/normalize.css',
'css/style.css'
]
customjs_archive_files = [
"js/slider/range-slider.js",
"js/utils/Basics.js",
"js/utils/Interpolation.js",
"js/utils/MorphableMesh.js",
"js/Ground.js",
"js/BoneScalePreset.js",
"js/SysiphusBone.js",
"js/SysiphusAvatar.js",
"js/PantonPouf.js",
"js/TimeManager.js",
"js/ObjectTracker.js",
"js/main_avatar_only.js"
threejs_files = [
'build/three.min.js',
'js/threejs/loaders/ColladaLoader.js',
'js/threejs/controls/OrbitControls.js',
'js/threejs/Detector.js',
'js/threejs/libs/stats.min.js',
'js/threejs/libs/dat.gui.min.js'
]
export_folder = "../package"
# [ [ source file, template file, custom javascripts, target file ] ]
#export_file = "index.html"
export_file = [
("index.html", "template.html", customjs_files, "index.html"),
("index_avatar_only.html", "template_archive.html", customjs_archive_files, "archive.html")
export_folder = '../package'
export_file_css = 'sisyphus_#.css'
export_file_threejs = 'three.js'
export_files = [
{
'html_tmpl': 'template.html',
'js_src' : [
'js/utils/Basics.js',
'js/utils/Interpolation.js',
'js/utils/MorphableMesh.js',
'js/Ground.js',
'js/BoneScalePreset.js',
'js/SysiphusBone.js',
'js/SysiphusAvatar.js',
'js/PantonPouf.js',
'js/TimeManager.js',
'js/ObjectTracker.js',
'js/main.js'
],
'html_dst': 'index.html',
'js_dst': 'sisyphus_prod_#.js'
},
{
'html_tmpl': 'template_archive.html',
'js_src' : [
'js/threejs/shaders/UnpackDepthRGBAShader.js',
'js/threejs/utils/ShadowMapViewer.js',
'js/slider/range-slider.js',
'js/utils/Basics.js',
'js/utils/Interpolation.js',
'js/utils/MorphableMesh.js',
'js/Ground.js',
'js/BoneScalePreset.js',
'js/SysiphusBone.js',
'js/SysiphusAvatar.js',
'js/Cube.js',
'js/TimeManager.js',
'js/ObjectTracker.js',
'js/main_avatar_only.js'
],
'html_dst': 'archive.html',
'js_dst': 'sisyphus_archive_#.js'
}
]
export_file_css = "sisyphus_#.css"
export_file_threejs = "three.js"
export_file_customjs = "sisyphus_#.js"
'''
CONFIGURATION
'''
template_file = "template.html"
# pairs of strings [needle, replace] to find/replace
# in custom javascript
......@@ -98,27 +96,34 @@ js_replace = [
[
'var remote_gallery_server = "server/json/gallery.json";',
'var remote_gallery_server = "http://51.15.234.17/gallery";'
],
[
"var remote_timestamp_server = 'server/json/timestamp.json';",
"var remote_timestamp_server = 'http://51.15.234.17/timestamp';"
],
[
"var remote_gallery_server = 'server/json/gallery.json';",
"var remote_gallery_server = 'http://51.15.234.17/gallery';"
]
]
#copy_dirs = [ "fonts", "models", "presets", "textures", "gallery" ]
copy_dirs = [ "presets" ]
#copy_dirs = [ 'fonts', 'models', 'presets', 'textures', 'gallery' ]
copy_dirs = [ 'fonts', 'models', 'presets', 'textures' ]
create_dir = []
copy_files = [
["README.md"],
["LICENSE"],
["server/.htaccess",".htaccess"]
['README.md'],
['LICENSE'],
['server/.htaccess','.htaccess']
]
license = ""
license = ''
'''
GLOBAL VARS
'''
css_content = ""
threejs_content = ""
customjs_content = ""
css_content = ''
threejs_content = ''
def copy(src, dst):
try:
......@@ -181,14 +186,17 @@ for root, dirs, files in os.walk( export_folder+"/" ):
for d in dirs:
shutil.rmtree(os.path.join( root, d ))
# copying all dirs
for d in copy_dirs:
copy( d, export_folder + "/" + d )
# creation of directories in package folder
for d in create_dir:
newpath = export_folder + "/" + d
if not os.path.exists(newpath):
os.makedirs(newpath)
# copying all files
for d in copy_files:
infife = d[0]
outfife = export_folder + "/" + d[0]
......@@ -197,44 +205,44 @@ for d in copy_files:
with open(infife, 'rb') as src, open( outfife, 'wb') as dst:
copyfileobj_example(src, dst)
# generation of common files, CSS
css_content = get_content( css_files, 'css' )
css_content = css_content.replace('../', '')
threejs_content = get_content( threejs_files, 'js' )
customjs_content = get_content( customjs_files, 'js' )
for pair in js_replace:
customjs_content = customjs_content.replace( pair[0], pair[1] )
export_path = export_folder+'/'+export_file_threejs
with open( export_folder+'/'+export_file_threejs , 'w') as f:
f.write( threejs_content )
f.close()
uglify( export_path )
export_file_customjs = export_file_customjs.replace( "#", str(uuid.uuid1()) )
export_path = export_folder+'/'+export_file_customjs
with open( export_path, 'w') as f:
f.write( customjs_content )
f.close()
uglify( export_path )
export_file_css = export_file_css.replace( "#", str(uuid.uuid1()) )
export_path = export_folder+'/'+export_file_css
with open( export_path, 'w') as f:
f.write( css_content )
f.close()
template_content = open(template_file, 'r').read()
template_content = template_content.replace('<!--INCLUDE_CSS-->', '<link rel="stylesheet" href="'+export_file_css+'"/>')
template_content = template_content.replace('<!--INCLUDE_JS-->', '<script src="'+export_file_threejs+'"></script><script src="'+export_file_customjs+'"></script>')
with open( export_folder+'/'+export_file , 'w') as f:
f.write( template_content )
# generation of common files, JS
threejs_content = get_content( threejs_files, 'js' )
export_path = export_folder+'/'+export_file_threejs
with open( export_folder+'/'+export_file_threejs , 'w') as f:
f.write( threejs_content )
f.close()
uglify( export_path )
# print( "\ncss_content\n*****************************************************" )
# print( css_content )
# print( "\njs_content\n*****************************************************" )
# print( js_content )
# print( "\ntemplate\n*****************************************************" )
# print( template_content )
# generation of custom files
for ef in export_files:
customjs_content = get_content( ef['js_src'], 'js' )
for pair in js_replace:
customjs_content = customjs_content.replace( pair[0], pair[1] )
export_file_customjs = ef['js_dst'].replace( '#', str(uuid.uuid1()) )
export_path = export_folder+'/'+export_file_customjs
with open( export_path, 'w') as f:
f.write( customjs_content )
f.close()
uglify( export_path )
template_content = open( ef['html_tmpl'], 'r').read()
template_content = template_content.replace('<!--INCLUDE_CSS-->', '<link rel="stylesheet" href="'+export_file_css+'"/>')
template_content = template_content.replace('<!--INCLUDE_JS-->', '<script src="'+export_file_threejs+'"></script><script src="'+export_file_customjs+'"></script>')
with open( export_folder+'/'+ef['html_dst'] , 'w') as f:
f.write( template_content )
f.close()
print( )
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment