Start gruntification

This commit is contained in:
Florian Mounier
2014-04-30 11:03:57 +02:00
parent 5330429b7a
commit 253dd61e38
14 changed files with 8070 additions and 16 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
*.crt
*.key
*.p12
node_modules/

78
Gruntfile.coffee Normal file
View File

@@ -0,0 +1,78 @@
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
uglify:
options:
banner: '/*! <%= pkg.name %>
<%= grunt.template.today("yyyy-mm-dd") %> */\n'
sourceMap: true
butterfly:
files:
'butterfly/static/main.min.js': 'butterfly/static/main.js'
sass_to_scss:
butterfly:
expand: true
cwd: 'sass/'
src: '*.sass'
dest: 'sass/scss/'
ext: '.scss'
sass:
butterfly:
expand: true
cwd: 'sass/scss'
src: '*.scss'
dest: 'butterfly/static/'
ext: '.css'
coffee:
options:
sourceMap: true
butterfly:
files:
'butterfly/static/main.js': [
'coffees/term.coffee'
'coffees/selection.coffee'
'coffees/virtual_input.coffee'
'coffees/main.coffee'
]
coffeelint:
butterfly:
'coffees/*.coffee'
watch:
coffee:
files: [
'coffees/*.coffee'
'Gruntfile.coffee'
]
tasks: ['coffeelint', 'coffee']
sass:
files: [
'sass/*.sass'
]
tasks: ['sass_to_scss', 'sass']
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-cssmin'
grunt.loadNpmTasks 'grunt-coffeelint'
grunt.loadNpmTasks 'grunt-sass'
grunt.loadNpmTasks 'grunt-sass-to-scss'
grunt.loadNpmTasks 'grunt-bower-task'
grunt.registerTask 'dev', ['coffeelint', 'coffee', 'watch']
grunt.registerTask 'css', ['sass_to_scss', 'sass']
grunt.registerTask 'default', [
'coffeelint', 'coffee',
'sass_to_scss', 'sass',
'uglify', 'cssmin']

View File

@@ -43,6 +43,9 @@ tornado.options.define("generate_certs", default=False,
tornado.options.define("generate_user_pkcs", default='',
help="Generate user pfx for client authentication")
tornado.options.define("unminified", default=False,
help="Use the unminified js (for development only)")
tornado.options.parse_command_line()

View File

@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '1.4.3'
__version__ = '1.4.5'
import os

View File

@@ -138,14 +138,17 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
self.caller == self.callee and
server == self.callee):
# User has been auth with ssl or is the same user as server
try:
os.initgroups(self.callee.name, self.callee.gid)
os.setgid(self.callee.gid)
os.setuid(self.callee.uid)
except:
print('The server must be run as root '
'if you want to log as different user\n')
sys.exit(1)
if not tornado.options.options.unsecure:
# User is authed by ssl, setting groups
try:
os.initgroups(self.callee.name, self.callee.gid)
os.setgid(self.callee.gid)
os.setuid(self.callee.uid)
except:
print('The server must be run as root '
'if you want to log as different user\n')
sys.exit(1)
args = [tornado.options.options.shell or self.callee.shell]
args.append('-i')
os.execvpe(args[0], args, env)
@@ -200,9 +203,9 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
self.fd, self.shell_handler, ioloop.READ | ioloop.ERROR)
def open(self, user, path):
if self.request.headers['Origin'] != 'http%s://%s' % (
"s" if not tornado.options.options.unsecure else "",
self.request.headers['Host']):
if self.request.headers['Origin'] not in (
'http://%s' % self.request.headers['Host'],
'https://%s' % self.request.headers['Host']):
self.log.warning(
'Unauthorized connection attempt: from : %s to: %s' % (
self.request.headers['Origin'],

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,5 @@
<!DOCTYPE html>
{% from tornado.options import options %}
<html>
<head>
<meta charset="utf-8">
@@ -14,6 +15,7 @@
<body spellcheck="false">
<main id="wrapper"> </main>
<script src="{{ static_url('javascripts/main.js') }}"></script>
<script src="{{ static_url('javascripts/main.%sjs' % (
'' if options.unminified else 'min.')) }}"></script>
</body>
</html>

25
package.json Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "butterfly",
"version": "1.4.5",
"description": "A sleek web based terminal emulator",
"repository": {
"type": "git",
"url": "https://github.com/paradoxxxzero/butterfly.git"
},
"private": true,
"license": "GPLv3",
"bugs": {
"url": "https://github.com/paradoxxxzero/butterfly/issues"
},
"homepage": "https://github.com/paradoxxxzero/butterfly",
"devDependencies": {
"grunt": "~0.4.4",
"grunt-contrib-coffee": "^0.10.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-contrib-uglify": "^0.4.0",
"grunt-contrib-cssmin": "^0.9.0",
"grunt-coffeelint": "0.0.8",
"grunt-sass": "^0.12.1",
"grunt-sass-to-scss": "^0.1.9"
}
}